Debian Codegraph @

gcc/config/bfin/bfin.md

raw
1 ;;- Machine description for Blackfin for GNU compiler
2 ;; Copyright (C) 2005-2025 Free Software Foundation, Inc.
3 ;; Contributed by Analog Devices.
4
5 ;; This file is part of GCC.
6
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published
9 ;; by the Free Software Foundation; either version 3, or (at your
10 ;; option) any later version.
11
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 ;; License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>.
20
21 ; operand punctuation marks:
22 ;
23 ; X -- integer value printed as log2
24 ; Y -- integer value printed as log2(~value) - for bitclear
25 ; h -- print half word register, low part
26 ; d -- print half word register, high part
27 ; D -- print operand as dregs pairs
28 ; w -- print operand as accumulator register word (a0w, a1w)
29 ; H -- high part of double mode operand
30 ; T -- byte register representation Oct. 02 2001
31
32 ; constant operand classes
33 ;
34 ; J 2**N 5bit imm scaled
35 ; Ks7 -64 .. 63 signed 7bit imm
36 ; Ku5 0..31 unsigned 5bit imm
37 ; Ks4 -8 .. 7 signed 4bit imm
38 ; Ks3 -4 .. 3 signed 3bit imm
39 ; Ku3 0 .. 7 unsigned 3bit imm
40 ; Pn 0, 1, 2 constants 0, 1 or 2, corresponding to n
41 ;
42 ; register operands
43 ; d (r0..r7)
44 ; a (p0..p5,fp,sp)
45 ; e (a0, a1)
46 ; b (i0..i3)
47 ; f (m0..m3)
48 ; v (b0..b3)
49 ; c (i0..i3,m0..m3) CIRCREGS
50 ; C (CC) CCREGS
51 ; t (lt0,lt1)
52 ; k (lc0,lc1)
53 ; u (lb0,lb1)
54 ;
55
56 ;; Define constants for hard registers.
57
58 (define_constants
59 [(REG_R0 0)
60 (REG_R1 1)
61 (REG_R2 2)
62 (REG_R3 3)
63 (REG_R4 4)
64 (REG_R5 5)
65 (REG_R6 6)
66 (REG_R7 7)
67
68 (REG_P0 8)
69 (REG_P1 9)
70 (REG_P2 10)
71 (REG_P3 11)
72 (REG_P4 12)
73 (REG_P5 13)
74 (REG_P6 14)
75 (REG_P7 15)
76
77 (REG_SP 14)
78 (REG_FP 15)
79
80 (REG_I0 16)
81 (REG_I1 17)
82 (REG_I2 18)
83 (REG_I3 19)
84
85 (REG_B0 20)
86 (REG_B1 21)
87 (REG_B2 22)
88 (REG_B3 23)
89
90 (REG_L0 24)
91 (REG_L1 25)
92 (REG_L2 26)
93 (REG_L3 27)
94
95 (REG_M0 28)
96 (REG_M1 29)
97 (REG_M2 30)
98 (REG_M3 31)
99
100 (REG_A0 32)
101 (REG_A1 33)
102
103 (REG_CC 34)
104 (REG_RETS 35)
105 (REG_RETI 36)
106 (REG_RETX 37)
107 (REG_RETN 38)
108 (REG_RETE 39)
109
110 (REG_ASTAT 40)
111 (REG_SEQSTAT 41)
112 (REG_USP 42)
113
114 (REG_ARGP 43)
115
116 (REG_LT0 44)
117 (REG_LT1 45)
118 (REG_LC0 46)
119 (REG_LC1 47)
120 (REG_LB0 48)
121 (REG_LB1 49)])
122
123 ;; Constants used in UNSPECs and UNSPEC_VOLATILEs.
124
125 (define_constants
126 [(UNSPEC_CBRANCH_TAKEN 0)
127 (UNSPEC_CBRANCH_NOPS 1)
128 (UNSPEC_RETURN 2)
129 (UNSPEC_MOVE_PIC 3)
130 (UNSPEC_LIBRARY_OFFSET 4)
131 (UNSPEC_PUSH_MULTIPLE 5)
132 ;; Multiply or MAC with extra CONST_INT operand specifying the macflag
133 (UNSPEC_MUL_WITH_FLAG 6)
134 (UNSPEC_MAC_WITH_FLAG 7)
135 (UNSPEC_MOVE_FDPIC 8)
136 (UNSPEC_FUNCDESC_GOT17M4 9)
137 (UNSPEC_LSETUP_END 10)
138 ;; Distinguish a 32-bit version of an insn from a 16-bit version.
139 (UNSPEC_32BIT 11)
140 (UNSPEC_NOP 12)
141 (UNSPEC_ATOMIC 13)])
142
143 (define_constants
144 [(UNSPEC_VOLATILE_CSYNC 1)
145 (UNSPEC_VOLATILE_SSYNC 2)
146 (UNSPEC_VOLATILE_LOAD_FUNCDESC 3)
147 (UNSPEC_VOLATILE_STORE_EH_HANDLER 4)
148 (UNSPEC_VOLATILE_DUMMY 5)
149 (UNSPEC_VOLATILE_STALL 6)])
150
151 (define_constants
152 [(MACFLAG_NONE 0)
153 (MACFLAG_T 1)
154 (MACFLAG_FU 2)
155 (MACFLAG_TFU 3)
156 (MACFLAG_IS 4)
157 (MACFLAG_IU 5)
158 (MACFLAG_W32 6)
159 (MACFLAG_M 7)
160 (MACFLAG_IS_M 8)
161 (MACFLAG_S2RND 9)
162 (MACFLAG_ISS2 10)
163 (MACFLAG_IH 11)])
164
165 (define_attr "type"
166 "move,movcc,mvi,mcld,mcst,dsp32,dsp32shiftimm,mult,alu0,shft,brcc,br,call,misc,sync,compare,dummy,stall"
167 (const_string "misc"))
168
169 (define_attr "addrtype" "32bit,preg,spreg,ireg"
170 (cond [(and (eq_attr "type" "mcld")
171 (and (match_operand 0 "dp_register_operand" "")
172 (match_operand 1 "mem_p_address_operand" "")))
173 (const_string "preg")
174 (and (eq_attr "type" "mcld")
175 (and (match_operand 0 "dp_register_operand" "")
176 (match_operand 1 "mem_spfp_address_operand" "")))
177 (const_string "spreg")
178 (and (eq_attr "type" "mcld")
179 (and (match_operand 0 "dp_register_operand" "")
180 (match_operand 1 "mem_i_address_operand" "")))
181 (const_string "ireg")
182 (and (eq_attr "type" "mcst")
183 (and (match_operand 1 "dp_register_operand" "")
184 (match_operand 0 "mem_p_address_operand" "")))
185 (const_string "preg")
186 (and (eq_attr "type" "mcst")
187 (and (match_operand 1 "dp_register_operand" "")
188 (match_operand 0 "mem_spfp_address_operand" "")))
189 (const_string "spreg")
190 (and (eq_attr "type" "mcst")
191 (and (match_operand 1 "dp_register_operand" "")
192 (match_operand 0 "mem_i_address_operand" "")))
193 (const_string "ireg")]
194 (const_string "32bit")))
195
196 (define_attr "storereg" "preg,other"
197 (cond [(and (eq_attr "type" "mcst")
198 (match_operand 1 "p_register_operand" ""))
199 (const_string "preg")]
200 (const_string "other")))
201
202 ;; Scheduling definitions
203
204 (define_automaton "bfin")
205
206 (define_cpu_unit "slot0" "bfin")
207 (define_cpu_unit "slot1" "bfin")
208 (define_cpu_unit "slot2" "bfin")
209
210 ;; Three units used to enforce parallel issue restrictions:
211 ;; only one of the 16-bit slots can use a P register in an address,
212 ;; and only one them can be a store.
213 (define_cpu_unit "store" "bfin")
214 (define_cpu_unit "pregs" "bfin")
215
216 ;; A dummy unit used to delay scheduling of loads after a conditional
217 ;; branch.
218 (define_cpu_unit "load" "bfin")
219
220 ;; A logical unit used to work around anomaly 05000074.
221 (define_cpu_unit "anomaly_05000074" "bfin")
222
223 (define_reservation "core" "slot0+slot1+slot2")
224
225 (define_insn_reservation "alu" 1
226 (eq_attr "type" "move,movcc,mvi,alu0,shft,brcc,br,call,misc,sync,compare")
227 "core")
228
229 (define_insn_reservation "imul" 3
230 (eq_attr "type" "mult")
231 "core*3")
232
233 (define_insn_reservation "dsp32" 1
234 (eq_attr "type" "dsp32")
235 "slot0")
236
237 (define_insn_reservation "dsp32shiftimm" 1
238 (and (eq_attr "type" "dsp32shiftimm")
239 (not (match_test "ENABLE_WA_05000074")))
240 "slot0")
241
242 (define_insn_reservation "dsp32shiftimm_anomaly_05000074" 1
243 (and (eq_attr "type" "dsp32shiftimm")
244 (match_test "ENABLE_WA_05000074"))
245 "slot0+anomaly_05000074")
246
247 (define_insn_reservation "load32" 1
248 (and (not (eq_attr "seq_insns" "multi"))
249 (and (eq_attr "type" "mcld") (eq_attr "addrtype" "32bit")))
250 "core+load")
251
252 (define_insn_reservation "loadp" 1
253 (and (not (eq_attr "seq_insns" "multi"))
254 (and (eq_attr "type" "mcld") (eq_attr "addrtype" "preg")))
255 "slot1+pregs+load")
256
257 (define_insn_reservation "loadsp" 1
258 (and (not (eq_attr "seq_insns" "multi"))
259 (and (eq_attr "type" "mcld") (eq_attr "addrtype" "spreg")))
260 "slot1+pregs")
261
262 (define_insn_reservation "loadi" 1
263 (and (not (eq_attr "seq_insns" "multi"))
264 (and (eq_attr "type" "mcld") (eq_attr "addrtype" "ireg")))
265 "(slot1|slot2)+load")
266
267 (define_insn_reservation "store32" 1
268 (and (not (eq_attr "seq_insns" "multi"))
269 (and (eq_attr "type" "mcst") (eq_attr "addrtype" "32bit")))
270 "core")
271
272 (define_insn_reservation "storep" 1
273 (and (and (not (eq_attr "seq_insns" "multi"))
274 (and (eq_attr "type" "mcst")
275 (ior (eq_attr "addrtype" "preg")
276 (eq_attr "addrtype" "spreg"))))
277 (ior (not (match_test "ENABLE_WA_05000074"))
278 (eq_attr "storereg" "other")))
279 "slot1+pregs+store")
280
281 (define_insn_reservation "storep_anomaly_05000074" 1
282 (and (and (not (eq_attr "seq_insns" "multi"))
283 (and (eq_attr "type" "mcst")
284 (ior (eq_attr "addrtype" "preg")
285 (eq_attr "addrtype" "spreg"))))
286 (and (match_test "ENABLE_WA_05000074")
287 (eq_attr "storereg" "preg")))
288 "slot1+anomaly_05000074+pregs+store")
289
290 (define_insn_reservation "storei" 1
291 (and (and (not (eq_attr "seq_insns" "multi"))
292 (and (eq_attr "type" "mcst") (eq_attr "addrtype" "ireg")))
293 (ior (not (match_test "ENABLE_WA_05000074"))
294 (eq_attr "storereg" "other")))
295 "(slot1|slot2)+store")
296
297 (define_insn_reservation "storei_anomaly_05000074" 1
298 (and (and (not (eq_attr "seq_insns" "multi"))
299 (and (eq_attr "type" "mcst") (eq_attr "addrtype" "ireg")))
300 (and (match_test "ENABLE_WA_05000074")
301 (eq_attr "storereg" "preg")))
302 "((slot1+anomaly_05000074)|slot2)+store")
303
304 (define_insn_reservation "multi" 2
305 (eq_attr "seq_insns" "multi")
306 "core")
307
308 (define_insn_reservation "load_stall1" 1
309 (and (eq_attr "type" "stall")
310 (match_operand 0 "const1_operand" ""))
311 "core+load*2")
312
313 (define_insn_reservation "load_stall3" 1
314 (and (eq_attr "type" "stall")
315 (match_operand 0 "const3_operand" ""))
316 "core+load*4")
317
318 (absence_set "slot0" "slot1,slot2")
319 (absence_set "slot1" "slot2")
320
321 ;; Make sure genautomata knows about the maximum latency that can be produced
322 ;; by the adjust_cost function.
323 (define_insn_reservation "dummy" 5
324 (eq_attr "type" "dummy")
325 "core")
326
327 ;; Operand and operator predicates
328
329 (include "predicates.md")
330 (include "constraints.md")
331
332 ;;; FRIO branches have been optimized for code density
333 ;;; this comes at a slight cost of complexity when
334 ;;; a compiler needs to generate branches in the general
335 ;;; case. In order to generate the correct branching
336 ;;; mechanisms the compiler needs keep track of instruction
337 ;;; lengths. The follow table describes how to count instructions
338 ;;; for the FRIO architecture.
339 ;;;
340 ;;; unconditional br are 12-bit imm pcrelative branches *2
341 ;;; conditional br are 10-bit imm pcrelative branches *2
342 ;;; brcc 10-bit:
343 ;;; 1024 10-bit imm *2 is 2048 (-1024..1022)
344 ;;; br 12-bit :
345 ;;; 4096 12-bit imm *2 is 8192 (-4096..4094)
346 ;;; NOTE : For brcc we generate instructions such as
347 ;;; if cc jmp; jump.[sl] offset
348 ;;; offset of jump.[sl] is from the jump instruction but
349 ;;; gcc calculates length from the if cc jmp instruction
350 ;;; furthermore gcc takes the end address of the branch instruction
351 ;;; as (pc) for a forward branch
352 ;;; hence our range is (-4094, 4092) instead of (-4096, 4094) for a br
353 ;;;
354 ;;; The way the (pc) rtx works in these calculations is somewhat odd;
355 ;;; for backward branches it's the address of the current instruction,
356 ;;; for forward branches it's the previously known address of the following
357 ;;; instruction - we have to take this into account by reducing the range
358 ;;; for a forward branch.
359
360 ;; Lengths for type "mvi" insns are always defined by the instructions
361 ;; themselves.
362 (define_attr "length" ""
363 (cond [(eq_attr "type" "mcld")
364 (if_then_else (match_operand 1 "effective_address_32bit_p" "")
365 (const_int 4) (const_int 2))
366
367 (eq_attr "type" "mcst")
368 (if_then_else (match_operand 0 "effective_address_32bit_p" "")
369 (const_int 4) (const_int 2))
370
371 (eq_attr "type" "move") (const_int 2)
372
373 (eq_attr "type" "dsp32") (const_int 4)
374 (eq_attr "type" "dsp32shiftimm") (const_int 4)
375 (eq_attr "type" "call") (const_int 4)
376
377 (eq_attr "type" "br")
378 (if_then_else (and
379 (le (minus (match_dup 0) (pc)) (const_int 4092))
380 (ge (minus (match_dup 0) (pc)) (const_int -4096)))
381 (const_int 2)
382 (const_int 4))
383
384 (eq_attr "type" "brcc")
385 (cond [(and
386 (le (minus (match_dup 3) (pc)) (const_int 1020))
387 (ge (minus (match_dup 3) (pc)) (const_int -1024)))
388 (const_int 2)
389 (and
390 (le (minus (match_dup 3) (pc)) (const_int 4092))
391 (ge (minus (match_dup 3) (pc)) (const_int -4094)))
392 (const_int 4)]
393 (const_int 6))
394 ]
395
396 (const_int 2)))
397
398 ;; Classify the insns into those that are one instruction and those that
399 ;; are more than one in sequence.
400 (define_attr "seq_insns" "single,multi"
401 (const_string "single"))
402
403 ;; Describe a user's asm statement.
404 (define_asm_attributes
405 [(set_attr "type" "misc")
406 (set_attr "seq_insns" "multi")
407 (set_attr "length" "4")])
408
409 ;; Conditional moves
410
411 (define_mode_iterator CCMOV [QI HI SI])
412
413 (define_expand "mov<mode>cc"
414 [(set (match_operand:CCMOV 0 "register_operand" "")
415 (if_then_else:CCMOV (match_operand 1 "comparison_operator" "")
416 (match_operand:CCMOV 2 "register_operand" "")
417 (match_operand:CCMOV 3 "register_operand" "")))]
418 ""
419 {
420 operands[1] = bfin_gen_compare (operands[1], <MODE>mode);
421 })
422
423 (define_insn "*mov<mode>cc_insn1"
424 [(set (match_operand:CCMOV 0 "register_operand" "=da,da,da")
425 (if_then_else:CCMOV
426 (eq:BI (match_operand:BI 3 "register_operand" "C,C,C")
427 (const_int 0))
428 (match_operand:CCMOV 1 "register_operand" "da,0,da")
429 (match_operand:CCMOV 2 "register_operand" "0,da,da")))]
430 ""
431 "@
432 if !cc %0 = %1;
433 if cc %0 = %2;
434 if !cc %0 = %1; if cc %0 = %2;"
435 [(set_attr "length" "2,2,4")
436 (set_attr "type" "movcc")
437 (set_attr "seq_insns" "*,*,multi")])
438
439 (define_insn "*mov<mode>cc_insn2"
440 [(set (match_operand:CCMOV 0 "register_operand" "=da,da,da")
441 (if_then_else:CCMOV
442 (ne:BI (match_operand:BI 3 "register_operand" "C,C,C")
443 (const_int 0))
444 (match_operand:CCMOV 1 "register_operand" "0,da,da")
445 (match_operand:CCMOV 2 "register_operand" "da,0,da")))]
446 ""
447 "@
448 if !cc %0 = %2;
449 if cc %0 = %1;
450 if cc %0 = %1; if !cc %0 = %2;"
451 [(set_attr "length" "2,2,4")
452 (set_attr "type" "movcc")
453 (set_attr "seq_insns" "*,*,multi")])
454
455 ;; Insns to load HIGH and LO_SUM
456
457 (define_insn "movsi_high"
458 [(set (match_operand:SI 0 "register_operand" "=x")
459 (high:SI (match_operand:SI 1 "immediate_operand" "i")))]
460 "reload_completed"
461 "%d0 = %d1;"
462 [(set_attr "type" "mvi")
463 (set_attr "length" "4")])
464
465 (define_insn "movstricthi_high"
466 [(set (match_operand:SI 0 "register_operand" "+x")
467 (ior:SI (and:SI (match_dup 0) (const_int 65535))
468 (match_operand:SI 1 "immediate_operand" "i")))]
469 "reload_completed"
470 "%d0 = %d1;"
471 [(set_attr "type" "mvi")
472 (set_attr "length" "4")])
473
474 (define_insn "movsi_low"
475 [(set (match_operand:SI 0 "register_operand" "=x")
476 (lo_sum:SI (match_operand:SI 1 "register_operand" "0")
477 (match_operand:SI 2 "immediate_operand" "i")))]
478 "reload_completed"
479 "%h0 = %h2;"
480 [(set_attr "type" "mvi")
481 (set_attr "length" "4")])
482
483 (define_insn "movsi_high_pic"
484 [(set (match_operand:SI 0 "register_operand" "=x")
485 (high:SI (unspec:SI [(match_operand:SI 1 "" "")]
486 UNSPEC_MOVE_PIC)))]
487 ""
488 "%d0 = %1@GOT_LOW;"
489 [(set_attr "type" "mvi")
490 (set_attr "length" "4")])
491
492 (define_insn "movsi_low_pic"
493 [(set (match_operand:SI 0 "register_operand" "=x")
494 (lo_sum:SI (match_operand:SI 1 "register_operand" "0")
495 (unspec:SI [(match_operand:SI 2 "" "")]
496 UNSPEC_MOVE_PIC)))]
497 ""
498 "%h0 = %h2@GOT_HIGH;"
499 [(set_attr "type" "mvi")
500 (set_attr "length" "4")])
501
502 ;;; Move instructions
503
504 (define_insn_and_split "movdi_insn"
505 [(set (match_operand:DI 0 "nonimmediate_operand" "=x,mx,r")
506 (match_operand:DI 1 "general_operand" "iFx,r,mx"))]
507 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) == REG"
508 "#"
509 "reload_completed"
510 [(set (match_dup 2) (match_dup 3))
511 (set (match_dup 4) (match_dup 5))]
512 {
513 rtx lo_half[2], hi_half[2];
514 split_di (operands, 2, lo_half, hi_half);
515
516 if (reg_overlap_mentioned_p (lo_half[0], hi_half[1]))
517 {
518 operands[2] = hi_half[0];
519 operands[3] = hi_half[1];
520 operands[4] = lo_half[0];
521 operands[5] = lo_half[1];
522 }
523 else
524 {
525 operands[2] = lo_half[0];
526 operands[3] = lo_half[1];
527 operands[4] = hi_half[0];
528 operands[5] = hi_half[1];
529 }
530 })
531
532 (define_insn "movbi"
533 [(set (match_operand:BI 0 "nonimmediate_operand" "=x,x,d,md,C,d,C,P1")
534 (match_operand:BI 1 "general_operand" "x,xKs3,md,d,d,C,P0,P1"))]
535
536 ""
537 "@
538 %0 = %1;
539 %0 = %1 (X);
540 %0 = B %1 (Z)%!
541 B %0 = %1;
542 CC = %1;
543 %0 = CC;
544 CC = R0 < R0;
545 CC = R0 == R0;"
546 [(set_attr "type" "move,mvi,mcld,mcst,compare,compare,compare,compare")
547 (set_attr "length" "2,2,*,*,2,2,2,2")
548 (set_attr "seq_insns" "*,*,*,*,*,*,*,*")])
549
550 (define_insn "movpdi"
551 [(set (match_operand:PDI 0 "nonimmediate_operand" "=e,<,e")
552 (match_operand:PDI 1 "general_operand" " e,e,>"))]
553 ""
554 "@
555 %0 = %1;
556 %0 = %x1; %0 = %w1;
557 %w0 = %1; %x0 = %1;"
558 [(set_attr "type" "move,mcst,mcld")
559 (set_attr "length" "4,*,*")
560 (set_attr "seq_insns" "*,multi,multi")])
561
562 (define_insn "load_accumulator"
563 [(set (match_operand:PDI 0 "register_operand" "=e")
564 (sign_extend:PDI (match_operand:SI 1 "register_operand" "d")))]
565 ""
566 "%0 = %1;"
567 [(set_attr "type" "move")])
568
569 (define_insn_and_split "load_accumulator_pair"
570 [(set (match_operand:V2PDI 0 "register_operand" "=e")
571 (sign_extend:V2PDI (vec_concat:V2SI
572 (match_operand:SI 1 "register_operand" "d")
573 (match_operand:SI 2 "register_operand" "d"))))]
574 ""
575 "#"
576 "reload_completed"
577 [(set (match_dup 3) (sign_extend:PDI (match_dup 1)))
578 (set (match_dup 4) (sign_extend:PDI (match_dup 2)))]
579 {
580 operands[3] = gen_rtx_REG (PDImode, REGNO (operands[0]));
581 operands[4] = gen_rtx_REG (PDImode, REGNO (operands[0]) + 1);
582 })
583
584 (define_insn "*pushsi_insn"
585 [(set (mem:SI (pre_dec:SI (reg:SI REG_SP)))
586 (match_operand:SI 0 "register_operand" "xy"))]
587 ""
588 "[--SP] = %0;"
589 [(set_attr "type" "mcst")
590 (set_attr "addrtype" "32bit")
591 (set_attr "length" "2")])
592
593 (define_insn "*popsi_insn"
594 [(set (match_operand:SI 0 "register_operand" "=d,xy")
595 (mem:SI (post_inc:SI (reg:SI REG_SP))))]
596 ""
597 "%0 = [SP++]%!"
598 [(set_attr "type" "mcld")
599 (set_attr "addrtype" "preg,32bit")
600 (set_attr "length" "2")])
601
602 ;; The first alternative is used to make reload choose a limited register
603 ;; class when faced with a movsi_insn that had its input operand replaced
604 ;; with a PLUS. We generally require fewer secondary reloads this way.
605
606 (define_insn "*movsi_insn"
607 [(set (match_operand:SI 0 "nonimmediate_operand" "=da,x,da,y,da,x,x,x,da,mr")
608 (match_operand:SI 1 "general_operand" "da,x,y,da,xKs7,xKsh,xKuh,ix,mr,da"))]
609 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) == REG"
610 "@
611 %0 = %1;
612 %0 = %1;
613 %0 = %1;
614 %0 = %1;
615 %0 = %1 (X);
616 %0 = %1 (X);
617 %0 = %1 (Z);
618 #
619 %0 = %1%!
620 %0 = %1%!"
621 [(set_attr "type" "move,move,move,move,mvi,mvi,mvi,*,mcld,mcst")
622 (set_attr "length" "2,2,2,2,2,4,4,*,*,*")])
623
624 (define_insn "*movsi_insn32"
625 [(set (match_operand:SI 0 "register_operand" "=d,d")
626 (unspec:SI [(match_operand:SI 1 "nonmemory_operand" "d,P0")] UNSPEC_32BIT))]
627 ""
628 "@
629 %0 = ROT %1 BY 0%!
630 %0 = %0 -|- %0%!"
631 [(set_attr "type" "dsp32shiftimm,dsp32")])
632
633 (define_split
634 [(set (match_operand:SI 0 "d_register_operand" "")
635 (const_int 0))]
636 "splitting_for_sched && !optimize_size"
637 [(set (match_dup 0) (unspec:SI [(const_int 0)] UNSPEC_32BIT))])
638
639 (define_split
640 [(set (match_operand:SI 0 "d_register_operand" "")
641 (match_operand:SI 1 "d_register_operand" ""))]
642 "splitting_for_sched && !optimize_size"
643 [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_32BIT))])
644
645 (define_insn_and_split "*movv2hi_insn"
646 [(set (match_operand:V2HI 0 "nonimmediate_operand" "=da,da,d,dm")
647 (match_operand:V2HI 1 "general_operand" "i,di,md,d"))]
648
649 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) == REG"
650 "@
651 #
652 %0 = %1;
653 %0 = %1%!
654 %0 = %1%!"
655 "reload_completed && GET_CODE (operands[1]) == CONST_VECTOR"
656 [(set (match_dup 0) (high:SI (match_dup 2)))
657 (set (match_dup 0) (lo_sum:SI (match_dup 0) (match_dup 3)))]
658 {
659 HOST_WIDE_INT intval = INTVAL (XVECEXP (operands[1], 0, 1)) << 16;
660 intval |= INTVAL (XVECEXP (operands[1], 0, 0)) & 0xFFFF;
661
662 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));
663 operands[2] = operands[3] = GEN_INT (trunc_int_for_mode (intval, SImode));
664 }
665 [(set_attr "type" "move,move,mcld,mcst")
666 (set_attr "length" "2,2,*,*")])
667
668 (define_insn "*movhi_insn"
669 [(set (match_operand:HI 0 "nonimmediate_operand" "=x,da,x,d,mr")
670 (match_operand:HI 1 "general_operand" "x,xKs7,xKsh,mr,d"))]
671 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) == REG"
672 {
673 static const char *templates[] = {
674 "%0 = %1;",
675 "%0 = %1 (X);",
676 "%0 = %1 (X);",
677 "%0 = W %1 (X)%!",
678 "W %0 = %1%!",
679 "%h0 = W %1%!",
680 "W %0 = %h1%!"
681 };
682 int alt = which_alternative;
683 rtx mem = (MEM_P (operands[0]) ? operands[0]
684 : MEM_P (operands[1]) ? operands[1] : NULL_RTX);
685 if (mem && bfin_dsp_memref_p (mem))
686 alt += 2;
687 return templates[alt];
688 }
689 [(set_attr "type" "move,mvi,mvi,mcld,mcst")
690 (set_attr "length" "2,2,4,*,*")])
691
692 (define_insn "*movqi_insn"
693 [(set (match_operand:QI 0 "nonimmediate_operand" "=x,da,x,d,mr")
694 (match_operand:QI 1 "general_operand" "x,xKs7,xKsh,mr,d"))]
695 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) == REG"
696 "@
697 %0 = %1;
698 %0 = %1 (X);
699 %0 = %1 (X);
700 %0 = B %1 (X)%!
701 B %0 = %1%!"
702 [(set_attr "type" "move,mvi,mvi,mcld,mcst")
703 (set_attr "length" "2,2,4,*,*")])
704
705 (define_insn "*movsf_insn"
706 [(set (match_operand:SF 0 "nonimmediate_operand" "=x,x,da,mr")
707 (match_operand:SF 1 "general_operand" "x,Fx,mr,da"))]
708 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) == REG"
709 "@
710 %0 = %1;
711 #
712 %0 = %1%!
713 %0 = %1%!"
714 [(set_attr "type" "move,*,mcld,mcst")])
715
716 (define_insn_and_split "movdf_insn"
717 [(set (match_operand:DF 0 "nonimmediate_operand" "=x,mx,r")
718 (match_operand:DF 1 "general_operand" "iFx,r,mx"))]
719 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) == REG"
720 "#"
721 "reload_completed"
722 [(set (match_dup 2) (match_dup 3))
723 (set (match_dup 4) (match_dup 5))]
724 {
725 rtx lo_half[2], hi_half[2];
726 split_di (operands, 2, lo_half, hi_half);
727
728 if (reg_overlap_mentioned_p (lo_half[0], hi_half[1]))
729 {
730 operands[2] = hi_half[0];
731 operands[3] = hi_half[1];
732 operands[4] = lo_half[0];
733 operands[5] = lo_half[1];
734 }
735 else
736 {
737 operands[2] = lo_half[0];
738 operands[3] = lo_half[1];
739 operands[4] = hi_half[0];
740 operands[5] = hi_half[1];
741 }
742 })
743
744 ;; Storing halfwords.
745 (define_insn "*movsi_insv"
746 [(set (zero_extract:SI (match_operand 0 "register_operand" "+d,x")
747 (const_int 16)
748 (const_int 16))
749 (match_operand:SI 1 "nonmemory_operand" "d,n"))]
750 ""
751 "@
752 %d0 = %h1 << 0%!
753 %d0 = %1;"
754 [(set_attr "type" "dsp32shiftimm,mvi")
755 (set_attr "length" "*,4")])
756
757 (define_expand "insv"
758 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "")
759 (match_operand:SI 1 "immediate_operand" "")
760 (match_operand:SI 2 "immediate_operand" ""))
761 (match_operand:SI 3 "nonmemory_operand" ""))]
762 ""
763 {
764 if (INTVAL (operands[1]) != 16 || INTVAL (operands[2]) != 16)
765 FAIL;
766
767 /* From mips.md: insert_bit_field doesn't verify that our source
768 matches the predicate, so check it again here. */
769 if (! register_operand (operands[0], VOIDmode))
770 FAIL;
771 })
772
773 ;; This is the main "hook" for PIC code. When generating
774 ;; PIC, movsi is responsible for determining when the source address
775 ;; needs PIC relocation and appropriately calling legitimize_pic_address
776 ;; to perform the actual relocation.
777
778 (define_expand "movsi"
779 [(set (match_operand:SI 0 "nonimmediate_operand" "")
780 (match_operand:SI 1 "general_operand" ""))]
781 ""
782 {
783 if (expand_move (operands, SImode))
784 DONE;
785 })
786
787 (define_expand "movv2hi"
788 [(set (match_operand:V2HI 0 "nonimmediate_operand" "")
789 (match_operand:V2HI 1 "general_operand" ""))]
790 ""
791 "expand_move (operands, V2HImode);")
792
793 (define_expand "movdi"
794 [(set (match_operand:DI 0 "nonimmediate_operand" "")
795 (match_operand:DI 1 "general_operand" ""))]
796 ""
797 "expand_move (operands, DImode);")
798
799 (define_expand "movsf"
800 [(set (match_operand:SF 0 "nonimmediate_operand" "")
801 (match_operand:SF 1 "general_operand" ""))]
802 ""
803 "expand_move (operands, SFmode);")
804
805 (define_expand "movdf"
806 [(set (match_operand:DF 0 "nonimmediate_operand" "")
807 (match_operand:DF 1 "general_operand" ""))]
808 ""
809 "expand_move (operands, DFmode);")
810
811 (define_expand "movhi"
812 [(set (match_operand:HI 0 "nonimmediate_operand" "")
813 (match_operand:HI 1 "general_operand" ""))]
814 ""
815 "expand_move (operands, HImode);")
816
817 (define_expand "movqi"
818 [(set (match_operand:QI 0 "nonimmediate_operand" "")
819 (match_operand:QI 1 "general_operand" ""))]
820 ""
821 " expand_move (operands, QImode); ")
822
823 ;; Some define_splits to break up SI/SFmode loads of immediate constants.
824
825 (define_split
826 [(set (match_operand:SI 0 "register_operand" "")
827 (match_operand:SI 1 "symbolic_or_const_operand" ""))]
828 "reload_completed
829 /* Always split symbolic operands; split integer constants that are
830 too large for a single instruction. */
831 && (GET_CODE (operands[1]) != CONST_INT
832 || (INTVAL (operands[1]) < -32768
833 || INTVAL (operands[1]) >= 65536
834 || (INTVAL (operands[1]) >= 32768 && PREG_P (operands[0]))))"
835 [(set (match_dup 0) (high:SI (match_dup 1)))
836 (set (match_dup 0) (lo_sum:SI (match_dup 0) (match_dup 1)))]
837 {
838 if (GET_CODE (operands[1]) == CONST_INT
839 && split_load_immediate (operands))
840 DONE;
841 /* ??? Do something about TARGET_LOW_64K. */
842 })
843
844 (define_split
845 [(set (match_operand:SF 0 "register_operand" "")
846 (match_operand:SF 1 "immediate_operand" ""))]
847 "reload_completed"
848 [(set (match_dup 2) (high:SI (match_dup 3)))
849 (set (match_dup 2) (lo_sum:SI (match_dup 2) (match_dup 3)))]
850 {
851 long values;
852
853 gcc_assert (GET_CODE (operands[1]) == CONST_DOUBLE);
854
855 REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (operands[1]), values);
856
857 operands[2] = gen_rtx_REG (SImode, true_regnum (operands[0]));
858 operands[3] = GEN_INT (trunc_int_for_mode (values, SImode));
859 if (values >= -32768 && values < 65536)
860 {
861 emit_move_insn (operands[2], operands[3]);
862 DONE;
863 }
864 if (split_load_immediate (operands + 2))
865 DONE;
866 })
867
868 ;; Sadly, this can't be a proper named movstrict pattern, since the compiler
869 ;; expects to be able to use registers for operand 1.
870 ;; Note that the asm instruction is defined by the manual to take an unsigned
871 ;; constant, but it doesn't matter to the assembler, and the compiler only
872 ;; deals with sign-extended constants. Hence "Ksh".
873 (define_insn "movstricthi_1"
874 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+x"))
875 (match_operand:HI 1 "immediate_operand" "Ksh"))]
876 ""
877 "%h0 = %1;"
878 [(set_attr "type" "mvi")
879 (set_attr "length" "4")])
880
881 ;; Sign and zero extensions
882
883 (define_insn_and_split "extendhisi2"
884 [(set (match_operand:SI 0 "register_operand" "=d, d")
885 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "d, m")))]
886 ""
887 "@
888 %0 = %h1 (X);
889 %0 = W %h1 (X)%!"
890 "reload_completed && bfin_dsp_memref_p (operands[1])"
891 [(set (match_dup 2) (match_dup 1))
892 (set (match_dup 0) (sign_extend:SI (match_dup 2)))]
893 {
894 operands[2] = gen_lowpart (HImode, operands[0]);
895 }
896 [(set_attr "type" "alu0,mcld")])
897
898 (define_insn_and_split "zero_extendhisi2"
899 [(set (match_operand:SI 0 "register_operand" "=d, d")
900 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "d, m")))]
901 ""
902 "@
903 %0 = %h1 (Z);
904 %0 = W %h1 (Z)%!"
905 "reload_completed && bfin_dsp_memref_p (operands[1])"
906 [(set (match_dup 2) (match_dup 1))
907 (set (match_dup 0) (zero_extend:SI (match_dup 2)))]
908 {
909 operands[2] = gen_lowpart (HImode, operands[0]);
910 }
911 [(set_attr "type" "alu0,mcld")])
912
913 (define_insn "zero_extendbisi2"
914 [(set (match_operand:SI 0 "register_operand" "=d")
915 (zero_extend:SI (match_operand:BI 1 "nonimmediate_operand" "C")))]
916 ""
917 "%0 = %1;"
918 [(set_attr "type" "compare")])
919
920 (define_insn "extendqihi2"
921 [(set (match_operand:HI 0 "register_operand" "=d, d")
922 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "m, d")))]
923 ""
924 "@
925 %0 = B %1 (X)%!
926 %0 = %T1 (X);"
927 [(set_attr "type" "mcld,alu0")])
928
929 (define_insn "extendqisi2"
930 [(set (match_operand:SI 0 "register_operand" "=d, d")
931 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "m, d")))]
932 ""
933 "@
934 %0 = B %1 (X)%!
935 %0 = %T1 (X);"
936 [(set_attr "type" "mcld,alu0")])
937
938
939 (define_insn "zero_extendqihi2"
940 [(set (match_operand:HI 0 "register_operand" "=d, d")
941 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "m, d")))]
942 ""
943 "@
944 %0 = B %1 (Z)%!
945 %0 = %T1 (Z);"
946 [(set_attr "type" "mcld,alu0")])
947
948
949 (define_insn "zero_extendqisi2"
950 [(set (match_operand:SI 0 "register_operand" "=d, d")
951 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "m, d")))]
952 ""
953 "@
954 %0 = B %1 (Z)%!
955 %0 = %T1 (Z);"
956 [(set_attr "type" "mcld,alu0")])
957
958 ;; DImode logical operations
959
960 (define_code_iterator any_logical [and ior xor])
961 (define_code_attr optab [(and "and")
962 (ior "ior")
963 (xor "xor")])
964 (define_code_attr op [(and "&")
965 (ior "|")
966 (xor "^")])
967 (define_code_attr high_result [(and "0")
968 (ior "%H1")
969 (xor "%H1")])
970
971 ;; Keep this pattern around to avoid generating NO_CONFLICT blocks.
972 (define_expand "<optab>di3"
973 [(set (match_operand:DI 0 "register_operand" "=d")
974 (any_logical:DI (match_operand:DI 1 "register_operand" "0")
975 (match_operand:DI 2 "general_operand" "d")))]
976 ""
977 {
978 rtx hi_half[3], lo_half[3];
979 enum insn_code icode = CODE_FOR_<optab>si3;
980 if (!reg_overlap_mentioned_p (operands[0], operands[1])
981 && !reg_overlap_mentioned_p (operands[0], operands[2]))
982 emit_clobber (operands[0]);
983 split_di (operands, 3, lo_half, hi_half);
984 if (!(*insn_data[icode].operand[2].predicate) (lo_half[2], SImode))
985 lo_half[2] = force_reg (SImode, lo_half[2]);
986 emit_insn (GEN_FCN (icode) (lo_half[0], lo_half[1], lo_half[2]));
987 if (!(*insn_data[icode].operand[2].predicate) (hi_half[2], SImode))
988 hi_half[2] = force_reg (SImode, hi_half[2]);
989 emit_insn (GEN_FCN (icode) (hi_half[0], hi_half[1], hi_half[2]));
990 DONE;
991 })
992
993 (define_insn "zero_extendqidi2"
994 [(set (match_operand:DI 0 "register_operand" "=d")
995 (zero_extend:DI (match_operand:QI 1 "register_operand" "d")))]
996 ""
997 "%0 = %T1 (Z);\\n\\t%H0 = 0;"
998 [(set_attr "length" "4")
999 (set_attr "seq_insns" "multi")])
1000
1001 (define_insn "zero_extendhidi2"
1002 [(set (match_operand:DI 0 "register_operand" "=d")
1003 (zero_extend:DI (match_operand:HI 1 "register_operand" "d")))]
1004 ""
1005 "%0 = %h1 (Z);\\n\\t%H0 = 0;"
1006 [(set_attr "length" "4")
1007 (set_attr "seq_insns" "multi")])
1008
1009 (define_insn_and_split "extendsidi2"
1010 [(set (match_operand:DI 0 "register_operand" "=d")
1011 (sign_extend:DI (match_operand:SI 1 "register_operand" "d")))]
1012 ""
1013 "#"
1014 "reload_completed"
1015 [(set (match_dup 3) (match_dup 1))
1016 (set (match_dup 3) (ashiftrt:SI (match_dup 3) (const_int 31)))]
1017 {
1018 split_di (operands, 1, operands + 2, operands + 3);
1019 if (REGNO (operands[0]) != REGNO (operands[1]))
1020 emit_move_insn (operands[2], operands[1]);
1021 })
1022
1023 (define_insn_and_split "extendqidi2"
1024 [(set (match_operand:DI 0 "register_operand" "=d")
1025 (sign_extend:DI (match_operand:QI 1 "register_operand" "d")))]
1026 ""
1027 "#"
1028 "reload_completed"
1029 [(set (match_dup 2) (sign_extend:SI (match_dup 1)))
1030 (set (match_dup 3) (sign_extend:SI (match_dup 1)))
1031 (set (match_dup 3) (ashiftrt:SI (match_dup 3) (const_int 31)))]
1032 {
1033 split_di (operands, 1, operands + 2, operands + 3);
1034 })
1035
1036 (define_insn_and_split "extendhidi2"
1037 [(set (match_operand:DI 0 "register_operand" "=d")
1038 (sign_extend:DI (match_operand:HI 1 "register_operand" "d")))]
1039 ""
1040 "#"
1041 "reload_completed"
1042 [(set (match_dup 2) (sign_extend:SI (match_dup 1)))
1043 (set (match_dup 3) (sign_extend:SI (match_dup 1)))
1044 (set (match_dup 3) (ashiftrt:SI (match_dup 3) (const_int 31)))]
1045 {
1046 split_di (operands, 1, operands + 2, operands + 3);
1047 })
1048
1049 ;; DImode arithmetic operations
1050
1051 (define_insn "add_with_carry"
1052 [(set (match_operand:SI 0 "register_operand" "=d,d")
1053 (plus:SI (match_operand:SI 1 "register_operand" "%0,d")
1054 (match_operand:SI 2 "nonmemory_operand" "Ks7,d")))
1055 (set (match_operand:BI 3 "register_operand" "=C,C")
1056 (ltu:BI (not:SI (match_dup 1)) (match_dup 2)))]
1057 ""
1058 "@
1059 %0 += %2; cc = ac0;
1060 %0 = %1 + %2; cc = ac0;"
1061 [(set_attr "type" "alu0")
1062 (set_attr "length" "4")
1063 (set_attr "seq_insns" "multi")])
1064
1065 (define_insn "sub_with_carry"
1066 [(set (match_operand:SI 0 "register_operand" "=d")
1067 (minus:SI (match_operand:SI 1 "register_operand" "%d")
1068 (match_operand:SI 2 "nonmemory_operand" "d")))
1069 (set (match_operand:BI 3 "register_operand" "=C")
1070 (leu:BI (match_dup 2) (match_dup 1)))]
1071 ""
1072 "%0 = %1 - %2; cc = ac0;"
1073 [(set_attr "type" "alu0")
1074 (set_attr "length" "4")
1075 (set_attr "seq_insns" "multi")])
1076
1077 (define_expand "adddi3"
1078 [(set (match_operand:DI 0 "register_operand" "")
1079 (plus:DI (match_operand:DI 1 "register_operand" "")
1080 (match_operand:DI 2 "nonmemory_operand" "")))
1081 (clobber (match_scratch:SI 3 ""))
1082 (clobber (reg:CC 34))]
1083 ""
1084 {
1085 rtx xops[8];
1086 xops[0] = gen_lowpart (SImode, operands[0]);
1087 xops[1] = simplify_gen_subreg (SImode, operands[0], DImode, 4);
1088 xops[2] = gen_lowpart (SImode, operands[1]);
1089 xops[3] = simplify_gen_subreg (SImode, operands[1], DImode, 4);
1090 xops[4] = gen_lowpart (SImode, operands[2]);
1091 xops[5] = simplify_gen_subreg (SImode, operands[2], DImode, 4);
1092 xops[6] = gen_reg_rtx (SImode);
1093 xops[7] = gen_rtx_REG (BImode, REG_CC);
1094 if (!register_operand (xops[4], SImode)
1095 && (GET_CODE (xops[4]) != CONST_INT
1096 || !satisfies_constraint_Ks7 (xops[4])))
1097 xops[4] = force_reg (SImode, xops[4]);
1098 if (!reg_overlap_mentioned_p (operands[0], operands[1])
1099 && !reg_overlap_mentioned_p (operands[0], operands[2]))
1100 emit_clobber (operands[0]);
1101 emit_insn (gen_add_with_carry (xops[0], xops[2], xops[4], xops[7]));
1102 emit_insn (gen_movbisi (xops[6], xops[7]));
1103 if (!register_operand (xops[5], SImode)
1104 && (GET_CODE (xops[5]) != CONST_INT
1105 || !satisfies_constraint_Ks7 (xops[5])))
1106 xops[5] = force_reg (SImode, xops[5]);
1107 if (xops[5] != const0_rtx)
1108 emit_insn (gen_addsi3 (xops[1], xops[3], xops[5]));
1109 else
1110 emit_move_insn (xops[1], xops[3]);
1111 emit_insn (gen_addsi3 (xops[1], xops[1], xops[6]));
1112 DONE;
1113 })
1114
1115 (define_expand "subdi3"
1116 [(set (match_operand:DI 0 "register_operand" "")
1117 (minus:DI (match_operand:DI 1 "register_operand" "")
1118 (match_operand:DI 2 "register_operand" "")))
1119 (clobber (reg:CC 34))]
1120 ""
1121 {
1122 rtx xops[8];
1123 xops[0] = gen_lowpart (SImode, operands[0]);
1124 xops[1] = simplify_gen_subreg (SImode, operands[0], DImode, 4);
1125 xops[2] = gen_lowpart (SImode, operands[1]);
1126 xops[3] = simplify_gen_subreg (SImode, operands[1], DImode, 4);
1127 xops[4] = gen_lowpart (SImode, operands[2]);
1128 xops[5] = simplify_gen_subreg (SImode, operands[2], DImode, 4);
1129 xops[6] = gen_reg_rtx (SImode);
1130 xops[7] = gen_rtx_REG (BImode, REG_CC);
1131 if (!reg_overlap_mentioned_p (operands[0], operands[1])
1132 && !reg_overlap_mentioned_p (operands[0], operands[2]))
1133 emit_clobber (operands[0]);
1134 emit_insn (gen_sub_with_carry (xops[0], xops[2], xops[4], xops[7]));
1135 emit_insn (gen_notbi (xops[7], xops[7]));
1136 emit_insn (gen_movbisi (xops[6], xops[7]));
1137 emit_insn (gen_subsi3 (xops[1], xops[3], xops[5]));
1138 emit_insn (gen_subsi3 (xops[1], xops[1], xops[6]));
1139 DONE;
1140 })
1141
1142 ;; Combined shift/add instructions
1143
1144 (define_insn ""
1145 [(set (match_operand:SI 0 "register_operand" "=a,d")
1146 (ashift:SI (plus:SI (match_operand:SI 1 "register_operand" "%0,0")
1147 (match_operand:SI 2 "register_operand" "a,d"))
1148 (match_operand:SI 3 "pos_scale_operand" "P1P2,P1P2")))]
1149 ""
1150 "%0 = (%0 + %2) << %3;" /* "shadd %0,%2,%3;" */
1151 [(set_attr "type" "alu0")])
1152
1153 (define_insn ""
1154 [(set (match_operand:SI 0 "register_operand" "=a")
1155 (plus:SI (match_operand:SI 1 "register_operand" "a")
1156 (mult:SI (match_operand:SI 2 "register_operand" "a")
1157 (match_operand:SI 3 "scale_by_operand" "i"))))]
1158 ""
1159 "%0 = %1 + (%2 << %X3);"
1160 [(set_attr "type" "alu0")])
1161
1162 (define_insn ""
1163 [(set (match_operand:SI 0 "register_operand" "=a")
1164 (plus:SI (match_operand:SI 1 "register_operand" "a")
1165 (ashift:SI (match_operand:SI 2 "register_operand" "a")
1166 (match_operand:SI 3 "pos_scale_operand" "i"))))]
1167 ""
1168 "%0 = %1 + (%2 << %3);"
1169 [(set_attr "type" "alu0")])
1170
1171 (define_insn ""
1172 [(set (match_operand:SI 0 "register_operand" "=a")
1173 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "a")
1174 (match_operand:SI 2 "scale_by_operand" "i"))
1175 (match_operand:SI 3 "register_operand" "a")))]
1176 ""
1177 "%0 = %3 + (%1 << %X2);"
1178 [(set_attr "type" "alu0")])
1179
1180 (define_insn ""
1181 [(set (match_operand:SI 0 "register_operand" "=a")
1182 (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "a")
1183 (match_operand:SI 2 "pos_scale_operand" "i"))
1184 (match_operand:SI 3 "register_operand" "a")))]
1185 ""
1186 "%0 = %3 + (%1 << %2);"
1187 [(set_attr "type" "alu0")])
1188
1189 (define_insn "mulhisi3"
1190 [(set (match_operand:SI 0 "register_operand" "=d")
1191 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "%d"))
1192 (sign_extend:SI (match_operand:HI 2 "register_operand" "d"))))]
1193 ""
1194 "%0 = %h1 * %h2 (IS)%!"
1195 [(set_attr "type" "dsp32")])
1196
1197 (define_insn "umulhisi3"
1198 [(set (match_operand:SI 0 "register_operand" "=d")
1199 (mult:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "%d"))
1200 (zero_extend:SI (match_operand:HI 2 "register_operand" "d"))))]
1201 ""
1202 "%0 = %h1 * %h2 (FU)%!"
1203 [(set_attr "type" "dsp32")])
1204
1205 (define_insn "usmulhisi3"
1206 [(set (match_operand:SI 0 "register_operand" "=W")
1207 (mult:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "W"))
1208 (sign_extend:SI (match_operand:HI 2 "register_operand" "W"))))]
1209 ""
1210 "%0 = %h2 * %h1 (IS,M)%!"
1211 [(set_attr "type" "dsp32")])
1212
1213 ;; The alternative involving IREGS requires that the corresponding L register
1214 ;; is zero.
1215
1216 (define_insn "addsi3"
1217 [(set (match_operand:SI 0 "register_operand" "=ad,a,d,b")
1218 (plus:SI (match_operand:SI 1 "register_operand" "%0, a,d,0")
1219 (match_operand:SI 2 "reg_or_7bit_operand" "Ks7, a,d,fP2P4")))]
1220 ""
1221 "@
1222 %0 += %2;
1223 %0 = %1 + %2;
1224 %0 = %1 + %2;
1225 %0 += %2;"
1226 [(set_attr "type" "alu0")
1227 (set_attr "length" "2,2,2,2")])
1228
1229 (define_insn "ssaddsi3"
1230 [(set (match_operand:SI 0 "register_operand" "=d")
1231 (ss_plus:SI (match_operand:SI 1 "register_operand" "d")
1232 (match_operand:SI 2 "register_operand" "d")))]
1233 ""
1234 "%0 = %1 + %2 (S)%!"
1235 [(set_attr "type" "dsp32")])
1236
1237 (define_insn "subsi3"
1238 [(set (match_operand:SI 0 "register_operand" "=da,d,a")
1239 (minus:SI (match_operand:SI 1 "register_operand" "0,d,0")
1240 (match_operand:SI 2 "reg_or_neg7bit_operand" "KN7,d,a")))]
1241 ""
1242 {
1243 static const char *const strings_subsi3[] = {
1244 "%0 += -%2;",
1245 "%0 = %1 - %2;",
1246 "%0 -= %2;",
1247 };
1248
1249 if (CONSTANT_P (operands[2]) && INTVAL (operands[2]) < 0) {
1250 rtx tmp_op = operands[2];
1251 operands[2] = GEN_INT (-INTVAL (operands[2]));
1252 output_asm_insn ("%0 += %2;", operands);
1253 operands[2] = tmp_op;
1254 return "";
1255 }
1256
1257 return strings_subsi3[which_alternative];
1258 }
1259 [(set_attr "type" "alu0")])
1260
1261 (define_insn "sssubsi3"
1262 [(set (match_operand:SI 0 "register_operand" "=d")
1263 (ss_minus:SI (match_operand:SI 1 "register_operand" "d")
1264 (match_operand:SI 2 "register_operand" "d")))]
1265 ""
1266 "%0 = %1 - %2 (S)%!"
1267 [(set_attr "type" "dsp32")])
1268
1269 ;; Accumulator addition
1270
1271 (define_insn "addpdi3"
1272 [(set (match_operand:PDI 0 "register_operand" "=A")
1273 (ss_plus:PDI (match_operand:PDI 1 "register_operand" "%0")
1274 (match_operand:PDI 2 "nonmemory_operand" "B")))]
1275 ""
1276 "A0 += A1%!"
1277 [(set_attr "type" "dsp32")])
1278
1279 (define_insn "sum_of_accumulators"
1280 [(set (match_operand:SI 0 "register_operand" "=d")
1281 (ss_truncate:SI
1282 (ss_plus:PDI (match_operand:PDI 2 "register_operand" "1")
1283 (match_operand:PDI 3 "register_operand" "B"))))
1284 (set (match_operand:PDI 1 "register_operand" "=A")
1285 (ss_plus:PDI (match_dup 2) (match_dup 3)))]
1286 ""
1287 "%0 = (A0 += A1)%!"
1288 [(set_attr "type" "dsp32")])
1289
1290 (define_insn "us_truncpdisi2"
1291 [(set (match_operand:SI 0 "register_operand" "=D,W")
1292 (us_truncate:SI (match_operand:PDI 1 "register_operand" "A,B")))]
1293 ""
1294 "%0 = %1 (FU)%!"
1295 [(set_attr "type" "dsp32")])
1296
1297 ;; Bit test instructions
1298
1299 (define_insn "*not_bittst"
1300 [(set (match_operand:BI 0 "register_operand" "=C")
1301 (eq:BI (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
1302 (const_int 1)
1303 (match_operand:SI 2 "immediate_operand" "Ku5"))
1304 (const_int 0)))]
1305 ""
1306 "cc = !BITTST (%1,%2);"
1307 [(set_attr "type" "alu0")])
1308
1309 (define_insn "*bittst"
1310 [(set (match_operand:BI 0 "register_operand" "=C")
1311 (ne:BI (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
1312 (const_int 1)
1313 (match_operand:SI 2 "immediate_operand" "Ku5"))
1314 (const_int 0)))]
1315 ""
1316 "cc = BITTST (%1,%2);"
1317 [(set_attr "type" "alu0")])
1318
1319 (define_insn_and_split "*bit_extract"
1320 [(set (match_operand:SI 0 "register_operand" "=d")
1321 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
1322 (const_int 1)
1323 (match_operand:SI 2 "immediate_operand" "Ku5")))
1324 (clobber (reg:BI REG_CC))]
1325 ""
1326 "#"
1327 ""
1328 [(set (reg:BI REG_CC)
1329 (ne:BI (zero_extract:SI (match_dup 1) (const_int 1) (match_dup 2))
1330 (const_int 0)))
1331 (set (match_dup 0)
1332 (ne:SI (reg:BI REG_CC) (const_int 0)))])
1333
1334 (define_insn_and_split "*not_bit_extract"
1335 [(set (match_operand:SI 0 "register_operand" "=d")
1336 (zero_extract:SI (not:SI (match_operand:SI 1 "register_operand" "d"))
1337 (const_int 1)
1338 (match_operand:SI 2 "immediate_operand" "Ku5")))
1339 (clobber (reg:BI REG_CC))]
1340 ""
1341 "#"
1342 ""
1343 [(set (reg:BI REG_CC)
1344 (eq:BI (zero_extract:SI (match_dup 1) (const_int 1) (match_dup 2))
1345 (const_int 0)))
1346 (set (match_dup 0)
1347 (ne:SI (reg:BI REG_CC) (const_int 0)))])
1348
1349 (define_insn "*andsi_insn"
1350 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
1351 (and:SI (match_operand:SI 1 "register_operand" "%0,d,d,d")
1352 (match_operand:SI 2 "rhs_andsi3_operand" "L,M1,M2,d")))]
1353 ""
1354 "@
1355 BITCLR (%0,%Y2);
1356 %0 = %T1 (Z);
1357 %0 = %h1 (Z);
1358 %0 = %1 & %2;"
1359 [(set_attr "type" "alu0")])
1360
1361 (define_expand "andsi3"
1362 [(set (match_operand:SI 0 "register_operand" "")
1363 (and:SI (match_operand:SI 1 "register_operand" "")
1364 (match_operand:SI 2 "general_operand" "")))]
1365 ""
1366 {
1367 if (highbits_operand (operands[2], SImode))
1368 {
1369 operands[2] = GEN_INT (exact_log2 (-INTVAL (operands[2])));
1370 emit_insn (gen_ashrsi3 (operands[0], operands[1], operands[2]));
1371 emit_insn (gen_ashlsi3 (operands[0], operands[0], operands[2]));
1372 DONE;
1373 }
1374 if (! rhs_andsi3_operand (operands[2], SImode))
1375 operands[2] = force_reg (SImode, operands[2]);
1376 })
1377
1378 (define_insn "iorsi3"
1379 [(set (match_operand:SI 0 "register_operand" "=d,d")
1380 (ior:SI (match_operand:SI 1 "register_operand" "%0,d")
1381 (match_operand:SI 2 "regorlog2_operand" "J,d")))]
1382 ""
1383 "@
1384 BITSET (%0, %X2);
1385 %0 = %1 | %2;"
1386 [(set_attr "type" "alu0")])
1387
1388 (define_insn "xorsi3"
1389 [(set (match_operand:SI 0 "register_operand" "=d,d")
1390 (xor:SI (match_operand:SI 1 "register_operand" "%0,d")
1391 (match_operand:SI 2 "regorlog2_operand" "J,d")))]
1392 ""
1393 "@
1394 BITTGL (%0, %X2);
1395 %0 = %1 ^ %2;"
1396 [(set_attr "type" "alu0")])
1397
1398 (define_insn "ones"
1399 [(set (match_operand:HI 0 "register_operand" "=d")
1400 (truncate:HI
1401 (popcount:SI (match_operand:SI 1 "register_operand" "d"))))]
1402 ""
1403 "%h0 = ONES %1;"
1404 [(set_attr "type" "alu0")
1405 (set_attr "length" "4")])
1406
1407 (define_expand "popcountsi2"
1408 [(set (match_dup 2)
1409 (truncate:HI (popcount:SI (match_operand:SI 1 "register_operand" ""))))
1410 (set (match_operand:SI 0 "register_operand")
1411 (zero_extend:SI (match_dup 2)))]
1412 ""
1413 {
1414 operands[2] = gen_reg_rtx (HImode);
1415 })
1416
1417 (define_expand "popcounthi2"
1418 [(set (match_dup 2)
1419 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))
1420 (set (match_operand:HI 0 "register_operand")
1421 (truncate:HI (popcount:SI (match_dup 2))))]
1422 ""
1423 {
1424 operands[2] = gen_reg_rtx (SImode);
1425 })
1426
1427 (define_insn "smaxsi3"
1428 [(set (match_operand:SI 0 "register_operand" "=d")
1429 (smax:SI (match_operand:SI 1 "register_operand" "d")
1430 (match_operand:SI 2 "register_operand" "d")))]
1431 ""
1432 "%0 = max(%1,%2)%!"
1433 [(set_attr "type" "dsp32")])
1434
1435 (define_insn "sminsi3"
1436 [(set (match_operand:SI 0 "register_operand" "=d")
1437 (smin:SI (match_operand:SI 1 "register_operand" "d")
1438 (match_operand:SI 2 "register_operand" "d")))]
1439 ""
1440 "%0 = min(%1,%2)%!"
1441 [(set_attr "type" "dsp32")])
1442
1443 ;; The ABS instruction is defined as saturating. So at the least
1444 ;; it is inappropriate for -fwrapv. This also fixes the C23 uabs
1445 ;; tests.
1446 ;;(define_insn "abssi2"
1447 ;; [(set (match_operand:SI 0 "register_operand" "=d")
1448 ;; (abs:SI (match_operand:SI 1 "register_operand" "d")))]
1449 ;; ""
1450 ;; "%0 = abs %1%!"
1451 ;; [(set_attr "type" "dsp32")])
1452
1453 (define_insn "ssabssi2"
1454 [(set (match_operand:SI 0 "register_operand" "=d")
1455 (ss_abs:SI (match_operand:SI 1 "register_operand" "d")))]
1456 ""
1457 "%0 = abs %1%!"
1458 [(set_attr "type" "dsp32")])
1459
1460 (define_insn "negsi2"
1461 [(set (match_operand:SI 0 "register_operand" "=d")
1462 (neg:SI (match_operand:SI 1 "register_operand" "d")))]
1463 ""
1464 "%0 = -%1;"
1465 [(set_attr "type" "alu0")])
1466
1467 (define_insn "ssnegsi2"
1468 [(set (match_operand:SI 0 "register_operand" "=d")
1469 (ss_neg:SI (match_operand:SI 1 "register_operand" "d")))]
1470 ""
1471 "%0 = -%1 (S)%!"
1472 [(set_attr "type" "dsp32")])
1473
1474 (define_insn "one_cmplsi2"
1475 [(set (match_operand:SI 0 "register_operand" "=d")
1476 (not:SI (match_operand:SI 1 "register_operand" "d")))]
1477 ""
1478 "%0 = ~%1;"
1479 [(set_attr "type" "alu0")])
1480
1481 (define_expand "clrsbsi2"
1482 [(set (match_dup 2)
1483 (truncate:HI (clrsb:SI (match_operand:SI 1 "register_operand" "d"))))
1484 (set (match_operand:SI 0 "register_operand")
1485 (zero_extend:SI (match_dup 2)))]
1486 ""
1487 {
1488 operands[2] = gen_reg_rtx (HImode);
1489 })
1490
1491 (define_insn "signbitssi2"
1492 [(set (match_operand:HI 0 "register_operand" "=d")
1493 (truncate:HI (clrsb:SI (match_operand:SI 1 "register_operand" "d"))))]
1494 ""
1495 "%h0 = signbits %1%!"
1496 [(set_attr "type" "dsp32")])
1497
1498 (define_insn "ssroundsi2"
1499 [(set (match_operand:HI 0 "register_operand" "=d")
1500 (truncate:HI
1501 (lshiftrt:SI (ss_plus:SI (match_operand:SI 1 "register_operand" "d")
1502 (const_int 32768))
1503 (const_int 16))))]
1504 ""
1505 "%h0 = %1 (RND)%!"
1506 [(set_attr "type" "dsp32")])
1507
1508 (define_insn "smaxhi3"
1509 [(set (match_operand:HI 0 "register_operand" "=d")
1510 (smax:HI (match_operand:HI 1 "register_operand" "d")
1511 (match_operand:HI 2 "register_operand" "d")))]
1512 ""
1513 "%0 = max(%1,%2) (V)%!"
1514 [(set_attr "type" "dsp32")])
1515
1516 (define_insn "sminhi3"
1517 [(set (match_operand:HI 0 "register_operand" "=d")
1518 (smin:HI (match_operand:HI 1 "register_operand" "d")
1519 (match_operand:HI 2 "register_operand" "d")))]
1520 ""
1521 "%0 = min(%1,%2) (V)%!"
1522 [(set_attr "type" "dsp32")])
1523
1524 (define_insn "abshi2"
1525 [(set (match_operand:HI 0 "register_operand" "=d")
1526 (abs:HI (match_operand:HI 1 "register_operand" "d")))]
1527 ""
1528 "%0 = abs %1 (V)%!"
1529 [(set_attr "type" "dsp32")])
1530
1531 (define_insn "neghi2"
1532 [(set (match_operand:HI 0 "register_operand" "=d")
1533 (neg:HI (match_operand:HI 1 "register_operand" "d")))]
1534 ""
1535 "%0 = -%1;"
1536 [(set_attr "type" "alu0")])
1537
1538 (define_insn "ssneghi2"
1539 [(set (match_operand:HI 0 "register_operand" "=d")
1540 (ss_neg:HI (match_operand:HI 1 "register_operand" "d")))]
1541 ""
1542 "%0 = -%1 (V)%!"
1543 [(set_attr "type" "dsp32")])
1544
1545 (define_insn "clrsbhi2"
1546 [(set (match_operand:HI 0 "register_operand" "=d")
1547 (clrsb:HI (match_operand:HI 1 "register_operand" "d")))]
1548 ""
1549 "%h0 = signbits %h1%!"
1550 [(set_attr "type" "dsp32")])
1551
1552 (define_insn "mulsi3"
1553 [(set (match_operand:SI 0 "register_operand" "=d")
1554 (mult:SI (match_operand:SI 1 "register_operand" "%0")
1555 (match_operand:SI 2 "register_operand" "d")))]
1556 ""
1557 "%0 *= %2;"
1558 [(set_attr "type" "mult")])
1559
1560 (define_expand "umulsi3_highpart"
1561 [(parallel
1562 [(set (match_operand:SI 0 "register_operand" "")
1563 (truncate:SI
1564 (lshiftrt:DI
1565 (mult:DI (zero_extend:DI
1566 (match_operand:SI 1 "nonimmediate_operand" ""))
1567 (zero_extend:DI
1568 (match_operand:SI 2 "register_operand" "")))
1569 (const_int 32))))
1570 (clobber (reg:PDI REG_A0))
1571 (clobber (reg:PDI REG_A1))])]
1572 ""
1573 {
1574 if (!optimize_size)
1575 {
1576 rtx a1reg = gen_rtx_REG (PDImode, REG_A1);
1577 rtx a0reg = gen_rtx_REG (PDImode, REG_A0);
1578 emit_insn (gen_flag_macinit1hi (a1reg,
1579 gen_lowpart (HImode, operands[1]),
1580 gen_lowpart (HImode, operands[2]),
1581 GEN_INT (MACFLAG_FU)));
1582 emit_insn (gen_lshrpdi3 (a1reg, a1reg, GEN_INT (16)));
1583 emit_insn (gen_flag_mul_macv2hi_parts_acconly (a0reg, a1reg,
1584 gen_lowpart (V2HImode, operands[1]),
1585 gen_lowpart (V2HImode, operands[2]),
1586 const1_rtx, const1_rtx,
1587 const1_rtx, const0_rtx, a1reg,
1588 const0_rtx, GEN_INT (MACFLAG_FU),
1589 GEN_INT (MACFLAG_FU)));
1590 emit_insn (gen_flag_machi_parts_acconly (a1reg,
1591 gen_lowpart (V2HImode, operands[2]),
1592 gen_lowpart (V2HImode, operands[1]),
1593 const1_rtx, const0_rtx,
1594 a1reg, const0_rtx, GEN_INT (MACFLAG_FU)));
1595 emit_insn (gen_lshrpdi3 (a1reg, a1reg, GEN_INT (16)));
1596 emit_insn (gen_addpdi3 (a0reg, a0reg, a1reg));
1597 emit_insn (gen_us_truncpdisi2 (operands[0], a0reg));
1598 }
1599 else
1600 {
1601 rtx umulsi3_highpart_libfunc
1602 = init_one_libfunc ("__umulsi3_highpart");
1603
1604 emit_library_call_value (umulsi3_highpart_libfunc,
1605 operands[0], LCT_NORMAL, SImode,
1606 operands[1], SImode, operands[2], SImode);
1607 }
1608 DONE;
1609 })
1610
1611 (define_expand "smulsi3_highpart"
1612 [(parallel
1613 [(set (match_operand:SI 0 "register_operand" "")
1614 (truncate:SI
1615 (lshiftrt:DI
1616 (mult:DI (sign_extend:DI
1617 (match_operand:SI 1 "nonimmediate_operand" ""))
1618 (sign_extend:DI
1619 (match_operand:SI 2 "register_operand" "")))
1620 (const_int 32))))
1621 (clobber (reg:PDI REG_A0))
1622 (clobber (reg:PDI REG_A1))])]
1623 ""
1624 {
1625 if (!optimize_size)
1626 {
1627 rtx a1reg = gen_rtx_REG (PDImode, REG_A1);
1628 rtx a0reg = gen_rtx_REG (PDImode, REG_A0);
1629 emit_insn (gen_flag_macinit1hi (a1reg,
1630 gen_lowpart (HImode, operands[1]),
1631 gen_lowpart (HImode, operands[2]),
1632 GEN_INT (MACFLAG_FU)));
1633 emit_insn (gen_lshrpdi3 (a1reg, a1reg, GEN_INT (16)));
1634 emit_insn (gen_flag_mul_macv2hi_parts_acconly (a0reg, a1reg,
1635 gen_lowpart (V2HImode, operands[1]),
1636 gen_lowpart (V2HImode, operands[2]),
1637 const1_rtx, const1_rtx,
1638 const1_rtx, const0_rtx, a1reg,
1639 const0_rtx, GEN_INT (MACFLAG_IS),
1640 GEN_INT (MACFLAG_IS_M)));
1641 emit_insn (gen_flag_machi_parts_acconly (a1reg,
1642 gen_lowpart (V2HImode, operands[2]),
1643 gen_lowpart (V2HImode, operands[1]),
1644 const1_rtx, const0_rtx,
1645 a1reg, const0_rtx, GEN_INT (MACFLAG_IS_M)));
1646 emit_insn (gen_ashrpdi3 (a1reg, a1reg, GEN_INT (16)));
1647 emit_insn (gen_sum_of_accumulators (operands[0], a0reg, a0reg, a1reg));
1648 }
1649 else
1650 {
1651 rtx smulsi3_highpart_libfunc
1652 = init_one_libfunc ("__smulsi3_highpart");
1653
1654 emit_library_call_value (smulsi3_highpart_libfunc,
1655 operands[0], LCT_NORMAL, SImode,
1656 operands[1], SImode, operands[2], SImode);
1657 }
1658 DONE;
1659 })
1660
1661 (define_expand "ashlsi3"
1662 [(set (match_operand:SI 0 "register_operand" "")
1663 (ashift:SI (match_operand:SI 1 "register_operand" "")
1664 (match_operand:SI 2 "nonmemory_operand" "")))]
1665 ""
1666 {
1667 if (GET_CODE (operands[2]) == CONST_INT
1668 && ((unsigned HOST_WIDE_INT) INTVAL (operands[2])) > 31)
1669 {
1670 emit_insn (gen_movsi (operands[0], const0_rtx));
1671 DONE;
1672 }
1673 })
1674
1675 (define_insn_and_split "*ashlsi3_insn"
1676 [(set (match_operand:SI 0 "register_operand" "=d,d,a,a,a")
1677 (ashift:SI (match_operand:SI 1 "register_operand" "0,d,a,a,a")
1678 (match_operand:SI 2 "nonmemory_operand" "dKu5,Ku5,P1,P2,?P3P4")))]
1679 ""
1680 "@
1681 %0 <<= %2;
1682 %0 = %1 << %2%!
1683 %0 = %1 + %1;
1684 %0 = %1 << %2;
1685 #"
1686 "PREG_P (operands[0]) && INTVAL (operands[2]) > 2"
1687 [(set (match_dup 0) (ashift:SI (match_dup 1) (const_int 2)))
1688 (set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 3)))]
1689 "operands[3] = GEN_INT (INTVAL (operands[2]) - 2);"
1690 [(set_attr "type" "shft,dsp32shiftimm,shft,shft,*")])
1691
1692 (define_insn "ashrsi3"
1693 [(set (match_operand:SI 0 "register_operand" "=d,d")
1694 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,d")
1695 (match_operand:SI 2 "nonmemory_operand" "dKu5,Ku5")))]
1696 ""
1697 "@
1698 %0 >>>= %2;
1699 %0 = %1 >>> %2%!"
1700 [(set_attr "type" "shft,dsp32shiftimm")])
1701
1702 (define_insn "rotl16"
1703 [(set (match_operand:SI 0 "register_operand" "=d")
1704 (rotate:SI (match_operand:SI 1 "register_operand" "d")
1705 (const_int 16)))]
1706 ""
1707 "%0 = PACK (%h1, %d1)%!"
1708 [(set_attr "type" "dsp32")])
1709
1710 (define_expand "rotlsi3"
1711 [(set (match_operand:SI 0 "register_operand" "")
1712 (rotate:SI (match_operand:SI 1 "register_operand" "")
1713 (match_operand:SI 2 "const_int_operand" "")))]
1714 ""
1715 {
1716 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 16)
1717 FAIL;
1718 })
1719
1720 (define_expand "rotrsi3"
1721 [(set (match_operand:SI 0 "register_operand" "")
1722 (rotatert:SI (match_operand:SI 1 "register_operand" "")
1723 (match_operand:SI 2 "const_int_operand" "")))]
1724 ""
1725 {
1726 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 16)
1727 FAIL;
1728 emit_insn (gen_rotl16 (operands[0], operands[1]));
1729 DONE;
1730 })
1731
1732
1733 (define_insn "ror_one"
1734 [(set (match_operand:SI 0 "register_operand" "=d")
1735 (ior:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "d") (const_int 1))
1736 (ashift:SI (zero_extend:SI (reg:BI REG_CC)) (const_int 31))))
1737 (set (reg:BI REG_CC)
1738 (zero_extract:BI (match_dup 1) (const_int 1) (const_int 0)))]
1739 ""
1740 "%0 = ROT %1 BY -1%!"
1741 [(set_attr "type" "dsp32shiftimm")])
1742
1743 (define_insn "rol_one"
1744 [(set (match_operand:SI 0 "register_operand" "+d")
1745 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "d") (const_int 1))
1746 (zero_extend:SI (reg:BI REG_CC))))
1747 (set (reg:BI REG_CC)
1748 (zero_extract:BI (match_dup 1) (const_int 1) (const_int 31)))]
1749 ""
1750 "%0 = ROT %1 BY 1%!"
1751 [(set_attr "type" "dsp32shiftimm")])
1752
1753 (define_expand "lshrdi3"
1754 [(set (match_operand:DI 0 "register_operand" "")
1755 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
1756 (match_operand:DI 2 "general_operand" "")))]
1757 ""
1758 {
1759 rtx lo_half[2], hi_half[2];
1760
1761 if (operands[2] != const1_rtx)
1762 FAIL;
1763 if (! rtx_equal_p (operands[0], operands[1]))
1764 emit_move_insn (operands[0], operands[1]);
1765
1766 split_di (operands, 2, lo_half, hi_half);
1767
1768 emit_move_insn (bfin_cc_rtx, const0_rtx);
1769 emit_insn (gen_ror_one (hi_half[0], hi_half[0]));
1770 emit_insn (gen_ror_one (lo_half[0], lo_half[0]));
1771 DONE;
1772 })
1773
1774 (define_expand "ashrdi3"
1775 [(set (match_operand:DI 0 "register_operand" "")
1776 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
1777 (match_operand:DI 2 "general_operand" "")))]
1778 ""
1779 {
1780 rtx lo_half[2], hi_half[2];
1781
1782 if (operands[2] != const1_rtx)
1783 FAIL;
1784 if (! rtx_equal_p (operands[0], operands[1]))
1785 emit_move_insn (operands[0], operands[1]);
1786
1787 split_di (operands, 2, lo_half, hi_half);
1788
1789 emit_insn (gen_compare_lt (gen_rtx_REG (BImode, REG_CC),
1790 hi_half[1], const0_rtx));
1791 emit_insn (gen_ror_one (hi_half[0], hi_half[0]));
1792 emit_insn (gen_ror_one (lo_half[0], lo_half[0]));
1793 DONE;
1794 })
1795
1796 (define_expand "ashldi3"
1797 [(set (match_operand:DI 0 "register_operand" "")
1798 (ashift:DI (match_operand:DI 1 "register_operand" "")
1799 (match_operand:DI 2 "general_operand" "")))]
1800 ""
1801 {
1802 rtx lo_half[2], hi_half[2];
1803
1804 if (operands[2] != const1_rtx)
1805 FAIL;
1806 if (! rtx_equal_p (operands[0], operands[1]))
1807 emit_move_insn (operands[0], operands[1]);
1808
1809 split_di (operands, 2, lo_half, hi_half);
1810
1811 emit_move_insn (bfin_cc_rtx, const0_rtx);
1812 emit_insn (gen_rol_one (lo_half[0], lo_half[0]));
1813 emit_insn (gen_rol_one (hi_half[0], hi_half[0]));
1814 DONE;
1815 })
1816
1817 (define_insn "lshrsi3"
1818 [(set (match_operand:SI 0 "register_operand" "=d,d,a")
1819 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0,d,a")
1820 (match_operand:SI 2 "nonmemory_operand" "dKu5,Ku5,P1P2")))]
1821 ""
1822 "@
1823 %0 >>= %2;
1824 %0 = %1 >> %2%!
1825 %0 = %1 >> %2;"
1826 [(set_attr "type" "shft,dsp32shiftimm,shft")])
1827
1828 (define_insn "lshrpdi3"
1829 [(set (match_operand:PDI 0 "register_operand" "=e")
1830 (lshiftrt:PDI (match_operand:PDI 1 "register_operand" "0")
1831 (match_operand:SI 2 "nonmemory_operand" "Ku5")))]
1832 ""
1833 "%0 = %1 >> %2%!"
1834 [(set_attr "type" "dsp32shiftimm")])
1835
1836 (define_insn "ashrpdi3"
1837 [(set (match_operand:PDI 0 "register_operand" "=e")
1838 (ashiftrt:PDI (match_operand:PDI 1 "register_operand" "0")
1839 (match_operand:SI 2 "nonmemory_operand" "Ku5")))]
1840 ""
1841 "%0 = %1 >>> %2%!"
1842 [(set_attr "type" "dsp32shiftimm")])
1843
1844 ;; A pattern to reload the equivalent of
1845 ;; (set (Dreg) (plus (FP) (large_constant)))
1846 ;; or
1847 ;; (set (dagreg) (plus (FP) (arbitrary_constant)))
1848 ;; using a scratch register
1849 (define_expand "reload_insi"
1850 [(parallel [(set (match_operand:SI 0 "register_operand" "=w")
1851 (match_operand:SI 1 "fp_plus_const_operand" ""))
1852 (clobber (match_operand:SI 2 "register_operand" "=&a"))])]
1853 ""
1854 {
1855 rtx fp_op = XEXP (operands[1], 0);
1856 rtx const_op = XEXP (operands[1], 1);
1857 rtx primary = operands[0];
1858 rtx scratch = operands[2];
1859
1860 emit_move_insn (scratch, const_op);
1861 emit_insn (gen_addsi3 (scratch, scratch, fp_op));
1862 emit_move_insn (primary, scratch);
1863 DONE;
1864 })
1865
1866 (define_mode_iterator AREG [PDI V2PDI])
1867
1868 (define_insn "reload_in<mode>"
1869 [(set (match_operand:AREG 0 "register_operand" "=e")
1870 (match_operand:AREG 1 "memory_operand" "m"))
1871 (clobber (match_operand:SI 2 "register_operand" "=d"))]
1872 ""
1873 {
1874 rtx xops[4];
1875 xops[0] = operands[0];
1876 xops[1] = operands[2];
1877 split_di (operands + 1, 1, xops + 2, xops + 3);
1878 output_asm_insn ("%1 = %2;", xops);
1879 output_asm_insn ("%w0 = %1;", xops);
1880 output_asm_insn ("%1 = %3;", xops);
1881 output_asm_insn ("%x0 = %1;", xops);
1882 return "";
1883 }
1884 [(set_attr "seq_insns" "multi")
1885 (set_attr "type" "mcld")
1886 (set_attr "length" "12")])
1887
1888 (define_insn "reload_out<mode>"
1889 [(set (match_operand:AREG 0 "memory_operand" "=m")
1890 (match_operand:AREG 1 "register_operand" "e"))
1891 (clobber (match_operand:SI 2 "register_operand" "=d"))]
1892 ""
1893 {
1894 rtx xops[4];
1895 xops[0] = operands[1];
1896 xops[1] = operands[2];
1897 split_di (operands, 1, xops + 2, xops + 3);
1898 output_asm_insn ("%1 = %w0;", xops);
1899 output_asm_insn ("%2 = %1;", xops);
1900 output_asm_insn ("%1 = %x0;", xops);
1901 output_asm_insn ("%3 = %1;", xops);
1902 return "";
1903 }
1904 [(set_attr "seq_insns" "multi")
1905 (set_attr "type" "mcld")
1906 (set_attr "length" "12")])
1907
1908 ;; Jump instructions
1909
1910 (define_insn "jump"
1911 [(set (pc)
1912 (label_ref (match_operand 0 "" "")))]
1913 ""
1914 {
1915 if (get_attr_length (insn) == 2)
1916 return "jump.s %0;";
1917 else
1918 return "jump.l %0;";
1919 }
1920 [(set_attr "type" "br")])
1921
1922 (define_insn "indirect_jump"
1923 [(set (pc)
1924 (match_operand:SI 0 "register_operand" "a"))]
1925 ""
1926 "jump (%0);"
1927 [(set_attr "type" "misc")])
1928
1929 (define_expand "tablejump"
1930 [(parallel [(set (pc) (match_operand:SI 0 "register_operand" "a"))
1931 (use (label_ref (match_operand 1 "" "")))])]
1932 ""
1933 {
1934 /* In PIC mode, the table entries are stored PC relative.
1935 Convert the relative address to an absolute address. */
1936 if (flag_pic)
1937 {
1938 rtx op1 = gen_rtx_LABEL_REF (Pmode, operands[1]);
1939
1940 operands[0] = expand_simple_binop (Pmode, PLUS, operands[0],
1941 op1, NULL_RTX, 0, OPTAB_DIRECT);
1942 }
1943 })
1944
1945 (define_insn "*tablejump_internal"
1946 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
1947 (use (label_ref (match_operand 1 "" "")))]
1948 ""
1949 "jump (%0);"
1950 [(set_attr "type" "misc")])
1951
1952 ;; Hardware loop
1953
1954 ; operand 0 is the loop count pseudo register
1955 ; operand 1 is the label to jump to at the top of the loop
1956 (define_expand "doloop_end"
1957 [(parallel [(set (pc) (if_then_else
1958 (ne (match_operand:SI 0 "" "")
1959 (const_int 1))
1960 (label_ref (match_operand 1 "" ""))
1961 (pc)))
1962 (set (match_dup 0)
1963 (plus:SI (match_dup 0)
1964 (const_int -1)))
1965 (unspec [(const_int 0)] UNSPEC_LSETUP_END)
1966 (clobber (match_dup 2))
1967 (clobber (reg:BI REG_CC))])] ; match_scratch
1968 ""
1969 {
1970 /* The loop optimizer doesn't check the predicates... */
1971 if (GET_MODE (operands[0]) != SImode)
1972 FAIL;
1973 bfin_hardware_loop ();
1974 operands[2] = gen_rtx_SCRATCH (SImode);
1975 })
1976
1977 (define_insn "loop_end"
1978 [(set (pc)
1979 (if_then_else (ne (match_operand:SI 2 "nonimmediate_operand" "0,0,0")
1980 (const_int 1))
1981 (label_ref (match_operand 1 "" ""))
1982 (pc)))
1983 (set (match_operand:SI 0 "nonimmediate_operand" "=a*d,*b*v*f,m")
1984 (plus (match_dup 2)
1985 (const_int -1)))
1986 (unspec [(const_int 0)] UNSPEC_LSETUP_END)
1987 (clobber (match_scratch:SI 3 "=X,&r,&r"))
1988 (clobber (reg:BI REG_CC))]
1989 ""
1990 "@
1991 /* loop end %0 %l1 */
1992 #
1993 #"
1994 [(set_attr "length" "6,10,14")])
1995
1996 (define_split
1997 [(set (pc)
1998 (if_then_else (ne (match_operand:SI 0 "nondp_reg_or_memory_operand")
1999 (const_int 1))
2000 (label_ref (match_operand 1 ""))
2001 (pc)))
2002 (set (match_dup 0)
2003 (plus (match_dup 0)
2004 (const_int -1)))
2005 (unspec [(const_int 0)] UNSPEC_LSETUP_END)
2006 (clobber (match_scratch:SI 2))
2007 (clobber (reg:BI REG_CC))]
2008 "memory_operand (operands[0], SImode) || splitting_loops"
2009 [(set (match_dup 2) (match_dup 0))
2010 (set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
2011 (set (match_dup 0) (match_dup 2))
2012 (set (reg:BI REG_CC) (eq:BI (match_dup 2) (const_int 0)))
2013 (set (pc)
2014 (if_then_else (eq (reg:BI REG_CC)
2015 (const_int 0))
2016 (label_ref (match_dup 1))
2017 (pc)))]
2018 "")
2019
2020 (define_insn "lsetup_with_autoinit"
2021 [(set (match_operand:SI 0 "lt_register_operand" "=t")
2022 (label_ref (match_operand 1 "" "")))
2023 (set (match_operand:SI 2 "lb_register_operand" "=u")
2024 (label_ref (match_operand 3 "" "")))
2025 (set (match_operand:SI 4 "lc_register_operand" "=k")
2026 (match_operand:SI 5 "register_operand" "a"))]
2027 ""
2028 "LSETUP (%1, %3) %4 = %5;"
2029 [(set_attr "length" "4")])
2030
2031 (define_insn "lsetup_without_autoinit"
2032 [(set (match_operand:SI 0 "lt_register_operand" "=t")
2033 (label_ref (match_operand 1 "" "")))
2034 (set (match_operand:SI 2 "lb_register_operand" "=u")
2035 (label_ref (match_operand 3 "" "")))
2036 (use (match_operand:SI 4 "lc_register_operand" "k"))]
2037 ""
2038 "LSETUP (%1, %3) %4;"
2039 [(set_attr "length" "4")])
2040
2041 ;; Call instructions..
2042
2043 ;; The explicit MEM inside the UNSPEC prevents the compiler from moving
2044 ;; the load before a branch after a NULL test, or before a store that
2045 ;; initializes a function descriptor.
2046
2047 (define_insn_and_split "load_funcdescsi"
2048 [(set (match_operand:SI 0 "register_operand" "=a")
2049 (unspec_volatile:SI [(mem:SI (match_operand:SI 1 "address_operand" "p"))]
2050 UNSPEC_VOLATILE_LOAD_FUNCDESC))]
2051 ""
2052 "#"
2053 "reload_completed"
2054 [(set (match_dup 0) (mem:SI (match_dup 1)))])
2055
2056 (define_expand "call"
2057 [(parallel [(call (match_operand:SI 0 "" "")
2058 (match_operand 1 "" ""))
2059 (use (match_operand 2 "" ""))])]
2060 ""
2061 {
2062 bfin_expand_call (NULL_RTX, operands[0], operands[1], operands[2], 0);
2063 DONE;
2064 })
2065
2066 (define_expand "sibcall"
2067 [(parallel [(call (match_operand:SI 0 "" "")
2068 (match_operand 1 "" ""))
2069 (use (match_operand 2 "" ""))
2070 (return)])]
2071 ""
2072 {
2073 bfin_expand_call (NULL_RTX, operands[0], operands[1], operands[2], 1);
2074 DONE;
2075 })
2076
2077 (define_expand "call_value"
2078 [(parallel [(set (match_operand 0 "register_operand" "")
2079 (call (match_operand:SI 1 "" "")
2080 (match_operand 2 "" "")))
2081 (use (match_operand 3 "" ""))])]
2082 ""
2083 {
2084 bfin_expand_call (operands[0], operands[1], operands[2], operands[3], 0);
2085 DONE;
2086 })
2087
2088 (define_expand "sibcall_value"
2089 [(parallel [(set (match_operand 0 "register_operand" "")
2090 (call (match_operand:SI 1 "" "")
2091 (match_operand 2 "" "")))
2092 (use (match_operand 3 "" ""))
2093 (return)])]
2094 ""
2095 {
2096 bfin_expand_call (operands[0], operands[1], operands[2], operands[3], 1);
2097 DONE;
2098 })
2099
2100 (define_insn "*call_symbol_fdpic"
2101 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "Q"))
2102 (match_operand 1 "general_operand" "g"))
2103 (use (match_operand:SI 2 "register_operand" "Z"))
2104 (use (match_operand 3 "" ""))
2105 (clobber (reg:SI REG_RETS))]
2106 "! SIBLING_CALL_P (insn)
2107 && GET_CODE (operands[0]) == SYMBOL_REF
2108 && !bfin_longcall_p (operands[0], INTVAL (operands[3]))"
2109 "call %0;"
2110 [(set_attr "type" "call")
2111 (set_attr "length" "4")])
2112
2113 (define_insn "*sibcall_symbol_fdpic"
2114 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "Q"))
2115 (match_operand 1 "general_operand" "g"))
2116 (use (match_operand:SI 2 "register_operand" "Z"))
2117 (use (match_operand 3 "" ""))
2118 (return)]
2119 "SIBLING_CALL_P (insn)
2120 && GET_CODE (operands[0]) == SYMBOL_REF
2121 && !bfin_longcall_p (operands[0], INTVAL (operands[3]))"
2122 "jump.l %0;"
2123 [(set_attr "type" "br")
2124 (set_attr "length" "4")])
2125
2126 (define_insn "*call_value_symbol_fdpic"
2127 [(set (match_operand 0 "register_operand" "=d")
2128 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "Q"))
2129 (match_operand 2 "general_operand" "g")))
2130 (use (match_operand:SI 3 "register_operand" "Z"))
2131 (use (match_operand 4 "" ""))
2132 (clobber (reg:SI REG_RETS))]
2133 "! SIBLING_CALL_P (insn)
2134 && GET_CODE (operands[1]) == SYMBOL_REF
2135 && !bfin_longcall_p (operands[1], INTVAL (operands[4]))"
2136 "call %1;"
2137 [(set_attr "type" "call")
2138 (set_attr "length" "4")])
2139
2140 (define_insn "*sibcall_value_symbol_fdpic"
2141 [(set (match_operand 0 "register_operand" "=d")
2142 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "Q"))
2143 (match_operand 2 "general_operand" "g")))
2144 (use (match_operand:SI 3 "register_operand" "Z"))
2145 (use (match_operand 4 "" ""))
2146 (return)]
2147 "SIBLING_CALL_P (insn)
2148 && GET_CODE (operands[1]) == SYMBOL_REF
2149 && !bfin_longcall_p (operands[1], INTVAL (operands[4]))"
2150 "jump.l %1;"
2151 [(set_attr "type" "br")
2152 (set_attr "length" "4")])
2153
2154 (define_insn "*call_insn_fdpic"
2155 [(call (mem:SI (match_operand:SI 0 "register_no_elim_operand" "Y"))
2156 (match_operand 1 "general_operand" "g"))
2157 (use (match_operand:SI 2 "register_operand" "Z"))
2158 (use (match_operand 3 "" ""))
2159 (clobber (reg:SI REG_RETS))]
2160 "! SIBLING_CALL_P (insn)"
2161 "call (%0);"
2162 [(set_attr "type" "call")
2163 (set_attr "length" "2")])
2164
2165 (define_insn "*sibcall_insn_fdpic"
2166 [(call (mem:SI (match_operand:SI 0 "register_no_elim_operand" "Y"))
2167 (match_operand 1 "general_operand" "g"))
2168 (use (match_operand:SI 2 "register_operand" "Z"))
2169 (use (match_operand 3 "" ""))
2170 (return)]
2171 "SIBLING_CALL_P (insn)"
2172 "jump (%0);"
2173 [(set_attr "type" "br")
2174 (set_attr "length" "2")])
2175
2176 (define_insn "*call_value_insn_fdpic"
2177 [(set (match_operand 0 "register_operand" "=d")
2178 (call (mem:SI (match_operand:SI 1 "register_no_elim_operand" "Y"))
2179 (match_operand 2 "general_operand" "g")))
2180 (use (match_operand:SI 3 "register_operand" "Z"))
2181 (use (match_operand 4 "" ""))
2182 (clobber (reg:SI REG_RETS))]
2183 "! SIBLING_CALL_P (insn)"
2184 "call (%1);"
2185 [(set_attr "type" "call")
2186 (set_attr "length" "2")])
2187
2188 (define_insn "*sibcall_value_insn_fdpic"
2189 [(set (match_operand 0 "register_operand" "=d")
2190 (call (mem:SI (match_operand:SI 1 "register_no_elim_operand" "Y"))
2191 (match_operand 2 "general_operand" "g")))
2192 (use (match_operand:SI 3 "register_operand" "Z"))
2193 (use (match_operand 4 "" ""))
2194 (return)]
2195 "SIBLING_CALL_P (insn)"
2196 "jump (%1);"
2197 [(set_attr "type" "br")
2198 (set_attr "length" "2")])
2199
2200 (define_insn "*call_symbol"
2201 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "Q"))
2202 (match_operand 1 "general_operand" "g"))
2203 (use (match_operand 2 "" ""))
2204 (clobber (reg:SI REG_RETS))]
2205 "! SIBLING_CALL_P (insn)
2206 && (!TARGET_ID_SHARED_LIBRARY || TARGET_LEAF_ID_SHARED_LIBRARY)
2207 && GET_CODE (operands[0]) == SYMBOL_REF
2208 && !bfin_longcall_p (operands[0], INTVAL (operands[2]))"
2209 "call %0;"
2210 [(set_attr "type" "call")
2211 (set_attr "length" "4")])
2212
2213 (define_insn "*sibcall_symbol"
2214 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "Q"))
2215 (match_operand 1 "general_operand" "g"))
2216 (use (match_operand 2 "" ""))
2217 (return)]
2218 "SIBLING_CALL_P (insn)
2219 && (!TARGET_ID_SHARED_LIBRARY || TARGET_LEAF_ID_SHARED_LIBRARY)
2220 && GET_CODE (operands[0]) == SYMBOL_REF
2221 && !bfin_longcall_p (operands[0], INTVAL (operands[2]))"
2222 "jump.l %0;"
2223 [(set_attr "type" "br")
2224 (set_attr "length" "4")])
2225
2226 (define_insn "*call_value_symbol"
2227 [(set (match_operand 0 "register_operand" "=d")
2228 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "Q"))
2229 (match_operand 2 "general_operand" "g")))
2230 (use (match_operand 3 "" ""))
2231 (clobber (reg:SI REG_RETS))]
2232 "! SIBLING_CALL_P (insn)
2233 && (!TARGET_ID_SHARED_LIBRARY || TARGET_LEAF_ID_SHARED_LIBRARY)
2234 && GET_CODE (operands[1]) == SYMBOL_REF
2235 && !bfin_longcall_p (operands[1], INTVAL (operands[3]))"
2236 "call %1;"
2237 [(set_attr "type" "call")
2238 (set_attr "length" "4")])
2239
2240 (define_insn "*sibcall_value_symbol"
2241 [(set (match_operand 0 "register_operand" "=d")
2242 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "Q"))
2243 (match_operand 2 "general_operand" "g")))
2244 (use (match_operand 3 "" ""))
2245 (return)]
2246 "SIBLING_CALL_P (insn)
2247 && (!TARGET_ID_SHARED_LIBRARY || TARGET_LEAF_ID_SHARED_LIBRARY)
2248 && GET_CODE (operands[1]) == SYMBOL_REF
2249 && !bfin_longcall_p (operands[1], INTVAL (operands[3]))"
2250 "jump.l %1;"
2251 [(set_attr "type" "br")
2252 (set_attr "length" "4")])
2253
2254 (define_insn "*call_insn"
2255 [(call (mem:SI (match_operand:SI 0 "register_no_elim_operand" "a"))
2256 (match_operand 1 "general_operand" "g"))
2257 (use (match_operand 2 "" ""))
2258 (clobber (reg:SI REG_RETS))]
2259 "! SIBLING_CALL_P (insn)"
2260 "call (%0);"
2261 [(set_attr "type" "call")
2262 (set_attr "length" "2")])
2263
2264 (define_insn "*sibcall_insn"
2265 [(call (mem:SI (match_operand:SI 0 "register_no_elim_operand" "z"))
2266 (match_operand 1 "general_operand" "g"))
2267 (use (match_operand 2 "" ""))
2268 (return)]
2269 "SIBLING_CALL_P (insn)"
2270 "jump (%0);"
2271 [(set_attr "type" "br")
2272 (set_attr "length" "2")])
2273
2274 (define_insn "*call_value_insn"
2275 [(set (match_operand 0 "register_operand" "=d")
2276 (call (mem:SI (match_operand:SI 1 "register_no_elim_operand" "a"))
2277 (match_operand 2 "general_operand" "g")))
2278 (use (match_operand 3 "" ""))
2279 (clobber (reg:SI REG_RETS))]
2280 "! SIBLING_CALL_P (insn)"
2281 "call (%1);"
2282 [(set_attr "type" "call")
2283 (set_attr "length" "2")])
2284
2285 (define_insn "*sibcall_value_insn"
2286 [(set (match_operand 0 "register_operand" "=d")
2287 (call (mem:SI (match_operand:SI 1 "register_no_elim_operand" "z"))
2288 (match_operand 2 "general_operand" "g")))
2289 (use (match_operand 3 "" ""))
2290 (return)]
2291 "SIBLING_CALL_P (insn)"
2292 "jump (%1);"
2293 [(set_attr "type" "br")
2294 (set_attr "length" "2")])
2295
2296 ;; Block move patterns
2297
2298 ;; We cheat. This copies one more word than operand 2 indicates.
2299
2300 (define_insn "rep_movsi"
2301 [(set (match_operand:SI 0 "register_operand" "=&a")
2302 (plus:SI (plus:SI (match_operand:SI 3 "register_operand" "0")
2303 (ashift:SI (match_operand:SI 2 "register_operand" "a")
2304 (const_int 2)))
2305 (const_int 4)))
2306 (set (match_operand:SI 1 "register_operand" "=&b")
2307 (plus:SI (plus:SI (match_operand:SI 4 "register_operand" "1")
2308 (ashift:SI (match_dup 2) (const_int 2)))
2309 (const_int 4)))
2310 (set (mem:BLK (match_dup 3))
2311 (mem:BLK (match_dup 4)))
2312 (use (match_dup 2))
2313 (clobber (match_scratch:HI 5 "=&d"))
2314 (clobber (reg:SI REG_LT1))
2315 (clobber (reg:SI REG_LC1))
2316 (clobber (reg:SI REG_LB1))]
2317 ""
2318 "%5 = [%4++]; lsetup (1f, 1f) LC1 = %2; 1: MNOP || [%3++] = %5 || %5 = [%4++]; [%3++] = %5;"
2319 [(set_attr "type" "misc")
2320 (set_attr "length" "16")
2321 (set_attr "seq_insns" "multi")])
2322
2323 (define_insn "rep_movhi"
2324 [(set (match_operand:SI 0 "register_operand" "=&a")
2325 (plus:SI (plus:SI (match_operand:SI 3 "register_operand" "0")
2326 (ashift:SI (match_operand:SI 2 "register_operand" "a")
2327 (const_int 1)))
2328 (const_int 2)))
2329 (set (match_operand:SI 1 "register_operand" "=&b")
2330 (plus:SI (plus:SI (match_operand:SI 4 "register_operand" "1")
2331 (ashift:SI (match_dup 2) (const_int 1)))
2332 (const_int 2)))
2333 (set (mem:BLK (match_dup 3))
2334 (mem:BLK (match_dup 4)))
2335 (use (match_dup 2))
2336 (clobber (match_scratch:HI 5 "=&d"))
2337 (clobber (reg:SI REG_LT1))
2338 (clobber (reg:SI REG_LC1))
2339 (clobber (reg:SI REG_LB1))]
2340 ""
2341 "%h5 = W[%4++]; lsetup (1f, 1f) LC1 = %2; 1: MNOP || W [%3++] = %5 || %h5 = W [%4++]; W [%3++] = %5;"
2342 [(set_attr "type" "misc")
2343 (set_attr "length" "16")
2344 (set_attr "seq_insns" "multi")])
2345
2346 (define_expand "cpymemsi"
2347 [(match_operand:BLK 0 "general_operand" "")
2348 (match_operand:BLK 1 "general_operand" "")
2349 (match_operand:SI 2 "const_int_operand" "")
2350 (match_operand:SI 3 "const_int_operand" "")]
2351 ""
2352 {
2353 if (bfin_expand_cpymem (operands[0], operands[1], operands[2], operands[3]))
2354 DONE;
2355 FAIL;
2356 })
2357
2358 ;; Conditional branch patterns
2359 ;; The Blackfin has only few condition codes: eq, lt, lte, ltu, leu
2360
2361 (define_insn "compare_eq"
2362 [(set (match_operand:BI 0 "register_operand" "=C,C")
2363 (eq:BI (match_operand:SI 1 "register_operand" "d,a")
2364 (match_operand:SI 2 "reg_or_const_int_operand" "dKs3,aKs3")))]
2365 ""
2366 "cc =%1==%2;"
2367 [(set_attr "type" "compare")])
2368
2369 (define_insn "compare_ne"
2370 [(set (match_operand:BI 0 "register_operand" "=C,C")
2371 (ne:BI (match_operand:SI 1 "register_operand" "d,a")
2372 (match_operand:SI 2 "reg_or_const_int_operand" "dKs3,aKs3")))]
2373 "0"
2374 "cc =%1!=%2;"
2375 [(set_attr "type" "compare")])
2376
2377 (define_insn "compare_lt"
2378 [(set (match_operand:BI 0 "register_operand" "=C,C")
2379 (lt:BI (match_operand:SI 1 "register_operand" "d,a")
2380 (match_operand:SI 2 "reg_or_const_int_operand" "dKs3,aKs3")))]
2381 ""
2382 "cc =%1<%2;"
2383 [(set_attr "type" "compare")])
2384
2385 (define_insn "compare_le"
2386 [(set (match_operand:BI 0 "register_operand" "=C,C")
2387 (le:BI (match_operand:SI 1 "register_operand" "d,a")
2388 (match_operand:SI 2 "reg_or_const_int_operand" "dKs3,aKs3")))]
2389 ""
2390 "cc =%1<=%2;"
2391 [(set_attr "type" "compare")])
2392
2393 (define_insn "compare_leu"
2394 [(set (match_operand:BI 0 "register_operand" "=C,C")
2395 (leu:BI (match_operand:SI 1 "register_operand" "d,a")
2396 (match_operand:SI 2 "reg_or_const_int_operand" "dKu3,aKu3")))]
2397 ""
2398 "cc =%1<=%2 (iu);"
2399 [(set_attr "type" "compare")])
2400
2401 (define_insn "compare_ltu"
2402 [(set (match_operand:BI 0 "register_operand" "=C,C")
2403 (ltu:BI (match_operand:SI 1 "register_operand" "d,a")
2404 (match_operand:SI 2 "reg_or_const_int_operand" "dKu3,aKu3")))]
2405 ""
2406 "cc =%1<%2 (iu);"
2407 [(set_attr "type" "compare")])
2408
2409 ;; Same as above, but and CC with the overflow bit generated by the first
2410 ;; multiplication.
2411 (define_insn "flag_mul_macv2hi_parts_acconly_andcc0"
2412 [(set (match_operand:PDI 0 "register_operand" "=B,e,e")
2413 (unspec:PDI [(vec_select:HI
2414 (match_operand:V2HI 2 "register_operand" "d,d,d")
2415 (parallel [(match_operand 4 "const01_operand" "P0P1,P0P1,P0P1")]))
2416 (vec_select:HI
2417 (match_operand:V2HI 3 "register_operand" "d,d,d")
2418 (parallel [(match_operand 6 "const01_operand" "P0P1,P0P1,P0P1")]))
2419 (match_operand 10 "const_int_operand" "PB,PA,PA")]
2420 UNSPEC_MUL_WITH_FLAG))
2421 (set (match_operand:PDI 1 "register_operand" "=B,e,e")
2422 (unspec:PDI [(vec_select:HI
2423 (match_dup 2)
2424 (parallel [(match_operand 5 "const01_operand" "P0P1,P0P1,P0P1")]))
2425 (vec_select:HI
2426 (match_dup 3)
2427 (parallel [(match_operand 7 "const01_operand" "P0P1,P0P1,P0P1")]))
2428 (match_operand:PDI 8 "register_operand" "1,1,1")
2429 (match_operand 9 "const01_operand" "P0P1,P0P1,P0P1")
2430 (match_operand 11 "const_int_operand" "PA,PB,PA")]
2431 UNSPEC_MAC_WITH_FLAG))
2432 (set (reg:BI REG_CC)
2433 (and:BI (reg:BI REG_CC)
2434 (unspec:BI [(vec_select:HI (match_dup 2) (parallel [(match_dup 4)]))
2435 (vec_select:HI (match_dup 3) (parallel [(match_dup 6)]))
2436 (match_dup 10)]
2437 UNSPEC_MUL_WITH_FLAG)))]
2438 "MACFLAGS_MATCH_P (INTVAL (operands[10]), INTVAL (operands[11]))"
2439 {
2440 rtx xops[6];
2441 const char *templates[] = {
2442 "%0 = %h2 * %h3, %1 %b4 %h2 * %h3 %M5;\n\tCC &= %v0;",
2443 "%0 = %d2 * %h3, %1 %b4 %h2 * %h3 %M5;\n\tCC &= %v0;",
2444 "%0 = %h2 * %h3, %1 %b4 %d2 * %h3 %M5;\n\tCC &= %v0;",
2445 "%0 = %d2 * %h3, %1 %b4 %d2 * %h3 %M5;\n\tCC &= %v0;",
2446 "%0 = %h2 * %d3, %1 %b4 %h2 * %h3 %M5;\n\tCC &= %v0;",
2447 "%0 = %d2 * %d3, %1 %b4 %h2 * %h3 %M5;\n\tCC &= %v0;",
2448 "%0 = %h2 * %d3, %1 %b4 %d2 * %h3 %M5;\n\tCC &= %v0;",
2449 "%0 = %d2 * %d3, %1 %b4 %d2 * %h3 %M5;\n\tCC &= %v0;",
2450 "%0 = %h2 * %h3, %1 %b4 %h2 * %d3 %M5;\n\tCC &= %v0;",
2451 "%0 = %d2 * %h3, %1 %b4 %h2 * %d3 %M5;\n\tCC &= %v0;",
2452 "%0 = %h2 * %h3, %1 %b4 %d2 * %d3 %M5;\n\tCC &= %v0;",
2453 "%0 = %d2 * %h3, %1 %b4 %d2 * %d3 %M5;\n\tCC &= %v0;",
2454 "%0 = %h2 * %d3, %1 %b4 %h2 * %d3 %M5;\n\tCC &= %v0;",
2455 "%0 = %d2 * %d3, %1 %b4 %h2 * %d3 %M5;\n\tCC &= %v0;",
2456 "%0 = %h2 * %d3, %1 %b4 %d2 * %d3 %M5;\n\tCC &= %v0;",
2457 "%0 = %d2 * %d3, %1 %b4 %d2 * %d3 %M5;\n\tCC &= %v0;" };
2458 int alt = (INTVAL (operands[4]) + (INTVAL (operands[5]) << 1)
2459 + (INTVAL (operands[6]) << 2) + (INTVAL (operands[7]) << 3));
2460 xops[0] = operands[0];
2461 xops[1] = operands[1];
2462 xops[2] = operands[2];
2463 xops[3] = operands[3];
2464 xops[4] = operands[9];
2465 xops[5] = which_alternative == 0 ? operands[10] : operands[11];
2466 output_asm_insn (templates[alt], xops);
2467 return "";
2468 }
2469 [(set_attr "type" "misc")
2470 (set_attr "length" "6")
2471 (set_attr "seq_insns" "multi")])
2472
2473 (define_expand "cbranchsi4"
2474 [(set (pc)
2475 (if_then_else (match_operator 0 "ordered_comparison_operator"
2476 [(match_operand:SI 1 "register_operand" "")
2477 (match_operand:SI 2 "reg_or_const_int_operand" "")])
2478 (label_ref (match_operand 3 "" ""))
2479 (pc)))]
2480 ""
2481 {
2482 rtx bi_compare = bfin_gen_compare (operands[0], SImode);
2483 emit_jump_insn (gen_cbranchbi4 (bi_compare, bfin_cc_rtx, CONST0_RTX (BImode),
2484 operands[3]));
2485 DONE;
2486 })
2487
2488 (define_insn "cbranchbi4"
2489 [(set (pc)
2490 (if_then_else
2491 (match_operator 0 "bfin_bimode_comparison_operator"
2492 [(match_operand:BI 1 "register_operand" "C")
2493 (match_operand:BI 2 "immediate_operand" "P0")])
2494 (label_ref (match_operand 3 "" ""))
2495 (pc)))]
2496 ""
2497 {
2498 asm_conditional_branch (insn, operands, 0, 0);
2499 return "";
2500 }
2501 [(set_attr "type" "brcc")])
2502
2503 ;; Special cbranch patterns to deal with the speculative load problem - see
2504 ;; bfin_reorg for details.
2505
2506 (define_insn "cbranch_predicted_taken"
2507 [(set (pc)
2508 (if_then_else
2509 (match_operator 0 "bfin_bimode_comparison_operator"
2510 [(match_operand:BI 1 "register_operand" "C")
2511 (match_operand:BI 2 "immediate_operand" "P0")])
2512 (label_ref (match_operand 3 "" ""))
2513 (pc)))
2514 (unspec [(const_int 0)] UNSPEC_CBRANCH_TAKEN)]
2515 ""
2516 {
2517 asm_conditional_branch (insn, operands, 0, 1);
2518 return "";
2519 }
2520 [(set_attr "type" "brcc")])
2521
2522 (define_insn "cbranch_with_nops"
2523 [(set (pc)
2524 (if_then_else
2525 (match_operator 0 "bfin_bimode_comparison_operator"
2526 [(match_operand:BI 1 "register_operand" "C")
2527 (match_operand:BI 2 "immediate_operand" "P0")])
2528 (label_ref (match_operand 3 "" ""))
2529 (pc)))
2530 (unspec [(match_operand 4 "immediate_operand" "")] UNSPEC_CBRANCH_NOPS)]
2531 "reload_completed"
2532 {
2533 asm_conditional_branch (insn, operands, INTVAL (operands[4]), 0);
2534 return "";
2535 }
2536 [(set_attr "type" "brcc")
2537 (set_attr "length" "8")])
2538
2539 ;; setcc insns.
2540
2541 (define_expand "cstorebi4"
2542 [(set (match_dup 4)
2543 (match_operator:BI 1 "bfin_bimode_comparison_operator"
2544 [(match_operand:BI 2 "register_operand" "")
2545 (match_operand:BI 3 "reg_or_const_int_operand" "")]))
2546 (set (match_operand:SI 0 "register_operand" "")
2547 (ne:SI (match_dup 4) (const_int 0)))]
2548 ""
2549 {
2550 /* It could be expanded as a movbisi instruction, but the portable
2551 alternative produces better code. */
2552 if (GET_CODE (operands[1]) == NE)
2553 FAIL;
2554
2555 operands[4] = bfin_cc_rtx;
2556 })
2557
2558 (define_expand "cstoresi4"
2559 [(set (match_operand:SI 0 "register_operand")
2560 (match_operator:SI 1 "ordered_comparison_operator"
2561 [(match_operand:SI 2 "register_operand" "")
2562 (match_operand:SI 3 "reg_or_const_int_operand" "")]))]
2563 ""
2564 {
2565 rtx bi_compare, test;
2566
2567 if (!bfin_direct_comparison_operator (operands[1], SImode))
2568 {
2569 if (!register_operand (operands[3], SImode)
2570 || GET_CODE (operands[1]) == NE)
2571 FAIL;
2572 test = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[1])),
2573 SImode, operands[3], operands[2]);
2574 }
2575 else
2576 test = operands[1];
2577
2578 bi_compare = bfin_gen_compare (test, SImode);
2579 gcc_assert (GET_CODE (bi_compare) == NE);
2580 emit_insn (gen_movbisi (operands[0], bfin_cc_rtx));
2581 DONE;
2582 })
2583
2584 (define_insn "nop"
2585 [(const_int 0)]
2586 ""
2587 "nop;")
2588
2589 ;; A nop which stays there when emitted.
2590 (define_insn "forced_nop"
2591 [(unspec [(const_int 0)] UNSPEC_NOP)]
2592 ""
2593 "nop;")
2594
2595 (define_insn "mnop"
2596 [(unspec [(const_int 0)] UNSPEC_32BIT)]
2597 ""
2598 "mnop%!"
2599 [(set_attr "type" "dsp32")])
2600
2601 ;;;;;;;;;;;;;;;;;;;; CC2dreg ;;;;;;;;;;;;;;;;;;;;;;;;;
2602 (define_insn "movsibi"
2603 [(set (match_operand:BI 0 "register_operand" "=C")
2604 (ne:BI (match_operand:SI 1 "register_operand" "d")
2605 (const_int 0)))]
2606 ""
2607 "CC = %1;"
2608 [(set_attr "length" "2")])
2609
2610 (define_insn_and_split "movbisi"
2611 [(set (match_operand:SI 0 "register_operand" "=d")
2612 (ne:SI (match_operand:BI 1 "register_operand" "C")
2613 (const_int 0)))]
2614 ""
2615 "#"
2616 ""
2617 [(set (match_operand:SI 0 "register_operand" "")
2618 (zero_extend:SI (match_operand:BI 1 "register_operand" "")))]
2619 "")
2620
2621 (define_insn "notbi"
2622 [(set (match_operand:BI 0 "register_operand" "=C")
2623 (eq:BI (match_operand:BI 1 "register_operand" " 0")
2624 (const_int 0)))]
2625 ""
2626 "%0 = ! %0;" /* NOT CC;" */
2627 [(set_attr "type" "compare")])
2628
2629 ;; Vector and DSP insns
2630
2631 (define_insn ""
2632 [(set (match_operand:SI 0 "register_operand" "=d")
2633 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "d")
2634 (const_int 24))
2635 (lshiftrt:SI (match_operand:SI 2 "register_operand" "d")
2636 (const_int 8))))]
2637 ""
2638 "%0 = ALIGN8(%1, %2)%!"
2639 [(set_attr "type" "dsp32")])
2640
2641 (define_insn ""
2642 [(set (match_operand:SI 0 "register_operand" "=d")
2643 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "d")
2644 (const_int 16))
2645 (lshiftrt:SI (match_operand:SI 2 "register_operand" "d")
2646 (const_int 16))))]
2647 ""
2648 "%0 = ALIGN16(%1, %2)%!"
2649 [(set_attr "type" "dsp32")])
2650
2651 (define_insn ""
2652 [(set (match_operand:SI 0 "register_operand" "=d")
2653 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "d")
2654 (const_int 8))
2655 (lshiftrt:SI (match_operand:SI 2 "register_operand" "d")
2656 (const_int 24))))]
2657 ""
2658 "%0 = ALIGN24(%1, %2)%!"
2659 [(set_attr "type" "dsp32")])
2660
2661 ;; Prologue and epilogue.
2662
2663 (define_expand "prologue"
2664 [(const_int 1)]
2665 ""
2666 "bfin_expand_prologue (); DONE;")
2667
2668 (define_expand "epilogue"
2669 [(const_int 1)]
2670 ""
2671 "bfin_expand_epilogue (1, 0, 0); DONE;")
2672
2673 (define_expand "sibcall_epilogue"
2674 [(const_int 1)]
2675 ""
2676 "bfin_expand_epilogue (0, 0, 1); DONE;")
2677
2678 (define_expand "eh_return"
2679 [(use (match_operand:SI 0 "register_operand" ""))]
2680 ""
2681 {
2682 emit_insn (gen_eh_store_handler (EH_RETURN_HANDLER_RTX, operands[0]));
2683 emit_jump_insn (gen_eh_return_internal ());
2684 emit_barrier ();
2685 DONE;
2686 })
2687
2688 (define_insn "eh_store_handler"
2689 [(unspec_volatile [(match_operand:SI 1 "register_operand" "da")]
2690 UNSPEC_VOLATILE_STORE_EH_HANDLER)
2691 (clobber (match_operand:SI 0 "memory_operand" "=m"))]
2692 ""
2693 "%0 = %1%!"
2694 [(set_attr "type" "mcst")])
2695
2696 (define_insn_and_split "eh_return_internal"
2697 [(eh_return)]
2698 ""
2699 "#"
2700 "epilogue_completed"
2701 [(const_int 1)]
2702 "bfin_expand_epilogue (1, 1, 0); DONE;")
2703
2704 (define_insn "link"
2705 [(set (mem:SI (plus:SI (reg:SI REG_SP) (const_int -4))) (reg:SI REG_RETS))
2706 (set (mem:SI (plus:SI (reg:SI REG_SP) (const_int -8))) (reg:SI REG_FP))
2707 (set (reg:SI REG_FP)
2708 (plus:SI (reg:SI REG_SP) (const_int -8)))
2709 (set (reg:SI REG_SP)
2710 (plus:SI (reg:SI REG_SP) (match_operand:SI 0 "immediate_operand" "i")))]
2711 ""
2712 "LINK %Z0;"
2713 [(set_attr "length" "4")])
2714
2715 (define_insn "unlink"
2716 [(set (reg:SI REG_FP) (mem:SI (reg:SI REG_FP)))
2717 (set (reg:SI REG_RETS) (mem:SI (plus:SI (reg:SI REG_FP) (const_int 4))))
2718 (set (reg:SI REG_SP) (plus:SI (reg:SI REG_FP) (const_int 8)))]
2719 ""
2720 "UNLINK;"
2721 [(set_attr "length" "4")])
2722
2723 ;; This pattern is slightly clumsy. The stack adjust must be the final SET in
2724 ;; the pattern, otherwise dwarf2out becomes very confused about which reg goes
2725 ;; where on the stack, since it goes through all elements of the parallel in
2726 ;; sequence.
2727 (define_insn "push_multiple"
2728 [(match_parallel 0 "push_multiple_operation"
2729 [(unspec [(match_operand:SI 1 "immediate_operand" "i")] UNSPEC_PUSH_MULTIPLE)])]
2730 ""
2731 {
2732 output_push_multiple (insn, operands);
2733 return "";
2734 })
2735
2736 (define_insn "pop_multiple"
2737 [(match_parallel 0 "pop_multiple_operation"
2738 [(set (reg:SI REG_SP)
2739 (plus:SI (reg:SI REG_SP) (match_operand:SI 1 "immediate_operand" "i")))])]
2740 ""
2741 {
2742 output_pop_multiple (insn, operands);
2743 return "";
2744 })
2745
2746 (define_insn "return_internal"
2747 [(return)
2748 (use (match_operand 0 "register_operand" ""))]
2749 "reload_completed"
2750 {
2751 switch (REGNO (operands[0]))
2752 {
2753 case REG_RETX:
2754 return "rtx;";
2755 case REG_RETN:
2756 return "rtn;";
2757 case REG_RETI:
2758 return "rti;";
2759 case REG_RETS:
2760 return "rts;";
2761 }
2762 gcc_unreachable ();
2763 })
2764
2765 ;; When used at a location where CC contains 1, causes a speculative load
2766 ;; that is later cancelled. This is used for certain workarounds in
2767 ;; interrupt handler prologues.
2768 (define_insn "dummy_load"
2769 [(unspec_volatile [(match_operand 0 "register_operand" "a")
2770 (match_operand 1 "register_operand" "C")]
2771 UNSPEC_VOLATILE_DUMMY)]
2772 ""
2773 "if cc jump 4;\n\tr7 = [%0];"
2774 [(set_attr "type" "misc")
2775 (set_attr "length" "4")
2776 (set_attr "seq_insns" "multi")])
2777
2778 ;; A placeholder insn inserted before the final scheduling pass. It is used
2779 ;; to improve scheduling of loads when workarounds for speculative loads are
2780 ;; needed, by not placing them in the first few cycles after a conditional
2781 ;; branch.
2782 (define_insn "stall"
2783 [(unspec_volatile [(match_operand 0 "const_int_operand" "P1P3")]
2784 UNSPEC_VOLATILE_STALL)]
2785 ""
2786 ""
2787 [(set_attr "type" "stall")])
2788
2789 (define_insn "csync"
2790 [(unspec_volatile [(const_int 0)] UNSPEC_VOLATILE_CSYNC)]
2791 ""
2792 "csync;"
2793 [(set_attr "type" "sync")])
2794
2795 (define_insn "ssync"
2796 [(unspec_volatile [(const_int 0)] UNSPEC_VOLATILE_SSYNC)]
2797 ""
2798 "ssync;"
2799 [(set_attr "type" "sync")])
2800
2801 (define_insn "trap"
2802 [(trap_if (const_int 1) (const_int 3))]
2803 ""
2804 "excpt 3;"
2805 [(set_attr "type" "misc")
2806 (set_attr "length" "2")])
2807
2808 (define_insn "trapifcc"
2809 [(trap_if (reg:BI REG_CC) (const_int 3))]
2810 ""
2811 "if !cc jump 4 (bp); excpt 3;"
2812 [(set_attr "type" "misc")
2813 (set_attr "length" "4")
2814 (set_attr "seq_insns" "multi")])
2815
2816 ;;; Vector instructions
2817
2818 ;; First, all sorts of move variants
2819
2820 (define_insn "movhiv2hi_low"
2821 [(set (match_operand:V2HI 0 "register_operand" "=d")
2822 (vec_concat:V2HI
2823 (match_operand:HI 2 "register_operand" "d")
2824 (vec_select:HI (match_operand:V2HI 1 "register_operand" "0")
2825 (parallel [(const_int 1)]))))]
2826 ""
2827 "%h0 = %h2 << 0%!"
2828 [(set_attr "type" "dsp32shiftimm")])
2829
2830 (define_insn "movhiv2hi_high"
2831 [(set (match_operand:V2HI 0 "register_operand" "=d")
2832 (vec_concat:V2HI
2833 (vec_select:HI (match_operand:V2HI 1 "register_operand" "0")
2834 (parallel [(const_int 0)]))
2835 (match_operand:HI 2 "register_operand" "d")))]
2836 ""
2837 "%d0 = %h2 << 0%!"
2838 [(set_attr "type" "dsp32shiftimm")])
2839
2840 ;; No earlyclobber on alternative two since our sequence ought to be safe.
2841 ;; The order of operands is intentional to match the VDSP builtin (high word
2842 ;; is passed first).
2843 (define_insn_and_split "composev2hi"
2844 [(set (match_operand:V2HI 0 "register_operand" "=d,d")
2845 (vec_concat:V2HI (match_operand:HI 2 "register_operand" "0,d")
2846 (match_operand:HI 1 "register_operand" "d,d")))]
2847 ""
2848 "@
2849 %d0 = %h1 << 0%!
2850 #"
2851 "reload_completed"
2852 [(set (match_dup 0)
2853 (vec_concat:V2HI
2854 (vec_select:HI (match_dup 0) (parallel [(const_int 0)]))
2855 (match_dup 1)))
2856 (set (match_dup 0)
2857 (vec_concat:V2HI
2858 (match_dup 2)
2859 (vec_select:HI (match_dup 0) (parallel [(const_int 1)]))))]
2860 ""
2861 [(set_attr "type" "dsp32shiftimm")])
2862
2863 ; Like composev2hi, but operating on elements of V2HI vectors.
2864 ; Useful on its own, and as a combiner bridge for the multiply and
2865 ; mac patterns.
2866 (define_insn "packv2hi"
2867 [(set (match_operand:V2HI 0 "register_operand" "=d,d,d,d,d,d,d,d")
2868 (vec_concat:V2HI (vec_select:HI
2869 (match_operand:V2HI 1 "register_operand" "0,0,d,d,d,d,d,d")
2870 (parallel [(match_operand 3 "const01_operand" "P0,P0,P0,P1,P0,P1,P0,P1")]))
2871 (vec_select:HI
2872 (match_operand:V2HI 2 "register_operand" "d,d,0,0,d,d,d,d")
2873 (parallel [(match_operand 4 "const01_operand" "P0,P1,P1,P1,P0,P0,P1,P1")]))))]
2874 ""
2875 "@
2876 %d0 = %h2 << 0%!
2877 %d0 = %d2 << 0%!
2878 %h0 = %h1 << 0%!
2879 %h0 = %d1 << 0%!
2880 %0 = PACK (%h2,%h1)%!
2881 %0 = PACK (%h2,%d1)%!
2882 %0 = PACK (%d2,%h1)%!
2883 %0 = PACK (%d2,%d1)%!"
2884 [(set_attr "type" "dsp32shiftimm,dsp32shiftimm,dsp32shiftimm,dsp32shiftimm,dsp32,dsp32,dsp32,dsp32")])
2885
2886 (define_insn "movv2hi_hi"
2887 [(set (match_operand:HI 0 "register_operand" "=d,d,d")
2888 (vec_select:HI (match_operand:V2HI 1 "register_operand" "0,d,d")
2889 (parallel [(match_operand 2 "const01_operand" "P0,P0,P1")])))]
2890 ""
2891 "@
2892 /* optimized out */
2893 %h0 = %h1 << 0%!
2894 %h0 = %d1 << 0%!"
2895 [(set_attr "type" "dsp32shiftimm")])
2896
2897 (define_expand "movv2hi_hi_low"
2898 [(set (match_operand:HI 0 "register_operand" "")
2899 (vec_select:HI (match_operand:V2HI 1 "register_operand" "")
2900 (parallel [(const_int 0)])))]
2901 ""
2902 "")
2903
2904 (define_expand "movv2hi_hi_high"
2905 [(set (match_operand:HI 0 "register_operand" "")
2906 (vec_select:HI (match_operand:V2HI 1 "register_operand" "")
2907 (parallel [(const_int 1)])))]
2908 ""
2909 "")
2910
2911 ;; Unusual arithmetic operations on 16-bit registers.
2912
2913 (define_code_iterator sp_or_sm [ss_plus ss_minus])
2914 (define_code_attr spm_string [(ss_plus "+") (ss_minus "-")])
2915 (define_code_attr spm_name [(ss_plus "add") (ss_minus "sub")])
2916
2917 (define_insn "ss<spm_name>hi3"
2918 [(set (match_operand:HI 0 "register_operand" "=d")
2919 (sp_or_sm:HI (match_operand:HI 1 "register_operand" "d")
2920 (match_operand:HI 2 "register_operand" "d")))]
2921 ""
2922 "%h0 = %h1 <spm_string> %h2 (S)%!"
2923 [(set_attr "type" "dsp32")])
2924
2925 (define_insn "ss<spm_name>hi3_parts"
2926 [(set (match_operand:HI 0 "register_operand" "=d")
2927 (sp_or_sm:HI (vec_select:HI
2928 (match_operand:V2HI 1 "register_operand" "d")
2929 (parallel [(match_operand 3 "const01_operand" "P0P1")]))
2930 (vec_select:HI
2931 (match_operand:V2HI 2 "register_operand" "d")
2932 (parallel [(match_operand 4 "const01_operand" "P0P1")]))))]
2933 ""
2934 {
2935 const char *templates[] = {
2936 "%h0 = %h1 <spm_string> %h2 (S)%!",
2937 "%h0 = %d1 <spm_string> %h2 (S)%!",
2938 "%h0 = %h1 <spm_string> %d2 (S)%!",
2939 "%h0 = %d1 <spm_string> %d2 (S)%!" };
2940 int alt = INTVAL (operands[3]) + (INTVAL (operands[4]) << 1);
2941 return templates[alt];
2942 }
2943 [(set_attr "type" "dsp32")])
2944
2945 (define_insn "ss<spm_name>hi3_low_parts"
2946 [(set (match_operand:V2HI 0 "register_operand" "=d")
2947 (vec_concat:V2HI
2948 (vec_select:HI (match_operand:V2HI 1 "register_operand" "0")
2949 (parallel [(const_int 0)]))
2950 (sp_or_sm:HI (vec_select:HI
2951 (match_operand:V2HI 2 "register_operand" "d")
2952 (parallel [(match_operand 4 "const01_operand" "P0P1")]))
2953 (vec_select:HI
2954 (match_operand:V2HI 3 "register_operand" "d")
2955 (parallel [(match_operand 5 "const01_operand" "P0P1")])))))]
2956 ""
2957 {
2958 const char *templates[] = {
2959 "%h0 = %h2 <spm_string> %h3 (S)%!",
2960 "%h0 = %d2 <spm_string> %h3 (S)%!",
2961 "%h0 = %h2 <spm_string> %d3 (S)%!",
2962 "%h0 = %d2 <spm_string> %d3 (S)%!" };
2963 int alt = INTVAL (operands[4]) + (INTVAL (operands[5]) << 1);
2964 return templates[alt];
2965 }
2966 [(set_attr "type" "dsp32")])
2967
2968 (define_insn "ss<spm_name>hi3_high_parts"
2969 [(set (match_operand:V2HI 0 "register_operand" "=d")
2970 (vec_concat:V2HI
2971 (sp_or_sm:HI (vec_select:HI
2972 (match_operand:V2HI 2 "register_operand" "d")
2973 (parallel [(match_operand 4 "const01_operand" "P0P1")]))
2974 (vec_select:HI
2975 (match_operand:V2HI 3 "register_operand" "d")
2976 (parallel [(match_operand 5 "const01_operand" "P0P1")])))
2977 (vec_select:HI (match_operand:V2HI 1 "register_operand" "0")
2978 (parallel [(const_int 1)]))))]
2979 ""
2980 {
2981 const char *templates[] = {
2982 "%d0 = %h2 <spm_string> %h3 (S)%!",
2983 "%d0 = %d2 <spm_string> %h3 (S)%!",
2984 "%d0 = %h2 <spm_string> %d3 (S)%!",
2985 "%d0 = %d2 <spm_string> %d3 (S)%!" };
2986 int alt = INTVAL (operands[4]) + (INTVAL (operands[5]) << 1);
2987 return templates[alt];
2988 }
2989 [(set_attr "type" "dsp32")])
2990
2991 ;; V2HI vector insns
2992
2993 (define_insn "addv2hi3"
2994 [(set (match_operand:V2HI 0 "register_operand" "=d")
2995 (plus:V2HI (match_operand:V2HI 1 "register_operand" "d")
2996 (match_operand:V2HI 2 "register_operand" "d")))]
2997 ""
2998 "%0 = %1 +|+ %2%!"
2999 [(set_attr "type" "dsp32")])
3000
3001 (define_insn "ssaddv2hi3"
3002 [(set (match_operand:V2HI 0 "register_operand" "=d")
3003 (ss_plus:V2HI (match_operand:V2HI 1 "register_operand" "d")
3004 (match_operand:V2HI 2 "register_operand" "d")))]
3005 ""
3006 "%0 = %1 +|+ %2 (S)%!"
3007 [(set_attr "type" "dsp32")])
3008
3009 (define_insn "subv2hi3"
3010 [(set (match_operand:V2HI 0 "register_operand" "=d")
3011 (minus:V2HI (match_operand:V2HI 1 "register_operand" "d")
3012 (match_operand:V2HI 2 "register_operand" "d")))]
3013 ""
3014 "%0 = %1 -|- %2%!"
3015 [(set_attr "type" "dsp32")])
3016
3017 (define_insn "sssubv2hi3"
3018 [(set (match_operand:V2HI 0 "register_operand" "=d")
3019 (ss_minus:V2HI (match_operand:V2HI 1 "register_operand" "d")
3020 (match_operand:V2HI 2 "register_operand" "d")))]
3021 ""
3022 "%0 = %1 -|- %2 (S)%!"
3023 [(set_attr "type" "dsp32")])
3024
3025 (define_insn "addsubv2hi3"
3026 [(set (match_operand:V2HI 0 "register_operand" "=d")
3027 (vec_concat:V2HI
3028 (minus:HI (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3029 (parallel [(const_int 0)]))
3030 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3031 (parallel [(const_int 0)])))
3032 (plus:HI (vec_select:HI (match_dup 1) (parallel [(const_int 1)]))
3033 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
3034 ""
3035 "%0 = %1 +|- %2%!"
3036 [(set_attr "type" "dsp32")])
3037
3038 (define_insn "subaddv2hi3"
3039 [(set (match_operand:V2HI 0 "register_operand" "=d")
3040 (vec_concat:V2HI
3041 (plus:HI (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3042 (parallel [(const_int 0)]))
3043 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3044 (parallel [(const_int 0)])))
3045 (minus:HI (vec_select:HI (match_dup 1) (parallel [(const_int 1)]))
3046 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
3047 ""
3048 "%0 = %1 -|+ %2%!"
3049 [(set_attr "type" "dsp32")])
3050
3051 (define_insn "ssaddsubv2hi3"
3052 [(set (match_operand:V2HI 0 "register_operand" "=d")
3053 (vec_concat:V2HI
3054 (ss_minus:HI (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3055 (parallel [(const_int 0)]))
3056 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3057 (parallel [(const_int 0)])))
3058 (ss_plus:HI (vec_select:HI (match_dup 1) (parallel [(const_int 1)]))
3059 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
3060 ""
3061 "%0 = %1 +|- %2 (S)%!"
3062 [(set_attr "type" "dsp32")])
3063
3064 (define_insn "sssubaddv2hi3"
3065 [(set (match_operand:V2HI 0 "register_operand" "=d")
3066 (vec_concat:V2HI
3067 (ss_plus:HI (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3068 (parallel [(const_int 0)]))
3069 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3070 (parallel [(const_int 0)])))
3071 (ss_minus:HI (vec_select:HI (match_dup 1) (parallel [(const_int 1)]))
3072 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
3073 ""
3074 "%0 = %1 -|+ %2 (S)%!"
3075 [(set_attr "type" "dsp32")])
3076
3077 (define_insn "sublohiv2hi3"
3078 [(set (match_operand:HI 0 "register_operand" "=d")
3079 (minus:HI (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3080 (parallel [(const_int 1)]))
3081 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3082 (parallel [(const_int 0)]))))]
3083 ""
3084 "%h0 = %d1 - %h2%!"
3085 [(set_attr "type" "dsp32")])
3086
3087 (define_insn "subhilov2hi3"
3088 [(set (match_operand:HI 0 "register_operand" "=d")
3089 (minus:HI (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3090 (parallel [(const_int 0)]))
3091 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3092 (parallel [(const_int 1)]))))]
3093 ""
3094 "%h0 = %h1 - %d2%!"
3095 [(set_attr "type" "dsp32")])
3096
3097 (define_insn "sssublohiv2hi3"
3098 [(set (match_operand:HI 0 "register_operand" "=d")
3099 (ss_minus:HI (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3100 (parallel [(const_int 1)]))
3101 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3102 (parallel [(const_int 0)]))))]
3103 ""
3104 "%h0 = %d1 - %h2 (S)%!"
3105 [(set_attr "type" "dsp32")])
3106
3107 (define_insn "sssubhilov2hi3"
3108 [(set (match_operand:HI 0 "register_operand" "=d")
3109 (ss_minus:HI (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3110 (parallel [(const_int 0)]))
3111 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3112 (parallel [(const_int 1)]))))]
3113 ""
3114 "%h0 = %h1 - %d2 (S)%!"
3115 [(set_attr "type" "dsp32")])
3116
3117 (define_insn "addlohiv2hi3"
3118 [(set (match_operand:HI 0 "register_operand" "=d")
3119 (plus:HI (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3120 (parallel [(const_int 1)]))
3121 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3122 (parallel [(const_int 0)]))))]
3123 ""
3124 "%h0 = %d1 + %h2%!"
3125 [(set_attr "type" "dsp32")])
3126
3127 (define_insn "addhilov2hi3"
3128 [(set (match_operand:HI 0 "register_operand" "=d")
3129 (plus:HI (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3130 (parallel [(const_int 0)]))
3131 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3132 (parallel [(const_int 1)]))))]
3133 ""
3134 "%h0 = %h1 + %d2%!"
3135 [(set_attr "type" "dsp32")])
3136
3137 (define_insn "ssaddlohiv2hi3"
3138 [(set (match_operand:HI 0 "register_operand" "=d")
3139 (ss_plus:HI (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3140 (parallel [(const_int 1)]))
3141 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3142 (parallel [(const_int 0)]))))]
3143 ""
3144 "%h0 = %d1 + %h2 (S)%!"
3145 [(set_attr "type" "dsp32")])
3146
3147 (define_insn "ssaddhilov2hi3"
3148 [(set (match_operand:HI 0 "register_operand" "=d")
3149 (ss_plus:HI (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3150 (parallel [(const_int 0)]))
3151 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3152 (parallel [(const_int 1)]))))]
3153 ""
3154 "%h0 = %h1 + %d2 (S)%!"
3155 [(set_attr "type" "dsp32")])
3156
3157 (define_insn "sminv2hi3"
3158 [(set (match_operand:V2HI 0 "register_operand" "=d")
3159 (smin:V2HI (match_operand:V2HI 1 "register_operand" "d")
3160 (match_operand:V2HI 2 "register_operand" "d")))]
3161 ""
3162 "%0 = MIN (%1, %2) (V)%!"
3163 [(set_attr "type" "dsp32")])
3164
3165 (define_insn "smaxv2hi3"
3166 [(set (match_operand:V2HI 0 "register_operand" "=d")
3167 (smax:V2HI (match_operand:V2HI 1 "register_operand" "d")
3168 (match_operand:V2HI 2 "register_operand" "d")))]
3169 ""
3170 "%0 = MAX (%1, %2) (V)%!"
3171 [(set_attr "type" "dsp32")])
3172
3173 ;; Multiplications.
3174
3175 ;; The Blackfin allows a lot of different options, and we need many patterns to
3176 ;; cover most of the hardware's abilities.
3177 ;; There are a few simple patterns using MULT rtx codes, but most of them use
3178 ;; an unspec with a const_int operand that determines which flag to use in the
3179 ;; instruction.
3180 ;; There are variants for single and parallel multiplications.
3181 ;; There are variants which just use 16-bit lowparts as inputs, and variants
3182 ;; which allow the user to choose just which halves to use as input values.
3183 ;; There are variants which set D registers, variants which set accumulators,
3184 ;; variants which set both, some of them optionally using the accumulators as
3185 ;; inputs for multiply-accumulate operations.
3186
3187 (define_insn "flag_mulhi"
3188 [(set (match_operand:HI 0 "register_operand" "=d")
3189 (unspec:HI [(match_operand:HI 1 "register_operand" "d")
3190 (match_operand:HI 2 "register_operand" "d")
3191 (match_operand 3 "const_int_operand" "n")]
3192 UNSPEC_MUL_WITH_FLAG))]
3193 ""
3194 "%h0 = %h1 * %h2 %M3%!"
3195 [(set_attr "type" "dsp32")])
3196
3197 (define_insn "flag_mulhi_parts"
3198 [(set (match_operand:HI 0 "register_operand" "=d")
3199 (unspec:HI [(vec_select:HI
3200 (match_operand:V2HI 1 "register_operand" "d")
3201 (parallel [(match_operand 3 "const01_operand" "P0P1")]))
3202 (vec_select:HI
3203 (match_operand:V2HI 2 "register_operand" "d")
3204 (parallel [(match_operand 4 "const01_operand" "P0P1")]))
3205 (match_operand 5 "const_int_operand" "n")]
3206 UNSPEC_MUL_WITH_FLAG))]
3207 ""
3208 {
3209 const char *templates[] = {
3210 "%h0 = %h1 * %h2 %M5%!",
3211 "%h0 = %d1 * %h2 %M5%!",
3212 "%h0 = %h1 * %d2 %M5%!",
3213 "%h0 = %d1 * %d2 %M5%!" };
3214 int alt = INTVAL (operands[3]) + (INTVAL (operands[4]) << 1);
3215 return templates[alt];
3216 }
3217 [(set_attr "type" "dsp32")])
3218
3219 (define_insn "flag_mulhisi"
3220 [(set (match_operand:SI 0 "register_operand" "=d")
3221 (unspec:SI [(match_operand:HI 1 "register_operand" "d")
3222 (match_operand:HI 2 "register_operand" "d")
3223 (match_operand 3 "const_int_operand" "n")]
3224 UNSPEC_MUL_WITH_FLAG))]
3225 ""
3226 "%0 = %h1 * %h2 %M3%!"
3227 [(set_attr "type" "dsp32")])
3228
3229 (define_insn "flag_mulhisi_parts"
3230 [(set (match_operand:SI 0 "register_operand" "=d")
3231 (unspec:SI [(vec_select:HI
3232 (match_operand:V2HI 1 "register_operand" "d")
3233 (parallel [(match_operand 3 "const01_operand" "P0P1")]))
3234 (vec_select:HI
3235 (match_operand:V2HI 2 "register_operand" "d")
3236 (parallel [(match_operand 4 "const01_operand" "P0P1")]))
3237 (match_operand 5 "const_int_operand" "n")]
3238 UNSPEC_MUL_WITH_FLAG))]
3239 ""
3240 {
3241 const char *templates[] = {
3242 "%0 = %h1 * %h2 %M5%!",
3243 "%0 = %d1 * %h2 %M5%!",
3244 "%0 = %h1 * %d2 %M5%!",
3245 "%0 = %d1 * %d2 %M5%!" };
3246 int alt = INTVAL (operands[3]) + (INTVAL (operands[4]) << 1);
3247 return templates[alt];
3248 }
3249 [(set_attr "type" "dsp32")])
3250
3251 ;; Three alternatives here to cover all possible allocations:
3252 ;; 0. mac flag is usable only for accumulator 1 - use A1 and odd DREG
3253 ;; 1. mac flag is usable for accumulator 0 - use A0 and even DREG
3254 ;; 2. mac flag is usable in any accumulator - use A1 and odd DREG
3255 ;; Other patterns which don't have a DREG destination can collapse cases
3256 ;; 1 and 2 into one.
3257 (define_insn "flag_machi"
3258 [(set (match_operand:HI 0 "register_operand" "=W,D,W")
3259 (unspec:HI [(match_operand:HI 2 "register_operand" "d,d,d")
3260 (match_operand:HI 3 "register_operand" "d,d,d")
3261 (match_operand 4 "register_operand" "1,1,1")
3262 (match_operand 5 "const01_operand" "P0P1,P0P1,P0P1")
3263 (match_operand 6 "const_int_operand" "PB,PA,PA")]
3264 UNSPEC_MAC_WITH_FLAG))
3265 (set (match_operand:PDI 1 "register_operand" "=B,A,B")
3266 (unspec:PDI [(match_dup 1) (match_dup 2) (match_dup 3)
3267 (match_dup 4) (match_dup 5)]
3268 UNSPEC_MAC_WITH_FLAG))]
3269 ""
3270 "%h0 = (%1 %b5 %h2 * %h3) %M6%!"
3271 [(set_attr "type" "dsp32")])
3272
3273 (define_insn "flag_machi_acconly"
3274 [(set (match_operand:PDI 0 "register_operand" "=B,e")
3275 (unspec:PDI [(match_operand:HI 1 "register_operand" "d,d")
3276 (match_operand:HI 2 "register_operand" "d,d")
3277 (match_operand 3 "register_operand" "0,0")
3278 (match_operand 4 "const01_operand" "P0P1,P0P1")
3279 (match_operand 5 "const_int_operand" "PB,PA")]
3280 UNSPEC_MAC_WITH_FLAG))]
3281 ""
3282 "%0 %b4 %h1 * %h2 %M5%!"
3283 [(set_attr "type" "dsp32")])
3284
3285 (define_insn "flag_machi_parts_acconly"
3286 [(set (match_operand:PDI 0 "register_operand" "=B,e")
3287 (unspec:PDI [(vec_select:HI
3288 (match_operand:V2HI 1 "register_operand" "d,d")
3289 (parallel [(match_operand 3 "const01_operand" "P0P1,P0P1")]))
3290 (vec_select:HI
3291 (match_operand:V2HI 2 "register_operand" "d,d")
3292 (parallel [(match_operand 4 "const01_operand" "P0P1,P0P1")]))
3293 (match_operand:PDI 5 "register_operand" "0,0")
3294 (match_operand 6 "const01_operand" "P0P1,P0P1")
3295 (match_operand 7 "const_int_operand" "PB,PA")]
3296 UNSPEC_MAC_WITH_FLAG))]
3297 ""
3298 {
3299 const char *templates[] = {
3300 "%0 %b6 %h1 * %h2 %M7%!",
3301 "%0 %b6 %d1 * %h2 %M7%!",
3302 "%0 %b6 %h1 * %d2 %M7%!",
3303 "%0 %b6 %d1 * %d2 %M7%!"
3304 };
3305 int alt = INTVAL (operands[3]) + (INTVAL (operands[4]) << 1);
3306 return templates[alt];
3307 }
3308 [(set_attr "type" "dsp32")])
3309
3310 (define_insn "flag_macinithi"
3311 [(set (match_operand:HI 0 "register_operand" "=W,D,W")
3312 (unspec:HI [(match_operand:HI 1 "register_operand" "d,d,d")
3313 (match_operand:HI 2 "register_operand" "d,d,d")
3314 (match_operand 3 "const_int_operand" "PB,PA,PA")]
3315 UNSPEC_MAC_WITH_FLAG))
3316 (set (match_operand:PDI 4 "register_operand" "=B,A,B")
3317 (unspec:PDI [(match_dup 1) (match_dup 2) (match_dup 3)]
3318 UNSPEC_MAC_WITH_FLAG))]
3319 ""
3320 "%h0 = (%4 = %h1 * %h2) %M3%!"
3321 [(set_attr "type" "dsp32")])
3322
3323 (define_insn "flag_macinit1hi"
3324 [(set (match_operand:PDI 0 "register_operand" "=B,e")
3325 (unspec:PDI [(match_operand:HI 1 "register_operand" "d,d")
3326 (match_operand:HI 2 "register_operand" "d,d")
3327 (match_operand 3 "const_int_operand" "PB,PA")]
3328 UNSPEC_MAC_WITH_FLAG))]
3329 ""
3330 "%0 = %h1 * %h2 %M3%!"
3331 [(set_attr "type" "dsp32")])
3332
3333 (define_insn "mulv2hi3"
3334 [(set (match_operand:V2HI 0 "register_operand" "=d")
3335 (mult:V2HI (match_operand:V2HI 1 "register_operand" "d")
3336 (match_operand:V2HI 2 "register_operand" "d")))]
3337 ""
3338 "%h0 = %h1 * %h2, %d0 = %d1 * %d2 (IS)%!"
3339 [(set_attr "type" "dsp32")])
3340
3341 (define_insn "flag_mulv2hi"
3342 [(set (match_operand:V2HI 0 "register_operand" "=d")
3343 (unspec:V2HI [(match_operand:V2HI 1 "register_operand" "d")
3344 (match_operand:V2HI 2 "register_operand" "d")
3345 (match_operand 3 "const_int_operand" "n")]
3346 UNSPEC_MUL_WITH_FLAG))]
3347 ""
3348 "%h0 = %h1 * %h2, %d0 = %d1 * %d2 %M3%!"
3349 [(set_attr "type" "dsp32")])
3350
3351 (define_insn "flag_mulv2hi_parts"
3352 [(set (match_operand:V2HI 0 "register_operand" "=d")
3353 (unspec:V2HI [(vec_concat:V2HI
3354 (vec_select:HI
3355 (match_operand:V2HI 1 "register_operand" "d")
3356 (parallel [(match_operand 3 "const01_operand" "P0P1")]))
3357 (vec_select:HI
3358 (match_dup 1)
3359 (parallel [(match_operand 4 "const01_operand" "P0P1")])))
3360 (vec_concat:V2HI
3361 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3362 (parallel [(match_operand 5 "const01_operand" "P0P1")]))
3363 (vec_select:HI (match_dup 2)
3364 (parallel [(match_operand 6 "const01_operand" "P0P1")])))
3365 (match_operand 7 "const_int_operand" "n")]
3366 UNSPEC_MUL_WITH_FLAG))]
3367 ""
3368 {
3369 const char *templates[] = {
3370 "%h0 = %h1 * %h2, %d0 = %h1 * %h2 %M7%!",
3371 "%h0 = %d1 * %h2, %d0 = %h1 * %h2 %M7%!",
3372 "%h0 = %h1 * %h2, %d0 = %d1 * %h2 %M7%!",
3373 "%h0 = %d1 * %h2, %d0 = %d1 * %h2 %M7%!",
3374 "%h0 = %h1 * %d2, %d0 = %h1 * %h2 %M7%!",
3375 "%h0 = %d1 * %d2, %d0 = %h1 * %h2 %M7%!",
3376 "%h0 = %h1 * %d2, %d0 = %d1 * %h2 %M7%!",
3377 "%h0 = %d1 * %d2, %d0 = %d1 * %h2 %M7%!",
3378 "%h0 = %h1 * %h2, %d0 = %h1 * %d2 %M7%!",
3379 "%h0 = %d1 * %h2, %d0 = %h1 * %d2 %M7%!",
3380 "%h0 = %h1 * %h2, %d0 = %d1 * %d2 %M7%!",
3381 "%h0 = %d1 * %h2, %d0 = %d1 * %d2 %M7%!",
3382 "%h0 = %h1 * %d2, %d0 = %h1 * %d2 %M7%!",
3383 "%h0 = %d1 * %d2, %d0 = %h1 * %d2 %M7%!",
3384 "%h0 = %h1 * %d2, %d0 = %d1 * %d2 %M7%!",
3385 "%h0 = %d1 * %d2, %d0 = %d1 * %d2 %M7%!" };
3386 int alt = (INTVAL (operands[3]) + (INTVAL (operands[4]) << 1)
3387 + (INTVAL (operands[5]) << 2) + (INTVAL (operands[6]) << 3));
3388 return templates[alt];
3389 }
3390 [(set_attr "type" "dsp32")])
3391
3392 ;; A slightly complicated pattern.
3393 ;; Operand 0 is the halfword output; operand 11 is the accumulator output
3394 ;; Halfword inputs are operands 1 and 2; operands 3, 4, 5 and 6 specify which
3395 ;; parts of these 2x16 bit registers to use.
3396 ;; Operand 7 is the accumulator input.
3397 ;; Operands 8/9 specify whether low/high parts are mac (0) or msu (1)
3398 ;; Operand 10 is the macflag to be used.
3399 (define_insn "flag_macv2hi_parts"
3400 [(set (match_operand:V2HI 0 "register_operand" "=d")
3401 (unspec:V2HI [(vec_concat:V2HI
3402 (vec_select:HI
3403 (match_operand:V2HI 1 "register_operand" "d")
3404 (parallel [(match_operand 3 "const01_operand" "P0P1")]))
3405 (vec_select:HI
3406 (match_dup 1)
3407 (parallel [(match_operand 4 "const01_operand" "P0P1")])))
3408 (vec_concat:V2HI
3409 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3410 (parallel [(match_operand 5 "const01_operand" "P0P1")]))
3411 (vec_select:HI (match_dup 2)
3412 (parallel [(match_operand 6 "const01_operand" "P0P1")])))
3413 (match_operand:V2PDI 7 "register_operand" "e")
3414 (match_operand 8 "const01_operand" "P0P1")
3415 (match_operand 9 "const01_operand" "P0P1")
3416 (match_operand 10 "const_int_operand" "n")]
3417 UNSPEC_MAC_WITH_FLAG))
3418 (set (match_operand:V2PDI 11 "register_operand" "=e")
3419 (unspec:V2PDI [(vec_concat:V2HI
3420 (vec_select:HI (match_dup 1) (parallel [(match_dup 3)]))
3421 (vec_select:HI (match_dup 1) (parallel [(match_dup 4)])))
3422 (vec_concat:V2HI
3423 (vec_select:HI (match_dup 2) (parallel [(match_dup 5)]))
3424 (vec_select:HI (match_dup 2) (parallel [(match_dup 5)])))
3425 (match_dup 7) (match_dup 8) (match_dup 9) (match_dup 10)]
3426 UNSPEC_MAC_WITH_FLAG))]
3427 ""
3428 {
3429 const char *templates[] = {
3430 "%h0 = (A0 %b8 %h1 * %h2), %d0 = (A1 %b9 %h1 * %h2) %M10%!",
3431 "%h0 = (A0 %b8 %d1 * %h2), %d0 = (A1 %b9 %h1 * %h2) %M10%!",
3432 "%h0 = (A0 %b8 %h1 * %h2), %d0 = (A1 %b9 %d1 * %h2) %M10%!",
3433 "%h0 = (A0 %b8 %d1 * %h2), %d0 = (A1 %b9 %d1 * %h2) %M10%!",
3434 "%h0 = (A0 %b8 %h1 * %d2), %d0 = (A1 %b9 %h1 * %h2) %M10%!",
3435 "%h0 = (A0 %b8 %d1 * %d2), %d0 = (A1 %b9 %h1 * %h2) %M10%!",
3436 "%h0 = (A0 %b8 %h1 * %d2), %d0 = (A1 %b9 %d1 * %h2) %M10%!",
3437 "%h0 = (A0 %b8 %d1 * %d2), %d0 = (A1 %b9 %d1 * %h2) %M10%!",
3438 "%h0 = (A0 %b8 %h1 * %h2), %d0 = (A1 %b9 %h1 * %d2) %M10%!",
3439 "%h0 = (A0 %b8 %d1 * %h2), %d0 = (A1 %b9 %h1 * %d2) %M10%!",
3440 "%h0 = (A0 %b8 %h1 * %h2), %d0 = (A1 %b9 %d1 * %d2) %M10%!",
3441 "%h0 = (A0 %b8 %d1 * %h2), %d0 = (A1 %b9 %d1 * %d2) %M10%!",
3442 "%h0 = (A0 %b8 %h1 * %d2), %d0 = (A1 %b9 %h1 * %d2) %M10%!",
3443 "%h0 = (A0 %b8 %d1 * %d2), %d0 = (A1 %b9 %h1 * %d2) %M10%!",
3444 "%h0 = (A0 %b8 %h1 * %d2), %d0 = (A1 %b9 %d1 * %d2) %M10%!",
3445 "%h0 = (A0 %b8 %d1 * %d2), %d0 = (A1 %b9 %d1 * %d2) %M10%!" };
3446 int alt = (INTVAL (operands[3]) + (INTVAL (operands[4]) << 1)
3447 + (INTVAL (operands[5]) << 2) + (INTVAL (operands[6]) << 3));
3448 return templates[alt];
3449 }
3450 [(set_attr "type" "dsp32")])
3451
3452 (define_insn "flag_macv2hi_parts_acconly"
3453 [(set (match_operand:V2PDI 0 "register_operand" "=e")
3454 (unspec:V2PDI [(vec_concat:V2HI
3455 (vec_select:HI
3456 (match_operand:V2HI 1 "register_operand" "d")
3457 (parallel [(match_operand 3 "const01_operand" "P0P1")]))
3458 (vec_select:HI
3459 (match_dup 1)
3460 (parallel [(match_operand 4 "const01_operand" "P0P1")])))
3461 (vec_concat:V2HI
3462 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3463 (parallel [(match_operand 5 "const01_operand" "P0P1")]))
3464 (vec_select:HI (match_dup 2)
3465 (parallel [(match_operand 6 "const01_operand" "P0P1")])))
3466 (match_operand:V2PDI 7 "register_operand" "e")
3467 (match_operand 8 "const01_operand" "P0P1")
3468 (match_operand 9 "const01_operand" "P0P1")
3469 (match_operand 10 "const_int_operand" "n")]
3470 UNSPEC_MAC_WITH_FLAG))]
3471 ""
3472 {
3473 const char *templates[] = {
3474 "A0 %b8 %h1 * %h2, A1 %b9 %h1 * %h2 %M10%!",
3475 "A0 %b8 %d1 * %h2, A1 %b9 %h1 * %h2 %M10%!",
3476 "A0 %b8 %h1 * %h2, A1 %b9 %d1 * %h2 %M10%!",
3477 "A0 %b8 %d1 * %h2, A1 %b9 %d1 * %h2 %M10%!",
3478 "A0 %b8 %h1 * %d2, A1 %b9 %h1 * %h2 %M10%!",
3479 "A0 %b8 %d1 * %d2, A1 %b9 %h1 * %h2 %M10%!",
3480 "A0 %b8 %h1 * %d2, A1 %b9 %d1 * %h2 %M10%!",
3481 "A0 %b8 %d1 * %d2, A1 %b9 %d1 * %h2 %M10%!",
3482 "A0 %b8 %h1 * %h2, A1 %b9 %h1 * %d2 %M10%!",
3483 "A0 %b8 %d1 * %h2, A1 %b9 %h1 * %d2 %M10%!",
3484 "A0 %b8 %h1 * %h2, A1 %b9 %d1 * %d2 %M10%!",
3485 "A0 %b8 %d1 * %h2, A1 %b9 %d1 * %d2 %M10%!",
3486 "A0 %b8 %h1 * %d2, A1 %b9 %h1 * %d2 %M10%!",
3487 "A0 %b8 %d1 * %d2, A1 %b9 %h1 * %d2 %M10%!",
3488 "A0 %b8 %h1 * %d2, A1 %b9 %d1 * %d2 %M10%!",
3489 "A0 %b8 %d1 * %d2, A1 %b9 %d1 * %d2 %M10%!" };
3490 int alt = (INTVAL (operands[3]) + (INTVAL (operands[4]) << 1)
3491 + (INTVAL (operands[5]) << 2) + (INTVAL (operands[6]) << 3));
3492 return templates[alt];
3493 }
3494 [(set_attr "type" "dsp32")])
3495
3496 ;; Same as above, but initializing the accumulators and therefore a couple fewer
3497 ;; necessary operands.
3498 (define_insn "flag_macinitv2hi_parts"
3499 [(set (match_operand:V2HI 0 "register_operand" "=d")
3500 (unspec:V2HI [(vec_concat:V2HI
3501 (vec_select:HI
3502 (match_operand:V2HI 1 "register_operand" "d")
3503 (parallel [(match_operand 3 "const01_operand" "P0P1")]))
3504 (vec_select:HI
3505 (match_dup 1)
3506 (parallel [(match_operand 4 "const01_operand" "P0P1")])))
3507 (vec_concat:V2HI
3508 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3509 (parallel [(match_operand 5 "const01_operand" "P0P1")]))
3510 (vec_select:HI (match_dup 2)
3511 (parallel [(match_operand 6 "const01_operand" "P0P1")])))
3512 (match_operand 7 "const_int_operand" "n")]
3513 UNSPEC_MAC_WITH_FLAG))
3514 (set (match_operand:V2PDI 8 "register_operand" "=e")
3515 (unspec:V2PDI [(vec_concat:V2HI
3516 (vec_select:HI (match_dup 1) (parallel [(match_dup 3)]))
3517 (vec_select:HI (match_dup 1) (parallel [(match_dup 4)])))
3518 (vec_concat:V2HI
3519 (vec_select:HI (match_dup 2) (parallel [(match_dup 5)]))
3520 (vec_select:HI (match_dup 2) (parallel [(match_dup 5)])))
3521 (match_dup 7)]
3522 UNSPEC_MAC_WITH_FLAG))]
3523 ""
3524 {
3525 const char *templates[] = {
3526 "%h0 = (A0 = %h1 * %h2), %d0 = (A1 = %h1 * %h2) %M7%!",
3527 "%h0 = (A0 = %d1 * %h2), %d0 = (A1 = %h1 * %h2) %M7%!",
3528 "%h0 = (A0 = %h1 * %h2), %d0 = (A1 = %d1 * %h2) %M7%!",
3529 "%h0 = (A0 = %d1 * %h2), %d0 = (A1 = %d1 * %h2) %M7%!",
3530 "%h0 = (A0 = %h1 * %d2), %d0 = (A1 = %h1 * %h2) %M7%!",
3531 "%h0 = (A0 = %d1 * %d2), %d0 = (A1 = %h1 * %h2) %M7%!",
3532 "%h0 = (A0 = %h1 * %d2), %d0 = (A1 = %d1 * %h2) %M7%!",
3533 "%h0 = (A0 = %d1 * %d2), %d0 = (A1 = %d1 * %h2) %M7%!",
3534 "%h0 = (A0 = %h1 * %h2), %d0 = (A1 = %h1 * %d2) %M7%!",
3535 "%h0 = (A0 = %d1 * %h2), %d0 = (A1 = %h1 * %d2) %M7%!",
3536 "%h0 = (A0 = %h1 * %h2), %d0 = (A1 = %d1 * %d2) %M7%!",
3537 "%h0 = (A0 = %d1 * %h2), %d0 = (A1 = %d1 * %d2) %M7%!",
3538 "%h0 = (A0 = %h1 * %d2), %d0 = (A1 = %h1 * %d2) %M7%!",
3539 "%h0 = (A0 = %d1 * %d2), %d0 = (A1 = %h1 * %d2) %M7%!",
3540 "%h0 = (A0 = %h1 * %d2), %d0 = (A1 = %d1 * %d2) %M7%!",
3541 "%h0 = (A0 = %d1 * %d2), %d0 = (A1 = %d1 * %d2) %M7%!" };
3542 int alt = (INTVAL (operands[3]) + (INTVAL (operands[4]) << 1)
3543 + (INTVAL (operands[5]) << 2) + (INTVAL (operands[6]) << 3));
3544 return templates[alt];
3545 }
3546 [(set_attr "type" "dsp32")])
3547
3548 (define_insn "flag_macinit1v2hi_parts"
3549 [(set (match_operand:V2PDI 0 "register_operand" "=e")
3550 (unspec:V2PDI [(vec_concat:V2HI
3551 (vec_select:HI
3552 (match_operand:V2HI 1 "register_operand" "d")
3553 (parallel [(match_operand 3 "const01_operand" "P0P1")]))
3554 (vec_select:HI
3555 (match_dup 1)
3556 (parallel [(match_operand 4 "const01_operand" "P0P1")])))
3557 (vec_concat:V2HI
3558 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3559 (parallel [(match_operand 5 "const01_operand" "P0P1")]))
3560 (vec_select:HI (match_dup 2)
3561 (parallel [(match_operand 6 "const01_operand" "P0P1")])))
3562 (match_operand 7 "const_int_operand" "n")]
3563 UNSPEC_MAC_WITH_FLAG))]
3564 ""
3565 {
3566 const char *templates[] = {
3567 "A0 = %h1 * %h2, A1 = %h1 * %h2 %M7%!",
3568 "A0 = %d1 * %h2, A1 = %h1 * %h2 %M7%!",
3569 "A0 = %h1 * %h2, A1 = %d1 * %h2 %M7%!",
3570 "A0 = %d1 * %h2, A1 = %d1 * %h2 %M7%!",
3571 "A0 = %h1 * %d2, A1 = %h1 * %h2 %M7%!",
3572 "A0 = %d1 * %d2, A1 = %h1 * %h2 %M7%!",
3573 "A0 = %h1 * %d2, A1 = %d1 * %h2 %M7%!",
3574 "A0 = %d1 * %d2, A1 = %d1 * %h2 %M7%!",
3575 "A0 = %h1 * %h2, A1 = %h1 * %d2 %M7%!",
3576 "A0 = %d1 * %h2, A1 = %h1 * %d2 %M7%!",
3577 "A0 = %h1 * %h2, A1 = %d1 * %d2 %M7%!",
3578 "A0 = %d1 * %h2, A1 = %d1 * %d2 %M7%!",
3579 "A0 = %h1 * %d2, A1 = %h1 * %d2 %M7%!",
3580 "A0 = %d1 * %d2, A1 = %h1 * %d2 %M7%!",
3581 "A0 = %h1 * %d2, A1 = %d1 * %d2 %M7%!",
3582 "A0 = %d1 * %d2, A1 = %d1 * %d2 %M7%!" };
3583 int alt = (INTVAL (operands[3]) + (INTVAL (operands[4]) << 1)
3584 + (INTVAL (operands[5]) << 2) + (INTVAL (operands[6]) << 3));
3585 return templates[alt];
3586 }
3587 [(set_attr "type" "dsp32")])
3588
3589 ;; A mixture of multiply and multiply-accumulate for when we only want to
3590 ;; initialize one part.
3591 (define_insn "flag_mul_macv2hi_parts_acconly"
3592 [(set (match_operand:PDI 0 "register_operand" "=B,e,e")
3593 (unspec:PDI [(vec_select:HI
3594 (match_operand:V2HI 2 "register_operand" "d,d,d")
3595 (parallel [(match_operand 4 "const01_operand" "P0P1,P0P1,P0P1")]))
3596 (vec_select:HI
3597 (match_operand:V2HI 3 "register_operand" "d,d,d")
3598 (parallel [(match_operand 6 "const01_operand" "P0P1,P0P1,P0P1")]))
3599 (match_operand 10 "const_int_operand" "PB,PA,PA")]
3600 UNSPEC_MUL_WITH_FLAG))
3601 (set (match_operand:PDI 1 "register_operand" "=B,e,e")
3602 (unspec:PDI [(vec_select:HI
3603 (match_dup 2)
3604 (parallel [(match_operand 5 "const01_operand" "P0P1,P0P1,P0P1")]))
3605 (vec_select:HI
3606 (match_dup 3)
3607 (parallel [(match_operand 7 "const01_operand" "P0P1,P0P1,P0P1")]))
3608 (match_operand:PDI 8 "register_operand" "1,1,1")
3609 (match_operand 9 "const01_operand" "P0P1,P0P1,P0P1")
3610 (match_operand 11 "const_int_operand" "PA,PB,PA")]
3611 UNSPEC_MAC_WITH_FLAG))]
3612 "MACFLAGS_MATCH_P (INTVAL (operands[10]), INTVAL (operands[11]))"
3613 {
3614 rtx xops[6];
3615 const char *templates[] = {
3616 "%0 = %h2 * %h3, %1 %b4 %h2 * %h3 %M5%!",
3617 "%0 = %d2 * %h3, %1 %b4 %h2 * %h3 %M5%!",
3618 "%0 = %h2 * %h3, %1 %b4 %d2 * %h3 %M5%!",
3619 "%0 = %d2 * %h3, %1 %b4 %d2 * %h3 %M5%!",
3620 "%0 = %h2 * %d3, %1 %b4 %h2 * %h3 %M5%!",
3621 "%0 = %d2 * %d3, %1 %b4 %h2 * %h3 %M5%!",
3622 "%0 = %h2 * %d3, %1 %b4 %d2 * %h3 %M5%!",
3623 "%0 = %d2 * %d3, %1 %b4 %d2 * %h3 %M5%!",
3624 "%0 = %h2 * %h3, %1 %b4 %h2 * %d3 %M5%!",
3625 "%0 = %d2 * %h3, %1 %b4 %h2 * %d3 %M5%!",
3626 "%0 = %h2 * %h3, %1 %b4 %d2 * %d3 %M5%!",
3627 "%0 = %d2 * %h3, %1 %b4 %d2 * %d3 %M5%!",
3628 "%0 = %h2 * %d3, %1 %b4 %h2 * %d3 %M5%!",
3629 "%0 = %d2 * %d3, %1 %b4 %h2 * %d3 %M5%!",
3630 "%0 = %h2 * %d3, %1 %b4 %d2 * %d3 %M5%!",
3631 "%0 = %d2 * %d3, %1 %b4 %d2 * %d3 %M5%!" };
3632 int alt = (INTVAL (operands[4]) + (INTVAL (operands[5]) << 1)
3633 + (INTVAL (operands[6]) << 2) + (INTVAL (operands[7]) << 3));
3634 xops[0] = operands[0];
3635 xops[1] = operands[1];
3636 xops[2] = operands[2];
3637 xops[3] = operands[3];
3638 xops[4] = operands[9];
3639 xops[5] = which_alternative == 0 ? operands[10] : operands[11];
3640 output_asm_insn (templates[alt], xops);
3641 return "";
3642 }
3643 [(set_attr "type" "dsp32")])
3644
3645
3646 (define_code_iterator s_or_u [sign_extend zero_extend])
3647 (define_code_attr su_optab [(sign_extend "mul")
3648 (zero_extend "umul")])
3649 (define_code_attr su_modifier [(sign_extend "IS")
3650 (zero_extend "FU")])
3651
3652 (define_insn "<su_optab>hisi_ll"
3653 [(set (match_operand:SI 0 "register_operand" "=d")
3654 (mult:SI (s_or_u:SI
3655 (vec_select:HI (match_operand:V2HI 1 "register_operand" "%d")
3656 (parallel [(const_int 0)])))
3657 (s_or_u:SI
3658 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3659 (parallel [(const_int 0)])))))]
3660 ""
3661 "%0 = %h1 * %h2 (<su_modifier>)%!"
3662 [(set_attr "type" "dsp32")])
3663
3664 (define_insn "<su_optab>hisi_lh"
3665 [(set (match_operand:SI 0 "register_operand" "=d")
3666 (mult:SI (s_or_u:SI
3667 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3668 (parallel [(const_int 0)])))
3669 (s_or_u:SI
3670 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3671 (parallel [(const_int 1)])))))]
3672 ""
3673 "%0 = %h1 * %d2 (<su_modifier>)%!"
3674 [(set_attr "type" "dsp32")])
3675
3676 (define_insn "<su_optab>hisi_hl"
3677 [(set (match_operand:SI 0 "register_operand" "=d")
3678 (mult:SI (s_or_u:SI
3679 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3680 (parallel [(const_int 1)])))
3681 (s_or_u:SI
3682 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3683 (parallel [(const_int 0)])))))]
3684 ""
3685 "%0 = %d1 * %h2 (<su_modifier>)%!"
3686 [(set_attr "type" "dsp32")])
3687
3688 (define_insn "<su_optab>hisi_hh"
3689 [(set (match_operand:SI 0 "register_operand" "=d")
3690 (mult:SI (s_or_u:SI
3691 (vec_select:HI (match_operand:V2HI 1 "register_operand" "%d")
3692 (parallel [(const_int 1)])))
3693 (s_or_u:SI
3694 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3695 (parallel [(const_int 1)])))))]
3696 ""
3697 "%0 = %d1 * %d2 (<su_modifier>)%!"
3698 [(set_attr "type" "dsp32")])
3699
3700 ;; Additional variants for signed * unsigned multiply.
3701
3702 (define_insn "usmulhisi_ull"
3703 [(set (match_operand:SI 0 "register_operand" "=W")
3704 (mult:SI (zero_extend:SI
3705 (vec_select:HI (match_operand:V2HI 1 "register_operand" "%d")
3706 (parallel [(const_int 0)])))
3707 (sign_extend:SI
3708 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3709 (parallel [(const_int 0)])))))]
3710 ""
3711 "%0 = %h2 * %h1 (IS,M)%!"
3712 [(set_attr "type" "dsp32")])
3713
3714 (define_insn "usmulhisi_ulh"
3715 [(set (match_operand:SI 0 "register_operand" "=W")
3716 (mult:SI (zero_extend:SI
3717 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3718 (parallel [(const_int 0)])))
3719 (sign_extend:SI
3720 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3721 (parallel [(const_int 1)])))))]
3722 ""
3723 "%0 = %d2 * %h1 (IS,M)%!"
3724 [(set_attr "type" "dsp32")])
3725
3726 (define_insn "usmulhisi_uhl"
3727 [(set (match_operand:SI 0 "register_operand" "=W")
3728 (mult:SI (zero_extend:SI
3729 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d")
3730 (parallel [(const_int 1)])))
3731 (sign_extend:SI
3732 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3733 (parallel [(const_int 0)])))))]
3734 ""
3735 "%0 = %h2 * %d1 (IS,M)%!"
3736 [(set_attr "type" "dsp32")])
3737
3738 (define_insn "usmulhisi_uhh"
3739 [(set (match_operand:SI 0 "register_operand" "=W")
3740 (mult:SI (zero_extend:SI
3741 (vec_select:HI (match_operand:V2HI 1 "register_operand" "%d")
3742 (parallel [(const_int 1)])))
3743 (sign_extend:SI
3744 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d")
3745 (parallel [(const_int 1)])))))]
3746 ""
3747 "%0 = %d2 * %d1 (IS,M)%!"
3748 [(set_attr "type" "dsp32")])
3749
3750 ;; Parallel versions of these operations. First, normal signed or unsigned
3751 ;; multiplies.
3752
3753 (define_insn "<su_optab>hisi_ll_lh"
3754 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3755 (mult:SI (s_or_u:SI
3756 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3757 (parallel [(const_int 0)])))
3758 (s_or_u:SI
3759 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
3760 (parallel [(const_int 0)])))))
3761 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
3762 (mult:SI (s_or_u:SI
3763 (vec_select:HI (match_dup 1) (parallel [(const_int 0)])))
3764 (s_or_u:SI
3765 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
3766 ""
3767 "%0 = %h1 * %h2, %3 = %h1 * %d2 (<su_modifier>)%!"
3768 [(set_attr "type" "dsp32")])
3769
3770 (define_insn "<su_optab>hisi_ll_hl"
3771 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3772 (mult:SI (s_or_u:SI
3773 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3774 (parallel [(const_int 0)])))
3775 (s_or_u:SI
3776 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
3777 (parallel [(const_int 0)])))))
3778 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
3779 (mult:SI (s_or_u:SI
3780 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
3781 (s_or_u:SI
3782 (vec_select:HI (match_dup 2) (parallel [(const_int 0)])))))]
3783 ""
3784 "%0 = %h1 * %h2, %3 = %d1 * %h2 (<su_modifier>)%!"
3785 [(set_attr "type" "dsp32")])
3786
3787 (define_insn "<su_optab>hisi_ll_hh"
3788 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3789 (mult:SI (s_or_u:SI
3790 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3791 (parallel [(const_int 0)])))
3792 (s_or_u:SI
3793 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
3794 (parallel [(const_int 0)])))))
3795 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
3796 (mult:SI (s_or_u:SI
3797 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
3798 (s_or_u:SI
3799 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
3800 ""
3801 "%0 = %h1 * %h2, %3 = %d1 * %d2 (<su_modifier>)%!"
3802 [(set_attr "type" "dsp32")])
3803
3804 (define_insn "<su_optab>hisi_lh_hl"
3805 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3806 (mult:SI (s_or_u:SI
3807 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3808 (parallel [(const_int 0)])))
3809 (s_or_u:SI
3810 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
3811 (parallel [(const_int 1)])))))
3812 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
3813 (mult:SI (s_or_u:SI
3814 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
3815 (s_or_u:SI
3816 (vec_select:HI (match_dup 2) (parallel [(const_int 0)])))))]
3817 ""
3818 "%0 = %h1 * %d2, %3 = %d1 * %h2 (<su_modifier>)%!"
3819 [(set_attr "type" "dsp32")])
3820
3821 (define_insn "<su_optab>hisi_lh_hh"
3822 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3823 (mult:SI (s_or_u:SI
3824 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3825 (parallel [(const_int 0)])))
3826 (s_or_u:SI
3827 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
3828 (parallel [(const_int 1)])))))
3829 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
3830 (mult:SI (s_or_u:SI
3831 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
3832 (s_or_u:SI
3833 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
3834 ""
3835 "%0 = %h1 * %d2, %3 = %d1 * %d2 (<su_modifier>)%!"
3836 [(set_attr "type" "dsp32")])
3837
3838 (define_insn "<su_optab>hisi_hl_hh"
3839 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3840 (mult:SI (s_or_u:SI
3841 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3842 (parallel [(const_int 1)])))
3843 (s_or_u:SI
3844 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
3845 (parallel [(const_int 0)])))))
3846 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
3847 (mult:SI (s_or_u:SI
3848 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
3849 (s_or_u:SI
3850 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
3851 ""
3852 "%0 = %d1 * %h2, %3 = %d1 * %d2 (<su_modifier>)%!"
3853 [(set_attr "type" "dsp32")])
3854
3855 ;; Special signed * unsigned variants.
3856
3857 (define_insn "usmulhisi_ll_lul"
3858 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3859 (mult:SI (sign_extend:SI
3860 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3861 (parallel [(const_int 0)])))
3862 (sign_extend:SI
3863 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
3864 (parallel [(const_int 0)])))))
3865 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
3866 (mult:SI (sign_extend:SI
3867 (vec_select:HI (match_dup 1) (parallel [(const_int 0)])))
3868 (zero_extend:SI
3869 (vec_select:HI (match_dup 2) (parallel [(const_int 0)])))))]
3870 ""
3871 "%0 = %h1 * %h2, %3 = %h1 * %h2 (IS,M)%!"
3872 [(set_attr "type" "dsp32")])
3873
3874 (define_insn "usmulhisi_ll_luh"
3875 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3876 (mult:SI (sign_extend:SI
3877 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3878 (parallel [(const_int 0)])))
3879 (sign_extend:SI
3880 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
3881 (parallel [(const_int 0)])))))
3882 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
3883 (mult:SI (sign_extend:SI
3884 (vec_select:HI (match_dup 1) (parallel [(const_int 0)])))
3885 (zero_extend:SI
3886 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
3887 ""
3888 "%0 = %h1 * %h2, %3 = %h1 * %d2 (IS,M)%!"
3889 [(set_attr "type" "dsp32")])
3890
3891 (define_insn "usmulhisi_ll_hul"
3892 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3893 (mult:SI (sign_extend:SI
3894 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3895 (parallel [(const_int 0)])))
3896 (sign_extend:SI
3897 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
3898 (parallel [(const_int 0)])))))
3899 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
3900 (mult:SI (sign_extend:SI
3901 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
3902 (zero_extend:SI
3903 (vec_select:HI (match_dup 2) (parallel [(const_int 0)])))))]
3904 ""
3905 "%0 = %h1 * %h2, %3 = %d1 * %h2 (IS,M)%!"
3906 [(set_attr "type" "dsp32")])
3907
3908 (define_insn "usmulhisi_ll_huh"
3909 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3910 (mult:SI (sign_extend:SI
3911 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3912 (parallel [(const_int 0)])))
3913 (sign_extend:SI
3914 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
3915 (parallel [(const_int 0)])))))
3916 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
3917 (mult:SI (sign_extend:SI
3918 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
3919 (zero_extend:SI
3920 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
3921 ""
3922 "%0 = %h1 * %h2, %3 = %d1 * %d2 (IS,M)%!"
3923 [(set_attr "type" "dsp32")])
3924
3925 (define_insn "usmulhisi_lh_lul"
3926 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3927 (mult:SI (sign_extend:SI
3928 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3929 (parallel [(const_int 0)])))
3930 (sign_extend:SI
3931 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
3932 (parallel [(const_int 1)])))))
3933 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
3934 (mult:SI (sign_extend:SI
3935 (vec_select:HI (match_dup 1) (parallel [(const_int 0)])))
3936 (zero_extend:SI
3937 (vec_select:HI (match_dup 2) (parallel [(const_int 0)])))))]
3938 ""
3939 "%0 = %h1 * %d2, %3 = %h1 * %h2 (IS,M)%!"
3940 [(set_attr "type" "dsp32")])
3941
3942 (define_insn "usmulhisi_lh_luh"
3943 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3944 (mult:SI (sign_extend:SI
3945 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3946 (parallel [(const_int 0)])))
3947 (sign_extend:SI
3948 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
3949 (parallel [(const_int 1)])))))
3950 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
3951 (mult:SI (sign_extend:SI
3952 (vec_select:HI (match_dup 1) (parallel [(const_int 0)])))
3953 (zero_extend:SI
3954 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
3955 ""
3956 "%0 = %h1 * %d2, %3 = %h1 * %d2 (IS,M)%!"
3957 [(set_attr "type" "dsp32")])
3958
3959 (define_insn "usmulhisi_lh_hul"
3960 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3961 (mult:SI (sign_extend:SI
3962 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3963 (parallel [(const_int 0)])))
3964 (sign_extend:SI
3965 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
3966 (parallel [(const_int 1)])))))
3967 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
3968 (mult:SI (sign_extend:SI
3969 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
3970 (zero_extend:SI
3971 (vec_select:HI (match_dup 2) (parallel [(const_int 0)])))))]
3972 ""
3973 "%0 = %h1 * %d2, %3 = %d1 * %h2 (IS,M)%!"
3974 [(set_attr "type" "dsp32")])
3975
3976 (define_insn "usmulhisi_lh_huh"
3977 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3978 (mult:SI (sign_extend:SI
3979 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3980 (parallel [(const_int 0)])))
3981 (sign_extend:SI
3982 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
3983 (parallel [(const_int 1)])))))
3984 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
3985 (mult:SI (sign_extend:SI
3986 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
3987 (zero_extend:SI
3988 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
3989 ""
3990 "%0 = %h1 * %d2, %3 = %d1 * %d2 (IS,M)%!"
3991 [(set_attr "type" "dsp32")])
3992
3993 (define_insn "usmulhisi_hl_lul"
3994 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
3995 (mult:SI (sign_extend:SI
3996 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
3997 (parallel [(const_int 1)])))
3998 (sign_extend:SI
3999 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
4000 (parallel [(const_int 0)])))))
4001 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
4002 (mult:SI (sign_extend:SI
4003 (vec_select:HI (match_dup 1) (parallel [(const_int 0)])))
4004 (zero_extend:SI
4005 (vec_select:HI (match_dup 2) (parallel [(const_int 0)])))))]
4006 ""
4007 "%0 = %d1 * %h2, %3 = %h1 * %h2 (IS,M)%!"
4008 [(set_attr "type" "dsp32")])
4009
4010 (define_insn "usmulhisi_hl_luh"
4011 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
4012 (mult:SI (sign_extend:SI
4013 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
4014 (parallel [(const_int 1)])))
4015 (sign_extend:SI
4016 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
4017 (parallel [(const_int 0)])))))
4018 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
4019 (mult:SI (sign_extend:SI
4020 (vec_select:HI (match_dup 1) (parallel [(const_int 0)])))
4021 (zero_extend:SI
4022 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
4023 ""
4024 "%0 = %d1 * %h2, %3 = %h1 * %d2 (IS,M)%!"
4025 [(set_attr "type" "dsp32")])
4026
4027 (define_insn "usmulhisi_hl_hul"
4028 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
4029 (mult:SI (sign_extend:SI
4030 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
4031 (parallel [(const_int 1)])))
4032 (sign_extend:SI
4033 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
4034 (parallel [(const_int 0)])))))
4035 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
4036 (mult:SI (sign_extend:SI
4037 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
4038 (zero_extend:SI
4039 (vec_select:HI (match_dup 2) (parallel [(const_int 0)])))))]
4040 ""
4041 "%0 = %d1 * %h2, %3 = %d1 * %h2 (IS,M)%!"
4042 [(set_attr "type" "dsp32")])
4043
4044 (define_insn "usmulhisi_hl_huh"
4045 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
4046 (mult:SI (sign_extend:SI
4047 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
4048 (parallel [(const_int 1)])))
4049 (sign_extend:SI
4050 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
4051 (parallel [(const_int 0)])))))
4052 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
4053 (mult:SI (sign_extend:SI
4054 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
4055 (zero_extend:SI
4056 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
4057 ""
4058 "%0 = %d1 * %h2, %3 = %d1 * %d2 (IS,M)%!"
4059 [(set_attr "type" "dsp32")])
4060
4061 (define_insn "usmulhisi_hh_lul"
4062 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
4063 (mult:SI (sign_extend:SI
4064 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
4065 (parallel [(const_int 1)])))
4066 (sign_extend:SI
4067 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
4068 (parallel [(const_int 1)])))))
4069 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
4070 (mult:SI (sign_extend:SI
4071 (vec_select:HI (match_dup 1) (parallel [(const_int 0)])))
4072 (zero_extend:SI
4073 (vec_select:HI (match_dup 2) (parallel [(const_int 0)])))))]
4074 ""
4075 "%0 = %d1 * %d2, %3 = %h1 * %h2 (IS,M)%!"
4076 [(set_attr "type" "dsp32")])
4077
4078 (define_insn "usmulhisi_hh_luh"
4079 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
4080 (mult:SI (sign_extend:SI
4081 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
4082 (parallel [(const_int 1)])))
4083 (sign_extend:SI
4084 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
4085 (parallel [(const_int 1)])))))
4086 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
4087 (mult:SI (sign_extend:SI
4088 (vec_select:HI (match_dup 1) (parallel [(const_int 0)])))
4089 (zero_extend:SI
4090 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
4091 ""
4092 "%0 = %d1 * %d2, %3 = %h1 * %d2 (IS,M)%!"
4093 [(set_attr "type" "dsp32")])
4094
4095 (define_insn "usmulhisi_hh_hul"
4096 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
4097 (mult:SI (sign_extend:SI
4098 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
4099 (parallel [(const_int 1)])))
4100 (sign_extend:SI
4101 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
4102 (parallel [(const_int 1)])))))
4103 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
4104 (mult:SI (sign_extend:SI
4105 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
4106 (zero_extend:SI
4107 (vec_select:HI (match_dup 2) (parallel [(const_int 0)])))))]
4108 ""
4109 "%0 = %d1 * %d2, %3 = %d1 * %h2 (IS,M)%!"
4110 [(set_attr "type" "dsp32")])
4111
4112 (define_insn "usmulhisi_hh_huh"
4113 [(set (match_operand:SI 0 "register_operand" "=q0,q2,q4,q6")
4114 (mult:SI (sign_extend:SI
4115 (vec_select:HI (match_operand:V2HI 1 "register_operand" "d,d,d,d")
4116 (parallel [(const_int 1)])))
4117 (sign_extend:SI
4118 (vec_select:HI (match_operand:V2HI 2 "register_operand" "d,d,d,d")
4119 (parallel [(const_int 1)])))))
4120 (set (match_operand:SI 3 "register_operand" "=q1,q3,q5,q7")
4121 (mult:SI (sign_extend:SI
4122 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
4123 (zero_extend:SI
4124 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))))]
4125 ""
4126 "%0 = %d1 * %d2, %3 = %d1 * %d2 (IS,M)%!"
4127 [(set_attr "type" "dsp32")])
4128
4129 ;; Vector neg/abs.
4130
4131 (define_insn "ssnegv2hi2"
4132 [(set (match_operand:V2HI 0 "register_operand" "=d")
4133 (ss_neg:V2HI (match_operand:V2HI 1 "register_operand" "d")))]
4134 ""
4135 "%0 = - %1 (V)%!"
4136 [(set_attr "type" "dsp32")])
4137
4138 (define_insn "ssabsv2hi2"
4139 [(set (match_operand:V2HI 0 "register_operand" "=d")
4140 (ss_abs:V2HI (match_operand:V2HI 1 "register_operand" "d")))]
4141 ""
4142 "%0 = ABS %1 (V)%!"
4143 [(set_attr "type" "dsp32")])
4144
4145 ;; Shifts.
4146
4147 (define_insn "ssashiftv2hi3"
4148 [(set (match_operand:V2HI 0 "register_operand" "=d,d,d")
4149 (if_then_else:V2HI
4150 (lt (match_operand:HI 2 "vec_shift_operand" "d,Ku4,Ks4") (const_int 0))
4151 (ashiftrt:V2HI (match_operand:V2HI 1 "register_operand" "d,d,d")
4152 (match_dup 2))
4153 (ss_ashift:V2HI (match_dup 1) (match_dup 2))))]
4154 ""
4155 "@
4156 %0 = ASHIFT %1 BY %h2 (V, S)%!
4157 %0 = %1 << %2 (V,S)%!
4158 %0 = %1 >>> %N2 (V,S)%!"
4159 [(set_attr "type" "dsp32,dsp32shiftimm,dsp32shiftimm")])
4160
4161 (define_insn "ssashifthi3"
4162 [(set (match_operand:HI 0 "register_operand" "=d,d,d")
4163 (if_then_else:HI
4164 (lt (match_operand:HI 2 "vec_shift_operand" "d,Ku4,Ks4") (const_int 0))
4165 (ashiftrt:HI (match_operand:HI 1 "register_operand" "d,d,d")
4166 (match_dup 2))
4167 (ss_ashift:HI (match_dup 1) (match_dup 2))))]
4168 ""
4169 "@
4170 %0 = ASHIFT %1 BY %h2 (V, S)%!
4171 %0 = %1 << %2 (V,S)%!
4172 %0 = %1 >>> %N2 (V,S)%!"
4173 [(set_attr "type" "dsp32,dsp32shiftimm,dsp32shiftimm")])
4174
4175 (define_insn "ssashiftsi3"
4176 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
4177 (if_then_else:SI
4178 (lt (match_operand:HI 2 "reg_or_const_int_operand" "d,Ku5,Ks5") (const_int 0))
4179 (ashiftrt:SI (match_operand:HI 1 "register_operand" "d,d,d")
4180 (match_dup 2))
4181 (ss_ashift:SI (match_dup 1) (match_dup 2))))]
4182 ""
4183 "@
4184 %0 = ASHIFT %1 BY %h2 (S)%!
4185 %0 = %1 << %2 (S)%!
4186 %0 = %1 >>> %N2 (S)%!"
4187 [(set_attr "type" "dsp32,dsp32shiftimm,dsp32shiftimm")])
4188
4189 (define_insn "lshiftv2hi3"
4190 [(set (match_operand:V2HI 0 "register_operand" "=d,d,d")
4191 (if_then_else:V2HI
4192 (lt (match_operand:HI 2 "vec_shift_operand" "d,Ku4,Ks4") (const_int 0))
4193 (lshiftrt:V2HI (match_operand:V2HI 1 "register_operand" "d,d,d")
4194 (match_dup 2))
4195 (ashift:V2HI (match_dup 1) (match_dup 2))))]
4196 ""
4197 "@
4198 %0 = LSHIFT %1 BY %h2 (V)%!
4199 %0 = %1 << %2 (V)%!
4200 %0 = %1 >> %N2 (V)%!"
4201 [(set_attr "type" "dsp32,dsp32shiftimm,dsp32shiftimm")])
4202
4203 (define_insn "lshifthi3"
4204 [(set (match_operand:HI 0 "register_operand" "=d,d,d")
4205 (if_then_else:HI
4206 (lt (match_operand:HI 2 "vec_shift_operand" "d,Ku4,Ks4") (const_int 0))
4207 (lshiftrt:HI (match_operand:HI 1 "register_operand" "d,d,d")
4208 (match_dup 2))
4209 (ashift:HI (match_dup 1) (match_dup 2))))]
4210 ""
4211 "@
4212 %0 = LSHIFT %1 BY %h2 (V)%!
4213 %0 = %1 << %2 (V)%!
4214 %0 = %1 >> %N2 (V)%!"
4215 [(set_attr "type" "dsp32,dsp32shiftimm,dsp32shiftimm")])
4216
4217 ;; Load without alignment exception (masking off low bits)
4218
4219 (define_insn "loadbytes"
4220 [(set (match_operand:SI 0 "register_operand" "=d")
4221 (mem:SI (and:SI (match_operand:SI 1 "register_operand" "b")
4222 (const_int -4))))]
4223 ""
4224 "DISALGNEXCPT || %0 = [%1];"
4225 [(set_attr "type" "mcld")
4226 (set_attr "length" "8")])
4227
4228 (include "sync.md")