|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.backend.RegisterAllocator
public abstract class RegisterAllocator
This is the base class for all register allocators.
$Id: RegisterAllocator.java,v 1.55 2007-04-12 20:09:29 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Field Summary | |
---|---|
static boolean |
classTrace
True if traces are to be performed. |
protected Generator |
generator
The backend in use for code generation. |
protected BitVect[] |
regDef
regDef[instruction,register] is true if instruction sets the register. |
protected int[] |
regDefCnt
A count of the number of times the register was set - indexed by register number. |
protected RegisterSet |
registers
The register set definition in use for allocation. |
protected BitVect[] |
regMod
regMod[instruction,register] is true if instruction destroys the value in the register. |
protected long[] |
regStrength
The register strength - indexed by register number. |
protected BitVect[] |
regUse
regUse[instruction,register] is true if instruction uses the register. |
protected int[] |
regUseCnt
A count of the number of times the register was referenced - indexed by register number. |
static int |
spillLoadCount
|
static int |
spillStoreCount
|
protected boolean |
trace
True if tracing requested. |
Constructor Summary | |
---|---|
RegisterAllocator(Generator generator,
boolean trace)
|
Method Summary | |
---|---|
abstract int[] |
allocate(Instruction first)
Determine a mapping from virtual registers to real registers. |
protected BitVect[] |
compress(BitVect[] in)
Remove un-needed bit vectors from the liveness array. |
protected BitVect[] |
computeLiveness(Instruction[] insts)
Compute the liveness for every register at every instruction. |
protected void |
computePredecessors(Instruction first)
The predecessors of labels are determined. |
void |
defRegister(int inst,
int reg)
Specify that instruction inst defines the value of register reg. |
long |
getStrength(int register)
Return the importance of the register. |
protected Instruction[] |
linearize(Instruction first)
Linearize the instructions so that an index can be used to access an instruction. |
void |
modRegister(int inst,
int reg)
Specify that instruction inst destroys the value in register reg. |
protected void |
spill(int reg,
Instruction first,
boolean aggressive)
Insert loads and stores to shorten the liveness ranges of a virtual register. |
static int |
spillLoads()
Return the number of spill loads inserted. |
static int |
spillStores()
Return the number of spill stores inserted. |
protected BitVect[] |
transpose(BitVect[] in,
int n)
Convert a m by n bit array to an n by m bit array. |
void |
useRegister(int inst,
int reg,
int strength)
Specify that instruction inst uses the value of register reg. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int spillLoadCount
public static int spillStoreCount
public static boolean classTrace
protected RegisterSet registers
protected Generator generator
protected BitVect[] regUse
protected BitVect[] regDef
protected BitVect[] regMod
protected long[] regStrength
protected int[] regDefCnt
protected int[] regUseCnt
protected boolean trace
Constructor Detail |
---|
public RegisterAllocator(Generator generator, boolean trace)
Method Detail |
---|
public static int spillLoads()
public static int spillStores()
public void useRegister(int inst, int reg, int strength)
inst
- is the instruction indexreg
- is the registerstrength
- is the importance of the instructiondefRegister(int,int)
,
Instruction.specifyRegisterUsage(scale.backend.RegisterAllocator, int, int)
public void defRegister(int inst, int reg)
inst
- is the instruction indexreg
- is the registeruseRegister(int,int,int)
,
Instruction.specifyRegisterUsage(scale.backend.RegisterAllocator, int, int)
public void modRegister(int inst, int reg)
inst
- is the instruction indexreg
- is the registeruseRegister(int,int,int)
,
Instruction.specifyRegisterUsage(scale.backend.RegisterAllocator, int, int)
public long getStrength(int register)
useRegister(int,int,int)
public abstract int[] allocate(Instruction first)
first
- is the first instruction in the instruction sequence
protected Instruction[] linearize(Instruction first)
first
- is the first instructionprotected BitVect[] computeLiveness(Instruction[] insts)
protected BitVect[] compress(BitVect[] in)
protected BitVect[] transpose(BitVect[] in, int n)
n
- is the max in columnsprotected void computePredecessors(Instruction first)
first
- is the first instructionprotected void spill(int reg, Instruction first, boolean aggressive)
reg
- is the register to spillfirst
- is the first instruction of the programaggressive
- is true if aggressive spilling should be used
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |