DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(gcc.info) Defining Attributes

Info Catalog (gcc.info) Insn Attributes (gcc.info) Expressions
 
 Defining Attributes and their Values
 ------------------------------------
 
    The `define_attr' expression is used to define each attribute
 required by the target machine.  It looks like:
 
      (define_attr NAME LIST-OF-VALUES DEFAULT)
 
    NAME is a string specifying the name of the attribute being defined.
 
    LIST-OF-VALUES is either a string that specifies a comma-separated
 list of values that can be assigned to the attribute, or a null string
 to indicate that the attribute takes numeric values.
 
    DEFAULT is an attribute expression that gives the value of this
 attribute for insns that match patterns whose definition does not
 include an explicit value for this attribute.   Attr Example,
 for more information on the handling of defaults.   Constant
 Attributes, for information on attributes that do not depend on any
 particular insn.
 
    For each defined attribute, a number of definitions are written to
 the `insn-attr.h' file.  For cases where an explicit set of values is
 specified for an attribute, the following are defined:
 
    * A `#define' is written for the symbol `HAVE_ATTR_NAME'.
 
    * An enumeral class is defined for `attr_NAME' with elements of the
      form `UPPER-NAME_UPPER-VALUE' where the attribute name and value
      are first converted to upper case.
 
    * A function `get_attr_NAME' is defined that is passed an insn and
      returns the attribute value for that insn.
 
    For example, if the following is present in the `md' file:
 
      (define_attr "type" "branch,fp,load,store,arith" ...)
 
 the following lines will be written to the file `insn-attr.h'.
 
      #define HAVE_ATTR_type
      enum attr_type {TYPE_BRANCH, TYPE_FP, TYPE_LOAD,
                       TYPE_STORE, TYPE_ARITH};
      extern enum attr_type get_attr_type ();
 
    If the attribute takes numeric values, no `enum' type will be
 defined and the function to obtain the attribute's value will return
 `int'.
 
Info Catalog (gcc.info) Insn Attributes (gcc.info) Expressions
automatically generated byinfo2html