Next:Attribute Expressions, Up:Instruction Attributes [Contents][Index]
Thedefine_attr expression is used to define each attribute requiredby the target machine. It looks like:
(define_attrnamelist-of-valuesdefault)
name is a string specifying the name of the attribute beingdefined. Some attributes are used in a special way by the rest of thecompiler. Theenabled attribute can be used to conditionallyenable or disable insn alternatives (seeDisable insn alternatives using theenabled attribute). Thepredicable attribute, together with asuitabledefine_cond_exec (seeConditional Execution), canbe used to automatically generate conditional variants of instructionpatterns. Themnemonic attribute can be used to check for theinstruction mnemonic (seeMnemonic Attribute). The compilerinternally uses the namesce_enabled andnonce_enabled,so they should not be used elsewhere as alternative names.
list-of-values is either a string that specifies a comma-separatedlist of values that can be assigned to the attribute, or a null string toindicate that the attribute takes numeric values.
default is an attribute expression that gives the value of thisattribute for insns that match patterns whose definition does not includean explicit value for this attribute. SeeExample of Attribute Specifications, for moreinformation on the handling of defaults. SeeConstant Attributes,for information on attributes that do not depend on any particular insn.
For each defined attribute, a number of definitions are written to theinsn-attr.h file. For cases where an explicit set of values isspecified for an attribute, the following are defined:
For example, if the following is present in themd file:
(define_attr "type" "branch,fp,load,store,arith" …)
the following lines will be written to the fileinsn-attr.h.
#define HAVE_ATTR_type 1enum 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, noenum type will bedefined and the function to obtain the attribute’s value will returnint.
There are attributes which are tied to a specific meaning. Theseattributes are not free to use for other purposes:
lengthThelength attribute is used to calculate the length of emittedcode chunks. This is especially important when verifying branchdistances. SeeComputing the Length of an Insn.
enabledTheenabled attribute can be defined to prevent certainalternatives of an insn definition from being used during codegeneration. SeeDisable insn alternatives using theenabled attribute.
mnemonicThemnemonic attribute can be defined to implement instructionspecific checks in e.g. the pipeline description.SeeMnemonic Attribute.
For each of these special attributes, the corresponding‘HAVE_ATTR_name’ ‘#define’ is also written when theattribute is not defined; in that case, it is defined as ‘0’.
Another way of defining an attribute is to use:
(define_enum_attr "attr" "enum"default)
This works in just the same way asdefine_attr, except thatthe list of values is taken from a separate enumeration calledenum (seedefine_enum). This form allows you to usethe same list of values for several attributes without having torepeat the list each time. For example:
(define_enum "processor" [ model_a model_b …])(define_enum_attr "arch" "processor" (const (symbol_ref "target_arch")))(define_enum_attr "tune" "processor" (const (symbol_ref "target_tune")))
defines the same attributes as:
(define_attr "arch" "model_a,model_b,…" (const (symbol_ref "target_arch")))(define_attr "tune" "model_a,model_b,…" (const (symbol_ref "target_tune")))
but without duplicating the processor list. The second example defines twoseparate C enums (attr_arch andattr_tune) whereas the firstdefines a single C enum (processor).
Next:Attribute Expressions, Up:Instruction Attributes [Contents][Index]