OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [config/] [bfin/] [bfin.md] - Blame information for rev 709

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.