qat.experimental.dialect.q1.transforms.reg_alloc module
Q1 support for xDSL register allocation.
- class LinearScanRegisterAllocationPass
Bases:
ModulePassA pass that applies linear scan register allocation to all sequences in a module.
It applies register allocation individually to each
SequenceOpdefined throughout the module. The allocator works by walking the block within the sequence backwards, allocating registers for operands and freeing registers for results. This is a simple and efficient allocation strategy that avoids the complexity of graph colouring and fixed-point iteration.It is aimed at the structured control flow level (q1_scf); if a sequence contains multiple blocks, an exception will be raised. There are also certain requirements on for loops, see the documentation there.
- apply(ctx, op)
- Return type:
None
-
name:
ClassVar[str] = 'q1-lin-scan-reg-alloc'
- class Q1LinearScanAllocator(available_registers)
Bases:
BlockNaiveAllocatorA linear scan register allocator for Q1 physical registers.
Implements a register allocator strategy that traverses the use-def SSA chain backwards (i.e., from uses to defs) and allocates registers for operands and frees registers for results. This operates at the structured control flow level (q1_scf), and allows for simple and efficient allocation without resorting to more complex graph colouring algorithms and fixed-point iteration.
The assumption that this operates at the structured control flow level means that it can only handle sequences with a single block, and will raise an exception if multiple blocks are present.
- Parameters:
available_registers¶ (
Q1RegisterStack) – The Q1 physical registers available for allocation.
- allocate_sequence(sequence)
Allocate registers for the given sequence operation.
- Return type:
None
- class Q1RegisterStack(allocatable_registers=<factory>, next_infinite_indices=<factory>, reserved_registers=<factory>, available_registers=<factory>, allow_infinite=False)
Bases:
RegisterStackRegister stack configured with the Q1 physical register set.
- classmethod allocatable_registers(reserved_registers=None)
Return Q1 physical registers available after excluding reserved registers.
- Return type:
tuple[Q1RegisterType,...]
- classmethod default_allocatable_registers()
The default registers to be made available when instantiating the stack.
- Return type:
tuple[Q1RegisterType,...]
- classmethod from_reserved_registers(reserved_registers=None, allow_infinite=False)
Create a stack with the requested Q1 registers excluded from allocation.
- Return type: