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

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

public final class ConditionOperand
extends Operand

Encodes the condition codes for branches.

See Also:
Operand

Field Summary
static int CMPG_GREATER
          Branch if > or unordered
static int CMPG_GREATER_EQUAL
          Branch if >= or unordered
static int CMPG_LESS
          Branch if <
static int CMPG_LESS_EQUAL
          Branch if <=
static int CMPL_EQUAL
          Branch if == (equivalent to CMPG_EQUAL)
static int CMPL_GREATER
          Branch if >
static int CMPL_GREATER_EQUAL
          Branch if >=
static int CMPL_LESS
          Branch if < or unordered
static int CMPL_LESS_EQUAL
          Branch if <= or unordered
static int CMPL_NOT_EQUAL
          Branch if !
static int EQUAL
           
static int FALSE
           
static int GREATER
           
static int GREATER_EQUAL
           
static int HIGHER
           
static int HIGHER_EQUAL
           
static int LESS
           
static int LESS_EQUAL
           
static int LOWER
           
static int LOWER_EQUAL
           
static int NOT_EQUAL
           
static int TRUE
           
static int UNKNOWN
           
 int value
          Value of this operand.
 
Fields inherited from class org.jikesrvm.compilers.opt.ir.operand.Operand
instruction
 
Constructor Summary
private ConditionOperand(int code)
           
 
Method Summary
 boolean branchIfUnordered()
          Will this floating point compare branch if the results are unordered?
 Operand copy()
          Return a new operand that is semantically equivalent to this.
static ConditionOperand EQUAL()
          Create the condition code operand for EQUAL
 int evaluate(Address v1, Address v2)
          Given two Addresses, evaluate the condition on them.
 int evaluate(double v1, double v2)
          Given two doubles, evaluate the condition on them.
 int evaluate(float v1, float v2)
          Given two floats, evaluate the condition on them.
 int evaluate(int v1, int v2)
          Given two ints, evaluate the condition on them.
 int evaluate(long v1, long v2)
          Given two longs, evaluate the condition on them.
 int evaluate(Operand v1, Operand v2)
          Given two operands, evaluate the condition on them.
 ConditionOperand flipCode()
          Flip the direction of the condition.
 ConditionOperand flipOperands()
          Change the condition code to allow the order of the operands to be flipped. i.e.
static ConditionOperand GREATER_EQUAL()
          Create the condition code operand for GREATER_EQUAL
static ConditionOperand GREATER()
          Create the condition code operand for GREATER
static ConditionOperand HIGHER_EQUAL()
          Create the condition code operand for HIGHER_EQUAL
static ConditionOperand HIGHER()
          Create the condition code operand for HIGHER
 boolean isEQUAL()
          Is the condition code EQUAL?
 boolean isFLOATINGPOINT()
          Is the condition code a floating point compare?
 boolean isGREATER_EQUAL()
          Is the condition code GREATER_EQUAL?
 boolean isGREATER()
          Is the condition code GREATER?
 boolean isHIGHER_EQUAL()
          Is the condition code HIGHER_EQUAL?
 boolean isHIGHER()
          Is the condition code HIGHER?
 boolean isLESS_EQUAL()
          Is the condition code LESS EQUAL?
 boolean isLESS()
          Is the condition code LESS?
 boolean isLOWER_EQUAL()
          Is the condition code LOWER_EQUAL?
 boolean isLOWER()
          Is the condition code LOWER?
 boolean isNOT_EQUAL()
          Is the condition code NOT_EQUAL?
 boolean isUNSIGNED()
          Is the condition code an unsigned comparison?
static ConditionOperand LESS_EQUAL()
          Create the condition code operand for LESS_EQUAL
static ConditionOperand LESS()
          Create the condition code operand for LESS
static ConditionOperand LOWER_EQUAL()
          Create the condition code operand for LOWER_EQUAL
static ConditionOperand LOWER()
          Create the condition code operand for LOWER
static ConditionOperand NOT_EQUAL()
          Create the condition code operand for NOT_EQUAL
 boolean similar(Operand op)
          Are two operands semantically equivalent?
 String toString()
          Returns the string representation of this operand.
 void translateCMPG()
          Convert this integer compare to a floating point cmpg compare.
 void translateCMPL()
          Convert this integer compare to a floating point cmpl compare.
 ConditionOperand translateUNSIGNED()
          Convert this floating point compare to the equivalent unsigned integer compare.
 
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, getType, isAddress, isAddressConstant, isBlock, isBranch, isClassConstant, isConstant, isDefinitelyNull, isDouble, isDoubleConstant, isFloat, isFloatConstant, isInt, isIntConstant, isIntLike, isLocation, isLong, isLongConstant, isMemory, isMethod, isMovableObjectConstant, isNullConstant, isObjectConstant, isRef, 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

EQUAL

public static final int EQUAL
See Also:
Constant Field Values

NOT_EQUAL

public static final int NOT_EQUAL
See Also:
Constant Field Values

LESS

public static final int LESS
See Also:
Constant Field Values

GREATER_EQUAL

public static final int GREATER_EQUAL
See Also:
Constant Field Values

GREATER

public static final int GREATER
See Also:
Constant Field Values

LESS_EQUAL

public static final int LESS_EQUAL
See Also:
Constant Field Values

HIGHER

public static final int HIGHER
See Also:
Constant Field Values

LOWER

public static final int LOWER
See Also:
Constant Field Values

HIGHER_EQUAL

public static final int HIGHER_EQUAL
See Also:
Constant Field Values

LOWER_EQUAL

public static final int LOWER_EQUAL
See Also:
Constant Field Values

CMPL_EQUAL

public static final int CMPL_EQUAL
Branch if == (equivalent to CMPG_EQUAL)

See Also:
Constant Field Values

CMPL_GREATER

public static final int CMPL_GREATER
Branch if >

See Also:
Constant Field Values

CMPG_LESS

public static final int CMPG_LESS
Branch if <

See Also:
Constant Field Values

CMPL_GREATER_EQUAL

public static final int CMPL_GREATER_EQUAL
Branch if >=

See Also:
Constant Field Values

CMPG_LESS_EQUAL

public static final int CMPG_LESS_EQUAL
Branch if <=

See Also:
Constant Field Values

CMPL_NOT_EQUAL

public static final int CMPL_NOT_EQUAL
Branch if != (equivalent to CMPG_NOT_EQUAL)

See Also:
Constant Field Values

CMPL_LESS

public static final int CMPL_LESS
Branch if < or unordered

See Also:
Constant Field Values

CMPG_GREATER_EQUAL

public static final int CMPG_GREATER_EQUAL
Branch if >= or unordered

See Also:
Constant Field Values

CMPG_GREATER

public static final int CMPG_GREATER
Branch if > or unordered

See Also:
Constant Field Values

CMPL_LESS_EQUAL

public static final int CMPL_LESS_EQUAL
Branch if <= or unordered

See Also:
Constant Field Values

value

public int value
Value of this operand.


FALSE

public static final int FALSE
See Also:
Constant Field Values

TRUE

public static final int TRUE
See Also:
Constant Field Values

UNKNOWN

public static final int UNKNOWN
See Also:
Constant Field Values
Constructor Detail

ConditionOperand

private ConditionOperand(int code)
Parameters:
code - the condition code
Method Detail

EQUAL

public static ConditionOperand EQUAL()
Create the condition code operand for EQUAL

Returns:
a new condition code operand

NOT_EQUAL

public static ConditionOperand NOT_EQUAL()
Create the condition code operand for NOT_EQUAL

Returns:
a newly created condition code operand

LESS

public static ConditionOperand LESS()
Create the condition code operand for LESS

Returns:
a newly created condition code operand

GREATER_EQUAL

public static ConditionOperand GREATER_EQUAL()
Create the condition code operand for GREATER_EQUAL

Returns:
a newly created condition code operand

GREATER

public static ConditionOperand GREATER()
Create the condition code operand for GREATER

Returns:
a newly created condition code operand

LESS_EQUAL

public static ConditionOperand LESS_EQUAL()
Create the condition code operand for LESS_EQUAL

Returns:
a newly created condition code operand

HIGHER

public static ConditionOperand HIGHER()
Create the condition code operand for HIGHER

Returns:
a newly created condition code operand

LOWER

public static ConditionOperand LOWER()
Create the condition code operand for LOWER

Returns:
a newly created condition code operand

HIGHER_EQUAL

public static ConditionOperand HIGHER_EQUAL()
Create the condition code operand for HIGHER_EQUAL

Returns:
a newly created condition code operand

LOWER_EQUAL

public static ConditionOperand LOWER_EQUAL()
Create the condition code operand for LOWER_EQUAL

Returns:
a newly created condition code operand

isEQUAL

public boolean isEQUAL()
Is the condition code EQUAL?

Returns:
true if it is or false if it is not

isNOT_EQUAL

public boolean isNOT_EQUAL()
Is the condition code NOT_EQUAL?

Returns:
true if it is or false if it is not

isLESS_EQUAL

public boolean isLESS_EQUAL()
Is the condition code LESS EQUAL?

Returns:
true if it is or false if it is not

isGREATER_EQUAL

public boolean isGREATER_EQUAL()
Is the condition code GREATER_EQUAL?

Returns:
true if it is or false if it is not

isGREATER

public boolean isGREATER()
Is the condition code GREATER?

Returns:
true if it is or false if it is not

isLESS

public boolean isLESS()
Is the condition code LESS?

Returns:
true if it is or false if it is not

isHIGHER

public boolean isHIGHER()
Is the condition code HIGHER?

Returns:
true if it is or false if it is not

isLOWER

public boolean isLOWER()
Is the condition code LOWER?

Returns:
true if it is or false if it is not

isHIGHER_EQUAL

public boolean isHIGHER_EQUAL()
Is the condition code HIGHER_EQUAL?

Returns:
true if it is or false if it is not

isLOWER_EQUAL

public boolean isLOWER_EQUAL()
Is the condition code LOWER_EQUAL?

Returns:
true if it is or false if it is not

isUNSIGNED

public boolean isUNSIGNED()
Is the condition code an unsigned comparison?

Returns:
true if it is or false if it is not

isFLOATINGPOINT

public boolean isFLOATINGPOINT()
Is the condition code a floating point compare?

Returns:
true if it is or false if it is not

branchIfUnordered

public boolean branchIfUnordered()
Will this floating point compare branch if the results are unordered?

Returns:
true if it is or false if it is not

translateCMPL

public void translateCMPL()
Convert this integer compare to a floating point cmpl compare. Used during BC2IR.


translateCMPG

public void translateCMPG()
Convert this integer compare to a floating point cmpg compare. Used during BC2IR.


translateUNSIGNED

public ConditionOperand translateUNSIGNED()
Convert this floating point compare to the equivalent unsigned integer compare. Used during IA-32 BURS.

NB this doesn't respect ordered/unordered operation, so it should only be used when it's safe to.


copy

public Operand copy()
Description copied from class: Operand
Return a new operand that is semantically equivalent to this.

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

similar

public boolean similar(Operand op)
Description copied from class: Operand
Are two operands semantically equivalent?

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

evaluate

public int evaluate(Operand v1,
                    Operand v2)
Given two operands, evaluate the condition on them.

Parameters:
v1 - first operand to condition
v2 - second operand to condition
Returns:
TRUE if (v1 cond v2) or FALSE if !(v1 cond v2) or UNKNOWN

evaluate

public int evaluate(int v1,
                    int v2)
Given two ints, evaluate the condition on them.

Parameters:
v1 - first operand to condition
v2 - second operand to condition
Returns:
TRUE if (v1 cond v2) or FALSE if !(v1 cond v2) or UNKNOWN

evaluate

public int evaluate(long v1,
                    long v2)
Given two longs, evaluate the condition on them.

Parameters:
v1 - first operand to condition
v2 - second operand to condition
Returns:
TRUE if (v1 cond v2) or FALSE if !(v1 cond v2) or UNKNOWN

evaluate

public int evaluate(float v1,
                    float v2)
Given two floats, evaluate the condition on them.

Parameters:
v1 - first operand to condition
v2 - second operand to condition
Returns:
true if (v1 cond v2) or false otherwise

evaluate

public int evaluate(double v1,
                    double v2)
Given two doubles, evaluate the condition on them.

Parameters:
v1 - first operand to condition
v2 - second operand to condition
Returns:
true if (v1 cond v2) or false otherwise

evaluate

public int evaluate(Address v1,
                    Address v2)
Given two Addresses, evaluate the condition on them.

Parameters:
v1 - first operand to condition
v2 - second operand to condition
Returns:
TRUE if (v1 cond v2) or FALSE if !(v1 cond v2) or UNKNOWN

flipCode

public ConditionOperand flipCode()
Flip the direction of the condition. Typical use is if you want to change the direction of a branch. i.e. to transform: if (condition) goto A goto B A: into: if (!condition) goto B A: Note that this is not the same as calling flipOperands().


flipOperands

public ConditionOperand flipOperands()
Change the condition code to allow the order of the operands to be flipped. i.e. So that: if x < y then goto A becomes: if y >e; x then goto A Note that this is not the same as calling flipCode().


toString

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

Overrides:
toString in class Object
Returns:
a string representation of this operand.