RTL expressions used to define attributes use the codes described above plus a few specific to attribute definitions, to be discussed below. Attribute value expressions must have one of the following forms:
The value of a numeric attribute can be specified either with a
const_int, or as an integer represented as a string in
eq_attr (see below),
symbol_ref, simple arithmetic expressions, and
overrides on specific instructions (see Tagging Insns).
If the attribute whose value is being specified is numeric, value
must be a string containing a non-negative integer (normally
const_int would be used in this case). Otherwise, it must
contain one of the valid values for the attribute.
(if_then_elsetest true-value false-value
(cond [test1 value1
condexpression is that of the value corresponding to the first true test expression. If none of the test expressions are true, the value of the
condexpression is that of the default expression.
test expressions can have one of the following forms:
(match_operand:m n pred constraints
VOIDmode) and the function specified by the string pred returns a nonzero value when passed operand n and mode m (this part of the test is ignored if pred is the null string).
The constraints operand is ignored and should be the null string.
define_insnalternative that insn matches. See Output Statement.
c-expr behaves like the condition in a C
so there is no need to explicitly convert the expression into a boolean
0 or 1 value. For example, the following two tests are equivalent:
(match_test "x & 2") (match_test "(x & 2) != 0")
symbol_ref are always valid terms (see Insn Lengths,for additional forms).
symbol_ref is a string
denoting a C expression that yields an
int when evaluated by the
‘get_attr_...’ routine. It should normally be a global
value is a string that is either a valid value for attribute name, a comma-separated list of values, or ‘!’ followed by a value or list. If value does not begin with a ‘!’, this test is true if the value of the name attribute of the current insn is in the list specified by value. If value begins with a ‘!’, this test is true if the attribute's value is not in the specified list.
(eq_attr "type" "load,store")
is equivalent to
(ior (eq_attr "type" "load") (eq_attr "type" "store"))
If name specifies an attribute of ‘alternative’, it refers to the
value of the compiler variable
(see Output Statement) and the values must be small integers. For
(eq_attr "alternative" "2,3")
is equivalent to
(ior (eq (symbol_ref "which_alternative") (const_int 2)) (eq (symbol_ref "which_alternative") (const_int 3)))
Note that, for most attributes, an
eq_attr test is simplified in cases
where the value of the attribute being tested is known for all insns matching
a particular pattern. This is by far the most common case.
attr_flagexpression is true if the flag specified by name is true for the
insncurrently being scheduled.
name is a string specifying one of a fixed set of flags to test.
Test the flags
backward to determine the
direction of a conditional branch.
This example describes a conditional branch delay slot which can be nullified for forward branches that are taken (annul-true) or for backward branches which are not taken (annul-false).
(define_delay (eq_attr "type" "cbranch") [(eq_attr "in_branch_delay" "true") (and (eq_attr "in_branch_delay" "true") (attr_flag "forward")) (and (eq_attr "in_branch_delay" "true") (attr_flag "backward"))])
backward flags are false if the current
insn being scheduled is not a conditional branch.
attr_flag is only used during delay slot scheduling and has no
meaning to other passes of the compiler.
attr_flagproduce more efficient code for non-numeric attributes.