public abstract class GenericRegisterRestrictions extends Object
Each architecture will subclass this in a class RegisterRestrictions.
Modifier and Type | Class and Description |
---|---|
private static class |
GenericRegisterRestrictions.RestrictedRegisterSet
An instance of this class represents restrictions on physical register
assignment.
|
Modifier and Type | Field and Description |
---|---|
private HashMap<Register,GenericRegisterRestrictions.RestrictedRegisterSet> |
hash |
private HashSet<Register> |
noSpill |
protected GenericPhysicalRegisterSet |
phys |
protected RegisterAllocatorState |
regAllocState |
Modifier | Constructor and Description |
---|---|
protected |
GenericRegisterRestrictions(GenericPhysicalRegisterSet phys) |
Modifier and Type | Method and Description |
---|---|
void |
addArchRestrictions(BasicBlock bb,
ArrayList<LiveIntervalElement> symbolics)
Add architecture-specific register restrictions for a basic block.
|
protected void |
addRestriction(Register symb,
Register p)
Record thats it is illegal to assign a symbolic register symb to a
physical register p.
|
protected void |
addRestrictions(Register symb,
BitSet set)
Records that it is illegal to assign a symbolic register symb to any
of a set of physical registers.
|
boolean |
allVolatilesForbidden(Register symb)
Is it forbidden to assign symbolic register symb to any volatile
register?
|
protected boolean |
contains(LiveIntervalElement R,
int n)
Does a live range R contain an instruction with number n?
|
(package private) void |
forbidAllVolatiles(Register symb)
Records that it is illegal to assign a symbolic register symb to any
volatile physical registerss.
|
(package private) GenericRegisterRestrictions.RestrictedRegisterSet |
getRestrictions(Register symb) |
void |
init(IR ir)
Records all the register restrictions dictated by an IR.
|
boolean |
isForbidden(Register symb,
Register phys)
Is it forbidden to assign symbolic register symb to physical register
phys?
|
abstract boolean |
isForbidden(Register symb,
Register r,
Instruction s)
Is it forbidden to assign symbolic register symb to physical register r
in instruction s?
|
boolean |
mustNotSpill(Register r) |
protected void |
noteMustNotSpill(Register r) |
private boolean |
overlaps(LiveIntervalElement li1,
LiveIntervalElement li2)
Do two live ranges overlap?
|
private void |
processBlock(BasicBlock bb,
LiveInterval liveness)
Records all the register restrictions dictated by live ranges on a
particular basic block.
|
private final HashMap<Register,GenericRegisterRestrictions.RestrictedRegisterSet> hash
protected final GenericPhysicalRegisterSet phys
protected RegisterAllocatorState regAllocState
protected GenericRegisterRestrictions(GenericPhysicalRegisterSet phys)
protected final void noteMustNotSpill(Register r)
public final boolean mustNotSpill(Register r)
public final void init(IR ir)
ir
- the IR to processprivate void processBlock(BasicBlock bb, LiveInterval liveness)
PRECONDITION: the instructions in each basic block are numbered in increasing order before calling this.
bb
- the bb to processliveness
- liveness information for the IRpublic void addArchRestrictions(BasicBlock bb, ArrayList<LiveIntervalElement> symbolics)
bb
- the basic blocksymbolics
- the live intervals for symbolic registers on this
blockprotected final boolean contains(LiveIntervalElement R, int n)
PRECONDITION: the instructions in each basic block are numbered in increasing order before calling this.
R
- the live rangen
- the instruction numbertrue
if and only if the live range contains an instruction
with the given numberprivate boolean overlaps(LiveIntervalElement li1, LiveIntervalElement li2)
PRECONDITION: the instructions in each basic block are numbered in increasing order before calling this.
li1
- first live rangeli2
- second live rangetrue
if and only if the live ranges overlapfinal void forbidAllVolatiles(Register symb)
symb
- the register that must not be assigned to a volatile
physical registerprotected final void addRestrictions(Register symb, BitSet set)
symb
- the symbolic register to be restrictedset
- the physical registers that the symbolic register
must not be assigned toprotected final void addRestriction(Register symb, Register p)
symb
- the symbolic register to be restrictedp
- the physical register that the symbolic register
must not be assigned tofinal GenericRegisterRestrictions.RestrictedRegisterSet getRestrictions(Register symb)
symb
- the register whose restrictions where interested innull
if no restrictions.public final boolean allVolatilesForbidden(Register symb)
symb
- symbolic register to checktrue
: yes, all volatiles are forbidden.
false
:maybe, maybe notpublic final boolean isForbidden(Register symb, Register phys)
symb
- a symbolic registerphys
- a physical registertrue
if it's forbidden, false otherwisepublic abstract boolean isForbidden(Register symb, Register r, Instruction s)
symb
- a symbolic registerr
- a physical registers
- the instruction that's the scope for the checktrue
if it's forbidden, false otherwise