1 ;; Machine Descriptions for R8C/M16C/M32C
3 ;; Free Software Foundation, Inc.
4 ;; Contributed by Red Hat.
6 ;; This file is part of GCC.
8 ;; GCC is free software; you can redistribute it and/or modify it
9 ;; under the terms of the GNU General Public License as published
10 ;; by the Free Software Foundation; either version 2, or (at your
11 ;; option) any later version.
13 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
14 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 ;; License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING. If not, write to the Free
20 ;; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
23 ;; multiply and divide
25 ; Here is the pattern for the const_int.
26 (define_insn "mulqihi3_c"
27 [(set (match_operand:HI 0 "mra_operand" "=RhiSd,??Rmm")
28 (mult:HI (sign_extend:HI (match_operand:QI 1 "mra_operand" "%0,0"))
29 (match_operand 2 "immediate_operand" "i,i")))]
34 ; Here is the pattern for registers and such.
35 (define_insn "mulqihi3_r"
36 [(set (match_operand:HI 0 "mra_operand" "=RhiSd,RhiSd,??Rmm,??Rmm,Raa,Raa")
37 (mult:HI (sign_extend:HI (match_operand:QI 1 "mra_operand" "%0,0,0,0,0,0"))
38 (sign_extend:HI (match_operand:QI 2 "mra_operand" "RqiSd,?Rmm,RqiSd,?Rmm,RhlSd,?Rmm"))))]
43 ; Don't try to sign_extend a const_int. Same for all other multiplies.
44 (define_expand "mulqihi3"
45 [(set (match_operand:HI 0 "mra_operand" "=RhiSd,RhiSd,??Rmm,??Rmm,Raa,Raa")
46 (mult:HI (sign_extend:HI (match_operand:QI 1 "mra_operand" "%0,0,0,0,0,0"))
47 (match_operand:QI 2 "mra_operand" "RqiSd,?Rmm,RqiSd,?Rmm,RhlSd,?Rmm")))]
49 "{ if (GET_MODE (operands[2]) != VOIDmode)
50 operands[2] = gen_rtx_SIGN_EXTEND (HImode, operands[2]); }"
53 (define_insn "umulqihi3_c"
54 [(set (match_operand:HI 0 "mra_operand" "=RhiSd,??Rmm")
55 (mult:HI (zero_extend:HI (match_operand:QI 1 "mra_operand" "%0,0"))
56 (match_operand 2 "immediate_operand" "i,i")))]
61 (define_insn "umulqihi3_r"
62 [(set (match_operand:HI 0 "mra_operand" "=RhiSd,RhiSd,??Rmm,??Rmm,Raa,Raa")
63 (mult:HI (zero_extend:HI (match_operand:QI 1 "mra_operand" "%0,0,0,0,0,0"))
64 (zero_extend:HI (match_operand:QI 2 "mra_operand" "RqiSd,?Rmm,RqiSd,?Rmm,RhlSd,?Rmm"))))]
69 (define_expand "umulqihi3"
70 [(set (match_operand:HI 0 "mra_operand" "=RhiSd,RhiSd,??Rmm,??Rmm,Raa,Raa")
71 (mult:HI (zero_extend:HI (match_operand:QI 1 "mra_operand" "%0,0,0,0,0,0"))
72 (match_operand:QI 2 "mra_operand" "RqiSd,?Rmm,RqiSd,?Rmm,RhlSd,?Rmm")))]
74 "{ if (GET_MODE (operands[2]) != VOIDmode)
75 operands[2] = gen_rtx_ZERO_EXTEND (HImode, operands[2]); }"
78 (define_insn "mulhisi3_c"
79 [(set (match_operand:SI 0 "mra_operand" "=RsiSd,??Rmm")
80 (mult:SI (sign_extend:SI (match_operand:HI 1 "mra_operand" "%0,0"))
81 (match_operand 2 "immediate_operand" "i,i")))]
86 (define_insn "mulhisi3_r"
87 [(set (match_operand:SI 0 "mra_operand" "=RsiSd,RsiSd,??Rmm,??Rmm")
88 (mult:SI (sign_extend:SI (match_operand:HI 1 "mra_operand" "%0,0,0,0"))
89 (sign_extend:SI (match_operand:HI 2 "mra_operand" "RhiSd,?Rmm,RhiSd,?Rmm"))))]
94 (define_expand "mulhisi3"
95 [(set (match_operand:SI 0 "mra_operand" "=RsiSd,RsiSd,??Rmm,??Rmm")
96 (mult:SI (sign_extend:SI (match_operand:HI 1 "mra_operand" "%0,0,0,0"))
97 (match_operand:HI 2 "mra_operand" "RhiSd,?Rmm,RhiSd,?Rmm")))]
99 "{ if (GET_MODE (operands[2]) != VOIDmode)
100 operands[2] = gen_rtx_SIGN_EXTEND (SImode, operands[2]); }"
103 (define_insn "umulhisi3_c"
104 [(set (match_operand:SI 0 "mra_operand" "=RsiSd,??Rmm")
105 (mult:SI (zero_extend:SI (match_operand:HI 1 "mra_operand" "%0,0"))
106 (match_operand 2 "immediate_operand" "i,i")))]
111 (define_insn "umulhisi3_r"
112 [(set (match_operand:SI 0 "mra_operand" "=RsiSd,RsiSd,??Rmm,??Rmm")
113 (mult:SI (zero_extend:SI (match_operand:HI 1 "mra_operand" "%0,0,0,0"))
114 (zero_extend:SI (match_operand:HI 2 "mra_operand" "RhiSd,?Rmm,RhiSd,?Rmm"))))]
119 (define_expand "umulhisi3"
120 [(set (match_operand:SI 0 "mra_operand" "=RsiSd,RsiSd,??Rmm,??Rmm")
121 (mult:SI (zero_extend:SI (match_operand:HI 1 "mra_operand" "%0,0,0,0"))
122 (match_operand:HI 2 "mra_operand" "RhiSd,?Rmm,RhiSd,?Rmm")))]
124 "{ if (GET_MODE (operands[2]) != VOIDmode)
125 operands[2] = gen_rtx_ZERO_EXTEND (SImode, operands[2]); }"
129 ; GCC expects to be able to multiply pointer-sized integers too, but
130 ; fortunately it only multiplies by powers of two.
131 (define_insn "mulpsi3"
132 [(set (match_operand:PSI 0 "mra_operand" "=RsiSd")
133 (mult:PSI (match_operand:PSI 1 "mra_operand" "%0")
134 (match_operand 2 "const_int_operand" "Ilb")))]
137 [(set_attr "flags" "szc")]
142 (define_expand "divmodqi4"
144 (sign_extend:HI (match_operand:QI 1 "register_operand" "0,0")))
145 (parallel [(set (match_operand:QI 0 "register_operand" "=R0w,R0w")
146 (div:QI (match_dup 4)
147 (match_operand:QI 2 "general_operand" "iRqiSd,?Rmm")))
148 (set (match_operand:QI 3 "register_operand" "=&R0h,&R0h")
149 (mod:QI (match_dup 4) (match_dup 2)))
152 "operands[4] = gen_reg_rtx (HImode);"
155 (define_insn "divmodqi4_n"
156 [(set (match_operand:QI 0 "register_operand" "=R0l,R0l")
157 (div:QI (match_operand:HI 1 "register_operand" "R0w,R0w")
158 (match_operand:QI 2 "general_operand" "iRqiSd,?Rmm")))
159 (set (match_operand:QI 3 "register_operand" "=R0h,R0h")
160 (mod:QI (match_dup 1) (match_dup 2)))
166 (define_expand "udivmodqi4"
168 (zero_extend:HI (match_operand:QI 1 "register_operand" "0,0")))
169 (parallel [(set (match_operand:QI 0 "register_operand" "=R0l,R0l")
170 (udiv:QI (match_dup 4)
171 (match_operand:QI 2 "general_operand" "iRqiSd,?Rmm")))
172 (set (match_operand:QI 3 "register_operand" "=&R0h,&R0h")
173 (umod:QI (match_dup 4) (match_dup 2)))
176 "operands[4] = gen_reg_rtx (HImode);"
179 (define_insn "udivmodqi4_n"
180 [(set (match_operand:QI 0 "register_operand" "=R0l,R0l")
181 (udiv:QI (match_operand:HI 1 "register_operand" "R0w,R0w")
182 (match_operand:QI 2 "general_operand" "iRqiSd,?Rmm")))
183 (set (match_operand:QI 3 "register_operand" "=R0h,R0h")
184 (umod:QI (match_dup 1) (match_dup 2)))
190 (define_expand "divmodhi4"
192 (sign_extend:SI (match_operand:HI 1 "register_operand" "0,0")))
193 (parallel [(set (match_operand:HI 0 "register_operand" "=R0w,R0w")
194 (div:HI (match_dup 4)
195 (match_operand:HI 2 "general_operand" "iRhiSd,?Rmm")))
196 (set (match_operand:HI 3 "register_operand" "=R2w,R2w")
197 (mod:HI (match_dup 4) (match_dup 2)))
200 "operands[4] = gen_reg_rtx (SImode);"
203 (define_insn "divmodhi4_n"
204 [(set (match_operand:HI 0 "m32c_r0_operand" "=R0w,R0w")
205 (div:HI (match_operand:SI 1 "m32c_r0_operand" "R02,R02")
206 (match_operand:HI 2 "m32c_notr2_operand" "iR1wR3wRaaSd,?Rmm")))
207 (set (match_operand:HI 3 "m32c_r2_operand" "=R2w,R2w")
208 (mod:HI (match_dup 1) (match_dup 2)))
214 (define_expand "udivmodhi4"
216 (zero_extend:SI (match_operand:HI 1 "register_operand" "0,0")))
217 (parallel [(set (match_operand:HI 0 "register_operand" "=R0w,R0w")
218 (udiv:HI (match_dup 4)
219 (match_operand:HI 2 "general_operand" "iRhiSd,?Rmm")))
220 (set (match_operand:HI 3 "register_operand" "=R2w,R2w")
221 (umod:HI (match_dup 4) (match_dup 2)))
224 "operands[4] = gen_reg_rtx (SImode);"
227 (define_insn "udivmodhi4_n"
228 [(set (match_operand:HI 0 "m32c_r0_operand" "=R0w,R0w")
229 (udiv:HI (match_operand:SI 1 "m32c_r0_operand" "R02,R02")
230 (match_operand:HI 2 "m32c_notr2_operand" "iR1wR3wRaaSd,?Rmm")))
231 (set (match_operand:HI 3 "m32c_r2_operand" "=R2w,R2w")
232 (umod:HI (match_dup 1) (match_dup 2)))