org.jikesrvm.compilers.opt.ir.operand
Class RegisterOperand

java.lang.Object
  extended by org.jikesrvm.compilers.opt.ir.operand.Operand
      extended by org.jikesrvm.compilers.opt.ir.operand.RegisterOperand

public final class RegisterOperand
extends Operand

A symbolic or physical register. A wrapper around an Register that may contain program-point specific information about the value denoted by the Register.

TODO: This class is due for a refactor into subclasses to split out the symbolic & physical registers and to create special behavior for symbolic registers used as phi operands and as validation (guard) operands.

See Also:
Operand

Field Summary
private static byte BOUNDS_CHECK
          Guard operand that originates from a bounds-check
private static int DECLARED_TYPE
          The type has been declared as obtained from a getfield, getstatic, putfield, putstatic, array load
private static byte EXTANT
          is this an extant object?
private  byte flags
          Type of a RegisterOperand can be in one of three states: a- declared: the type obtained from a getfield,getstatic,putfield,putstatic,array load b- precise: obtained from a NEW.
private  byte flags2
          Some bits used to characterize guards.
private  short info
          16bit scratch word that can be used for different optimizations.
private static byte NON_VOLATILE
          is this a non-volatile physical register?
private static byte NOT_TAKEN
          guard operand that represents a not taken branch
private static byte NULL_CHECK
          Guard operand that originates from a null-check
private static byte PARAMETER
          the register operand is for a parameter
private static int POSITIVE
          Is the contents of the int-like register always positive?
private static int PRECISE_TYPE
          We know precisely the type as it was create by a NEW
 Register register
          Register object that this operand uses.
 Object scratchObject
          Optimizations can use it for different purposes, as long as they are not used simultaneously
private static byte TAKEN
          guard operand that represents a taken branch
 TypeReference type
          Inferred data type of the contents of the register.
 
Fields inherited from class org.jikesrvm.compilers.opt.ir.operand.Operand
instruction
 
Constructor Summary
RegisterOperand(Register reg, TypeReference typ)
          Constructs a new register operand with the given register and data type.
RegisterOperand(Register reg, TypeReference typ, byte inFlags, boolean isPrecise, boolean isDeclared)
          Constructs a new register operand with the given register, data type and flags.
 
Method Summary
 void addFlags(byte inFlag)
          Merge two sets of register flags
 void append(RegisterOperand next)
          Sets scratch object of the register operand to parameter.
 void clearBoundsCheck()
          Clear this from being a guard operand from a bounds check
 void clearDeclaredType()
          Clear this register from having a declared type
 void clearExtant()
          Clear this register from holding an extant value
 void clearFlags()
          Clear the flags of a register
 void clearNonVolatile()
          Set this register as being volatile
 void clearNotTaken()
          Clear this from being a guard operand from a not taken branch
 void clearNullCheck()
          Clear this from being a guard operand from a null check
 void clearParameter()
          Clear this register from being used to hold parameters
 void clearPreciseType()
          Clear this register from having a precise type
 void clearTaken()
          Clear this from being a guard operand from a taken branch
 Operand copy()
          Returns a copy of this register operand as an operand
 RegisterOperand copyD2D()
          Returns a copy of this def register operand as a def.
 RegisterOperand copyD2U()
          Returns a copy of this def register operand as a use.
 RegisterOperand copyRO()
          Returns a copy of this register operand as a register operand.
 void copyType(RegisterOperand rhs)
          Copy type information from the given operand into this one including flag information on whether this is a precise type or not
 RegisterOperand copyU2D()
          Returns a copy of this use register operand as a def.
 RegisterOperand copyU2U()
          Returns a copy of this use register operand as another use reg operand.
 byte getFlags()
          Return a byte encoding register flags
 short getInfo()
          Get info scratch short
 RegisterOperand getNext()
          Returns the scratch object of the register operand
 Register getRegister()
           
 TypeReference getType()
          Return the TypeReference of the value represented by the operand.
 boolean hasLessConservativeFlags(RegisterOperand other)
          Return true if we have any bits set (flag true) that other doesn't.
 boolean isAddress()
          Does the operand represent a value of the address data type?
 boolean isBoundsCheck()
          Is this a guard operand from a bounds check?
 boolean isDeclaredOrPreciseType()
          Is this register a declared or a precise type?
 boolean isDeclaredType()
          Does this register have a declared type?
 boolean isDefinitelyNull()
          Does the operand definitely represent null?
 boolean isDouble()
          Does the operand represent a value of the double data type?
 boolean isExtant()
          Is this register known to contain either NULL or an object whose class was fully loaded before the current method was called?
 boolean isFloat()
          Does the operand represent a value of the float data type?
 boolean isInt()
          Does the operand represent a value of the int data type?
 boolean isIntLike()
          Does the operand represent a value of an int-like data type?
 boolean isLong()
          Does the operand represent a value of the long data type?
 boolean isNonVolatile()
          Is this a volatile register?
 boolean isNotTaken()
          Is this a guard operand from a not taken branch?
 boolean isNullCheck()
          Is this a guard operand from a null check?
 boolean isParameter()
          Does this register hold a parameter
 boolean isPositiveInt()
          Is this register a positive int?
 boolean isPreciseType()
          Do we know the precise type of this register?
 boolean isRef()
          Does the operand represent a value of the reference data type?
 boolean isTaken()
          Is this a guard operand from a taken branch?
 void meetInheritableFlags(RegisterOperand other)
          Currently all flags are "meetable", so mask flags together
 void refine(TypeReference t)
          Refine the type of the register to t if t is a more precise type than the register currently holds
 void setBoundsCheck()
          Set this as a guard operand from a bounds check
 void setDeclaredType()
          Set this register as having a declared type
 void setExtant()
          Set this register as holding an extant object (or NULL) (ie, an object whose class was fully loaded before the current method was called).
 void setInfo(short value)
          Set info scratch short
 void setInheritableFlags(RegisterOperand src)
          Currently all flags are inheritable, so copy all flags from src
 void setNext(RegisterOperand Next)
          Sets scratch object of the register operand to parameter.
 void setNonVolatile()
          Set this register as being non-volatile
 void setNotTaken()
          Set this a guard operand from a not taken branch
 void setNullCheck()
          Set this as being a guard operand from a null check
 void setParameter()
          Set this register as being used to hold parameters
 void setPositiveInt()
          Set this register as being a positive int
 void setPreciseType()
          Set this register as having a precise type
 void setPreciseType(TypeReference t)
          Set the TypeReference of the value represented by the operand and make the type precise.
 void setRegister(Register register)
          Modify the register
 void setTaken()
          Set this a guard operand from a taken branch
 void setType(TypeReference t)
          Set the TypeReference of the value represented by the operand.
 boolean similar(Operand op)
          Returns whether the given operand is a register operand and has the same register object.
 String toString()
          Returns the string representation of this operand.
private  void verifyPreciseType()
           
 
Methods inherited from class org.jikesrvm.compilers.opt.ir.operand.Operand
asAddressConstant, asBlock, asBranch, asClassConstant, asCondition, asDoubleConstant, asFloatConstant, asIntConstant, asLocation, asLongConstant, asMemory, asMethod, asNullConstant, asObjectConstant, asRegister, asStackLocation, asStringConstant, asTIBConstant, asType, conservativelyApproximates, getIndexInInstruction, isAddressConstant, isBlock, isBranch, isClassConstant, isConstant, isDoubleConstant, isFloatConstant, isIntConstant, isLocation, isLongConstant, isMemory, isMethod, isMovableObjectConstant, isNullConstant, isObjectConstant, isRegister, isStackLocation, isStringConstant, isTIBConstant, isTrueGuard, isType, meet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

register

public Register register
Register object that this operand uses. TODO: make this field private, it is accessed via generated code


type

public TypeReference type
Inferred data type of the contents of the register. TODO: make this field private, it is accessed via generated code


scratchObject

public Object scratchObject
Optimizations can use it for different purposes, as long as they are not used simultaneously


info

private short info
16bit scratch word that can be used for different optimizations.


flags

private byte flags
Type of a RegisterOperand can be in one of three states:
  1. a- declared: the type obtained from a getfield,getstatic,putfield,putstatic,array load
  2. b- precise: obtained from a NEW.
  3. c- computed: (default) computed from propagating types.
If the register is holding an int-like type it can be holding just positive values. For calling conventions registers can be for parameters or volatile/non-volatile. The value in the register can also be extant - that is a definite non-null value (e.g. this pointer).


DECLARED_TYPE

private static final int DECLARED_TYPE
The type has been declared as obtained from a getfield, getstatic, putfield, putstatic, array load

See Also:
Constant Field Values

PRECISE_TYPE

private static final int PRECISE_TYPE
We know precisely the type as it was create by a NEW

See Also:
Constant Field Values

POSITIVE

private static final int POSITIVE
Is the contents of the int-like register always positive?

See Also:
Constant Field Values

PARAMETER

private static final byte PARAMETER
the register operand is for a parameter

See Also:
Constant Field Values

NON_VOLATILE

private static final byte NON_VOLATILE
is this a non-volatile physical register?

See Also:
Constant Field Values

EXTANT

private static final byte EXTANT
is this an extant object?

See Also:
Constant Field Values

flags2

private byte flags2
Some bits used to characterize guards. TODO: Maybe declare a new type GuardOperand extends RegisterOperand, and save this state there?


TAKEN

private static final byte TAKEN
guard operand that represents a taken branch

See Also:
Constant Field Values

NOT_TAKEN

private static final byte NOT_TAKEN
guard operand that represents a not taken branch

See Also:
Constant Field Values

BOUNDS_CHECK

private static final byte BOUNDS_CHECK
Guard operand that originates from a bounds-check

See Also:
Constant Field Values

NULL_CHECK

private static final byte NULL_CHECK
Guard operand that originates from a null-check

See Also:
Constant Field Values
Constructor Detail

RegisterOperand

public RegisterOperand(Register reg,
                       TypeReference typ)
Constructs a new register operand with the given register and data type.

Parameters:
reg - register object
typ - data type

RegisterOperand

public RegisterOperand(Register reg,
                       TypeReference typ,
                       byte inFlags,
                       boolean isPrecise,
                       boolean isDeclared)
Constructs a new register operand with the given register, data type and flags.

Parameters:
reg - register object
typ - data type
inFlags - to set for this register
isPrecise - is this a precise type
isDeclared - is this a declared type
Method Detail

copy

public Operand copy()
Returns a copy of this register operand as an operand

Specified by:
copy in class Operand
Returns:
a copy of this

copyRO

public RegisterOperand copyRO()
Returns a copy of this register operand as a register operand.

NOTE: preserves the flags, info and scratchObject. Preserving is required in all cases as several phases also depend on scratch and/or scratchObject being copied


copyU2U

public RegisterOperand copyU2U()
Returns a copy of this use register operand as another use reg operand.


copyD2U

public RegisterOperand copyD2U()
Returns a copy of this def register operand as a use.


copyU2D

public RegisterOperand copyU2D()
Returns a copy of this use register operand as a def.


copyD2D

public RegisterOperand copyD2D()
Returns a copy of this def register operand as a def.


similar

public boolean similar(Operand op)
Returns whether the given operand is a register operand and has the same register object.

Specified by:
similar in class Operand
Parameters:
op - operand to compare against
Returns:
true if this and op are semantically equivalent or false if they are not.

copyType

public void copyType(RegisterOperand rhs)
Copy type information from the given operand into this one including flag information on whether this is a precise type or not

Parameters:
rhs - the type to copy information from

isIntLike

public boolean isIntLike()
Description copied from class: Operand
Does the operand represent a value of an int-like data type?

Overrides:
isIntLike in class Operand
Returns:
true if the data type of this is int-like as defined by TypeReference.isIntLikeType() or false if it is not.

isInt

public boolean isInt()
Description copied from class: Operand
Does the operand represent a value of the int data type?

Overrides:
isInt in class Operand
Returns:
true if the data type of this is an int as defined by TypeReference.isIntType() or false if it is not.

isLong

public boolean isLong()
Description copied from class: Operand
Does the operand represent a value of the long data type?

Overrides:
isLong in class Operand
Returns:
true if the data type of this is a long as defined by TypeReference.isLongType() or false if it is not.

isFloat

public boolean isFloat()
Description copied from class: Operand
Does the operand represent a value of the float data type?

Overrides:
isFloat in class Operand
Returns:
true if the data type of this is a float as defined by TypeReference.isFloatType() or false if it is not.

isDouble

public boolean isDouble()
Description copied from class: Operand
Does the operand represent a value of the double data type?

Overrides:
isDouble in class Operand
Returns:
true if the data type of this is a double as defined by TypeReference.isDoubleType() or false if it is not.

isRef

public boolean isRef()
Description copied from class: Operand
Does the operand represent a value of the reference data type?

Overrides:
isRef in class Operand
Returns:
true if the data type of this is a reference as defined by TypeReference.isReferenceType() or false if it is not.

isAddress

public boolean isAddress()
Description copied from class: Operand
Does the operand represent a value of the address data type?

Overrides:
isAddress in class Operand
Returns:
true if the data type of this is an address as defined by TypeReference.isAddressType() or false if it is not.

isDefinitelyNull

public boolean isDefinitelyNull()
Description copied from class: Operand
Does the operand definitely represent null?

Overrides:
isDefinitelyNull in class Operand
Returns:
true if the operand definitely represents null or false if it does not.

isParameter

public boolean isParameter()
Does this register hold a parameter


setParameter

public void setParameter()
Set this register as being used to hold parameters


clearParameter

public void clearParameter()
Clear this register from being used to hold parameters


isNonVolatile

public boolean isNonVolatile()
Is this a volatile register?


setNonVolatile

public void setNonVolatile()
Set this register as being non-volatile


clearNonVolatile

public void clearNonVolatile()
Set this register as being volatile


isExtant

public boolean isExtant()
Is this register known to contain either NULL or an object whose class was fully loaded before the current method was called? This fact is used to determine whether we can optimize away inline guards based on pre-existence based inlining.


setExtant

public void setExtant()
Set this register as holding an extant object (or NULL) (ie, an object whose class was fully loaded before the current method was called). This fact is used to determine whether we can optimize away inline guards based on pre-existence based inlining.


clearExtant

public void clearExtant()
Clear this register from holding an extant value


isDeclaredType

public boolean isDeclaredType()
Does this register have a declared type?


setDeclaredType

public void setDeclaredType()
Set this register as having a declared type


clearDeclaredType

public void clearDeclaredType()
Clear this register from having a declared type


verifyPreciseType

private void verifyPreciseType()

isPreciseType

public boolean isPreciseType()
Do we know the precise type of this register?


setPreciseType

public void setPreciseType()
Set this register as having a precise type


clearPreciseType

public void clearPreciseType()
Clear this register from having a precise type


isDeclaredOrPreciseType

public boolean isDeclaredOrPreciseType()
Is this register a declared or a precise type?


isPositiveInt

public boolean isPositiveInt()
Is this register a positive int?


setPositiveInt

public void setPositiveInt()
Set this register as being a positive int


getFlags

public byte getFlags()
Return a byte encoding register flags


clearFlags

public void clearFlags()
Clear the flags of a register


addFlags

public void addFlags(byte inFlag)
Merge two sets of register flags


setInheritableFlags

public void setInheritableFlags(RegisterOperand src)
Currently all flags are inheritable, so copy all flags from src


meetInheritableFlags

public void meetInheritableFlags(RegisterOperand other)
Currently all flags are "meetable", so mask flags together


hasLessConservativeFlags

public boolean hasLessConservativeFlags(RegisterOperand other)
Return true if we have any bits set (flag true) that other doesn't. It's ok for other to have bits set true that we have set to false.


isTaken

public boolean isTaken()
Is this a guard operand from a taken branch?


setTaken

public void setTaken()
Set this a guard operand from a taken branch


clearTaken

public void clearTaken()
Clear this from being a guard operand from a taken branch


isNotTaken

public boolean isNotTaken()
Is this a guard operand from a not taken branch?


setNotTaken

public void setNotTaken()
Set this a guard operand from a not taken branch


clearNotTaken

public void clearNotTaken()
Clear this from being a guard operand from a not taken branch


isBoundsCheck

public boolean isBoundsCheck()
Is this a guard operand from a bounds check?


setBoundsCheck

public void setBoundsCheck()
Set this as a guard operand from a bounds check


clearBoundsCheck

public void clearBoundsCheck()
Clear this from being a guard operand from a bounds check


isNullCheck

public boolean isNullCheck()
Is this a guard operand from a null check?


setNullCheck

public void setNullCheck()
Set this as being a guard operand from a null check


clearNullCheck

public void clearNullCheck()
Clear this from being a guard operand from a null check


getInfo

public short getInfo()
Get info scratch short


setInfo

public void setInfo(short value)
Set info scratch short


setNext

public void setNext(RegisterOperand Next)
Sets scratch object of the register operand to parameter. (sic) Since there is not multiple inheritance in Java, I am copying the accessor functions & fields of LinkedListElement. This field is used to maintain lists of USEs and DEFs


append

public void append(RegisterOperand next)
Sets scratch object of the register operand to parameter.


getNext

public RegisterOperand getNext()
Returns the scratch object of the register operand


toString

public String toString()
Returns the string representation of this operand.

Overrides:
toString in class Object

setRegister

public void setRegister(Register register)
Modify the register


getRegister

public Register getRegister()
Returns:
the register

setType

public void setType(TypeReference t)
Set the TypeReference of the value represented by the operand.

Parameters:
t - the inferred data type of the contents of the register

setPreciseType

public void setPreciseType(TypeReference t)
Set the TypeReference of the value represented by the operand and make the type precise.

Parameters:
t - the inferred data type of the contents of the register

getType

public TypeReference getType()
Return the TypeReference of the value represented by the operand.

Overrides:
getType in class Operand
Returns:
the inferred data type of the contents of the register

refine

public void refine(TypeReference t)
Refine the type of the register to t if t is a more precise type than the register currently holds

Parameters:
t - type to try to refine to