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)
(lo_sum:m x y)
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
(see Constants).
m should be Pmode
.
(minus:m x y)
plus
but represents subtraction.
(compare:m x y)
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
. See 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)
(mult:m x y)
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)
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)
div
but represents unsigned division.
(mod:m x y)
(umod:m x y)
div
and udiv
but represent the remainder instead of
the quotient.
(smin:m x y)
(smax:m x y)
smin
) or larger (for smax
) of
x and y, interpreted as signed integers in mode m.
(umin:m x y)
(umax:m x y)
smin
and smax
, but the values are interpreted as unsigned
integers.
(not:m x)
(and:m x y)
(ior:m x y)
(xor:m x y)
(ashift:m x c)
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)
ashift
but for right shift. Unlike the case for left shift,
these two operations are distinct.
(rotate:m x c)
(rotatert:m x c)
rotate
.
(abs:m x)
(sqrt:m x)
(ffs:m x)