Next: Machine Constraints, Previous: Modifiers, Up: Constraints
enabled attribute
The enabled insn attribute may be used to disable certain insn
alternatives for machine-specific reasons. This is useful when adding
new instructions to an existing pattern which are only available for
certain cpu architecture levels as specified with the -march=
option.
If an insn alternative is disabled, then it will never be used. The compiler treats the constraints for the disabled alternative as unsatisfiable.
In order to make use of the enabled attribute a back end has to add
in the machine description files:
enabled insn attribute. The attribute is
defined as usual using the define_attr command. This
definition should be based on other insn attributes and/or target flags.
The enabled attribute is a numeric attribute and should evaluate to
(const_int 1) for an enabled alternative and to
(const_int 0) otherwise.
cpu_facility as in the example below.
E.g. the following two patterns could easily be merged using the enabled
attribute:
(define_insn "*movdi_old"
[(set (match_operand:DI 0 "register_operand" "=d")
(match_operand:DI 1 "register_operand" " d"))]
"!TARGET_NEW"
"lgr %0,%1")
(define_insn "*movdi_new"
[(set (match_operand:DI 0 "register_operand" "=d,f,d")
(match_operand:DI 1 "register_operand" " d,d,f"))]
"TARGET_NEW"
"@
lgr %0,%1
ldgr %0,%1
lgdr %0,%1")
to:
(define_insn "*movdi_combined"
[(set (match_operand:DI 0 "register_operand" "=d,f,d")
(match_operand:DI 1 "register_operand" " d,d,f"))]
""
"@
lgr %0,%1
ldgr %0,%1
lgdr %0,%1"
[(set_attr "cpu_facility" "*,new,new")])
with the enabled attribute defined like this:
(define_attr "cpu_facility" "standard,new" (const_string "standard"))
(define_attr "enabled" ""
(cond [(eq_attr "cpu_facility" "standard") (const_int 1)
(and (eq_attr "cpu_facility" "new")
(ne (symbol_ref "TARGET_NEW") (const_int 0)))
(const_int 1)]
(const_int 0)))