next up previous contents
Next: UnaryExpression Up: Expression Previous: Constant   Contents


BinaryExpression

The BinaryExpression is used to represent all operations that take two sources and produce a single result with no side effects.

    abstract BinaryExpression : Expression
      {
        LString opcode;
        Expression * owner source1 in source_ops;
        Expression * owner source2 in source_ops;
      };

Table 1 lists all the 23 operations defined.


Table 1: Binary Operations
Operation Semantics and Operands
add
subtract
multiply
divide
The add, subtract, multiply, and divide operations are allowed on any combination of integer and floating point types with the result as any integer or floating point type. In addition, add and subtract operations can do pointer arithmetic. Any pointer and integer type may be added to give any pointer type. Any integer type may be subtracted from any pointer type to give any pointer type. And any pointer type may be subtracted from any other pointer type to give any integer type.
remainder The remainder operation is allowed with source operands of any two integer types and result of any integer type. If both integers are non-negative, the remainder is defined as the first modulo the second source. The results when negative numbers are involved or when the second is zero are unspecified.
bitwise_and
bitwise_or
bitwise_nand
bitwise_nor
bitwise_xor
These operations are allowed for any two unsigned integer type source operands and with a result of any integer type. The result is defined as the appropriate bitwise operation where if the sources have different types the smaller is zero extended to the size of the larger. If the result type is larger, the result is zero-extended, while if it's lower the high-order bits are truncated.
left_shift
right_shift
These operations may take source operands with any two integer types, but the result type must be the same as the source1 type. The bits in source1 are shifted an amount specified by the value of source2. A negative value of a left_shift is equivalent to a right_shift of the oposite value and vice versa. For positive shifts to the left, low-order bits are shifted toward high-order bits and bits past the top are dropped. In that case, zeros fill in the low-order bits. For positive shifts to the right, high-order bits move toward low-order bits, with the lowest-order bits being dropped. If the type of source1 is unsigned, zeros fill in the high-order bits while if the type is signed, the sign bit fills in the high-order bits.
rotate The rotate operation may take as source1 an operand of any unsigned integer type and as source2 any signed or unsigned integer type. The result type must be the same as the source1 type. The bits in source1 are rotated by the amount specified in source2. The rotation moves bits from low-order to high-order with high-order bits wrapping around to low-order bits for positive values of source2. For negative values of source2, the rotation goes in the opposite direction.
is_equal_to
is_not_equal_to
is_less_than
is_less_than_or_equal_to
is_greater_than
is_greater_than_or_equal_to
These operations must have boolean result type. For either is_equal_to or is_not_equal_to operations, the source operand types can be any two boolean types, any two numeric types, any two pointer types, or the same enumerated type. For the other four operations, the source operand types can be any two numeric types or any two pointer types.
logical_and
logical_or
The logical_and and logical_or operations are allowed on source operands of any two boolean types and may return any Boolean type. Note that unlike the ``&&'' and ``||'' operations in C or C++, these two logical operations are not short-circuited in SUIF.
maximum
minimum
For the maximum and minimum operations, the source operands must have the same type and that must be the same as the result type. This type is allowed to be either any numeric type or any pointer type.


next up previous contents
Next: UnaryExpression Up: Expression Previous: Constant   Contents
SUIF Nightly Build
2000-08-14