Allocates values in function passed in to registers.
The whole function must have been lowered to the relevant x86 dialects
and it must contain no unrealized casts.
Source code in xdsl/backend/x86/register_allocation.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 | def allocate_func(self, func: x86_func.FuncOp) -> None:
"""
Allocates values in function passed in to registers.
The whole function must have been lowered to the relevant x86 dialects
and it must contain no unrealized casts.
"""
if not func.body.blocks:
# External function declaration
return
if len(func.body.blocks) != 1:
raise NotImplementedError(
f"Cannot register allocate func with {len(func.body.blocks)} blocks."
)
preallocated = {
reg
for reg in RegisterAllocatableOperation.iter_all_used_registers(func.body)
if isinstance(reg, registers.X86RegisterType)
}
for pa_reg in preallocated:
self.available_registers.exclude_register(pa_reg)
block = func.body.block
self.live_ins_per_block = live_ins_per_block(block)
assert not self.live_ins_per_block[block]
self.allocate_block(block)
|