gccint: Tagging Insns
1
1 17.19.3 Assigning Attribute Values to Insns
1 -------------------------------------------
1
1 The value assigned to an attribute of an insn is primarily determined by
1 which pattern is matched by that insn (or which 'define_peephole'
1 generated it). Every 'define_insn' and 'define_peephole' can have an
1 optional last argument to specify the values of attributes for matching
1 insns. The value of any attribute not specified in a particular insn is
1 set to the default value for that attribute, as specified in its
1 'define_attr'. Extensive use of default values for attributes permits
1 the specification of the values for only one or two attributes in the
1 definition of most insn patterns, as seen in the example in the next
1 section.
1
1 The optional last argument of 'define_insn' and 'define_peephole' is a
1 vector of expressions, each of which defines the value for a single
1 attribute. The most general way of assigning an attribute's value is to
1 use a 'set' expression whose first operand is an 'attr' expression
1 giving the name of the attribute being set. The second operand of the
1 'set' is an attribute expression (⇒Expressions) giving the value
1 of the attribute.
1
1 When the attribute value depends on the 'alternative' attribute (i.e.,
1 which is the applicable alternative in the constraint of the insn), the
1 'set_attr_alternative' expression can be used. It allows the
1 specification of a vector of attribute expressions, one for each
1 alternative.
1
1 When the generality of arbitrary attribute expressions is not required,
1 the simpler 'set_attr' expression can be used, which allows specifying a
1 string giving either a single attribute value or a list of attribute
1 values, one for each alternative.
1
1 The form of each of the above specifications is shown below. In each
1 case, NAME is a string specifying the attribute to be set.
1
1 '(set_attr NAME VALUE-STRING)'
1 VALUE-STRING is either a string giving the desired attribute value,
1 or a string containing a comma-separated list giving the values for
1 succeeding alternatives. The number of elements must match the
1 number of alternatives in the constraint of the insn pattern.
1
1 Note that it may be useful to specify '*' for some alternative, in
1 which case the attribute will assume its default value for insns
1 matching that alternative.
1
1 '(set_attr_alternative NAME [VALUE1 VALUE2 ...])'
1 Depending on the alternative of the insn, the value will be one of
1 the specified values. This is a shorthand for using a 'cond' with
1 tests on the 'alternative' attribute.
1
1 '(set (attr NAME) VALUE)'
1 The first operand of this 'set' must be the special RTL expression
1 'attr', whose sole operand is a string giving the name of the
1 attribute being set. VALUE is the value of the attribute.
1
1 The following shows three different ways of representing the same
1 attribute value specification:
1
1 (set_attr "type" "load,store,arith")
1
1 (set_attr_alternative "type"
1 [(const_string "load") (const_string "store")
1 (const_string "arith")])
1
1 (set (attr "type")
1 (cond [(eq_attr "alternative" "1") (const_string "load")
1 (eq_attr "alternative" "2") (const_string "store")]
1 (const_string "arith")))
1
1 The 'define_asm_attributes' expression provides a mechanism to specify
1 the attributes assigned to insns produced from an 'asm' statement. It
1 has the form:
1
1 (define_asm_attributes [ATTR-SETS])
1
1 where ATTR-SETS is specified the same as for both the 'define_insn' and
1 the 'define_peephole' expressions.
1
1 These values will typically be the "worst case" attribute values. For
1 example, they might indicate that the condition code will be clobbered.
1
1 A specification for a 'length' attribute is handled specially. The way
1 to compute the length of an 'asm' insn is to multiply the length
1 specified in the expression 'define_asm_attributes' by the number of
1 machine instructions specified in the 'asm' statement, determined by
1 counting the number of semicolons and newlines in the string.
1 Therefore, the value of the 'length' attribute specified in a
1 'define_asm_attributes' should be the maximum possible length of a
1 single machine instruction.
1