harpoon.IR.Quads
Class Qop

java.lang.Object
  extended by harpoon.IR.Quads.Qop
Direct Known Subclasses:
LQop

public abstract class Qop
extends Object

Qop is an enumerated type for the various kinds of OPER opcodes. The basic rationale is to use a minimal set of opcodes to simplify later analysis.

Note that (x - y) is uniformly expressed as (x + (-y)), and that (~x) is typically expressed (compiler-dependent) as (x ^ (-1)). There is also a minimal set of comparison operations; all other comparisons can be synthesized from the ones present. Note that floating-point (float/double) comparisons have special behaviors when NaN is an operand. Note also that one each of IAND/IOR and LAND/LOR could be removed, but the translation involved too many steps to be deemed worthwhile.

Version:
$Id: Qop.java,v 1.2 2002/02/25 21:05:12 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>

Field Summary
static int ACMPEQ
          Compares references for equality.
static int D2F
          Converts a double to a float.
static int D2I
          Converts a double to an int.
static int D2L
          Converts a double to a long.
static int DADD
          Computes the sum of two double values.
static int DCMPEQ
          Evaluates to true if double values are equal and neither is NaN, or false otherwise.
static int DCMPGE
          Evaluates to true if first double value is greater than or equal to the second double value and neither is NaN, or false otherwise.
static int DCMPGT
          Evaluates to true if first double value is greater than the second double value and neither is NaN, or false otherwise.
static int DDIV
          Computes the quotient of two double values.
static int DMUL
          Computes the product of two double values.
static int DNEG
          Computes the negation of a double value.
static int DREM
          Computes the remainder of two double values.
static int F2D
          Converts a float to a double.
static int F2I
          Converts a float to an int.
static int F2L
          Converts a float to a long.
static int FADD
          Computes the sum of two float values.
static int FCMPEQ
          Evaluates to true if the float values are equal and neither is NaN, or false otherwise.
static int FCMPGE
          Evaluates to true if the first float value is greater than or equal to the second float value and neither is NaN, or false otherwise.
static int FCMPGT
          Evaluates to true if the first float value is greater than the second float value and neither is NaN, or false otherwise.
static int FDIV
          Computes the quotient of two float values.
static int FMUL
          Computes the product of two float values.
static int FNEG
          Computes the negation of a float value.
static int FREM
          Computes the remainder of two float values.
static int I2B
          Converts an int to a byte.
static int I2C
          Converts an int to a character.
static int I2D
          Converts an int to a double.
static int I2F
          Converts an int to a float.
static int I2L
          Converts an int to a long.
static int I2S
          Converts an int to a short.
static int IADD
          Computes the sum of two int values.
static int IAND
          Computes the binary-AND of two int values.
static int ICMPEQ
          Evaluates to true if the two int values are equal, or false otherwise.
static int ICMPGT
          Evalutates to true if the first int value is greater than the second int value, or false otherwise.
static int IDIV
          Computes the int quotient of two int values.
static int IMUL
          Computes the product of two int values.
static int INEG
          Computes the negation of an int value.
static int IOR
          Computes the binary-OR of two int values.
static int IREM
          Computes the remainder of two int values.
static int ISHL
          Computes the value of the first int value shifted left by the number of bits specified in the low five bits of the second int value.
static int ISHR
          Computes the value of the first int value shifted right with sign extension by the number of bits specified in the low five bits of the second int value.
static int IUSHR
          Computes the value of the first int value shifted right without sign extension by the number of bits specified in the low five bits of the second int value.
static int IXOR
          Computes the binary-XOR of two int values.
static int L2D
          Converts a long to a double.
static int L2F
          Converts a long to a float.
static int L2I
          Converts a long to an int.
static int LADD
          Computes the sum of two long values.
static int LAND
          Computes the binary-AND of two long values.
static int LCMPEQ
          Evaluates to true if the two long values are equal, or false otherwise.
static int LCMPGT
          Evaluates to true if the first long value is greater than the second, or false otherwise.
static int LDIV
          Computes the quotient of two long values.
static int LMUL
          Computes the product of two long values.
static int LNEG
          Computes the negation of a long value.
static int LOR
          Computes the binary-OR of two long values.
static int LREM
          Computes the remainder of two long values.
static int LSHL
          Computes the value of the first long value shifted left by the number of bits specified in the low six bits of the second int value.
static int LSHR
          Computes the value of the first long value shifted right with sign extension by the number of bits specified in the low six bits of the second int value.
static int LUSHR
          Computes the value of the first long value shifted right without sign extension by the number of bits specified in the low six bits of the second int value.
static int LXOR
          Computes the binary-XOR of two long values.
 
Constructor Summary
Qop()
           
 
Method Summary
static Object evaluate(int opc, Object[] opd)
          Evaluates a constant value for the result of an OPER, given constant values for the operands.
static int forString(String op)
          Returns the enumerated Qop that corresponds to a given descriptive string.
static boolean isValid(int v)
          Determines if a given Qop value is valid.
static HClass resultType(int v)
          Determines the result type of an OPER.
static String toString(int v)
          Converts the enumerated Qop value to a descriptive string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACMPEQ

public static final int ACMPEQ
Compares references for equality.

See Also:
Constant Field Values

D2F

public static final int D2F
Converts a double to a float.

See Also:
Constant Field Values

D2I

public static final int D2I
Converts a double to an int.

See Also:
Constant Field Values

D2L

public static final int D2L
Converts a double to a long.

See Also:
Constant Field Values

DADD

public static final int DADD
Computes the sum of two double values.

See Also:
Constant Field Values

DCMPEQ

public static final int DCMPEQ
Evaluates to true if double values are equal and neither is NaN, or false otherwise.

See Also:
Constant Field Values

DCMPGE

public static final int DCMPGE
Evaluates to true if first double value is greater than or equal to the second double value and neither is NaN, or false otherwise.

See Also:
Constant Field Values

DCMPGT

public static final int DCMPGT
Evaluates to true if first double value is greater than the second double value and neither is NaN, or false otherwise.

See Also:
Constant Field Values

DDIV

public static final int DDIV
Computes the quotient of two double values.

See Also:
Constant Field Values

DMUL

public static final int DMUL
Computes the product of two double values.

See Also:
Constant Field Values

DNEG

public static final int DNEG
Computes the negation of a double value.

See Also:
Constant Field Values

DREM

public static final int DREM
Computes the remainder of two double values.

See Also:
Constant Field Values

F2D

public static final int F2D
Converts a float to a double.

See Also:
Constant Field Values

F2I

public static final int F2I
Converts a float to an int.

See Also:
Constant Field Values

F2L

public static final int F2L
Converts a float to a long.

See Also:
Constant Field Values

FADD

public static final int FADD
Computes the sum of two float values.

See Also:
Constant Field Values

FCMPEQ

public static final int FCMPEQ
Evaluates to true if the float values are equal and neither is NaN, or false otherwise.

See Also:
Constant Field Values

FCMPGE

public static final int FCMPGE
Evaluates to true if the first float value is greater than or equal to the second float value and neither is NaN, or false otherwise.

See Also:
Constant Field Values

FCMPGT

public static final int FCMPGT
Evaluates to true if the first float value is greater than the second float value and neither is NaN, or false otherwise.

See Also:
Constant Field Values

FDIV

public static final int FDIV
Computes the quotient of two float values.

See Also:
Constant Field Values

FMUL

public static final int FMUL
Computes the product of two float values.

See Also:
Constant Field Values

FNEG

public static final int FNEG
Computes the negation of a float value.

See Also:
Constant Field Values

FREM

public static final int FREM
Computes the remainder of two float values.

See Also:
Constant Field Values

I2B

public static final int I2B
Converts an int to a byte. Result is still int type, but it is truncated to 8 bits, then sign-extended.

See Also:
Constant Field Values

I2C

public static final int I2C
Converts an int to a character. Result is still int type, but is truncated to 16 bits. No sign extension.

See Also:
Constant Field Values

I2D

public static final int I2D
Converts an int to a double.

See Also:
Constant Field Values

I2F

public static final int I2F
Converts an int to a float.

See Also:
Constant Field Values

I2L

public static final int I2L
Converts an int to a long.

See Also:
Constant Field Values

I2S

public static final int I2S
Converts an int to a short. Result is still int type, but is truncated to 16 bits, then sign extended.

See Also:
Constant Field Values

IADD

public static final int IADD
Computes the sum of two int values.

See Also:
Constant Field Values

IAND

public static final int IAND
Computes the binary-AND of two int values.

See Also:
Constant Field Values

ICMPEQ

public static final int ICMPEQ
Evaluates to true if the two int values are equal, or false otherwise.

See Also:
Constant Field Values

ICMPGT

public static final int ICMPGT
Evalutates to true if the first int value is greater than the second int value, or false otherwise.

See Also:
Constant Field Values

IDIV

public static final int IDIV
Computes the int quotient of two int values.

See Also:
Constant Field Values

IMUL

public static final int IMUL
Computes the product of two int values.

See Also:
Constant Field Values

INEG

public static final int INEG
Computes the negation of an int value.

See Also:
Constant Field Values

IOR

public static final int IOR
Computes the binary-OR of two int values.

See Also:
Constant Field Values

IREM

public static final int IREM
Computes the remainder of two int values.

See Also:
Constant Field Values

ISHL

public static final int ISHL
Computes the value of the first int value shifted left by the number of bits specified in the low five bits of the second int value. That is, ( 1 << 34 ) == 4. Also, (x << -1) == (x << 31).

See Also:
Constant Field Values

ISHR

public static final int ISHR
Computes the value of the first int value shifted right with sign extension by the number of bits specified in the low five bits of the second int value. That is, ( -4 >> 33 ) == -2. Also, (x >> -1) == (x >> 31).

See Also:
Constant Field Values

IUSHR

public static final int IUSHR
Computes the value of the first int value shifted right without sign extension by the number of bits specified in the low five bits of the second int value. That is, ( -4 >>> 30) == 3. Also, (x >>> -1) == (x >>> 31).

See Also:
Constant Field Values

IXOR

public static final int IXOR
Computes the binary-XOR of two int values.

See Also:
Constant Field Values

L2D

public static final int L2D
Converts a long to a double.

See Also:
Constant Field Values

L2F

public static final int L2F
Converts a long to a float.

See Also:
Constant Field Values

L2I

public static final int L2I
Converts a long to an int.

See Also:
Constant Field Values

LADD

public static final int LADD
Computes the sum of two long values.

See Also:
Constant Field Values

LAND

public static final int LAND
Computes the binary-AND of two long values.

See Also:
Constant Field Values

LCMPEQ

public static final int LCMPEQ
Evaluates to true if the two long values are equal, or false otherwise.

See Also:
Constant Field Values

LCMPGT

public static final int LCMPGT
Evaluates to true if the first long value is greater than the second, or false otherwise.

See Also:
Constant Field Values

LDIV

public static final int LDIV
Computes the quotient of two long values.

See Also:
Constant Field Values

LMUL

public static final int LMUL
Computes the product of two long values.

See Also:
Constant Field Values

LNEG

public static final int LNEG
Computes the negation of a long value.

See Also:
Constant Field Values

LOR

public static final int LOR
Computes the binary-OR of two long values.

See Also:
Constant Field Values

LREM

public static final int LREM
Computes the remainder of two long values.

See Also:
Constant Field Values

LSHL

public static final int LSHL
Computes the value of the first long value shifted left by the number of bits specified in the low six bits of the second int value. That is, (1 << 66) == 4. Also, (x << -1) == (x << 63).

See Also:
Constant Field Values

LSHR

public static final int LSHR
Computes the value of the first long value shifted right with sign extension by the number of bits specified in the low six bits of the second int value. That is, (-4 >> 65) == -2. Also, (x >> -1) == (x >> 63).

See Also:
Constant Field Values

LUSHR

public static final int LUSHR
Computes the value of the first long value shifted right without sign extension by the number of bits specified in the low six bits of the second int value. That is, (-4 >>> 62) == 3. Also, (x >>> -1) == (x >>> 63).

See Also:
Constant Field Values

LXOR

public static final int LXOR
Computes the binary-XOR of two long values.

See Also:
Constant Field Values
Constructor Detail

Qop

public Qop()
Method Detail

isValid

public static boolean isValid(int v)
Determines if a given Qop value is valid.


toString

public static String toString(int v)
Converts the enumerated Qop value to a descriptive string.


forString

public static int forString(String op)
Returns the enumerated Qop that corresponds to a given descriptive string.


resultType

public static HClass resultType(int v)
Determines the result type of an OPER.


evaluate

public static Object evaluate(int opc,
                              Object[] opd)
Evaluates a constant value for the result of an OPER, given constant values for the operands.