org.jikesrvm.compilers.opt.regalloc
Class GenericRegisterRestrictions

java.lang.Object
  extended by org.jikesrvm.compilers.opt.regalloc.GenericRegisterRestrictions
Direct Known Subclasses:
RegisterRestrictions

public abstract class GenericRegisterRestrictions
extends Object

An instance of this class provides a mapping from symbolic register to a set of restricted registers.

Each architecture will subclass this in a class RegisterRestrictions.


Nested Class Summary
private static class GenericRegisterRestrictions.RestrictedRegisterSet
          An instance of this class represents restrictions on physical register assignment.
 
Field Summary
private  HashMap<Register,GenericRegisterRestrictions.RestrictedRegisterSet> hash
           
private  HashSet<Register> noSpill
           
protected  ArchitectureSpecificOpt.PhysicalRegisterSet phys
           
 
Constructor Summary
protected GenericRegisterRestrictions(ArchitectureSpecificOpt.PhysicalRegisterSet phys)
          Default Constructor
 
Method Summary
 void addArchRestrictions(BasicBlock bb, ArrayList<LiveIntervalElement> symbolics)
          Add architecture-specific register restrictions for a basic block.
protected  void addRestriction(Register symb, Register p)
          Record that it is illegal to assign a symbolic register symb to a physical register p
protected  void addRestrictions(Register symb, BitSet set)
          Record 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)
          Record that it is illegal to assign a symbolic register symb to any volatile physical registers
(package private)  GenericRegisterRestrictions.RestrictedRegisterSet getRestrictions(Register symb)
          Return the set of restricted physical register for a given symbolic register.
 void init(IR ir)
          Record 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)
          Is spilling a register forbidden?
protected  void noteMustNotSpill(Register r)
          Record that the register allocator must not spill a symbolic register.
private  boolean overlaps(LiveIntervalElement li1, LiveIntervalElement li2)
          Do two live ranges overlap?
private  void processBlock(BasicBlock bb)
          Record all the register restrictions dictated by live ranges on a particular basic block.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hash

private final HashMap<Register,GenericRegisterRestrictions.RestrictedRegisterSet> hash

noSpill

private final HashSet<Register> noSpill

phys

protected final ArchitectureSpecificOpt.PhysicalRegisterSet phys
Constructor Detail

GenericRegisterRestrictions

protected GenericRegisterRestrictions(ArchitectureSpecificOpt.PhysicalRegisterSet phys)
Default Constructor

Method Detail

noteMustNotSpill

protected final void noteMustNotSpill(Register r)
Record that the register allocator must not spill a symbolic register.


mustNotSpill

public final boolean mustNotSpill(Register r)
Is spilling a register forbidden?


init

public final void init(IR ir)
Record all the register restrictions dictated by an IR. PRECONDITION: the instructions in each basic block are numbered in increasing order before calling this. The number for each instruction is stored in its scratch field.


processBlock

private void processBlock(BasicBlock bb)
Record all the register restrictions dictated by live ranges on a particular basic block.

PRECONDITION: the instructions in each basic block are numbered in increasing order before calling this. The number for each instruction is stored in its scratch field.


addArchRestrictions

public void addArchRestrictions(BasicBlock bb,
                                ArrayList<LiveIntervalElement> symbolics)
Add architecture-specific register restrictions for a basic block. Override as needed.

Parameters:
bb - the basic block
symbolics - the live intervals for symbolic registers on this block

contains

protected final boolean contains(LiveIntervalElement R,
                                 int n)
Does a live range R contain an instruction with number n?

PRECONDITION: the instructions in each basic block are numbered in increasing order before calling this. The number for each instruction is stored in its scratch field.


overlaps

private boolean overlaps(LiveIntervalElement li1,
                         LiveIntervalElement li2)
Do two live ranges overlap?

PRECONDITION: the instructions in each basic block are numbered in increasing order before calling this. The number for each instruction is stored in its scratch field.


forbidAllVolatiles

final void forbidAllVolatiles(Register symb)
Record that it is illegal to assign a symbolic register symb to any volatile physical registers


addRestrictions

protected final void addRestrictions(Register symb,
                                     BitSet set)
Record that it is illegal to assign a symbolic register symb to any of a set of physical registers


addRestriction

protected final void addRestriction(Register symb,
                                    Register p)
Record that it is illegal to assign a symbolic register symb to a physical register p


getRestrictions

final GenericRegisterRestrictions.RestrictedRegisterSet getRestrictions(Register symb)
Return the set of restricted physical register for a given symbolic register. Return null if no restrictions.


allVolatilesForbidden

public final boolean allVolatilesForbidden(Register symb)
Is it forbidden to assign symbolic register symb to any volatile register?

Returns:
true: yes, all volatiles are forbidden. false :maybe, maybe not

isForbidden

public final boolean isForbidden(Register symb,
                                 Register phys)
Is it forbidden to assign symbolic register symb to physical register phys?


isForbidden

public abstract boolean isForbidden(Register symb,
                                    Register r,
                                    Instruction s)
Is it forbidden to assign symbolic register symb to physical register r in instruction s?