Skip to content

Assembly

assembly

AssemblyInstructionArg: TypeAlias = IntegerAttr | str | StringAttr module-attribute

assembly_arg_str(arg: AssemblyInstructionArg) -> str

Source code in xdsl/dialects/x86/assembly.py
14
15
16
17
18
19
20
def assembly_arg_str(arg: AssemblyInstructionArg) -> str:
    if isinstance(arg, IntegerAttr):
        return f"{arg.value.data}"
    elif isinstance(arg, StringAttr):
        return arg.data

    return arg

memory_access_str(register: SSAValue, offset: IntegerAttr) -> str

Source code in xdsl/dialects/x86/assembly.py
23
24
25
26
27
28
29
def memory_access_str(register: SSAValue, offset: IntegerAttr) -> str:
    register_str = reg(register)
    if offset.value.data:
        mem_acc_str = f"[{register_str}{offset.value.data:+d}]"
    else:
        mem_acc_str = f"[{register_str}]"
    return mem_acc_str

broadcast_memory_access_str(register: SSAValue, offset: IntegerAttr, broadcast: str) -> str

e.g. [rsi+512]{1to8}

The lane count depends on both the element width and the width of the register bank the instruction is allocated to, so it is computed by the operation rather than drawn from a fixed set.

Source code in xdsl/dialects/x86/assembly.py
32
33
34
35
36
37
38
39
40
41
42
43
44
def broadcast_memory_access_str(
    register: SSAValue,
    offset: IntegerAttr,
    broadcast: str,
) -> str:
    """
    e.g. ``[rsi+512]{1to8}``

    The lane count depends on both the element width and the width of the
    register bank the instruction is allocated to, so it is computed by the
    operation rather than drawn from a fixed set.
    """
    return f"{memory_access_str(register, offset)}{{{broadcast}}}"

print_type_pair(printer: Printer, value: SSAValue) -> None

Source code in xdsl/dialects/x86/assembly.py
47
48
49
50
def print_type_pair(printer: Printer, value: SSAValue) -> None:
    printer.print_ssa_value(value)
    printer.print_string(" : ")
    printer.print_attribute(value.type)

parse_type_pair(parser: Parser) -> SSAValue

Source code in xdsl/dialects/x86/assembly.py
53
54
55
56
57
def parse_type_pair(parser: Parser) -> SSAValue:
    unresolved = parser.parse_unresolved_operand()
    parser.parse_punctuation(":")
    type = parser.parse_type()
    return parser.resolve_operand(unresolved, type)

masked_memory_access_str(register: SSAValue, offset: IntegerAttr, mask: SSAValue, z: UnitAttr | None) -> str

Returns string for asm printing of a memory access followed by the {k} (and optionally {z}) specifiers, in AVX512 masked operations. e.g. [rdx+8] {k1} or [rdx] {k1}{z}

Source code in xdsl/dialects/x86/assembly.py
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
def masked_memory_access_str(
    register: SSAValue,
    offset: IntegerAttr,
    mask: SSAValue,
    z: UnitAttr | None,
) -> str:
    """
    Returns string for asm printing of a memory access followed by the {k}
    (and optionally {z}) specifiers, in AVX512 masked operations.
    e.g. ``[rdx+8] {k1}`` or ``[rdx] {k1}{z}``
    """
    mem_str = memory_access_str(register, offset)
    mask_str = reg(mask)
    res = f"{mem_str} {{{mask_str}}}"
    if z:
        res += "{z}"
    return res

masked_source_str(reg_in: SSAValue, mask: SSAValue, z: UnitAttr | None) -> str

Returns string for asm printing of the register followed by the {k} (and optionally {z}) specifiers, in AVX512 masked operations

Source code in xdsl/dialects/x86/assembly.py
79
80
81
82
83
84
85
86
87
88
89
def masked_source_str(reg_in: SSAValue, mask: SSAValue, z: UnitAttr | None) -> str:
    """
    Returns string for asm printing of the register followed by the {k} (and optionally {z})
    specifiers, in AVX512 masked operations
    """
    reg_in_str = reg(reg_in)
    mask_str = reg(mask)
    res = f"{reg_in_str} {{{mask_str}}}"
    if z:
        res += "{z}"
    return res