public abstract class Operand extends Object
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
RegisterOperand
represent symbolic and
and physical registers.
ConstantOperand
represent various kinds of constant operands.
MethodOperand
represents the targets of CALL instructions.
BranchOperand
, BasicBlockOperand
,
and BranchOperand
are used to encode CFG
information in LABEL, BBEND, and branch instructions.
ConditionOperand
and TrapCodeOperand
encode the conditions tested by conditional branches and
trap instructions.
LocationOperand
represents the memory location
accessed by a load or store operation.
TypeOperand
encodes a RVMType
for use
in instructions such as NEW or INSTANCEOF that operate on the
type hierarchy.
Instruction
,
BasicBlockOperand
,
BranchOperand
,
ConditionOperand
,
ConstantOperand
,
DoubleConstantOperand
,
FloatConstantOperand
,
IntConstantOperand
,
LocationOperand
,
LongConstantOperand
,
MethodOperand
,
NullConstantOperand
,
RegisterOperand
,
StringConstantOperand
,
TrapCodeOperand
,
TrueGuardOperand
,
TypeOperand
Modifier and Type | Field and Description |
---|---|
Instruction |
instruction
Handle back to containing instruction.
|
Constructor and Description |
---|
Operand() |
Modifier and Type | Method and Description |
---|---|
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?
|
public Instruction instruction
public Operand()
public final boolean isRegister()
RegisterOperand
?true
if this
is an
instanceof
an RegisterOperand
or false
if it is not.public final boolean isConstant()
ConstantOperand
?true
if this
is an
instanceof
an ConstantOperand
or false
if it is not.public final boolean isIntConstant()
IntConstantOperand
?true
if this
is an
instanceof
an IntConstantOperand
or false
if it is not.public final boolean isAddressConstant()
AddressConstantOperand
?true
if this
is an
instanceof
an AddressConstantOperand
or false
if it is not.public final boolean isFloatConstant()
FloatConstantOperand
?true
if this
is an
instanceof
an FloatConstantOperand
or false
if it is not.public final boolean isLongConstant()
LongConstantOperand
?true
if this
is an
instanceof
an LongConstantOperand
or false
if it is not.public final boolean isDoubleConstant()
DoubleConstantOperand
?true
if this
is an
instanceof
an DoubleConstantOperand
or false
if it is not.public final boolean isStringConstant()
StringConstantOperand
?true
if this
is an
instanceof
an StringConstantOperand
or false
if it is not.public final boolean isClassConstant()
ClassConstantOperand
?true
if this
is an
instanceof
an ClassConstantOperand
or false
if it is not.public final boolean isObjectConstant()
ObjectConstantOperand
?true
if this
is an
instanceof
an ObjectConstantOperand
or false
if it is not.public boolean isMovableObjectConstant()
ObjectConstantOperand
?public final boolean isTIBConstant()
TIBConstantOperand
?true
if this
is an
instanceof
an TIBConstantOperand
or false
if it is not.public final boolean isNullConstant()
NullConstantOperand
?true
if this
is an
instanceof
an NullConstantOperand
or false
if it is not.public final boolean isTrueGuard()
TrueGuardOperand
?true
if this
is an
instanceof
an TrueGuardOperand
or false
if it is not.public final boolean isBranch()
BranchOperand
?true
if this
is an
instanceof
an BranchOperand
or false
if it is not.public final boolean isBlock()
BasicBlockOperand
?true
if this
is an
instanceof
an BasicBlockOperand
or false
if it is not.public final boolean isMemory()
MemoryOperand
?true
if this
is an
instanceof
an MemoryOperand
or false
if it is not.public final boolean isStackLocation()
StackLocationOperand
?true
if this
is an
instanceof
an StackLocationOperand
or false
if it is not.public final boolean isMethod()
MethodOperand
?true
if this
is an
instanceof
an MethodOperand
or false
if it is not.public final boolean isLocation()
LocationOperand
?true
if this
is an
instanceof
an LocationOperand
or false
if it is not.public final boolean isType()
TypeOperand
?true
if this
is an
instanceof
an TypeOperand
or false
if it is not.public final RegisterOperand asRegister()
RegisterOperand
.this
cast as an RegisterOperand
public final IntConstantOperand asIntConstant()
IntConstantOperand
.this
cast as an IntConstantOperand
public final AddressConstantOperand asAddressConstant()
AddressConstantOperand
.this
cast as an AddressConstantOperand
public final FloatConstantOperand asFloatConstant()
FloatConstantOperand
.this
cast as an FloatConstantOperand
public final LongConstantOperand asLongConstant()
LongConstantOperand
.this
cast as an LongConstantOperand
public final DoubleConstantOperand asDoubleConstant()
DoubleConstantOperand
.this
cast as an DoubleConstantOperand
public final StringConstantOperand asStringConstant()
StringConstantOperand
.this
cast as an StringConstantOperand
public final ClassConstantOperand asClassConstant()
ClassConstantOperand
.this
cast as an ClassConstantOperand
public final ObjectConstantOperand asObjectConstant()
ObjectConstantOperand
.this
cast as an ObjectConstantOperand
public final TIBConstantOperand asTIBConstant()
TIBConstantOperand
.this
cast as an TIBConstantOperand
public final NullConstantOperand asNullConstant()
NullConstantOperand
.this
cast as an NullConstantOperand
public final BranchOperand asBranch()
BranchOperand
.this
cast as an BranchOperand
public final BasicBlockOperand asBlock()
BasicBlockOperand
.this
cast as an BasicBlockOperand
public final MemoryOperand asMemory()
MemoryOperand
.this
cast as an MemoryOperand
public final StackLocationOperand asStackLocation()
StackLocationOperand
.this
cast as an StackLocationOperand
public final MethodOperand asMethod()
MethodOperand
.this
cast as an MethodOperand
public final TypeOperand asType()
TypeOperand
.this
cast as an TypeOperand
public final ConditionOperand asCondition()
ConditionOperand
.this
cast as an ConditionOperand
public final LocationOperand asLocation()
LocationOperand
.this
cast as an LocationOperand
public boolean isIntLike()
true
if the data type of this
is int-like as defined by TypeReference.isIntLikeType()
or false
if it is not.public boolean isInt()
true
if the data type of this
is an int as defined by TypeReference.isIntType()
or false
if it is not.public boolean isLong()
true
if the data type of this
is a long as defined by TypeReference.isLongType()
or false
if it is not.public boolean isFloat()
true
if the data type of this
is a float as defined by TypeReference.isFloatType()
or false
if it is not.public boolean isDouble()
true
if the data type of this
is a double as defined by TypeReference.isDoubleType()
or false
if it is not.public boolean isRef()
true
if the data type of this
is a reference as defined by TypeReference.isReferenceType()
or false
if it is not.public boolean isAddress()
true
if the data type of this
is an address as defined by TypeReference.isAddressType()
or false
if it is not.public boolean isDefinitelyNull()
null
?true
if the operand definitely represents
null
or false
if it does not.public abstract Operand copy()
this
.this
public abstract boolean similar(Operand op)
op
- other operandtrue
if this
and op
are semantically equivalent or false
if they are not.public TypeReference getType()
TypeReference
of the value represented by the operand.public int getIndexInInstruction()
public static boolean conservativelyApproximates(Operand op1, Operand op2)
op1
- the first operand to compareop2
- the second operand to comparetrue
if op1 conservatively approximates op2 or
false
if it does not.public static Operand meet(Operand op1, Operand op2, Register reg)
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.
op1
- the first operand to meetop2
- the second operand to meetreg
- the Register
to use to
create a new RegisterOperand
if meeting op1 and op2 requires doing so.null
when
the meet evaluates to bottom. It will return
op1 when conservativelyApproximates(op1, op2)
evaluates to true
.private static boolean compatiblePrimitives(TypeReference type1, TypeReference type2)