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

java.lang.Object
  extended by org.jikesrvm.compilers.opt.ir.operand.Operand
Direct Known Subclasses:
BasicBlockOperand, BC2IR.DummyStackSlot, BranchOperand, BranchProfileOperand, BURSManagedFPROperand, ConditionOperand, ConstantOperand, HeapOperand, IA32ConditionOperand, InlinedOsrTypeInfoOperand, LocationOperand, MemoryOperand, MethodOperand, OsrTypeInfoOperand, RegisterOperand, ReturnAddressOperand, StackLocationOperand, TrapCodeOperand, TypeOperand

public abstract class Operand
extends Object

An Operand identifies an operand for an Instruction. A single Operand object should not be shared between instructions (or even be used twice in the same instruction). Operands should not be shared between instructions because we use the reference to the operand's containing instruction to construct use/def chains. We also store program-point specific information about an symbolic register in the RegisterOperands that refer to the Register.

Operands are divided into several primary categories

See Also:
Instruction, BasicBlockOperand, BranchOperand, ConditionOperand, ConstantOperand, DoubleConstantOperand, FloatConstantOperand, IntConstantOperand, LocationOperand, LongConstantOperand, MethodOperand, NullConstantOperand, RegisterOperand, StringConstantOperand, TrapCodeOperand, TrueGuardOperand, TypeOperand

Field Summary
 Instruction instruction
          Handle back to containing instruction.
 
Constructor Summary
Operand()
           
 
Method Summary
 AddressConstantOperand asAddressConstant()
          Cast to an AddressConstantOperand.
 BasicBlockOperand asBlock()
          Cast to an BasicBlockOperand.
 BranchOperand asBranch()
          Cast to an BranchOperand.
 ClassConstantOperand asClassConstant()
          Cast to an ClassConstantOperand.
 ConditionOperand asCondition()
          Cast to an ConditionOperand.
 DoubleConstantOperand asDoubleConstant()
          Cast to an DoubleConstantOperand.
 FloatConstantOperand asFloatConstant()
          Cast to an FloatConstantOperand.
 IntConstantOperand asIntConstant()
          Cast to an IntConstantOperand.
 LocationOperand asLocation()
          Cast to an LocationOperand.
 LongConstantOperand asLongConstant()
          Cast to an LongConstantOperand.
 MemoryOperand asMemory()
          Cast to an MemoryOperand.
 MethodOperand asMethod()
          Cast to an MethodOperand.
 NullConstantOperand asNullConstant()
          Cast to an NullConstantOperand.
 ObjectConstantOperand asObjectConstant()
          Cast to an ObjectConstantOperand.
 RegisterOperand asRegister()
          Cast to an RegisterOperand.
 StackLocationOperand asStackLocation()
          Cast to an StackLocationOperand.
 StringConstantOperand asStringConstant()
          Cast to an StringConstantOperand.
 TIBConstantOperand asTIBConstant()
          Cast to an TIBConstantOperand.
 TypeOperand asType()
          Cast to an TypeOperand.
private static boolean compatiblePrimitives(TypeReference type1, TypeReference type2)
           
static boolean conservativelyApproximates(Operand op1, Operand op2)
          Compare two operands based on their positions in the operand lattice.
abstract  Operand copy()
          Return a new operand that is semantically equivalent to this.
 int getIndexInInstruction()
          Return the index of the operand in its containing instruction (SLOW).
 TypeReference getType()
          Return the TypeReference of the value represented by the operand.
 boolean isAddress()
          Does the operand represent a value of the address data type?
 boolean isAddressConstant()
          Is the operand an AddressConstantOperand?
 boolean isBlock()
          Is the operand an BasicBlockOperand?
 boolean isBranch()
          Is the operand an BranchOperand?
 boolean isClassConstant()
          Is the operand an ClassConstantOperand?
 boolean isConstant()
          Is the operand an ConstantOperand?
 boolean isDefinitelyNull()
          Does the operand definitely represent null?
 boolean isDouble()
          Does the operand represent a value of the double data type?
 boolean isDoubleConstant()
          Is the operand an DoubleConstantOperand?
 boolean isFloat()
          Does the operand represent a value of the float data type?
 boolean isFloatConstant()
          Is the operand an FloatConstantOperand?
 boolean isInt()
          Does the operand represent a value of the int data type?
 boolean isIntConstant()
          Is the operand an IntConstantOperand?
 boolean isIntLike()
          Does the operand represent a value of an int-like data type?
 boolean isLocation()
          Is the operand an LocationOperand?
 boolean isLong()
          Does the operand represent a value of the long data type?
 boolean isLongConstant()
          Is the operand an LongConstantOperand?
 boolean isMemory()
          Is the operand an MemoryOperand?
 boolean isMethod()
          Is the operand an MethodOperand?
 boolean isMovableObjectConstant()
          Is the operand a movable ObjectConstantOperand?
 boolean isNullConstant()
          Is the operand an NullConstantOperand?
 boolean isObjectConstant()
          Is the operand an ObjectConstantOperand?
 boolean isRef()
          Does the operand represent a value of the reference data type?
 boolean isRegister()
          Is the operand an RegisterOperand?
 boolean isStackLocation()
          Is the operand an StackLocationOperand?
 boolean isStringConstant()
          Is the operand an StringConstantOperand?
 boolean isTIBConstant()
          Is the operand an TIBConstantOperand?
 boolean isTrueGuard()
          Is the operand an TrueGuardOperand?
 boolean isType()
          Is the operand an TypeOperand?
static Operand meet(Operand op1, Operand op2, Register reg)
          Meet two operands based on their positions in the operand lattice.
abstract  boolean similar(Operand op)
          Are two operands semantically equivalent?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instruction

public Instruction instruction
Handle back to containing instruction.

Constructor Detail

Operand

public Operand()
Method Detail

isRegister

public final boolean isRegister()
Is the operand an RegisterOperand?

Returns:
true if this is an instanceof an RegisterOperand or false if it is not.

isConstant

public final boolean isConstant()
Is the operand an ConstantOperand?

Returns:
true if this is an instanceof an ConstantOperand or false if it is not.

isIntConstant

public final boolean isIntConstant()
Is the operand an IntConstantOperand?

Returns:
true if this is an instanceof an IntConstantOperand or false if it is not.

isAddressConstant

public final boolean isAddressConstant()
Is the operand an AddressConstantOperand?

Returns:
true if this is an instanceof an AddressConstantOperand or false if it is not.

isFloatConstant

public final boolean isFloatConstant()
Is the operand an FloatConstantOperand?

Returns:
true if this is an instanceof an FloatConstantOperand or false if it is not.

isLongConstant

public final boolean isLongConstant()
Is the operand an LongConstantOperand?

Returns:
true if this is an instanceof an LongConstantOperand or false if it is not.

isDoubleConstant

public final boolean isDoubleConstant()
Is the operand an DoubleConstantOperand?

Returns:
true if this is an instanceof an DoubleConstantOperand or false if it is not.

isStringConstant

public final boolean isStringConstant()
Is the operand an StringConstantOperand?

Returns:
true if this is an instanceof an StringConstantOperand or false if it is not.

isClassConstant

public final boolean isClassConstant()
Is the operand an ClassConstantOperand?

Returns:
true if this is an instanceof an ClassConstantOperand or false if it is not.

isObjectConstant

public final boolean isObjectConstant()
Is the operand an ObjectConstantOperand?

Returns:
true if this is an instanceof an ObjectConstantOperand or false if it is not.

isMovableObjectConstant

public boolean isMovableObjectConstant()
Is the operand a movable ObjectConstantOperand?

Returns:
false

isTIBConstant

public final boolean isTIBConstant()
Is the operand an TIBConstantOperand?

Returns:
true if this is an instanceof an TIBConstantOperand or false if it is not.

isNullConstant

public final boolean isNullConstant()
Is the operand an NullConstantOperand?

Returns:
true if this is an instanceof an NullConstantOperand or false if it is not.

isTrueGuard

public final boolean isTrueGuard()
Is the operand an TrueGuardOperand?

Returns:
true if this is an instanceof an TrueGuardOperand or false if it is not.

isBranch

public final boolean isBranch()
Is the operand an BranchOperand?

Returns:
true if this is an instanceof an BranchOperand or false if it is not.

isBlock

public final boolean isBlock()
Is the operand an BasicBlockOperand?

Returns:
true if this is an instanceof an BasicBlockOperand or false if it is not.

isMemory

public final boolean isMemory()
Is the operand an MemoryOperand?

Returns:
true if this is an instanceof an MemoryOperand or false if it is not.

isStackLocation

public final boolean isStackLocation()
Is the operand an StackLocationOperand?

Returns:
true if this is an instanceof an StackLocationOperand or false if it is not.

isMethod

public final boolean isMethod()
Is the operand an MethodOperand?

Returns:
true if this is an instanceof an MethodOperand or false if it is not.

isLocation

public final boolean isLocation()
Is the operand an LocationOperand?

Returns:
true if this is an instanceof an LocationOperand or false if it is not.

isType

public final boolean isType()
Is the operand an TypeOperand?

Returns:
true if this is an instanceof an TypeOperand or false if it is not.

asRegister

public final RegisterOperand asRegister()
Cast to an RegisterOperand.

Returns:
this cast as an RegisterOperand

asIntConstant

public final IntConstantOperand asIntConstant()
Cast to an IntConstantOperand.

Returns:
this cast as an IntConstantOperand

asAddressConstant

public final AddressConstantOperand asAddressConstant()
Cast to an AddressConstantOperand.

Returns:
this cast as an AddressConstantOperand

asFloatConstant

public final FloatConstantOperand asFloatConstant()
Cast to an FloatConstantOperand.

Returns:
this cast as an FloatConstantOperand

asLongConstant

public final LongConstantOperand asLongConstant()
Cast to an LongConstantOperand.

Returns:
this cast as an LongConstantOperand

asDoubleConstant

public final DoubleConstantOperand asDoubleConstant()
Cast to an DoubleConstantOperand.

Returns:
this cast as an DoubleConstantOperand

asStringConstant

public final StringConstantOperand asStringConstant()
Cast to an StringConstantOperand.

Returns:
this cast as an StringConstantOperand

asClassConstant

public final ClassConstantOperand asClassConstant()
Cast to an ClassConstantOperand.

Returns:
this cast as an ClassConstantOperand

asObjectConstant

public final ObjectConstantOperand asObjectConstant()
Cast to an ObjectConstantOperand.

Returns:
this cast as an ObjectConstantOperand

asTIBConstant

public final TIBConstantOperand asTIBConstant()
Cast to an TIBConstantOperand.

Returns:
this cast as an TIBConstantOperand

asNullConstant

public final NullConstantOperand asNullConstant()
Cast to an NullConstantOperand.

Returns:
this cast as an NullConstantOperand

asBranch

public final BranchOperand asBranch()
Cast to an BranchOperand.

Returns:
this cast as an BranchOperand

asBlock

public final BasicBlockOperand asBlock()
Cast to an BasicBlockOperand.

Returns:
this cast as an BasicBlockOperand

asMemory

public final MemoryOperand asMemory()
Cast to an MemoryOperand.

Returns:
this cast as an MemoryOperand

asStackLocation

public final StackLocationOperand asStackLocation()
Cast to an StackLocationOperand.

Returns:
this cast as an StackLocationOperand

asMethod

public final MethodOperand asMethod()
Cast to an MethodOperand.

Returns:
this cast as an MethodOperand

asType

public final TypeOperand asType()
Cast to an TypeOperand.

Returns:
this cast as an TypeOperand

asCondition

public final ConditionOperand asCondition()
Cast to an ConditionOperand.

Returns:
this cast as an ConditionOperand

asLocation

public final LocationOperand asLocation()
Cast to an LocationOperand.

Returns:
this cast as an LocationOperand

isIntLike

public boolean isIntLike()
Does the operand represent a value of an int-like data type?

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()
Does the operand represent a value of the int data type?

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()
Does the operand represent a value of the long data type?

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()
Does the operand represent a value of the float data type?

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()
Does the operand represent a value of the double data type?

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()
Does the operand represent a value of the reference data type?

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()
Does the operand represent a value of the address data type?

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()
Does the operand definitely represent null?

Returns:
true if the operand definitely represents null or false if it does not.

copy

public abstract Operand copy()
Return a new operand that is semantically equivalent to this.

Returns:
a copy of this

similar

public abstract boolean similar(Operand op)
Are two operands semantically equivalent?

Parameters:
op - other operand
Returns:
true if this and op are semantically equivalent or false if they are not.

getType

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

Returns:
the type of the value represented by the operand

getIndexInInstruction

public int getIndexInInstruction()
Return the index of the operand in its containing instruction (SLOW).

Returns:
the index of the operand in its containing instruction

conservativelyApproximates

public static boolean conservativelyApproximates(Operand op1,
                                                 Operand op2)
Compare two operands based on their positions in the operand lattice. For the purposes of doing dataflow analysis, Operands can be thought of as forming a lattice. This function compares two operands and returns whether or not op1 is a conservative approximation of op2. Or in other words, if conservativelyApproximates(op1, op2) then meet(op1, op2) = op1. Note that lattices are partial orders, so it is quite possible for both conservativelyApproximates(op1, op2) and conservativelyApproximates(op2, op1) to return false.

Parameters:
op1 - the first operand to compare
op2 - the second operand to compare
Returns:
true if op1 conservatively approximates op2 or false if it does not.

meet

public static Operand meet(Operand op1,
                           Operand op2,
                           Register reg)
Meet two operands based on their positions in the operand lattice. For the purposes of doing dataflow analysis, Operands can be thought of as forming a lattice. This function takes two operands and returns their meet (glb). We use null to stand for bottom (the meet of the two operands is an illegal value). For exmaple, meet(5.0, "hi") would evalaute to bottom. Meet returns op1 iff conservativelyApproximates(op1, op2): this is exploited in BC2IR to avoid doing redundant work.

Unfortunately there is a fair amount of code duplication between conservativelyApproximates(org.jikesrvm.compilers.opt.ir.operand.Operand, org.jikesrvm.compilers.opt.ir.operand.Operand) and meet(org.jikesrvm.compilers.opt.ir.operand.Operand, org.jikesrvm.compilers.opt.ir.operand.Operand, org.jikesrvm.compilers.opt.ir.Register), but factoring out the common control logic is a non-trivial task.

Parameters:
op1 - the first operand to meet
op2 - the second operand to meet
reg - the Register to use to create a new RegisterOperand if meeting op1 and op2 requires doing so.
Returns:
the Operand that is the meet of op1 and op2. This function will return null when the meet evaluates to bottom. It will return op1 when conservativelyApproximates(op1, op2) evaluates to true.

compatiblePrimitives

private static boolean compatiblePrimitives(TypeReference type1,
                                            TypeReference type2)