scale.backend
Class RegisterSet

java.lang.Object
  extended by scale.backend.RegisterSet
Direct Known Subclasses:
AlphaRegisterSet, MipsRegisterSet, PPCRegisterSet, SparcRegisterSet, Trips2RegisterSet, X86RegisterSet, XyzRegisterSet

public abstract class RegisterSet
extends java.lang.Object

This is the base class for describing the register set of the machine.

$Id: RegisterSet.java,v 1.35 2007-10-04 19:57:49 burrill Exp $

Copyright 2007 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.


Field Summary
static short ADRREG
          Register may be used for addresses.
static short AFIREG
          Register may be used for address, floating point or integer values.
static short AIREG
          Register may be used for address or integer values.
static short checkMask
          The sizeMask + RDREG.
static short CNTREG
          Register is a continuation of another register.
static short DBLEREG
          Register spans two contiguous registers.
static short FIREG
          Register may be used for floating point or integer values.
static short FLTREG
          Register may be used for floating point value.
static short INTREG
          Register may be used for integer values.
protected  int nextRegister
          Index of next virtual register.
static short PAIRREG
          Register is first register of a two register pair.
static short QUADREG
          Register spans four contiguous registers.
static short RDREG
          Register is read-only.
protected  short[] registers
          Indexed by register number.
static short sizeMask
          Mask out the size information from the register attributes.
static short SPCREG
          Register may be used for special information.
static short typeMask
          Mask out the type information from the register attributes.
 
Constructor Summary
RegisterSet(short[] actualRegisters)
           
 
Method Summary
 int actualRegister(int reg)
          For architecture where a pseudo register are mapped onto actual registers, return the actual register.
 boolean adrRegister(int reg)
          Return true if the register contains address value.
 boolean compatible(int realReg, int virtualReg)
          Return true if the real register is able to hold the virtual register.
 boolean compatibleNS(int realReg, int virtualReg)
          Return true if the real register is able to hold part of the virtual register.
 boolean continueRegister(int reg)
          Return true if the register is a continuation of a multi-register register.
 java.lang.String display(int register)
          Return a string representation of the register.
 boolean doubleRegister(int reg)
          Return true if the register is a double register.
 boolean floatRegister(int reg)
          Return true if the register contains floating point value.
abstract  short[] getCalleeSaves()
          Return the callee saves registers.
abstract  short[] getCalleeUses()
          Return the callee uses registers.
 short[] getPreferredOrder()
          Return a mapping from an order index to a real register number.
 int getResultRegister(int type)
          Return a register to be used as the result register.
 int getType(int register)
          Return the register attributes.
 void initialize()
          Initialize for a new procedure.
 boolean intRegister(int reg)
          Return true if the register contains integer value.
 boolean isAdrType(int regType)
          Return true if the register type allows addresses.
 boolean isContinueType(int regType)
          Return true if the register type is for a continuation of a multi-register register.
 boolean isDoubleType(int regType)
          Return true if the register type is for a double register.
 boolean isFloatType(int regType)
          Return true if the register type allows floating point values.
 boolean isIntType(int regType)
          Return true if the register type alllows integers.
 boolean isModType(int regType, int bit)
          Return true if the register type has has specified bit set.
 boolean isPairType(int regType)
          Return true if the register type is for the first of a two register pair.
 boolean isQuadType(int regType)
          Return true if the register type is for a quad register.
 boolean isReadOnlyType(int regType)
          Return true if the register can only be read.
 boolean isSpecialType(int regType)
          Return true if the register type is for special values such as a status register.
 int lastRegister(int reg)
          Return the register number of the last register in the sequence of continguous real registers that this virtual register requires.
 boolean modRegister(int reg, int bit)
          Return true if the register is has specified bit set.
 int newTempRegister(int type)
          Allocate a new virtual/temporary register.
abstract  int numAllocatableRegisters()
          Return the number of unique registers that can hold programmer values.
 int numContiguousRegisters(int reg)
          Return the number of continguous real registers that this virtual register requires.
 int numContiguousType(int regType)
          Return the number of contiguous registers required for this type.
 int numRealRegisters()
          Return the number of addressable registers.
 int numRegisters()
          Return the number of registers currently defined.
 boolean pairRegister(int reg)
          Return true if the register is first of a two register pair.
 boolean quadRegister(int reg)
          Return true if the register is a quad register.
 int rangeBegin(int reg)
          Return the first real register that is affected when this register is modified.
 int rangeEnd(int reg)
          Return the last real register that is affected when this register is modified.
 boolean readOnlyRegister(int reg)
          Return true if the register can only be read.
abstract  java.lang.String registerName(int reg)
          Convert a register number into its assembly language form.
abstract  int registerSize(int reg)
          Return the size of the register in addressable memory units.
 void setResultRegister(int reg)
          Specify a register to be used for the next result register.
 boolean specialRegister(int reg)
          Return true if the register contains special values such as a status register.
 boolean tempRegister(int reg)
          Return true if the register is a virtual register.
 int tempRegisterType(int type, int bs)
          Return the register type with the size information added.
abstract  int tempRegisterType(Type type, long bs)
          Return the register type with the size information added.
 boolean useContiguous()
          Return true if virtual registers, that require more than one real register, must be allocated to contiguous real registers.
 boolean virtualRegister(int reg)
          Return true if the register is a virtual register.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DBLEREG

public static final short DBLEREG
Register spans two contiguous registers.

See Also:
Constant Field Values

QUADREG

public static final short QUADREG
Register spans four contiguous registers.

See Also:
Constant Field Values

INTREG

public static final short INTREG
Register may be used for integer values.

See Also:
Constant Field Values

FLTREG

public static final short FLTREG
Register may be used for floating point value.

See Also:
Constant Field Values

ADRREG

public static final short ADRREG
Register may be used for addresses.

See Also:
Constant Field Values

SPCREG

public static final short SPCREG
Register may be used for special information.

See Also:
Constant Field Values

RDREG

public static final short RDREG
Register is read-only.

See Also:
Constant Field Values

PAIRREG

public static final short PAIRREG
Register is first register of a two register pair. A PAIRREG differs from a DBLEREG in that no real register is a pair register. PAIRREG is used to represent two-values that are treated as one such as a complex value. Virtual registers may be paired registers. As such, they must have consecutive virtual register numbers. The lower numbered virtual register is used to refer to the pair. The second virtual register DOES NOT have the PAIRREG attribute. PAIRREG is not used when checking for register compatibility.

See Also:
Constant Field Values

CNTREG

public static final short CNTREG
Register is a continuation of another register.

See Also:
Constant Field Values

FIREG

public static final short FIREG
Register may be used for floating point or integer values.

See Also:
Constant Field Values

AIREG

public static final short AIREG
Register may be used for address or integer values.

See Also:
Constant Field Values

AFIREG

public static final short AFIREG
Register may be used for address, floating point or integer values.

See Also:
Constant Field Values

sizeMask

public static final short sizeMask
Mask out the size information from the register attributes.

See Also:
Constant Field Values

typeMask

public static final short typeMask
Mask out the type information from the register attributes.

See Also:
Constant Field Values

checkMask

public static final short checkMask
The sizeMask + RDREG.

See Also:
Constant Field Values

nextRegister

protected int nextRegister
Index of next virtual register.


registers

protected short[] registers
Indexed by register number.

Constructor Detail

RegisterSet

public RegisterSet(short[] actualRegisters)
Parameters:
actualRegisters - is a list of the types of the actual registers of the machine that specifies how each real register may be used
Method Detail

newTempRegister

public int newTempRegister(int type)
Allocate a new virtual/temporary register.

Parameters:
type - specifies the type of register
Returns:
the register number of the temporary register

getResultRegister

public int getResultRegister(int type)
Return a register to be used as the result register.

See Also:
setResultRegister(int)

setResultRegister

public void setResultRegister(int reg)
Specify a register to be used for the next result register. This register will be used if possible.

See Also:
getResultRegister(int)

getType

public int getType(int register)
Return the register attributes. This information must be specified.


initialize

public void initialize()
Initialize for a new procedure.


numRegisters

public int numRegisters()
Return the number of registers currently defined.


numRealRegisters

public int numRealRegisters()
Return the number of addressable registers. This includes registers that map to other registers.

Returns:
the number of addressable registers

numAllocatableRegisters

public abstract int numAllocatableRegisters()
Return the number of unique registers that can hold programmer values.

Returns:
the number of unique registers that can hold programmer values.

getPreferredOrder

public short[] getPreferredOrder()
Return a mapping from an order index to a real register number. This mapping allows the order of allocation of real registers to be specified. This method SHOULD BE overridden by derived classes.


useContiguous

public boolean useContiguous()
Return true if virtual registers, that require more than one real register, must be allocated to contiguous real registers.


tempRegister

public final boolean tempRegister(int reg)
Return true if the register is a virtual register.


floatRegister

public final boolean floatRegister(int reg)
Return true if the register contains floating point value.


isFloatType

public final boolean isFloatType(int regType)
Return true if the register type allows floating point values.


intRegister

public final boolean intRegister(int reg)
Return true if the register contains integer value.


isIntType

public final boolean isIntType(int regType)
Return true if the register type alllows integers.


adrRegister

public final boolean adrRegister(int reg)
Return true if the register contains address value.


isAdrType

public final boolean isAdrType(int regType)
Return true if the register type allows addresses.


specialRegister

public final boolean specialRegister(int reg)
Return true if the register contains special values such as a status register.


isSpecialType

public final boolean isSpecialType(int regType)
Return true if the register type is for special values such as a status register.


readOnlyRegister

public final boolean readOnlyRegister(int reg)
Return true if the register can only be read.


isReadOnlyType

public final boolean isReadOnlyType(int regType)
Return true if the register can only be read.


pairRegister

public final boolean pairRegister(int reg)
Return true if the register is first of a two register pair.


isPairType

public final boolean isPairType(int regType)
Return true if the register type is for the first of a two register pair.


virtualRegister

public final boolean virtualRegister(int reg)
Return true if the register is a virtual register.


continueRegister

public final boolean continueRegister(int reg)
Return true if the register is a continuation of a multi-register register.


isContinueType

public final boolean isContinueType(int regType)
Return true if the register type is for a continuation of a multi-register register.


doubleRegister

public final boolean doubleRegister(int reg)
Return true if the register is a double register.


isDoubleType

public final boolean isDoubleType(int regType)
Return true if the register type is for a double register.


quadRegister

public final boolean quadRegister(int reg)
Return true if the register is a quad register.


isQuadType

public final boolean isQuadType(int regType)
Return true if the register type is for a quad register.


modRegister

public final boolean modRegister(int reg,
                                 int bit)
Return true if the register is has specified bit set.


isModType

public final boolean isModType(int regType,
                               int bit)
Return true if the register type has has specified bit set.


rangeBegin

public int rangeBegin(int reg)
Return the first real register that is affected when this register is modified. This method will be shadowed by a machine specific register definition class for a machine that catenates multiple registers to provide a higher precision register.


rangeEnd

public int rangeEnd(int reg)
Return the last real register that is affected when this register is modified. This method will be shadowed by a machine specific register definition class for a machine that catenates multiple registers to provide a higher precision register.


actualRegister

public int actualRegister(int reg)
For architecture where a pseudo register are mapped onto actual registers, return the actual register. An example is shown by the SparcV8RegisterSet where a 64-bit long long register is mapped onto a set of two 32-bit registers.


compatibleNS

public final boolean compatibleNS(int realReg,
                                  int virtualReg)
Return true if the real register is able to hold part of the virtual register.


compatible

public final boolean compatible(int realReg,
                                int virtualReg)
Return true if the real register is able to hold the virtual register.


registerName

public abstract java.lang.String registerName(int reg)
Convert a register number into its assembly language form.


registerSize

public abstract int registerSize(int reg)
Return the size of the register in addressable memory units.


getCalleeSaves

public abstract short[] getCalleeSaves()
Return the callee saves registers.


getCalleeUses

public abstract short[] getCalleeUses()
Return the callee uses registers.


tempRegisterType

public int tempRegisterType(int type,
                            int bs)
Return the register type with the size information added.

Parameters:
type - is the type required
bs - is the size required

tempRegisterType

public abstract int tempRegisterType(Type type,
                                     long bs)
Return the register type with the size information added.

Parameters:
type - is the type required
bs - is the size required

numContiguousRegisters

public final int numContiguousRegisters(int reg)
Return the number of continguous real registers that this virtual register requires.


lastRegister

public final int lastRegister(int reg)
Return the register number of the last register in the sequence of continguous real registers that this virtual register requires.


numContiguousType

public final int numContiguousType(int regType)
Return the number of contiguous registers required for this type.


display

public java.lang.String display(int register)
Return a string representation of the register.