public abstract class LocalRegisterAllocator extends Object implements ILOCProcessor
| Modifier and Type | Field and Description |
|---|---|
ILOCBasicBlock |
currentBlock
Basic block that is currently being allocated
|
ILOCFunction |
currentFunction
Function that is currently being allocated
|
Set<ILOCBasicBlock> |
handled
Collection of basic blocks that have already been allocated
|
int |
numPhysicalRegs
Number of physical registers available for allocation
|
| Constructor and Description |
|---|
LocalRegisterAllocator(int numRegisters)
Initialize register allocator
|
| Modifier and Type | Method and Description |
|---|---|
void |
allocateRegisters(ILOCBasicBlock block)
Perform local register allocation for a single basic block.
|
void |
emitSpillLoad(int idx,
int offset,
int reg,
String comment)
Emit a new instruction at the given index.
|
int |
emitSpillStore(int idx,
int reg,
String comment)
Emit a new instruction at the given index.
|
void |
process(ILOCBasicBlock block)
Perform register allocation for a basic block and all basic blocks
reachable from it.
|
void |
process(ILOCProgram program)
Perform register allocation on each function.
|
public int numPhysicalRegs
public ILOCFunction currentFunction
public ILOCBasicBlock currentBlock
public Set<ILOCBasicBlock> handled
public LocalRegisterAllocator(int numRegisters)
numRegisters - Number of physical registerspublic void process(ILOCProgram program)
process in interface ILOCProcessorprogram - ILOCProgram to processpublic void process(ILOCBasicBlock block)
block - Entry blockpublic void allocateRegisters(ILOCBasicBlock block)
block - Block to allocatepublic void emitSpillLoad(int idx,
int offset,
int reg,
String comment)
idx - Block index at which to insert the instructionoffset - Spill value offsetreg - Destination registercomment - Comment for new instruction (can be blank)public int emitSpillStore(int idx,
int reg,
String comment)
idx - Block index at which to insert the instructionreg - Source registercomment - Comment for new instruction (can be blank)Copyright © 2019. All rights reserved.