1 ;; Multiplication patterns for TI C6X.
2 ;; This file is processed by genmult.sh to produce two variants of each
3 ;; pattern, a normal one and a real_mult variant for modulo scheduling.
4 ;; Copyright (C) 2010-2014 Free Software Foundation, Inc.
5 ;; Contributed by Bernd Schmidt <bernds@codesourcery.com>
6 ;; Contributed by CodeSourcery.
8 ;; This file is part of GCC.
10 ;; GCC is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; GCC is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GCC; see the file COPYING3. If not see
22 ;; <http://www.gnu.org/licenses/>.
24 ;; -------------------------------------------------------------------------
25 ;; Miscellaneous insns that execute on the M units
26 ;; -------------------------------------------------------------------------
28 (define_insn "rotlsi3_VARIANT_"
29 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
30 (rotate:SI (match_operand:SI 1 "register_operand" "a,b,?b,?a")
31 (match_operand:SI 2 "reg_or_ucst5_operand" "aIu5,bIu5,aIu5,bIu5"))_CBRK_)]
33 "%|%.\\trotl\\t%$\\t%1, %2, %_MODk_0"
34 [(set_attr "units" "m")
35 (set_attr "type" "mpy2")
36 (set_attr "cross" "n,n,y,y")])
38 (define_insn "bitrevsi2_VARIANT_"
39 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_A_,_B_,_B_")
40 (unspec:SI [(match_operand:SI 1 "register_operand" "a,?b,b,?a")]
41 UNSPEC_BITREV)_CBRK_)]
43 "%|%.\\tbitr\\t%$\\t%1, %_MODk_0"
44 [(set_attr "units" "m")
45 (set_attr "type" "mpy2")
46 (set_attr "cross" "n,y,n,y")])
50 (define_insn "avgv2hi3_VARIANT_"
51 [(_SET_ _OBRK_(match_operand:_MV2HI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
52 (unspec:V2HI [(match_operand:V2HI 1 "register_operand" "a,b,?b,?a")
53 (match_operand:V2HI 2 "register_operand" "a,b,a,b")] UNSPEC_AVG)_CBRK_)]
55 "%|%.\\tavg2\\t%$\\t%1, %2, %_MODk_0"
56 [(set_attr "units" "m")
57 (set_attr "type" "mpy2")
58 (set_attr "cross" "n,n,y,y")])
60 (define_insn "uavgv4qi3_VARIANT_"
61 [(_SET_ _OBRK_(match_operand:_MV4QI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
62 (unspec:V4QI [(match_operand:V4QI 1 "register_operand" "a,b,?b,?a")
63 (match_operand:V4QI 2 "register_operand" "a,b,a,b")] UNSPEC_AVG)_CBRK_)]
65 "%|%.\\tavgu4\\t%$\\t%1, %2, %_MODk_0"
66 [(set_attr "units" "m")
67 (set_attr "type" "mpy2")
68 (set_attr "cross" "n,n,y,y")])
70 ;; -------------------------------------------------------------------------
72 ;; -------------------------------------------------------------------------
74 (define_insn "mulhi3_VARIANT_"
75 [(_SET_ _OBRK_(match_operand:HI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
76 (mult:HI (match_operand:HI 1 "register_operand" "a,b,?b,?a")
77 (match_operand:HI 2 "reg_or_scst5_operand" "aIs5,bIs5,aIs5,bIs5"))_CBRK_)]
79 "%|%.\\tmpy\\t%$\\t%2, %1, %_MODk_0"
80 [(set_attr "type" "mpy2")
81 (set_attr "units" "m")
82 (set_attr "op_pattern" "sxs")
83 (set_attr "cross" "n,n,y,y")])
85 (define_insn "mulhisi3_const_VARIANT_"
86 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A__B_")
87 (mult:SI (sign_extend:SI
88 (match_operand:HI 1 "register_operand" "a,b,?ab"))
89 (match_operand:HI 2 "scst5_operand" "Is5,Is5,Is5"))_CBRK_)]
91 "%|%.\\tmpy\\t%$\\t%2, %1, %_MODk_0"
92 [(set_attr "type" "mpy2")
93 (set_attr "units" "m")
94 (set_attr "cross" "n,n,y")])
96 (define_insn "*mulhisi3_insn_VARIANT_"
97 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
98 (mult:SI (sign_extend:SI
99 (match_operand:HI 1 "register_operand" "%a,b,?a,?b"))
101 (match_operand:HI 2 "reg_or_scst5_operand" "a,b,b,a")))_CBRK_)]
103 "%|%.\\tmpy\\t%$\\t%1, %2, %_MODk_0"
104 [(set_attr "type" "mpy2")
105 (set_attr "units" "m")
106 (set_attr "op_pattern" "ssx")
107 (set_attr "cross" "n,n,y,y")])
109 (define_insn "mulhisi3_lh_VARIANT_"
110 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
111 (mult:SI (sign_extend:SI
112 (match_operand:HI 1 "register_operand" "a,b,?a,?b"))
114 (match_operand:SI 2 "register_operand" "a,b,b,a")
115 (const_int 16)))_CBRK_)]
117 "%|%.\\tmpylh\\t%$\\t%1, %2, %_MODk_0"
118 [(set_attr "type" "mpy2")
119 (set_attr "units" "m")
120 (set_attr "cross" "n,n,y,y")])
122 (define_insn "mulhisi3_hl_VARIANT_"
123 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
124 (mult:SI (ashiftrt:SI
125 (match_operand:SI 1 "register_operand" "a,b,?a,?b")
128 (match_operand:HI 2 "register_operand" "a,b,b,a")))_CBRK_)]
130 "%|%.\\tmpyhl\\t%$\\t%1, %2, %_MODk_0"
131 [(set_attr "type" "mpy2")
132 (set_attr "units" "m")
133 (set_attr "cross" "n,n,y,y")])
135 (define_insn "mulhisi3_hh_VARIANT_"
136 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
137 (mult:SI (ashiftrt:SI
138 (match_operand:SI 1 "register_operand" "%a,b,?a,?b")
141 (match_operand:SI 2 "register_operand" "a,b,b,a")
142 (const_int 16)))_CBRK_)]
144 "%|%.\\tmpyh\\t%$\\t%1, %2, %_MODk_0"
145 [(set_attr "type" "mpy2")
146 (set_attr "units" "m")
147 (set_attr "cross" "n,n,y,y")])
149 (define_insn "umulhisi3_VARIANT_"
150 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
151 (mult:SI (zero_extend:SI
152 (match_operand:HI 1 "register_operand" "%a,b,?a,?b"))
154 (match_operand:HI 2 "register_operand" "a,b,b,a")))_CBRK_)]
156 "%|%.\\tmpyu\\t%$\\t%1, %2, %_MODk_0"
157 [(set_attr "type" "mpy2")
158 (set_attr "units" "m")
159 (set_attr "cross" "n,n,y,y")])
161 (define_insn "umulhisi3_lh_VARIANT_"
162 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
163 (mult:SI (zero_extend:SI
164 (match_operand:HI 1 "register_operand" "a,b,?a,?b"))
166 (match_operand:SI 2 "register_operand" "a,b,b,a")
167 (const_int 16)))_CBRK_)]
169 "%|%.\\tmpylhu\\t%$\\t%1, %2, %_MODk_0"
170 [(set_attr "type" "mpy2")
171 (set_attr "units" "m")
172 (set_attr "cross" "n,n,y,y")])
174 (define_insn "umulhisi3_hl_VARIANT_"
175 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
176 (mult:SI (lshiftrt:SI
177 (match_operand:SI 1 "register_operand" "a,b,?a,?b")
180 (match_operand:HI 2 "register_operand" "a,b,b,a")))_CBRK_)]
182 "%|%.\\tmpyhlu\\t%$\\t%1, %2, %_MODk_0"
183 [(set_attr "type" "mpy2")
184 (set_attr "units" "m")
185 (set_attr "cross" "n,n,y,y")])
187 (define_insn "umulhisi3_hh_VARIANT_"
188 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
189 (mult:SI (lshiftrt:SI
190 (match_operand:SI 1 "register_operand" "%a,b,?a,?b")
193 (match_operand:SI 2 "register_operand" "a,b,b,a")
194 (const_int 16)))_CBRK_)]
196 "%|%.\\tmpyhu\\t%$\\t%1, %2, %_MODk_0"
197 [(set_attr "type" "mpy2")
198 (set_attr "units" "m")
199 (set_attr "cross" "n,n,y,y")])
201 (define_insn "usmulhisi3_const_VARIANT_"
202 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A__B_")
203 (mult:SI (zero_extend:SI
204 (match_operand:HI 1 "register_operand" "a,b,?ab"))
205 (match_operand:SI 2 "scst5_operand" "Is5,Is5,Is5"))_CBRK_)]
207 "%|%.\\tmpysu\\t%$\\t%2, %1, %_MODk_0"
208 [(set_attr "type" "mpy2")
209 (set_attr "units" "m")
210 (set_attr "cross" "n,n,y")])
212 (define_insn "*usmulhisi3_insn_VARIANT_"
213 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
214 (mult:SI (zero_extend:SI
215 (match_operand:HI 1 "register_operand" "a,b,?a,?b"))
217 (match_operand:HI 2 "reg_or_scst5_operand" "aIs5,bIs5,bIs5,aIs5")))_CBRK_)]
219 "%|%.\\tmpyus\\t%$\\t%1, %2, %_MODk_0"
220 [(set_attr "type" "mpy2")
221 (set_attr "units" "m")
222 (set_attr "cross" "n,n,y,y")])
224 (define_insn "usmulhisi3_lh_VARIANT_"
225 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
226 (mult:SI (zero_extend:SI
227 (match_operand:HI 1 "register_operand" "a,b,?a,?b"))
229 (match_operand:SI 2 "register_operand" "a,b,b,a")
230 (const_int 16)))_CBRK_)]
232 "%|%.\\tmpyluhs\\t%$\\t%1, %2, %_MODk_0"
233 [(set_attr "type" "mpy2")
234 (set_attr "units" "m")
235 (set_attr "cross" "n,n,y,y")])
237 (define_insn "usmulhisi3_hl_VARIANT_"
238 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
239 (mult:SI (lshiftrt:SI
240 (match_operand:SI 1 "register_operand" "a,b,?a,?b")
243 (match_operand:HI 2 "register_operand" "a,b,b,a")))_CBRK_)]
245 "%|%.\\tmpyhuls\\t%$\\t%1, %2, %_MODk_0"
246 [(set_attr "type" "mpy2")
247 (set_attr "units" "m")
248 (set_attr "cross" "n,n,y,y")])
250 (define_insn "usmulhisi3_hh_VARIANT_"
251 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
252 (mult:SI (lshiftrt:SI
253 (match_operand:SI 1 "register_operand" "a,b,?a,?b")
256 (match_operand:SI 2 "register_operand" "a,b,b,a")
257 (const_int 16)))_CBRK_)]
259 "%|%.\\tmpyhus\\t%$\\t%1, %2, %_MODk_0"
260 [(set_attr "type" "mpy2")
261 (set_attr "units" "m")
262 (set_attr "cross" "n,n,y,y")])
264 (define_insn "mulsi3_insn_VARIANT_"
265 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
266 (mult:SI (match_operand:SI 1 "register_operand" "%a,b,?a,?b")
267 (match_operand:SI 2 "register_operand" "a,b,b,a"))_CBRK_)]
269 "%|%.\\tmpy32\\t%$\\t%1, %2, %_MODk_0"
270 [(set_attr "type" "mpy4")
271 (set_attr "units" "m")
272 (set_attr "cross" "n,n,y,y")])
274 (define_insn "<u>mulsidi3_VARIANT_"
275 [(_SET_ _OBRK_(match_operand:DI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
277 (match_operand:SI 1 "register_operand" "%a,b,?a,?b"))
279 (match_operand:SI 2 "register_operand" "a,b,b,a")))_CBRK_)]
281 "%|%.\\tmpy32<u>\\t%$\\t%1, %2, %_MODK_0"
282 [(set_attr "type" "mpy4")
283 (set_attr "units" "m")
284 (set_attr "cross" "n,n,y,y")])
286 (define_insn "usmulsidi3_VARIANT_"
287 [(_SET_ _OBRK_(match_operand:DI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
288 (mult:DI (zero_extend:DI
289 (match_operand:SI 1 "register_operand" "a,b,?a,?b"))
291 (match_operand:SI 2 "register_operand" "a,b,b,a")))_CBRK_)]
293 "%|%.\\tmpy32us\\t%$\\t%1, %2, %_MODK_0"
294 [(set_attr "type" "mpy4")
295 (set_attr "units" "m")
296 (set_attr "cross" "n,n,y,y")])
298 ;; Widening vector multiply and dot product
300 (define_insn "mulv2hiv2si3_VARIANT_"
301 [(_SET_ _OBRK_(match_operand:V2SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
303 (sign_extend:V2SI (match_operand:V2HI 1 "register_operand" "a,b,a,b"))
304 (sign_extend:V2SI (match_operand:V2HI 2 "register_operand" "a,b,?b,?a")))_CBRK_)]
306 "%|%.\\tmpy2\\t%$\\t%1, %2, %_MODk_0"
307 [(set_attr "type" "mpy4")
308 (set_attr "units" "m")
309 (set_attr "cross" "n,n,y,y")])
311 (define_insn "umulv4qiv4hi3_VARIANT_"
312 [(_SET_ _OBRK_(match_operand:V4HI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
314 (zero_extend:V4HI (match_operand:V4QI 1 "register_operand" "a,b,a,b"))
315 (zero_extend:V4HI (match_operand:V4QI 2 "register_operand" "a,b,?b,?a")))_CBRK_)]
317 "%|%.\\tmpyu4\\t%$\\t%1, %2, %_MODk_0"
318 [(set_attr "type" "mpy4")
319 (set_attr "units" "m")
320 (set_attr "cross" "n,n,y,y")])
322 (define_insn "usmulv4qiv4hi3_VARIANT_"
323 [(_SET_ _OBRK_(match_operand:V4HI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
325 (zero_extend:V4HI (match_operand:V4QI 1 "register_operand" "a,b,?b,?a"))
326 (sign_extend:V4HI (match_operand:V4QI 2 "register_operand" "a,b,a,b")))_CBRK_)]
328 "%|%.\\tmpyus4\\t%$\\t%1, %2, %_MODk_0"
329 [(set_attr "type" "mpy4")
330 (set_attr "units" "m")
331 (set_attr "cross" "n,n,y,y")])
333 (define_insn "dotv2hi_VARIANT_"
334 [(_SET_ _OBRK_(match_operand:SI 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
339 (match_operand:V2HI 1 "register_operand" "a,b,a,b")
340 (parallel [(const_int 0)])))
343 (match_operand:V2HI 2 "register_operand" "a,b,?b,?a")
344 (parallel [(const_int 0)]))))
347 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
349 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))_CBRK_)]
351 "%|%.\\tdotp2\\t%$\\t%1, %2, %_MODk_0"
352 [(set_attr "type" "mpy4")
353 (set_attr "units" "m")
354 (set_attr "cross" "n,n,y,y")])
356 ;; Fractional multiply
358 (define_insn "mulv2hqv2sq3_VARIANT_"
359 [(_SET_ _OBRK_(match_operand:_MV2SQ 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
362 (match_operand:V2HQ 1 "register_operand" "%a,b,?a,?b"))
364 (match_operand:V2HQ 2 "register_operand" "a,b,b,a")))_CBRK_)]
366 "%|%.\\tsmpy2\\t%$\\t%1, %2, %_MODk_0"
367 [(set_attr "type" "mpy4")
368 (set_attr "units" "m")
369 (set_attr "cross" "n,n,y,y")])
371 (define_insn "mulhqsq3_VARIANT_"
372 [(_SET_ _OBRK_(match_operand:_MSQ 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
375 (match_operand:HQ 1 "register_operand" "%a,b,?a,?b"))
377 (match_operand:HQ 2 "register_operand" "a,b,b,a")))_CBRK_)]
379 "%|%.\\tsmpy\\t%$\\t%1, %2, %_MODk_0"
380 [(set_attr "type" "mpy2")
381 (set_attr "units" "m")
382 (set_attr "cross" "n,n,y,y")])
384 (define_insn "mulhqsq3_lh_VARIANT_"
385 [(_SET_ _OBRK_(match_operand:_MSQ 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
388 (match_operand:HQ 1 "register_operand" "a,b,?a,?b"))
390 (truncate:HQ (match_operand:SQ 2 "register_operand" "a,b,b,a"))))_CBRK_)]
392 "%|%.\\tsmpylh\\t%$\\t%1, %2, %_MODk_0"
393 [(set_attr "type" "mpy2")
394 (set_attr "units" "m")
395 (set_attr "cross" "n,n,y,y")])
397 (define_insn "mulhqsq3_hl_VARIANT_"
398 [(_SET_ _OBRK_(match_operand:_MSQ 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
401 (truncate:HQ (match_operand:SQ 1 "register_operand" "a,b,b,a")))
403 (match_operand:HQ 2 "register_operand" "a,b,b,a")))_CBRK_)]
405 "%|%.\\tsmpyhl\\t%$\\t%1, %2, %_MODk_0"
406 [(set_attr "type" "mpy2")
407 (set_attr "units" "m")
408 (set_attr "cross" "n,n,y,y")])
410 (define_insn "mulhqsq3_hh_VARIANT_"
411 [(_SET_ _OBRK_(match_operand:_MSQ 0 "_DESTOPERAND_" "=_A_,_B_,_A_,_B_")
414 (truncate:HQ (match_operand:SQ 1 "register_operand" "a,b,b,a")))
416 (truncate:HQ (match_operand:SQ 2 "register_operand" "a,b,b,a"))))_CBRK_)]
418 "%|%.\\tsmpyh\\t%$\\t%1, %2, %_MODk_0"
419 [(set_attr "type" "mpy2")
420 (set_attr "units" "m")
421 (set_attr "cross" "n,n,y,y")])