Skip to content

X86 allocate registers

x86_allocate_registers

X86AllocateRegisters dataclass

Bases: ModulePass

Allocates unallocated registers in the module.

The allocatable set depends on the target, read from the x86.arch module attribute. Without it the conservative VEX-only set is used, since handing out EVEX-only registers produces assembly the target cannot decode.

Source code in xdsl/transforms/x86_allocate_registers.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
@dataclass(frozen=True)
class X86AllocateRegisters(ModulePass):
    """
    Allocates unallocated registers in the module.

    The allocatable set depends on the target, read from the `x86.arch` module
    attribute. Without it the conservative VEX-only set is used, since handing
    out EVEX-only registers produces assembly the target cannot decode.
    """

    name = "x86-allocate-registers"

    def apply(self, ctx: Context, op: ModuleOp) -> None:
        arch = X86Arch.from_module(op)
        for inner_op in op.walk():
            if isinstance(inner_op, x86_func.FuncOp):
                available_registers = X86RegisterStack.get_for_arch(arch)
                allocator = X86RegisterAllocator(available_registers)
                allocator.allocate_func(inner_op)

name = 'x86-allocate-registers' class-attribute instance-attribute

__init__() -> None

apply(ctx: Context, op: ModuleOp) -> None

Source code in xdsl/transforms/x86_allocate_registers.py
24
25
26
27
28
29
30
def apply(self, ctx: Context, op: ModuleOp) -> None:
    arch = X86Arch.from_module(op)
    for inner_op in op.walk():
        if isinstance(inner_op, x86_func.FuncOp):
            available_registers = X86RegisterStack.get_for_arch(arch)
            allocator = X86RegisterAllocator(available_registers)
            allocator.allocate_func(inner_op)