Register stack
register_stack
OutOfRegisters
Bases: DiagnosticException
Source code in xdsl/backend/register_stack.py
15 16 17 | |
__str__()
Source code in xdsl/backend/register_stack.py
16 17 | |
RegisterStack
dataclass
LIFO stack of registers available for allocation.
Source code in xdsl/backend/register_stack.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
allocatable_registers: defaultdict[str, set[int]] = field(default_factory=(lambda: defaultdict(lambda: set[int]())))
class-attribute
instance-attribute
Registers that can be used by the register allocator for a given register set.
next_infinite_indices: defaultdict[str, int] = field(default_factory=(lambda: defaultdict(lambda: 0)))
class-attribute
instance-attribute
Next index for a given register set.
reserved_registers: defaultdict[str, defaultdict[int, int]] = field(default_factory=(lambda: defaultdict(lambda: defaultdict[int, int](lambda: 0))))
class-attribute
instance-attribute
Registers unavailable to be used by the register allocator for a given register set.
available_registers: defaultdict[str, list[int]] = field(default_factory=(lambda: defaultdict(list[int])))
class-attribute
instance-attribute
Registers from a given register set that values can be allocated to in the current context.
allow_infinite: bool = False
class-attribute
instance-attribute
When there are no more registers, use infinite register set.
__init__(allocatable_registers: defaultdict[str, set[int]] = (lambda: defaultdict(lambda: set[int]()))(), next_infinite_indices: defaultdict[str, int] = (lambda: defaultdict(lambda: 0))(), reserved_registers: defaultdict[str, defaultdict[int, int]] = (lambda: defaultdict(lambda: defaultdict[int, int](lambda: 0)))(), available_registers: defaultdict[str, list[int]] = (lambda: defaultdict(list[int]))(), allow_infinite: bool = False) -> None
default_allocatable_registers() -> Iterable[RegisterType]
classmethod
The default registers to be made available when instantiating the stack.
Source code in xdsl/backend/register_stack.py
58 59 60 61 62 63 | |
get(allocatable_registers: Iterable[RegisterType] | None = None, *, allow_infinite: bool = False)
classmethod
Source code in xdsl/backend/register_stack.py
65 66 67 68 69 70 71 72 73 74 75 76 77 | |
push(reg: RegisterType) -> None
Return a register to be made available for allocation.
Source code in xdsl/backend/register_stack.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
pop(reg_type: type[_T]) -> _T
Get the next available register for allocation.
Source code in xdsl/backend/register_stack.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
reserve_register(reg: RegisterType) -> None
Increase the reservation count for a register. If the reservation count is greater than 0, a register cannot be pushed back onto the stack. It is invalid to reserve a register that is available, and popping it before unreserving a register will result in an AssertionError.
Source code in xdsl/backend/register_stack.py
122 123 124 125 126 127 128 129 130 131 | |
reserve_registers(regs: Sequence[RegisterType])
Source code in xdsl/backend/register_stack.py
133 134 135 136 137 138 139 140 141 | |
unreserve_register(reg: RegisterType) -> None
Decrease the reservation count for a register. If the reservation count is 0, make the register available for allocation.
Source code in xdsl/backend/register_stack.py
143 144 145 146 147 148 149 150 151 152 153 154 | |
include_register(reg: RegisterType) -> None
Makes register available for allocation.
Source code in xdsl/backend/register_stack.py
156 157 158 159 160 161 162 | |
exclude_register(reg: RegisterType) -> None
Removes register from available set, if present.
Source code in xdsl/backend/register_stack.py
164 165 166 167 168 169 170 171 172 173 174 175 | |