org.jikesrvm.compilers.opt.ir
Class AbstractRegisterPool

java.lang.Object
  extended by org.jikesrvm.compilers.opt.ir.AbstractRegisterPool
Direct Known Subclasses:
GenericRegisterPool

public abstract class AbstractRegisterPool
extends Object


Field Summary
private  HashMap<Register,Register> _regPairs
          When 2 registers are necessary to encode a result, such as with a long on 32bit architectures, this hash map remembers the pairing of registers.
protected  int currentNum
          All registers are assigned unique numbers; currentNum is the counter containing the next available register number.
private  Register end
           
private  Register start
           
 
Constructor Summary
AbstractRegisterPool()
           
 
Method Summary
 Register getAddress()
          Gets a new address register.
 Register getCondition()
          Gets a new condition register.
 Register getDouble()
          Gets a new double register.
 Register getFirstSymbolicRegister()
          Return the first symbolic register in this pool.
 Register getFloat()
          Gets a new float register.
 Register getInteger()
          Gets a new integer register.
 Register getLong()
          Gets a new long register.
 Register getReg(Register template)
          Get a new register of the same type as the argument register
 Register getReg(RegisterOperand template)
          Get a new register of the same type as the argument RegisterOperand
 Register getReg(TypeReference type)
          Get a new register of the appropriate type to hold values of 'type'
 Register getSecondReg(Register reg)
          MIR: Get the other half of the register pair that is associated with the argument register.
 Register getValidation()
          Gets a new validation register.
private  Register makeNewReg()
           
 RegisterOperand makeTemp(Operand op)
          Make a temporary register operand that can hold the values implied by the passed operand.
 RegisterOperand makeTemp(RegisterOperand template)
          Make a temporary register operand that is similar to the argument.
 RegisterOperand makeTemp(TypeReference type)
          Make a temporary register operand to hold values of the specified type (a new register is allocated).
 RegisterOperand makeTempAddress()
          Make a temporary to hold an address (allocating a new register).
 RegisterOperand makeTempBoolean()
          Make a temporary to hold a boolean (allocating a new register).
 RegisterOperand makeTempCondition()
          Make a temporary to hold a condition code (allocating a new register).
 RegisterOperand makeTempDouble()
          Make a temporary to hold a double (allocating a new register).
 RegisterOperand makeTempFloat()
          Make a temporary to hold a float (allocating a new register).
 RegisterOperand makeTempInt()
          Make a temporary to hold an int (allocating a new register).
 RegisterOperand makeTempLong()
          Make a temporary to hold a long (allocating a new register).
 RegisterOperand makeTempOffset()
          Make a temporary to hold an address (allocating a new register).
 RegisterOperand makeTempValidation()
          Make a temporary to hold a guard (validation) (allocating a new register).
private  void registerListappend(Register reg)
           
private  void registerListremove(Register e)
           
 void release(RegisterOperand r)
          Release a now unused register.
 void removeRegister(Register reg)
          Remove register from register pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

start

private Register start

end

private Register end

_regPairs

private final HashMap<Register,Register> _regPairs
When 2 registers are necessary to encode a result, such as with a long on 32bit architectures, this hash map remembers the pairing of registers. It's key is the 1st register and the value is the 2nd register.


currentNum

protected int currentNum
All registers are assigned unique numbers; currentNum is the counter containing the next available register number.

Constructor Detail

AbstractRegisterPool

public AbstractRegisterPool()
Method Detail

getFirstSymbolicRegister

public Register getFirstSymbolicRegister()
Return the first symbolic register in this pool.


registerListappend

private void registerListappend(Register reg)

registerListremove

private void registerListremove(Register e)

makeNewReg

private Register makeNewReg()

release

public void release(RegisterOperand r)
Release a now unused register.

NOTE: It is the CALLERS responsibility to ensure that the register is no longer used!!!!

Parameters:
r - the register to release

removeRegister

public void removeRegister(Register reg)
Remove register from register pool.


getAddress

public Register getAddress()
Gets a new address register.

Returns:
the newly created register object

getInteger

public Register getInteger()
Gets a new integer register.

Returns:
the newly created register object

getFloat

public Register getFloat()
Gets a new float register.

Returns:
the newly created register object

getDouble

public Register getDouble()
Gets a new double register.

Returns:
the newly created register object

getCondition

public Register getCondition()
Gets a new condition register.

Returns:
the newly created register object

getLong

public Register getLong()
Gets a new long register.

Returns:
the newly created register object

getValidation

public Register getValidation()
Gets a new validation register.

Returns:
the newly created register object

getReg

public Register getReg(Register template)
Get a new register of the same type as the argument register

Parameters:
template - the register to get the type from
Returns:
the newly created register object

getReg

public Register getReg(RegisterOperand template)
Get a new register of the same type as the argument RegisterOperand

Parameters:
template - the register operand to get the type from
Returns:
the newly created register object

getReg

public Register getReg(TypeReference type)
Get a new register of the appropriate type to hold values of 'type'

Parameters:
type - the type of values that the register will hold
Returns:
the newly created register object

getSecondReg

public Register getSecondReg(Register reg)
MIR: Get the other half of the register pair that is associated with the argument register.

Note: this isn't incredibly general, but all architectures we're currently targeting need at most 2 machine registers to hold Java data values, so for now don't bother implementing a general mechanism.

Parameters:
reg - a register that may already be part of a register pair
Returns:
the register that is the other half of the register pair, if the pairing doesn't already exist then it is created.

makeTemp

public RegisterOperand makeTemp(TypeReference type)
Make a temporary register operand to hold values of the specified type (a new register is allocated).

Parameters:
type - the type of values to be held in the temp register
Returns:
the new temp

makeTemp

public RegisterOperand makeTemp(RegisterOperand template)
Make a temporary register operand that is similar to the argument.

Parameters:
template - the register operand to use as a template.
Returns:
the new temp

makeTemp

public RegisterOperand makeTemp(Operand op)
Make a temporary register operand that can hold the values implied by the passed operand.

Parameters:
op - the operand to use as a template.
Returns:
the new temp

makeTempAddress

public RegisterOperand makeTempAddress()
Make a temporary to hold an address (allocating a new register).

Returns:
the newly created temporary

makeTempOffset

public RegisterOperand makeTempOffset()
Make a temporary to hold an address (allocating a new register).

Returns:
the newly created temporary

makeTempInt

public RegisterOperand makeTempInt()
Make a temporary to hold an int (allocating a new register).

Returns:
the newly created temporary

makeTempBoolean

public RegisterOperand makeTempBoolean()
Make a temporary to hold a boolean (allocating a new register).

Returns:
the newly created temporary

makeTempFloat

public RegisterOperand makeTempFloat()
Make a temporary to hold a float (allocating a new register).

Returns:
the newly created temporary

makeTempDouble

public RegisterOperand makeTempDouble()
Make a temporary to hold a double (allocating a new register).

Returns:
the newly created temporary

makeTempLong

public RegisterOperand makeTempLong()
Make a temporary to hold a long (allocating a new register).

Returns:
the newly created temporary

makeTempCondition

public RegisterOperand makeTempCondition()
Make a temporary to hold a condition code (allocating a new register).

Returns:
the newly created temporary

makeTempValidation

public RegisterOperand makeTempValidation()
Make a temporary to hold a guard (validation) (allocating a new register).

Returns:
the newly created temporary