gccint: Examples
1
1 17.23.1.3 Mode Iterator Examples
1 ................................
1
1 Here is an example from the MIPS port. It defines the following modes
1 and attributes (among others):
1
1 (define_mode_iterator GPR [SI (DI "TARGET_64BIT")])
1 (define_mode_attr d [(SI "") (DI "d")])
1
1 and uses the following template to define both 'subsi3' and 'subdi3':
1
1 (define_insn "sub<mode>3"
1 [(set (match_operand:GPR 0 "register_operand" "=d")
1 (minus:GPR (match_operand:GPR 1 "register_operand" "d")
1 (match_operand:GPR 2 "register_operand" "d")))]
1 ""
1 "<d>subu\t%0,%1,%2"
1 [(set_attr "type" "arith")
1 (set_attr "mode" "<MODE>")])
1
1 This is exactly equivalent to:
1
1 (define_insn "subsi3"
1 [(set (match_operand:SI 0 "register_operand" "=d")
1 (minus:SI (match_operand:SI 1 "register_operand" "d")
1 (match_operand:SI 2 "register_operand" "d")))]
1 ""
1 "subu\t%0,%1,%2"
1 [(set_attr "type" "arith")
1 (set_attr "mode" "SI")])
1
1 (define_insn "subdi3"
1 [(set (match_operand:DI 0 "register_operand" "=d")
1 (minus:DI (match_operand:DI 1 "register_operand" "d")
1 (match_operand:DI 2 "register_operand" "d")))]
1 ""
1 "dsubu\t%0,%1,%2"
1 [(set_attr "type" "arith")
1 (set_attr "mode" "DI")])
1