DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(gcc.info) Arithmetic

Info Catalog (gcc.info) Regs and Memory (gcc.info) RTL (gcc.info) Comparisons
 
 RTL Expressions for Arithmetic
 ==============================
 
    Unless otherwise specified, all the operands of arithmetic
 expressions must be valid for mode M.  An operand is valid for mode M
 if it has mode M, or if it is a `const_int' or `const_double' and M is
 a mode of class `MODE_INT'.
 
    For commutative binary operations, constants should be placed in the
 second operand.
 
 `(plus:M X Y)'
      Represents the sum of the values represented by X and Y carried
      out in machine mode M.
 
 `(lo_sum:M X Y)'
      Like `plus', except that it represents that sum of X and the
      low-order bits of Y.  The number of low order bits is
      machine-dependent but is normally the number of bits in a `Pmode'
      item minus the number of bits set by the `high' code (
      Constants.).
 
      M should be `Pmode'.
 
 `(minus:M X Y)'
      Like `plus' but represents subtraction.
 
 `(compare:M X Y)'
      Represents the result of subtracting Y from X for purposes of
      comparison.  The result is computed without overflow, as if with
      infinite precision.
 
      Of course, machines can't really subtract with infinite precision.
      However, they can pretend to do so when only the sign of the
      result will be used, which is the case when the result is stored
      in the condition code.   And that is the only way this kind of
      expression may validly be used: as a value to be stored in the
      condition codes.
 
      The mode M is not related to the modes of X and Y, but instead is
      the mode of the condition code value.  If `(cc0)' is used, it is
      `VOIDmode'.  Otherwise it is some mode in class `MODE_CC', often
      `CCmode'.   Condition Code.
 
      Normally, X and Y must have the same mode.  Otherwise, `compare'
      is valid only if the mode of X is in class `MODE_INT' and Y is a
      `const_int' or `const_double' with mode `VOIDmode'.  The mode of X
      determines what mode the comparison is to be done in; thus it must
      not be `VOIDmode'.
 
      If one of the operands is a constant, it should be placed in the
      second operand and the comparison code adjusted as appropriate.
 
      A `compare' specifying two `VOIDmode' constants is not valid since
      there is no way to know in what mode the comparison is to be
      performed; the comparison must either be folded during the
      compilation or the first operand must be loaded into a register
      while its mode is still known.
 
 `(neg:M X)'
      Represents the negation (subtraction from zero) of the value
      represented by X, carried out in mode M.
 
 `(mult:M X Y)'
      Represents the signed product of the values represented by X and Y
      carried out in machine mode M.
 
      Some machines support a multiplication that generates a product
      wider than the operands.  Write the pattern for this as
 
           (mult:M (sign_extend:M X) (sign_extend:M Y))
 
      where M is wider than the modes of X and Y, which need not be the
      same.
 
      Write patterns for unsigned widening multiplication similarly using
      `zero_extend'.
 
 `(div:M X Y)'
      Represents the quotient in signed division of X by Y, carried out
      in machine mode M.  If M is a floating point mode, it represents
      the exact quotient; otherwise, the integerized quotient.
 
      Some machines have division instructions in which the operands and
      quotient widths are not all the same; you should represent such
      instructions using `truncate' and `sign_extend' as in,
 
           (truncate:M1 (div:M2 X (sign_extend:M2 Y)))
 
 `(udiv:M X Y)'
      Like `div' but represents unsigned division.
 
 `(mod:M X Y)'
 `(umod:M X Y)'
      Like `div' and `udiv' but represent the remainder instead of the
      quotient.
 
 `(smin:M X Y)'
 `(smax:M X Y)'
      Represents the smaller (for `smin') or larger (for `smax') of X
      and Y, interpreted as signed integers in mode M.
 
 `(umin:M X Y)'
 `(umax:M X Y)'
      Like `smin' and `smax', but the values are interpreted as unsigned
      integers.
 
 `(not:M X)'
      Represents the bitwise complement of the value represented by X,
      carried out in mode M, which must be a fixed-point machine mode.
 
 `(and:M X Y)'
      Represents the bitwise logical-and of the values represented by X
      and Y, carried out in machine mode M, which must be a fixed-point
      machine mode.
 
 `(ior:M X Y)'
      Represents the bitwise inclusive-or of the values represented by X
      and Y, carried out in machine mode M, which must be a fixed-point
      mode.
 
 `(xor:M X Y)'
      Represents the bitwise exclusive-or of the values represented by X
      and Y, carried out in machine mode M, which must be a fixed-point
      mode.
 
 `(ashift:M X C)'
      Represents the result of arithmetically shifting X left by C
      places.  X have mode M, a fixed-point machine mode.  C be a
      fixed-point mode or be a constant with mode `VOIDmode'; which mode
      is determined by the mode called for in the machine description
      entry for the left-shift instruction.  For example, on the Vax,
      the mode of C is `QImode' regardless of M.
 
 `(lshiftrt:M X C)'
 `(ashiftrt:M X C)'
      Like `ashift' but for right shift.  Unlike the case for left shift,
      these two operations are distinct.
 
 `(rotate:M X C)'
 `(rotatert:M X C)'
      Similar but represent left and right rotate.  If C is a constant,
      use `rotate'.
 
 `(abs:M X)'
      Represents the absolute value of X, computed in mode M.
 
 `(sqrt:M X)'
      Represents the square root of X, computed in mode M.  Most often M
      will be a floating point mode.
 
 `(ffs:M X)'
      Represents one plus the index of the least significant 1-bit in X,
      represented as an integer of mode M.  (The value is zero if X is
      zero.)  The mode of X need not be M; depending on the target
      machine, various mode combinations may be valid.
 
Info Catalog (gcc.info) Regs and Memory (gcc.info) RTL (gcc.info) Comparisons
automatically generated byinfo2html