Next: Subst Iterators, Previous: Code Iterators, Up: Iterators [Contents][Index]

#### 16.23.3 Int Iterators

Int iterators operate in a similar way to code iterators. See Code Iterators.

The construct:

    (define_int_iterator name [(int1 "cond1") … (intn "condn")])

defines a pseudo integer constant name that can be instantiated as inti if condition condi is true. Each int must have the same rtx format. See RTL Classes. Int iterators can appear in only those rtx fields that have ’i’ as the specifier. This means that each int has to be a constant defined using define_constant or define_c_enum.

As with mode and code iterators, each pattern that uses name will be expanded n times, once with all uses of name replaced by int1, once with all uses replaced by int2, and so on. See Defining Mode Iterators.

It is possible to define attributes for ints as well as for codes and modes. Attributes are defined using:

    (define_int_attr name [(int1 "value1") … (intn "valuen")])

Here’s an example of int iterators in action, taken from the ARM port:

    (define_int_iterator QABSNEG [UNSPEC_VQABS UNSPEC_VQNEG])

    (define_int_attr absneg [(UNSPEC_VQABS "abs") (UNSPEC_VQNEG "neg")])

    (define_insn "neon_vq<absneg><mode>"
      [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
    	(unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
    		       (match_operand:SI 2 "immediate_operand" "i")]
    		      QABSNEG))]
      "TARGET_NEON"
      "vq<absneg>.<V_s_elem>\t%<V_reg>0, %<V_reg>1"
      [(set_attr "type" "neon_vqneg_vqabs")]
    )

This is equivalent to:

    (define_insn "neon_vqabs<mode>"
      [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
    	(unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
    		       (match_operand:SI 2 "immediate_operand" "i")]
    		      UNSPEC_VQABS))]
      "TARGET_NEON"
      "vqabs.<V_s_elem>\t%<V_reg>0, %<V_reg>1"
      [(set_attr "type" "neon_vqneg_vqabs")]
    )

    (define_insn "neon_vqneg<mode>"
      [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
    	(unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
    		       (match_operand:SI 2 "immediate_operand" "i")]
    		      UNSPEC_VQNEG))]
      "TARGET_NEON"
      "vqneg.<V_s_elem>\t%<V_reg>0, %<V_reg>1"
      [(set_attr "type" "neon_vqneg_vqabs")]
    )

Next: Subst Iterators, Previous: Code Iterators, Up: Iterators [Contents][Index]