harpoon.IR.Tree
Class Bop

java.lang.Object
  extended by harpoon.IR.Tree.Bop

public abstract class Bop
extends Object

Bop is an enumerated type for BINOPs. Operations are typed: pointer (A), integer (I), long (L), float (F) or double (D).

Basic rationale: Include full set of comparisons so we can optimize jump direction for best cache locality, etc. Include minimal arithmetic, because we can pattern match (x+(-y)) for SUB pretty easily. Include full set of bitwise-operators to make it easier to pattern-match on those architectures with insanely complete sets of boolean ops (eg, SPARC has AND/OR/NAND/NOR/XOR/XNOR...). Allow fully-flexible typing for easy pointer manipulation (ie pointer shifts, pointer ANDs, pointer ORs, etc).

Note that SHL/SHR/USHR mask off all but the low 5 or 6 bits of their right-hand operand, just as Qop.xSHL/xSHR/xUSHR do. Also note that the NOT operation is included in Uop, but not in harpoon.IR.Quads.Qop. Thus you'll have to do some pattern matching on (x ^ (-1)) to properly generate Uop.NOT.

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

Field Summary
static int ADD
          Addition.
static int AND
          Bit-wise AND; long/integer only.
static int CMPEQ
          If equal-to, then 1 else 0.
static int CMPGE
          If greater-than-or-equal-to, then 1 else 0.
static int CMPGT
          If greater-than, then 1 else 0.
static int CMPLE
          If less-than-or-equal-to, then 1 else 0.
static int CMPLT
          If less-than, then 1 else 0.
static int CMPNE
          If not-equal-to, then 1 else 0.
static int DIV
          Division.
static int MUL
          Multiplication.
static int OR
          Bit-wise OR; long/integer only.
static int REM
          Remainder operation.
static int SHL
          Left bit-wise shift; long/integer only.
static int SHR
          Right signed bit-wise shift; long/integer only.
static int USHR
          Right unsigned bit-wise shift; long/integer only.
static int XOR
          Bit-wise XOR; long/integer only.
 
Constructor Summary
Bop()
           
 
Method Summary
static int invert(int op)
          Returns the inverted opposite for a compare Bop.
static boolean isAssociative(int op)
          Determines if the given Bop operation is associative.
static boolean isCommutative(int op)
          Determines if the given Bop operation is commutative.
static boolean isValid(int op)
          Determines if the given Bop value is valid.
static String toString(int op)
          Converts the enumerated Bop value to a human-readable string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CMPLT

public static final int CMPLT
If less-than, then 1 else 0.

See Also:
Constant Field Values

CMPLE

public static final int CMPLE
If less-than-or-equal-to, then 1 else 0.

See Also:
Constant Field Values

CMPEQ

public static final int CMPEQ
If equal-to, then 1 else 0.

See Also:
Constant Field Values

CMPNE

public static final int CMPNE
If not-equal-to, then 1 else 0.

See Also:
Constant Field Values

CMPGE

public static final int CMPGE
If greater-than-or-equal-to, then 1 else 0.

See Also:
Constant Field Values

CMPGT

public static final int CMPGT
If greater-than, then 1 else 0.

See Also:
Constant Field Values

ADD

public static final int ADD
Addition.

See Also:
Constant Field Values

MUL

public static final int MUL
Multiplication.

See Also:
Constant Field Values

DIV

public static final int DIV
Division.

See Also:
Constant Field Values

REM

public static final int REM
Remainder operation. Note that this is valid for floating-point as well as integer arithmetic; see the JVM definition of frem. Basically, this is remainder after a truncating division for both integer and floating-point.

See Also:
Constant Field Values

SHL

public static final int SHL
Left bit-wise shift; long/integer only.

See Also:
Constant Field Values

SHR

public static final int SHR
Right signed bit-wise shift; long/integer only.

See Also:
Constant Field Values

USHR

public static final int USHR
Right unsigned bit-wise shift; long/integer only.

See Also:
Constant Field Values

AND

public static final int AND
Bit-wise AND; long/integer only.

See Also:
Constant Field Values

OR

public static final int OR
Bit-wise OR; long/integer only.

See Also:
Constant Field Values

XOR

public static final int XOR
Bit-wise XOR; long/integer only.

See Also:
Constant Field Values
Constructor Detail

Bop

public Bop()
Method Detail

isValid

public static boolean isValid(int op)
Determines if the given Bop value is valid.


toString

public static String toString(int op)
Converts the enumerated Bop value to a human-readable string.


isCommutative

public static final boolean isCommutative(int op)
Determines if the given Bop operation is commutative.


isAssociative

public static final boolean isAssociative(int op)
Determines if the given Bop operation is associative.


invert

public static final int invert(int op)
Returns the inverted opposite for a compare Bop. That is, for CMPEQ it will return CMPNE; for CMPGT it will return CMPLE; etc.