gccint: Code Iterators
1
1 17.23.2 Code Iterators
1 ----------------------
1
11 Code iterators operate in a similar way to mode iterators. ⇒Mode
Iterators.
1
1 The construct:
1
1 (define_code_iterator NAME [(CODE1 "COND1") ... (CODEN "CONDN")])
1
1 defines a pseudo rtx code NAME that can be instantiated as CODEI if
1 condition CONDI is true. Each CODEI must have the same rtx format.
1 ⇒RTL Classes.
1
1 As with mode iterators, each pattern that uses NAME will be expanded N
1 times, once with all uses of NAME replaced by CODE1, once with all uses
1 replaced by CODE2, and so on. ⇒Defining Mode Iterators.
1
1 It is possible to define attributes for codes as well as for modes.
1 There are two standard code attributes: 'code', the name of the code in
1 lower case, and 'CODE', the name of the code in upper case. Other
1 attributes are defined using:
1
1 (define_code_attr NAME [(CODE1 "VALUE1") ... (CODEN "VALUEN")])
1
1 Here's an example of code iterators in action, taken from the MIPS
1 port:
1
1 (define_code_iterator any_cond [unordered ordered unlt unge uneq ltgt unle ungt
1 eq ne gt ge lt le gtu geu ltu leu])
1
1 (define_expand "b<code>"
1 [(set (pc)
1 (if_then_else (any_cond:CC (cc0)
1 (const_int 0))
1 (label_ref (match_operand 0 ""))
1 (pc)))]
1 ""
1 {
1 gen_conditional_branch (operands, <CODE>);
1 DONE;
1 })
1
1 This is equivalent to:
1
1 (define_expand "bunordered"
1 [(set (pc)
1 (if_then_else (unordered:CC (cc0)
1 (const_int 0))
1 (label_ref (match_operand 0 ""))
1 (pc)))]
1 ""
1 {
1 gen_conditional_branch (operands, UNORDERED);
1 DONE;
1 })
1
1 (define_expand "bordered"
1 [(set (pc)
1 (if_then_else (ordered:CC (cc0)
1 (const_int 0))
1 (label_ref (match_operand 0 ""))
1 (pc)))]
1 ""
1 {
1 gen_conditional_branch (operands, ORDERED);
1 DONE;
1 })
1
1 ...
1