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

Subversion Repositories openrisc

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 709 jeremybenn
;; IA-64 Machine description template
2
;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
3
;; 2009, 2010 Free Software Foundation, Inc.
4
;; Contributed by James E. Wilson  and
5
;;                David Mosberger .
6
 
7
;; This file is part of GCC.
8
 
9
;; GCC is free software; you can redistribute it and/or modify
10
;; it under the terms of the GNU General Public License as published by
11
;; the Free Software Foundation; either version 3, or (at your option)
12
;; any later version.
13
 
14
;; GCC is distributed in the hope that it will be useful,
15
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
;; GNU General Public License for more details.
18
 
19
;; You should have received a copy of the GNU General Public License
20
;; along with GCC; see the file COPYING3.  If not see
21
;; .
22
 
23
;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
24
 
25
;; ??? register_operand accepts (subreg:DI (mem:SI X)) which forces later
26
;; reload.  This will be fixed once scheduling support is turned on.
27
 
28
;; ??? Optimize for post-increment addressing modes.
29
 
30
;; ??? fselect is not supported, because there is no integer register
31
;; equivalent.
32
 
33
;; ??? fp abs/min/max instructions may also work for integer values.
34
 
35
;; ??? Would a predicate_reg_operand predicate be useful?  The HP one is buggy,
36
;; it assumes the operand is a register and takes REGNO of it without checking.
37
 
38
;; ??? Would a branch_reg_operand predicate be useful?  The HP one is buggy,
39
;; it assumes the operand is a register and takes REGNO of it without checking.
40
 
41
;; ??? Go through list of documented named patterns and look for more to
42
;; implement.
43
 
44
;; ??? Go through instruction manual and look for more instructions that
45
;; can be emitted.
46
 
47
;; ??? Add function unit scheduling info for Itanium (TM) processor.
48
 
49
;; ??? Need a better way to describe alternate fp status registers.
50
 
51
(define_c_enum "unspec"
52
  [; Relocations
53
   UNSPEC_LTOFF_DTPMOD
54
   UNSPEC_LTOFF_DTPREL
55
   UNSPEC_DTPREL
56
   UNSPEC_LTOFF_TPREL
57
   UNSPEC_TPREL
58
   UNSPEC_DTPMOD
59
 
60
   UNSPEC_LD_BASE
61
   UNSPEC_GR_SPILL
62
   UNSPEC_GR_RESTORE
63
   UNSPEC_FR_SPILL
64
   UNSPEC_FR_RESTORE
65
   UNSPEC_FR_RECIP_APPROX
66
   UNSPEC_PRED_REL_MUTEX
67
   UNSPEC_GETF_EXP
68
   UNSPEC_PIC_CALL
69
   UNSPEC_MF
70
   UNSPEC_CMPXCHG_ACQ
71
   UNSPEC_CMPXCHG_REL
72
   UNSPEC_FETCHADD_ACQ
73
   UNSPEC_FETCHADD_REL
74
   UNSPEC_BSP_VALUE
75
   UNSPEC_FLUSHRS
76
   UNSPEC_BUNDLE_SELECTOR
77
   UNSPEC_ADDP4
78
   UNSPEC_PROLOGUE_USE
79
   UNSPEC_RET_ADDR
80
   UNSPEC_SETF_EXP
81
   UNSPEC_FR_SQRT_RECIP_APPROX
82
   UNSPEC_SHRP
83
   UNSPEC_COPYSIGN
84
   UNSPEC_VECT_EXTR
85
   UNSPEC_LDA
86
   UNSPEC_LDS
87
   UNSPEC_LDS_A
88
   UNSPEC_LDSA
89
   UNSPEC_LDCCLR
90
   UNSPEC_LDCNC
91
   UNSPEC_CHKACLR
92
   UNSPEC_CHKANC
93
   UNSPEC_CHKS
94
   UNSPEC_FR_RECIP_APPROX_RES
95
   UNSPEC_FR_SQRT_RECIP_APPROX_RES
96
  ])
97
 
98
(define_c_enum "unspecv" [
99
   UNSPECV_ALLOC
100
   UNSPECV_BLOCKAGE
101
   UNSPECV_INSN_GROUP_BARRIER
102
   UNSPECV_BREAK
103
   UNSPECV_SET_BSP
104
   UNSPECV_PSAC_ALL             ; pred.safe_across_calls
105
   UNSPECV_PSAC_NORMAL
106
   UNSPECV_SETJMP_RECEIVER
107
   UNSPECV_GOTO_RECEIVER
108
  ])
109
 
110
(include "predicates.md")
111
(include "constraints.md")
112
 
113
;; ::::::::::::::::::::
114
;; ::
115
;; :: Attributes
116
;; ::
117
;; ::::::::::::::::::::
118
 
119
;; Processor type.  This attribute must exactly match the processor_type
120
;; enumeration in ia64.h.
121
(define_attr "cpu" "itanium,itanium2"
122
  (const (symbol_ref "((enum attr_cpu) ia64_tune)")))
123
 
124
;; Instruction type.  This primarily determines how instructions can be
125
;; packed in bundles, and secondarily affects scheduling to function units.
126
 
127
;; A alu, can go in I or M syllable of a bundle
128
;; I integer
129
;; M memory
130
;; F floating-point
131
;; B branch
132
;; L long immediate, takes two syllables
133
;; S stop bit
134
 
135
;; ??? Should not have any pattern with type unknown.  Perhaps add code to
136
;; check this in md_reorg?  Currently use unknown for patterns which emit
137
;; multiple instructions, patterns which emit 0 instructions, and patterns
138
;; which emit instruction that can go in any slot (e.g. nop).
139
 
140
(define_attr "itanium_class" "unknown,ignore,stop_bit,br,fcmp,fcvtfx,fld,
141
        fldp,fmac,fmisc,frar_i,frar_m,frbr,frfr,frpr,ialu,icmp,ilog,ishf,
142
        ld,chk_s_i,chk_s_f,chk_a,long_i,mmalua,mmmul,mmshf,mmshfi,rse_m,scall,sem,stf,
143
        st,syst_m0, syst_m,tbit,toar_i,toar_m,tobr,tofr,topr,xmpy,xtd,nop,
144
        nop_b,nop_f,nop_i,nop_m,nop_x,lfetch,pre_cycle"
145
  (const_string "unknown"))
146
 
147
;; chk_s_i has an I and an M form; use type A for convenience.
148
(define_attr "type" "unknown,A,I,M,F,B,L,X,S"
149
  (cond [(eq_attr "itanium_class" "ld,st,fld,fldp,stf,sem,nop_m") (const_string "M")
150
         (eq_attr "itanium_class" "rse_m,syst_m,syst_m0") (const_string "M")
151
         (eq_attr "itanium_class" "frar_m,toar_m,frfr,tofr") (const_string "M")
152
         (eq_attr "itanium_class" "lfetch") (const_string "M")
153
         (eq_attr "itanium_class" "chk_s_f,chk_a") (const_string "M")
154
         (eq_attr "itanium_class" "chk_s_i,ialu,icmp,ilog,mmalua")
155
           (const_string "A")
156
         (eq_attr "itanium_class" "fmisc,fmac,fcmp,xmpy") (const_string "F")
157
         (eq_attr "itanium_class" "fcvtfx,nop_f") (const_string "F")
158
         (eq_attr "itanium_class" "frar_i,toar_i,frbr,tobr") (const_string "I")
159
         (eq_attr "itanium_class" "frpr,topr,ishf,xtd,tbit") (const_string "I")
160
         (eq_attr "itanium_class" "mmmul,mmshf,mmshfi,nop_i") (const_string "I")
161
         (eq_attr "itanium_class" "br,scall,nop_b") (const_string "B")
162
         (eq_attr "itanium_class" "stop_bit") (const_string "S")
163
         (eq_attr "itanium_class" "nop_x") (const_string "X")
164
         (eq_attr "itanium_class" "long_i") (const_string "L")]
165
        (const_string "unknown")))
166
 
167
(define_attr "itanium_requires_unit0" "no,yes"
168
  (cond [(eq_attr "itanium_class" "syst_m0,sem,frfr,rse_m") (const_string "yes")
169
         (eq_attr "itanium_class" "toar_m,frar_m") (const_string "yes")
170
         (eq_attr "itanium_class" "frbr,tobr,mmmul") (const_string "yes")
171
         (eq_attr "itanium_class" "tbit,ishf,topr,frpr") (const_string "yes")
172
         (eq_attr "itanium_class" "toar_i,frar_i") (const_string "yes")
173
         (eq_attr "itanium_class" "fmisc,fcmp") (const_string "yes")]
174
        (const_string "no")))
175
 
176
;; Predication.  True iff this instruction can be predicated.
177
 
178
(define_attr "predicable" "no,yes" (const_string "yes"))
179
 
180
;; Empty.  True iff this insn does not generate any code.
181
 
182
(define_attr "empty" "no,yes" (const_string "no"))
183
 
184
;; True iff this insn must be the first insn of an instruction group.
185
;; This is true for the alloc instruction, and will also be true of others
186
;; when we have full intrinsics support.
187
 
188
(define_attr "first_insn" "no,yes" (const_string "no"))
189
 
190
(define_attr "data_speculative" "no,yes" (const_string "no"))
191
 
192
(define_attr "control_speculative" "no,yes" (const_string "no"))
193
 
194
(define_attr "check_load" "no,yes" (const_string "no"))
195
 
196
(define_attr "speculable1" "no,yes" (const_string "no"))
197
 
198
(define_attr "speculable2" "no,yes" (const_string "no"))
199
 
200
;; DFA descriptions of ia64 processors used for insn scheduling and
201
;; bundling.
202
 
203
(automata_option "ndfa")
204
 
205
;; Uncomment the following line to output automata for debugging.
206
;; (automata_option "v")
207
 
208
(automata_option "w")
209
 
210
(include "itanium2.md")
211
 
212
;; Mode iterators
213
 
214
; Used for truncations from XFmode.
215
(define_mode_iterator MODE_SDF [SF DF])
216
 
217
(define_mode_attr suffix [
218
  (SF ".s")
219
  (DF ".d")
220
  (XF "")
221
  ])
222
 
223
;; ::::::::::::::::::::
224
;; ::
225
;; :: Moves
226
;; ::
227
;; ::::::::::::::::::::
228
 
229
;; Set of a single predicate register.  This is only used to implement
230
;; pr-to-pr move and complement.
231
 
232
(define_insn "movcci"
233
  [(set (match_operand:CCI 0 "destination_operand" "=c,c,?c,?*r, c,*r,*m,*r")
234
        (match_operand:CCI 1 "move_operand"        " O,n, c,  c,*r,*m,*r,*r"))]
235
  ""
236
  "@
237
   cmp.ne %0, p0 = r0, r0
238
   cmp.eq %0, p0 = r0, r0
239
   (%1) cmp.eq.unc %0, p0 = r0, r0
240
   #
241
   tbit.nz %0, p0 = %1, 0
242
   ld1%O1 %0 = %1%P1
243
   st1%Q0 %0 = %1%P0
244
   mov %0 = %1"
245
  [(set_attr "itanium_class" "icmp,icmp,icmp,unknown,tbit,ld,st,ialu")
246
   (set_attr "predicable" "no")])
247
 
248
(define_split
249
  [(set (match_operand:CCI 0 "register_operand" "")
250
        (match_operand:CCI 1 "register_operand" ""))]
251
  "reload_completed
252
   && GET_CODE (operands[0]) == REG && GR_REGNO_P (REGNO (operands[0]))
253
   && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
254
  [(set (match_dup 2) (const_int 0))
255
   (cond_exec (ne (match_dup 3) (const_int 0))
256
     (set (match_dup 2) (const_int 1)))]
257
  "operands[2] = gen_rtx_REG (BImode, REGNO (operands[0]));
258
   operands[3] = gen_rtx_REG (BImode, REGNO (operands[1]));")
259
 
260
(define_insn "movbi"
261
  [(set (match_operand:BI 0 "destination_operand" "=c,c,?c,?*r, c,*r,*r,*m,*r")
262
        (match_operand:BI 1 "move_operand"        " O,n, c,  c,*r, n,*m,*r,*r"))]
263
  ""
264
  "@
265
   cmp.ne %0, %I0 = r0, r0
266
   cmp.eq %0, %I0 = r0, r0
267
   #
268
   #
269
   tbit.nz %0, %I0 = %1, 0
270
   adds %0 = %1, r0
271
   ld1%O1 %0 = %1%P1
272
   st1%Q0 %0 = %1%P0
273
   mov %0 = %1"
274
  [(set_attr "itanium_class" "icmp,icmp,unknown,unknown,tbit,ialu,ld,st,ialu")
275
   (set_attr "speculable1"   "yes")
276
   (set_attr "speculable2"   "no,  no,  no,     no,     no,  no, yes,no,no")])
277
 
278
(define_split
279
  [(set (match_operand:BI 0 "register_operand" "")
280
        (match_operand:BI 1 "register_operand" ""))]
281
  "reload_completed
282
   && GET_CODE (operands[0]) == REG && GR_REGNO_P (REGNO (operands[0]))
283
   && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
284
  [(cond_exec (ne (match_dup 1) (const_int 0))
285
     (set (match_dup 0) (const_int 1)))
286
   (cond_exec (eq (match_dup 1) (const_int 0))
287
     (set (match_dup 0) (const_int 0)))]
288
  "")
289
 
290
(define_split
291
  [(set (match_operand:BI 0 "register_operand" "")
292
        (match_operand:BI 1 "register_operand" ""))]
293
  "reload_completed
294
   && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
295
   && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
296
  [(set (match_dup 2) (match_dup 4))
297
   (set (match_dup 3) (match_dup 5))
298
   (set (match_dup 0) (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
299
  "operands[2] = gen_rtx_REG (CCImode, REGNO (operands[0]));
300
   operands[3] = gen_rtx_REG (CCImode, REGNO (operands[0]) + 1);
301
   operands[4] = gen_rtx_REG (CCImode, REGNO (operands[1]));
302
   operands[5] = gen_rtx_REG (CCImode, REGNO (operands[1]) + 1);")
303
 
304
(define_expand "movqi"
305
  [(set (match_operand:QI 0 "general_operand" "")
306
        (match_operand:QI 1 "general_operand" ""))]
307
  ""
308
{
309
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
310
  if (!op1)
311
    DONE;
312
  operands[1] = op1;
313
})
314
 
315
(define_insn "movqi_internal"
316
  [(set (match_operand:QI 0 "destination_operand" "=r,r,r, m, r,*f,*f")
317
        (match_operand:QI 1 "move_operand"        "rO,J,m,rO,*f,rO,*f"))]
318
  "ia64_move_ok (operands[0], operands[1])"
319
  "@
320
   mov %0 = %r1
321
   addl %0 = %1, r0
322
   ld1%O1 %0 = %1%P1
323
   st1%Q0 %0 = %r1%P0
324
   getf.sig %0 = %1
325
   setf.sig %0 = %r1
326
   mov %0 = %1"
327
  [(set_attr "itanium_class" "ialu,ialu,ld,st,frfr,tofr,fmisc")
328
   (set_attr "speculable1"   "yes")
329
   (set_attr "speculable2"   "no,  no, yes,no,no,  no,  no")])
330
 
331
(define_expand "movhi"
332
  [(set (match_operand:HI 0 "general_operand" "")
333
        (match_operand:HI 1 "general_operand" ""))]
334
  ""
335
{
336
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
337
  if (!op1)
338
    DONE;
339
  operands[1] = op1;
340
})
341
 
342
(define_insn "movhi_internal"
343
  [(set (match_operand:HI 0 "destination_operand" "=r,r,r, m, r,*f,*f")
344
        (match_operand:HI 1 "move_operand"        "rO,J,m,rO,*f,rO,*f"))]
345
  "ia64_move_ok (operands[0], operands[1])"
346
  "@
347
   mov %0 = %r1
348
   addl %0 = %1, r0
349
   ld2%O1 %0 = %1%P1
350
   st2%Q0 %0 = %r1%P0
351
   getf.sig %0 = %1
352
   setf.sig %0 = %r1
353
   mov %0 = %1"
354
  [(set_attr "itanium_class" "ialu,ialu,ld,st,frfr,tofr,fmisc")
355
   (set_attr "speculable1"   "yes")
356
   (set_attr "speculable2"   "no,  no, yes,no,no,  no,  no")])
357
 
358
(define_expand "movsi"
359
  [(set (match_operand:SI 0 "general_operand" "")
360
        (match_operand:SI 1 "general_operand" ""))]
361
  ""
362
{
363
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
364
  if (!op1)
365
    DONE;
366
  operands[1] = op1;
367
})
368
 
369
(define_insn "movsi_internal"
370
  [(set (match_operand:SI 0 "destination_operand" "=r,r,r,r,r, m, r,*f,*f, r,*d")
371
        (match_operand:SI 1 "move_operand"        "rO,J,j,i,m,rO,*f,rO,*f,*d,rK"))]
372
  "ia64_move_ok (operands[0], operands[1])"
373
  "@
374
  mov %0 = %r1
375
  addl %0 = %1, r0
376
  addp4 %0 = %1 - 0x100000000, r0
377
  movl %0 = %1
378
  ld4%O1 %0 = %1%P1
379
  st4%Q0 %0 = %r1%P0
380
  getf.sig %0 = %1
381
  setf.sig %0 = %r1
382
  mov %0 = %1
383
  mov %0 = %1
384
  mov %0 = %r1"
385
  ;; frar_m, toar_m ??? why not frar_i and toar_i
386
  [(set_attr "itanium_class" "ialu,ialu,ialu,long_i,ld,st,frfr,tofr,fmisc,frar_m,toar_m")
387
   (set_attr "speculable1"   "yes")
388
   (set_attr "speculable2"   "no,  no,  no,  no,   yes,no,no,  no,  no,   no,    no")])
389
 
390
(define_expand "movdi"
391
  [(set (match_operand:DI 0 "general_operand" "")
392
        (match_operand:DI 1 "general_operand" ""))]
393
  ""
394
{
395
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
396
  if (!op1)
397
    DONE;
398
  operands[1] = op1;
399
})
400
 
401
(define_insn "movdi_internal"
402
  [(set (match_operand:DI 0 "destination_operand"
403
                    "=r,r,r,r,r, m, r,*f,*f,*f, Q, r,*b, r,*e, r,*d, r,*c")
404
        (match_operand:DI 1 "move_operand"
405
                    "rO,JT,j,i,m,rO,*f,rO,*f, Q,*f,*b,rO,*e,rK,*d,rK,*c,rO"))]
406
  "ia64_move_ok (operands[0], operands[1])"
407
{
408
  static const char * const alt[] = {
409
    "%,mov %0 = %r1",
410
    "%,addl %0 = %1, r0",
411
    "%,addp4 %0 = %1 - 0x100000000, r0",
412
    "%,movl %0 = %1",
413
    "%,ld8%O1 %0 = %1%P1",
414
    "%,st8%Q0 %0 = %r1%P0",
415
    "%,getf.sig %0 = %1",
416
    "%,setf.sig %0 = %r1",
417
    "%,mov %0 = %1",
418
    "%,ldf8 %0 = %1%P1",
419
    "%,stf8 %0 = %1%P0",
420
    "%,mov %0 = %1",
421
    "%,mov %0 = %r1",
422
    "%,mov %0 = %1",
423
    "%,mov %0 = %1",
424
    "%,mov %0 = %1",
425
    "%,mov %0 = %1",
426
    "mov %0 = pr",
427
    "mov pr = %1, -1"
428
  };
429
 
430
  gcc_assert (which_alternative != 2 || TARGET_NO_PIC
431
              || !symbolic_operand (operands[1], VOIDmode));
432
 
433
  return alt[which_alternative];
434
}
435
  [(set_attr "itanium_class" "ialu,ialu,ialu,long_i,ld,st,frfr,tofr,fmisc,fld,stf,frbr,tobr,frar_i,toar_i,frar_m,toar_m,frpr,topr")
436
   (set_attr "speculable1"   "yes")
437
   (set_attr "speculable2"   "no,  no,  no,  no,   yes,no,no,  no,  no,   yes,no, no,  no,  no,    no,    no,    no,    no,  no")])
438
 
439
(define_mode_iterator MODE [BI QI HI SI DI SF DF XF TI])
440
(define_mode_iterator MODE_FOR_CMP [BI SI DI SF DF XF (TF "TARGET_HPUX")])
441
(define_mode_iterator MODE_FOR_EXTEND [QI HI SI])
442
 
443
(define_mode_attr output_a [
444
  (BI "ld1.a %0 = %1%P1")
445
  (QI "ld1.a %0 = %1%P1")
446
  (HI "ld2.a %0 = %1%P1")
447
  (SI "ld4.a %0 = %1%P1")
448
  (DI
449
   "@
450
    ld8.a %0 = %1%P1
451
    ldf8.a %0 = %1%P1")
452
  (SF
453
   "@
454
    ldfs.a %0 = %1%P1
455
    ld4.a %0 = %1%P1")
456
  (DF
457
   "@
458
    ldfd.a %0 = %1%P1
459
    ld8.a %0 = %1%P1")
460
  (XF "ldfe.a %0 = %1%P1")
461
  (TI "ldfp8.a %X0 = %1%P1")])
462
 
463
(define_mode_attr output_s [
464
  (BI "ld1.s %0 = %1%P1")
465
  (QI "ld1.s %0 = %1%P1")
466
  (HI "ld2.s %0 = %1%P1")
467
  (SI "ld4.s %0 = %1%P1")
468
  (DI
469
   "@
470
    ld8.s %0 = %1%P1
471
    ldf8.s %0 = %1%P1")
472
  (SF
473
   "@
474
    ldfs.s %0 = %1%P1
475
    ld4.s %0 = %1%P1")
476
  (DF
477
   "@
478
    ldfd.s %0 = %1%P1
479
    ld8.s %0 = %1%P1")
480
  (XF "ldfe.s %0 = %1%P1")
481
  (TI "ldfp8.s %X0 = %1%P1")])
482
 
483
(define_mode_attr output_sa [
484
  (BI "ld1.sa %0 = %1%P1")
485
  (QI "ld1.sa %0 = %1%P1")
486
  (HI "ld2.sa %0 = %1%P1")
487
  (SI "ld4.sa %0 = %1%P1")
488
  (DI
489
   "@
490
    ld8.sa %0 = %1%P1
491
    ldf8.sa %0 = %1%P1")
492
  (SF
493
   "@
494
    ldfs.sa %0 = %1%P1
495
    ld4.sa %0 = %1%P1")
496
  (DF
497
   "@
498
    ldfd.sa %0 = %1%P1
499
    ld8.sa %0 = %1%P1")
500
  (XF "ldfe.sa %0 = %1%P1")
501
  (TI "ldfp8.sa %X0 = %1%P1")])
502
 
503
(define_mode_attr output_c_clr [
504
  (BI "ld1.c.clr%O1 %0 = %1%P1")
505
  (QI "ld1.c.clr%O1 %0 = %1%P1")
506
  (HI "ld2.c.clr%O1 %0 = %1%P1")
507
  (SI "ld4.c.clr%O1 %0 = %1%P1")
508
  (DI
509
   "@
510
    ld8.c.clr%O1 %0 = %1%P1
511
    ldf8.c.clr %0 = %1%P1")
512
  (SF
513
   "@
514
    ldfs.c.clr %0 = %1%P1
515
    ld4.c.clr%O1 %0 = %1%P1")
516
  (DF
517
   "@
518
    ldfd.c.clr %0 = %1%P1
519
    ld8.c.clr%O1 %0 = %1%P1")
520
  (XF "ldfe.c.clr %0 = %1%P1")
521
  (TI "ldfp8.c.clr %X0 = %1%P1")])
522
 
523
(define_mode_attr output_c_nc [
524
  (BI "ld1.c.nc%O1 %0 = %1%P1")
525
  (QI "ld1.c.nc%O1 %0 = %1%P1")
526
  (HI "ld2.c.nc%O1 %0 = %1%P1")
527
  (SI "ld4.c.nc%O1 %0 = %1%P1")
528
  (DI
529
   "@
530
    ld8.c.nc%O1 %0 = %1%P1
531
    ldf8.c.nc %0 = %1%P1")
532
  (SF
533
   "@
534
    ldfs.c.nc %0 = %1%P1
535
    ld4.c.nc%O1 %0 = %1%P1")
536
  (DF
537
   "@
538
    ldfd.c.nc %0 = %1%P1
539
    ld8.c.nc%O1 %0 = %1%P1")
540
  (XF "ldfe.c.nc %0 = %1%P1")
541
  (TI "ldfp8.c.nc %X0 = %1%P1")])
542
 
543
(define_mode_attr ld_reg_constr [(BI "=*r") (QI "=r") (HI "=r") (SI "=r") (DI "=r,*f") (SF "=f,*r") (DF "=f,*r") (XF "=f") (TI "=*x")])
544
(define_mode_attr ldc_reg_constr [(BI "+*r") (QI "+r") (HI "+r") (SI "+r") (DI "+r,*f") (SF "+f,*r") (DF "+f,*r") (XF "+f") (TI "+*x")])
545
(define_mode_attr chk_reg_constr [(BI "*r") (QI "r") (HI "r") (SI "r") (DI "r,*f") (SF "f,*r") (DF "f,*r") (XF "f") (TI "*x")])
546
 
547
(define_mode_attr mem_constr [(BI "*m") (QI "m") (HI "m") (SI "m") (DI "m,Q") (SF "Q,m") (DF "Q,m") (XF "m") (TI "Q")])
548
 
549
;; Define register predicate prefix.
550
;; We can generate speculative loads only for general and fp registers - this
551
;; is constrained in ia64.c: ia64_speculate_insn ().
552
(define_mode_attr reg_pred_prefix [(BI "gr") (QI "gr") (HI "gr") (SI "gr") (DI "grfr") (SF "grfr") (DF "grfr") (XF "fr") (TI "fr")])
553
 
554
(define_mode_attr ld_class [(BI "ld") (QI "ld") (HI "ld") (SI "ld") (DI "ld,fld") (SF "fld,ld") (DF "fld,ld") (XF "fld") (TI "fldp")])
555
(define_mode_attr chka_class [(BI "chk_a") (QI "chk_a") (HI "chk_a") (SI "chk_a") (DI "chk_a,chk_a") (SF "chk_a,chk_a") (DF "chk_a,chk_a") (XF "chk_a") (TI "chk_a")])
556
(define_mode_attr chks_class [(BI "chk_s_i") (QI "chk_s_i") (HI "chk_s_i") (SI "chk_s_i") (DI "chk_s_i,chk_s_f") (SF "chk_s_f,chk_s_i") (DF "chk_s_f,chk_s_i") (XF "chk_s_f") (TI "chk_s_i")])
557
 
558
(define_mode_attr attr_yes [(BI "yes") (QI "yes") (HI "yes") (SI "yes") (DI "yes,yes") (SF "yes,yes") (DF "yes,yes") (XF "yes") (TI "yes")])
559
 
560
(define_insn "mov_advanced"
561
  [(set (match_operand:MODE 0 "_register_operand" "")
562
        (unspec:MODE [(match_operand:MODE 1 "memory_operand" "")] UNSPEC_LDA))]
563
  "ia64_move_ok (operands[0], operands[1])"
564
  ""
565
  [(set_attr "itanium_class" "")
566
   (set_attr "data_speculative" "")])
567
 
568
(define_insn "zero_extenddi2_advanced"
569
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
570
        (zero_extend:DI (unspec:MODE_FOR_EXTEND [(match_operand:MODE_FOR_EXTEND 1 "memory_operand" "")] UNSPEC_LDA)))]
571
  ""
572
  ""
573
  [(set_attr "itanium_class" "")
574
   (set_attr "data_speculative" "")])
575
 
576
(define_insn "mov_speculative"
577
  [(set (match_operand:MODE 0 "_register_operand" "")
578
        (unspec:MODE [(match_operand:MODE 1 "memory_operand" "")] UNSPEC_LDS))]
579
  "ia64_move_ok (operands[0], operands[1])"
580
  ""
581
  [(set_attr "itanium_class" "")
582
   (set_attr "control_speculative" "")])
583
 
584
(define_insn "zero_extenddi2_speculative"
585
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
586
        (zero_extend:DI (unspec:MODE_FOR_EXTEND [(match_operand:MODE_FOR_EXTEND 1 "memory_operand" "")] UNSPEC_LDS)))]
587
  ""
588
  ""
589
  [(set_attr "itanium_class" "")
590
   (set_attr "control_speculative" "")])
591
 
592
(define_insn "mov_speculative_advanced"
593
  [(set (match_operand:MODE 0 "_register_operand" "")
594
        (unspec:MODE [(match_operand:MODE 1 "memory_operand" "")] UNSPEC_LDSA))]
595
  "ia64_move_ok (operands[0], operands[1])"
596
  ""
597
  [(set_attr "itanium_class" "")
598
   (set_attr "data_speculative" "")
599
   (set_attr "control_speculative" "")])
600
 
601
(define_insn "mov_speculative_a"
602
  [(set (match_operand:MODE 0 "_register_operand" "")
603
        (unspec:MODE [(match_operand:MODE 1 "memory_operand" "")] UNSPEC_LDS_A))]
604
  "ia64_move_ok (operands[0], operands[1])"
605
  ""
606
  [(set_attr "itanium_class" "")
607
   (set_attr "data_speculative" "")
608
   (set_attr "control_speculative" "")])
609
 
610
(define_insn "zero_extenddi2_speculative_advanced"
611
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
612
        (zero_extend:DI (unspec:MODE_FOR_EXTEND [(match_operand:MODE_FOR_EXTEND 1 "memory_operand" "")] UNSPEC_LDSA)))]
613
  ""
614
  ""
615
  [(set_attr "itanium_class" "")
616
   (set_attr "data_speculative" "")
617
   (set_attr "control_speculative" "")])
618
 
619
(define_insn "zero_extenddi2_speculative_a"
620
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
621
        (zero_extend:DI (unspec:MODE_FOR_EXTEND [(match_operand:MODE_FOR_EXTEND 1 "memory_operand" "")] UNSPEC_LDS_A)))]
622
  ""
623
  ""
624
  [(set_attr "itanium_class" "")
625
   (set_attr "data_speculative" "")
626
   (set_attr "control_speculative" "")])
627
 
628
(define_insn "mov_clr"
629
  [(set (match_operand:MODE 0 "_register_operand" "")
630
        (if_then_else:MODE (ne (unspec [(match_dup 0)] UNSPEC_LDCCLR) (const_int 0))
631
                           (match_operand:MODE 1 "memory_operand" "")
632
                           (match_dup 0)))]
633
  "ia64_move_ok (operands[0], operands[1])"
634
  ""
635
  [(set_attr "itanium_class" "")
636
   (set_attr "check_load" "")])
637
 
638
(define_insn "mov_nc"
639
  [(set (match_operand:MODE 0 "_register_operand" "")
640
        (if_then_else:MODE (ne (unspec [(match_dup 0)] UNSPEC_LDCNC) (const_int 0))
641
                           (match_operand:MODE 1 "memory_operand" "")
642
                           (match_dup 0)))]
643
  "ia64_move_ok (operands[0], operands[1])"
644
  ""
645
  [(set_attr "itanium_class" "")
646
   (set_attr "check_load" "")])
647
 
648
(define_insn "zero_extenddi2_clr"
649
  [(set (match_operand:DI 0 "gr_register_operand" "+r")
650
        (if_then_else:DI (ne (unspec [(match_dup 0)] UNSPEC_LDCCLR) (const_int 0))
651
                         (zero_extend:DI (match_operand:MODE_FOR_EXTEND 1 "memory_operand" ""))
652
                         (match_dup 0)))]
653
  ""
654
  ""
655
  [(set_attr "itanium_class" "")
656
   (set_attr "check_load" "")])
657
 
658
(define_insn "zero_extenddi2_nc"
659
  [(set (match_operand:DI 0 "gr_register_operand" "+r")
660
        (if_then_else:DI (ne (unspec [(match_dup 0)] UNSPEC_LDCNC) (const_int 0))
661
                         (zero_extend:DI (match_operand:MODE_FOR_EXTEND 1 "memory_operand" ""))
662
                         (match_dup 0)))]
663
  ""
664
  ""
665
  [(set_attr "itanium_class" "")
666
   (set_attr "check_load" "")])
667
 
668
(define_insn "advanced_load_check_clr_"
669
  [(set (pc)
670
        (if_then_else (ne (unspec [(match_operand:MODE 0 "_register_operand" "")] UNSPEC_CHKACLR) (const_int 0))
671
                      (pc)
672
                      (label_ref (match_operand 1 "" ""))))]
673
  ""
674
  "chk.a.clr %0, %l1"
675
  [(set_attr "itanium_class" "")])
676
 
677
(define_insn "advanced_load_check_nc_"
678
  [(set (pc)
679
        (if_then_else (ne (unspec [(match_operand:MODE 0 "_register_operand" "")] UNSPEC_CHKANC) (const_int 0))
680
                      (pc)
681
                      (label_ref (match_operand 1 "" ""))))]
682
  ""
683
  "chk.a.clr %0, %l1"
684
  [(set_attr "itanium_class" "")])
685
 
686
(define_insn "speculation_check_"
687
  [(set (pc)
688
        (if_then_else (ne (unspec [(match_operand:MODE 0 "_register_operand" "")] UNSPEC_CHKS) (const_int 0))
689
                      (pc)
690
                      (label_ref (match_operand 1 "" ""))))]
691
  ""
692
  "chk.s %0, %l1"
693
  [(set_attr "itanium_class" "")])
694
 
695
(define_split
696
  [(set (match_operand 0 "register_operand" "")
697
        (match_operand 1 "symbolic_operand" ""))]
698
  "reload_completed"
699
  [(const_int 0)]
700
{
701
  if (ia64_expand_load_address (operands[0], operands[1]))
702
    DONE;
703
  else
704
    FAIL;
705
})
706
 
707
(define_expand "load_fptr"
708
  [(set (match_operand:DI 0 "register_operand" "")
709
        (plus:DI (match_dup 2) (match_operand 1 "function_operand" "")))
710
   (set (match_dup 0) (match_dup 3))]
711
  "reload_completed"
712
{
713
  operands[2] = pic_offset_table_rtx;
714
  operands[3] = gen_const_mem (DImode, operands[0]);
715
})
716
 
717
(define_insn "*load_fptr_internal1"
718
  [(set (match_operand:DI 0 "register_operand" "=r")
719
        (plus:DI (reg:DI 1) (match_operand 1 "function_operand" "s")))]
720
  "reload_completed"
721
  "addl %0 = @ltoff(@fptr(%1)), gp"
722
  [(set_attr "itanium_class" "ialu")])
723
 
724
(define_insn "load_gprel"
725
  [(set (match_operand:DI 0 "register_operand" "=r")
726
        (plus:DI (reg:DI 1) (match_operand 1 "sdata_symbolic_operand" "s")))]
727
  "reload_completed"
728
  "addl %0 = @gprel(%1), gp"
729
  [(set_attr "itanium_class" "ialu")])
730
 
731
(define_insn "*gprel64_offset"
732
  [(set (match_operand:DI 0 "register_operand" "=r")
733
        (minus:DI (match_operand:DI 1 "symbolic_operand" "") (reg:DI 1)))]
734
  "reload_completed"
735
  "movl %0 = @gprel(%1)"
736
  [(set_attr "itanium_class" "long_i")])
737
 
738
(define_expand "load_gprel64"
739
  [(set (match_operand:DI 0 "register_operand" "")
740
        (minus:DI (match_operand:DI 1 "symbolic_operand" "") (match_dup 2)))
741
   (set (match_dup 0)
742
        (plus:DI (match_dup 2) (match_dup 0)))]
743
  "reload_completed"
744
{
745
  operands[2] = pic_offset_table_rtx;
746
})
747
 
748
;; This is used as a placeholder for the return address during early
749
;; compilation.  We won't know where we've placed this until during
750
;; reload, at which point it can wind up in b0, a general register,
751
;; or memory.  The only safe destination under these conditions is a
752
;; general register.
753
 
754
(define_insn_and_split "*movdi_ret_addr"
755
  [(set (match_operand:DI 0 "register_operand" "=r")
756
        (unspec:DI [(const_int 0)] UNSPEC_RET_ADDR))]
757
  ""
758
  "#"
759
  "reload_completed"
760
  [(const_int 0)]
761
{
762
  ia64_split_return_addr_rtx (operands[0]);
763
  DONE;
764
}
765
  [(set_attr "itanium_class" "ialu")])
766
 
767
(define_insn "*load_symptr_high"
768
  [(set (match_operand:DI 0 "register_operand" "=r")
769
        (plus:DI (high:DI (match_operand 1 "got_symbolic_operand" "s"))
770
                 (match_operand:DI 2 "register_operand" "a")))]
771
  "reload_completed"
772
{
773
  if (HAVE_AS_LTOFFX_LDXMOV_RELOCS)
774
    return "%,addl %0 = @ltoffx(%1), %2";
775
  else
776
    return "%,addl %0 = @ltoff(%1), %2";
777
}
778
  [(set_attr "itanium_class" "ialu")])
779
 
780
(define_insn "*load_symptr_low"
781
  [(set (match_operand:DI 0 "register_operand" "=r")
782
        (lo_sum:DI (mem:DI (match_operand:DI 1 "register_operand" "r"))
783
                   (match_operand 2 "got_symbolic_operand" "s")))]
784
  "reload_completed"
785
{
786
  if (HAVE_AS_LTOFFX_LDXMOV_RELOCS)
787
    return "%,ld8.mov %0 = [%1], %2";
788
  else
789
    return "%,ld8 %0 = [%1]";
790
}
791
  [(set_attr "itanium_class" "ld")])
792
 
793
(define_insn_and_split "load_dtpmod"
794
  [(set (match_operand:DI 0 "register_operand" "=r")
795
        (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
796
                   UNSPEC_DTPMOD))]
797
  ""
798
  "#"
799
  "reload_completed"
800
  [(set (match_dup 0)
801
        (plus:DI (unspec:DI [(match_dup 1)] UNSPEC_LTOFF_DTPMOD)
802
                 (match_dup 2)))
803
   (set (match_dup 0) (match_dup 3))]
804
{
805
  operands[2] = pic_offset_table_rtx;
806
  operands[3] = gen_const_mem (DImode, operands[0]);
807
})
808
 
809
(define_insn "*load_ltoff_dtpmod"
810
  [(set (match_operand:DI 0 "register_operand" "=r")
811
        (plus:DI (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
812
                            UNSPEC_LTOFF_DTPMOD)
813
                 (match_operand:DI 2 "register_operand" "a")))]
814
  "reload_completed"
815
  "addl %0 = @ltoff(@dtpmod(%1)), %2"
816
  [(set_attr "itanium_class" "ialu")])
817
 
818
(define_expand "load_dtprel"
819
  [(set (match_operand:DI 0 "register_operand" "")
820
        (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
821
                   UNSPEC_DTPREL))]
822
  ""
823
  "")
824
 
825
(define_insn "*load_dtprel64"
826
  [(set (match_operand:DI 0 "register_operand" "=r")
827
        (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
828
                   UNSPEC_DTPREL))]
829
  "TARGET_TLS64"
830
  "movl %0 = @dtprel(%1)"
831
  [(set_attr "itanium_class" "long_i")])
832
 
833
(define_insn "*load_dtprel22"
834
  [(set (match_operand:DI 0 "register_operand" "=r")
835
        (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
836
                   UNSPEC_DTPREL))]
837
  ""
838
  "addl %0 = @dtprel(%1), r0"
839
  [(set_attr "itanium_class" "ialu")])
840
 
841
(define_insn_and_split "*load_dtprel_gd"
842
  [(set (match_operand:DI 0 "register_operand" "=r")
843
        (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
844
                   UNSPEC_DTPREL))]
845
  ""
846
  "#"
847
  "reload_completed"
848
  [(set (match_dup 0)
849
        (plus:DI (unspec:DI [(match_dup 1)] UNSPEC_LTOFF_DTPREL)
850
                 (match_dup 2)))
851
   (set (match_dup 0) (match_dup 3))]
852
{
853
  operands[2] = pic_offset_table_rtx;
854
  operands[3] = gen_const_mem (DImode, operands[0]);
855
})
856
 
857
(define_insn "*load_ltoff_dtprel"
858
  [(set (match_operand:DI 0 "register_operand" "=r")
859
        (plus:DI (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
860
                            UNSPEC_LTOFF_DTPREL)
861
                 (match_operand:DI 2 "register_operand" "a")))]
862
  ""
863
  "addl %0 = @ltoff(@dtprel(%1)), %2"
864
  [(set_attr "itanium_class" "ialu")])
865
 
866
(define_expand "add_dtprel"
867
  [(set (match_operand:DI 0 "register_operand" "")
868
        (plus:DI (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
869
                            UNSPEC_DTPREL)
870
                 (match_operand:DI 2 "register_operand" "")))]
871
  "!TARGET_TLS64"
872
  "")
873
 
874
(define_insn "*add_dtprel14"
875
  [(set (match_operand:DI 0 "register_operand" "=r")
876
        (plus:DI (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
877
                            UNSPEC_DTPREL)
878
                 (match_operand:DI 2 "register_operand" "r")))]
879
  "TARGET_TLS14"
880
  "adds %0 = @dtprel(%1), %2"
881
  [(set_attr "itanium_class" "ialu")])
882
 
883
(define_insn "*add_dtprel22"
884
  [(set (match_operand:DI 0 "register_operand" "=r")
885
        (plus:DI (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
886
                            UNSPEC_DTPREL)
887
                 (match_operand:DI 2 "register_operand" "a")))]
888
  "TARGET_TLS22"
889
  "addl %0 = @dtprel(%1), %2"
890
  [(set_attr "itanium_class" "ialu")])
891
 
892
(define_expand "load_tprel"
893
  [(set (match_operand:DI 0 "register_operand" "")
894
        (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
895
                   UNSPEC_TPREL))]
896
  ""
897
  "")
898
 
899
(define_insn "*load_tprel64"
900
  [(set (match_operand:DI 0 "register_operand" "=r")
901
        (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
902
                   UNSPEC_TPREL))]
903
  "TARGET_TLS64"
904
  "movl %0 = @tprel(%1)"
905
  [(set_attr "itanium_class" "long_i")])
906
 
907
(define_insn "*load_tprel22"
908
  [(set (match_operand:DI 0 "register_operand" "=r")
909
        (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
910
                   UNSPEC_TPREL))]
911
  ""
912
  "addl %0 = @tprel(%1), r0"
913
  [(set_attr "itanium_class" "ialu")])
914
 
915
(define_insn_and_split "*load_tprel_ie"
916
  [(set (match_operand:DI 0 "register_operand" "=r")
917
        (unspec:DI [(match_operand 1 "ie_tls_symbolic_operand" "")]
918
                   UNSPEC_TPREL))]
919
  ""
920
  "#"
921
  "reload_completed"
922
  [(set (match_dup 0)
923
        (plus:DI (unspec:DI [(match_dup 1)] UNSPEC_LTOFF_TPREL)
924
                 (match_dup 2)))
925
   (set (match_dup 0) (match_dup 3))]
926
{
927
  operands[2] = pic_offset_table_rtx;
928
  operands[3] = gen_const_mem (DImode, operands[0]);
929
})
930
 
931
(define_insn "*load_ltoff_tprel"
932
  [(set (match_operand:DI 0 "register_operand" "=r")
933
        (plus:DI (unspec:DI [(match_operand 1 "ie_tls_symbolic_operand" "")]
934
                            UNSPEC_LTOFF_TPREL)
935
                 (match_operand:DI 2 "register_operand" "a")))]
936
  ""
937
  "addl %0 = @ltoff(@tprel(%1)), %2"
938
  [(set_attr "itanium_class" "ialu")])
939
 
940
(define_expand "add_tprel"
941
  [(set (match_operand:DI 0 "register_operand" "")
942
        (plus:DI (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
943
                            UNSPEC_TPREL)
944
                 (match_operand:DI 2 "register_operand" "")))]
945
  "!TARGET_TLS64"
946
  "")
947
 
948
(define_insn "*add_tprel14"
949
  [(set (match_operand:DI 0 "register_operand" "=r")
950
        (plus:DI (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
951
                            UNSPEC_TPREL)
952
                 (match_operand:DI 2 "register_operand" "r")))]
953
  "TARGET_TLS14"
954
  "adds %0 = @tprel(%1), %2"
955
  [(set_attr "itanium_class" "ialu")])
956
 
957
(define_insn "*add_tprel22"
958
  [(set (match_operand:DI 0 "register_operand" "=r")
959
        (plus:DI (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
960
                            UNSPEC_TPREL)
961
                 (match_operand:DI 2 "register_operand" "a")))]
962
  "TARGET_TLS22"
963
  "addl %0 = @tprel(%1), %2"
964
  [(set_attr "itanium_class" "ialu")])
965
 
966
;; With no offsettable memory references, we've got to have a scratch
967
;; around to play with the second word.  However, in order to avoid a
968
;; reload nightmare we lie, claim we don't need one, and fix it up
969
;; in ia64_split_tmode_move.
970
(define_expand "movti"
971
  [(set (match_operand:TI 0 "general_operand" "")
972
        (match_operand:TI 1 "general_operand" ""))]
973
  ""
974
{
975
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
976
  if (!op1)
977
    DONE;
978
  operands[1] = op1;
979
})
980
 
981
(define_insn_and_split "movti_internal"
982
  [(set (match_operand:TI 0 "destination_operand" "=r,   *fm,*x,*f,  Q")
983
        (match_operand:TI 1 "general_operand"     "r*fim,r,  Q, *fOQ,*f"))]
984
  "ia64_move_ok (operands[0], operands[1])"
985
  "@
986
   #
987
   #
988
   ldfp8 %X0 = %1%P1
989
   #
990
   #"
991
  "reload_completed && !ia64_load_pair_ok(operands[0], operands[1])"
992
  [(const_int 0)]
993
{
994
  ia64_split_tmode_move (operands);
995
  DONE;
996
}
997
  [(set_attr "itanium_class" "unknown,unknown,fldp,unknown,unknown")
998
   (set_attr "speculable1"   "yes")
999
   (set_attr "speculable2"   "no,     no,     yes, no,     no")])
1000
 
1001
;; Floating Point Moves
1002
;;
1003
;; Note - Patterns for SF mode moves are compulsory, but
1004
;; patterns for DF are optional, as GCC can synthesize them.
1005
 
1006
(define_expand "movsf"
1007
  [(set (match_operand:SF 0 "general_operand" "")
1008
        (match_operand:SF 1 "general_operand" ""))]
1009
  ""
1010
{
1011
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
1012
  if (!op1)
1013
    DONE;
1014
  operands[1] = op1;
1015
})
1016
 
1017
(define_insn "movsf_internal"
1018
  [(set (match_operand:SF 0 "destination_operand" "=f,f, Q,*r, f,*r,*r, m,*r")
1019
        (match_operand:SF 1 "general_operand"     "fG,Q,fG,fG,*r,*r, m,*r, F"))]
1020
  "ia64_move_ok (operands[0], operands[1])"
1021
  "@
1022
   mov %0 = %F1
1023
   ldfs %0 = %1%P1
1024
   stfs %0 = %F1%P0
1025
   getf.s %0 = %F1
1026
   setf.s %0 = %1
1027
   mov %0 = %1
1028
   ld4%O1 %0 = %1%P1
1029
   st4%Q0 %0 = %1%P0
1030
   movl %0 = %G1"
1031
  [(set_attr "itanium_class" "fmisc,fld,stf,frfr,tofr,ialu,ld,st,long_i")
1032
   (set_attr "speculable1"   "yes")
1033
   (set_attr "speculable2"   "no,   yes,no, no,  no,  no, yes,no,no")])
1034
 
1035
(define_expand "movdf"
1036
  [(set (match_operand:DF 0 "general_operand" "")
1037
        (match_operand:DF 1 "general_operand" ""))]
1038
  ""
1039
{
1040
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
1041
  if (!op1)
1042
    DONE;
1043
  operands[1] = op1;
1044
})
1045
 
1046
(define_insn "movdf_internal"
1047
  [(set (match_operand:DF 0 "destination_operand" "=f,f, Q,*r, f,*r,*r, m,*r")
1048
        (match_operand:DF 1 "general_operand"     "fG,Q,fG,fG,*r,*r, m,*r, F"))]
1049
  "ia64_move_ok (operands[0], operands[1])"
1050
  "@
1051
   mov %0 = %F1
1052
   ldfd %0 = %1%P1
1053
   stfd %0 = %F1%P0
1054
   getf.d %0 = %F1
1055
   setf.d %0 = %1
1056
   mov %0 = %1
1057
   ld8%O1 %0 = %1%P1
1058
   st8%Q0 %0 = %1%P0
1059
   movl %0 = %G1"
1060
  [(set_attr "itanium_class" "fmisc,fld,stf,frfr,tofr,ialu,ld,st,long_i")
1061
   (set_attr "speculable1"   "yes")
1062
   (set_attr "speculable2"   "no,   yes,no, no,  no,  no, yes,no,no")])
1063
 
1064
;; With no offsettable memory references, we've got to have a scratch
1065
;; around to play with the second word if the variable winds up in GRs.
1066
(define_expand "movxf"
1067
  [(set (match_operand:XF 0 "general_operand" "")
1068
        (match_operand:XF 1 "general_operand" ""))]
1069
  ""
1070
{
1071
  if (ia64_expand_movxf_movrf (XFmode, operands))
1072
    DONE;
1073
})
1074
 
1075
;; ??? There's no easy way to mind volatile acquire/release semantics.
1076
 
1077
(define_insn "movxf_internal"
1078
  [(set (match_operand:XF 0 "destination_operand" "=f,f, m")
1079
        (match_operand:XF 1 "general_operand"     "fG,m,fG"))]
1080
  "ia64_move_ok (operands[0], operands[1])"
1081
  "@
1082
   mov %0 = %F1
1083
   ldfe %0 = %1%P1
1084
   stfe %0 = %F1%P0"
1085
  [(set_attr "itanium_class" "fmisc,fld,stf")
1086
   (set_attr "speculable1"   "yes")
1087
   (set_attr "speculable2"   "no,   yes,no")])
1088
 
1089
;; Same as for movxf, but for RFmode.
1090
(define_expand "movrf"
1091
  [(set (match_operand:RF 0 "general_operand" "")
1092
        (match_operand:RF 1 "general_operand" ""))]
1093
  ""
1094
{
1095
  if (ia64_expand_movxf_movrf (RFmode, operands))
1096
    DONE;
1097
})
1098
 
1099
(define_insn "*movrf_internal"
1100
  [(set (match_operand:RF 0 "destination_operand" "=f,f, m")
1101
        (match_operand:RF 1 "general_operand"     "fG,m,fG"))]
1102
  "ia64_move_ok (operands[0], operands[1])"
1103
  "@
1104
   mov %0 = %F1
1105
   ldf.fill %0 = %1%P1
1106
   stf.spill %0 = %F1%P0"
1107
  [(set_attr "itanium_class" "fmisc,fld,stf")])
1108
 
1109
;; Better code generation via insns that deal with TFmode register pairs
1110
;; directly.  Same concerns apply as for TImode.
1111
(define_expand "movtf"
1112
  [(set (match_operand:TF 0 "general_operand" "")
1113
        (match_operand:TF 1 "general_operand" ""))]
1114
  ""
1115
{
1116
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
1117
  if (!op1)
1118
    DONE;
1119
  operands[1] = op1;
1120
})
1121
 
1122
(define_insn_and_split "*movtf_internal"
1123
  [(set (match_operand:TF 0 "destination_operand"  "=r,r,m")
1124
        (match_operand:TF 1 "general_operand"      "ri,m,r"))]
1125
  "ia64_move_ok (operands[0], operands[1])"
1126
  "#"
1127
  "reload_completed"
1128
  [(const_int 0)]
1129
{
1130
  ia64_split_tmode_move (operands);
1131
  DONE;
1132
}
1133
  [(set_attr "itanium_class" "unknown")
1134
   (set_attr "predicable" "no")])
1135
 
1136
 
1137
;; ::::::::::::::::::::
1138
;; ::
1139
;; :: Conversions
1140
;; ::
1141
;; ::::::::::::::::::::
1142
 
1143
;; Signed conversions from a smaller integer to a larger integer
1144
 
1145
(define_insn "extendqidi2"
1146
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
1147
        (sign_extend:DI (match_operand:QI 1 "gr_register_operand" "r")))]
1148
  ""
1149
  "sxt1 %0 = %1"
1150
  [(set_attr "itanium_class" "xtd")])
1151
 
1152
(define_insn "extendhidi2"
1153
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
1154
        (sign_extend:DI (match_operand:HI 1 "gr_register_operand" "r")))]
1155
  ""
1156
  "sxt2 %0 = %1"
1157
  [(set_attr "itanium_class" "xtd")])
1158
 
1159
(define_insn "extendsidi2"
1160
  [(set (match_operand:DI 0 "grfr_register_operand" "=r,?f")
1161
        (sign_extend:DI (match_operand:SI 1 "grfr_register_operand" "r,f")))]
1162
  ""
1163
  "@
1164
   sxt4 %0 = %1
1165
   fsxt.r %0 = %1, %1"
1166
  [(set_attr "itanium_class" "xtd,fmisc")])
1167
 
1168
;; Unsigned conversions from a smaller integer to a larger integer
1169
 
1170
(define_insn "zero_extendqidi2"
1171
  [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
1172
        (zero_extend:DI (match_operand:QI 1 "gr_nonimmediate_operand" "r,m")))]
1173
  ""
1174
  "@
1175
   zxt1 %0 = %1
1176
   ld1%O1 %0 = %1%P1"
1177
  [(set_attr "itanium_class" "xtd,ld")
1178
   (set_attr "speculable1"   "yes")
1179
   (set_attr "speculable2"   "no, yes")])
1180
 
1181
(define_insn "zero_extendhidi2"
1182
  [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
1183
        (zero_extend:DI (match_operand:HI 1 "gr_nonimmediate_operand" "r,m")))]
1184
  ""
1185
  "@
1186
   zxt2 %0 = %1
1187
   ld2%O1 %0 = %1%P1"
1188
  [(set_attr "itanium_class" "xtd,ld")
1189
   (set_attr "speculable1"   "yes")
1190
   (set_attr "speculable2"   "no, yes")])
1191
 
1192
(define_insn "zero_extendsidi2"
1193
  [(set (match_operand:DI 0 "grfr_register_operand" "=r,r,?f")
1194
        (zero_extend:DI
1195
          (match_operand:SI 1 "grfr_nonimmediate_operand" "r,m,f")))]
1196
  ""
1197
  "@
1198
   addp4 %0 = %1, r0
1199
   ld4%O1 %0 = %1%P1
1200
   fmix.r %0 = f0, %1"
1201
  [(set_attr "itanium_class" "ialu,ld,fmisc")
1202
   (set_attr "speculable1"   "yes")
1203
   (set_attr "speculable2"   "no, yes,no")])
1204
 
1205
;; Convert between floating point types of different sizes.
1206
 
1207
;; At first glance, it would appear that emitting fnorm for an extending
1208
;; conversion is unnecessary.  However, the stf and getf instructions work
1209
;; correctly only if the input is properly rounded for its type.  In
1210
;; particular, we get the wrong result for getf.d/stfd if the input is a
1211
;; denorm single.  Since we don't know what the next instruction will be, we
1212
;; have to emit an fnorm.
1213
 
1214
;; ??? Optimization opportunity here.  Get rid of the insn altogether
1215
;; when we can.  Should probably use a scheme like has been proposed
1216
;; for ia32 in dealing with operands that match unary operators.  This
1217
;; would let combine merge the thing into adjacent insns.  See also how the
1218
;; mips port handles SIGN_EXTEND as operands to integer arithmetic insns via
1219
;; se_register_operand.
1220
 
1221
(define_insn "extendsfdf2"
1222
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
1223
        (float_extend:DF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")))]
1224
  ""
1225
  "fnorm.d %0 = %F1"
1226
  [(set_attr "itanium_class" "fmac")])
1227
 
1228
(define_insn "extendsfxf2"
1229
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
1230
        (float_extend:XF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")))]
1231
  ""
1232
  "fnorm %0 = %F1"
1233
  [(set_attr "itanium_class" "fmac")])
1234
 
1235
(define_insn "extenddfxf2"
1236
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
1237
        (float_extend:XF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")))]
1238
  ""
1239
  "fnorm %0 = %F1"
1240
  [(set_attr "itanium_class" "fmac")])
1241
 
1242
(define_insn "truncdfsf2"
1243
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
1244
        (float_truncate:SF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")))]
1245
  ""
1246
  "fnorm.s %0 = %F1"
1247
  [(set_attr "itanium_class" "fmac")])
1248
 
1249
(define_insn "truncxfsf2"
1250
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
1251
        (float_truncate:SF (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")))]
1252
  ""
1253
  "fnorm.s %0 = %F1"
1254
  [(set_attr "itanium_class" "fmac")])
1255
 
1256
(define_insn "truncxfdf2"
1257
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
1258
        (float_truncate:DF (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")))]
1259
  ""
1260
  "fnorm.d %0 = %F1"
1261
  [(set_attr "itanium_class" "fmac")])
1262
 
1263
;; Convert between signed integer types and floating point.
1264
 
1265
(define_insn "floatdirf2"
1266
  [(set (match_operand:RF 0 "fr_register_operand" "=f")
1267
        (float:RF (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG")))]
1268
  ""
1269
  "fcvt.xf %0 = %F1"
1270
  [(set_attr "itanium_class" "fcvtfx")])
1271
 
1272
(define_insn "floatdixf2"
1273
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
1274
        (float:XF (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG")))]
1275
  ""
1276
  "fcvt.xf %0 = %F1"
1277
  [(set_attr "itanium_class" "fcvtfx")])
1278
 
1279
(define_insn "fix_truncsfdi2"
1280
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1281
        (fix:DI (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")))]
1282
  ""
1283
  "fcvt.fx.trunc %0 = %F1"
1284
  [(set_attr "itanium_class" "fcvtfx")])
1285
 
1286
(define_insn "fix_truncdfdi2"
1287
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1288
        (fix:DI (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")))]
1289
  ""
1290
  "fcvt.fx.trunc %0 = %F1"
1291
  [(set_attr "itanium_class" "fcvtfx")])
1292
 
1293
(define_insn "fix_truncxfdi2"
1294
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1295
        (fix:DI (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")))]
1296
  ""
1297
  "fcvt.fx.trunc %0 = %F1"
1298
  [(set_attr "itanium_class" "fcvtfx")])
1299
 
1300
(define_insn "fix_truncrfdi2"
1301
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1302
        (fix:DI (match_operand:RF 1 "fr_reg_or_fp01_operand" "fG")))]
1303
  ""
1304
  "fcvt.fx.trunc %0 = %F1"
1305
  [(set_attr "itanium_class" "fcvtfx")])
1306
 
1307
;; Convert between unsigned integer types and floating point.
1308
 
1309
(define_insn "floatunsdisf2"
1310
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
1311
        (unsigned_float:SF (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG")))]
1312
  ""
1313
  "fcvt.xuf.s %0 = %F1"
1314
  [(set_attr "itanium_class" "fcvtfx")])
1315
 
1316
(define_insn "floatunsdidf2"
1317
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
1318
        (unsigned_float:DF (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG")))]
1319
  ""
1320
  "fcvt.xuf.d %0 = %F1"
1321
  [(set_attr "itanium_class" "fcvtfx")])
1322
 
1323
(define_insn "floatunsdixf2"
1324
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
1325
        (unsigned_float:XF (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG")))]
1326
  ""
1327
  "fcvt.xuf %0 = %F1"
1328
  [(set_attr "itanium_class" "fcvtfx")])
1329
 
1330
(define_insn "floatunsdirf2"
1331
  [(set (match_operand:RF 0 "fr_register_operand" "=f")
1332
        (unsigned_float:RF (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG")))]
1333
  ""
1334
  "fcvt.xuf %0 = %F1"
1335
  [(set_attr "itanium_class" "fcvtfx")])
1336
 
1337
(define_insn "fixuns_truncsfdi2"
1338
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1339
        (unsigned_fix:DI (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")))]
1340
  ""
1341
  "fcvt.fxu.trunc %0 = %F1"
1342
  [(set_attr "itanium_class" "fcvtfx")])
1343
 
1344
(define_insn "fixuns_truncdfdi2"
1345
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1346
        (unsigned_fix:DI (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")))]
1347
  ""
1348
  "fcvt.fxu.trunc %0 = %F1"
1349
  [(set_attr "itanium_class" "fcvtfx")])
1350
 
1351
(define_insn "fixuns_truncxfdi2"
1352
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1353
        (unsigned_fix:DI (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")))]
1354
  ""
1355
  "fcvt.fxu.trunc %0 = %F1"
1356
  [(set_attr "itanium_class" "fcvtfx")])
1357
 
1358
(define_insn "fixuns_truncrfdi2"
1359
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1360
        (unsigned_fix:DI (match_operand:RF 1 "fr_reg_or_fp01_operand" "fG")))]
1361
  ""
1362
  "fcvt.fxu.trunc %0 = %F1"
1363
  [(set_attr "itanium_class" "fcvtfx")])
1364
 
1365
;; ::::::::::::::::::::
1366
;; ::
1367
;; :: Bit field extraction
1368
;; ::
1369
;; ::::::::::::::::::::
1370
 
1371
(define_insn "extv"
1372
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
1373
        (sign_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
1374
                         (match_operand:DI 2 "extr_len_operand" "n")
1375
                         (match_operand:DI 3 "shift_count_operand" "M")))]
1376
  ""
1377
  "extr %0 = %1, %3, %2"
1378
  [(set_attr "itanium_class" "ishf")])
1379
 
1380
(define_insn "extzv"
1381
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
1382
        (zero_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
1383
                         (match_operand:DI 2 "extr_len_operand" "n")
1384
                         (match_operand:DI 3 "shift_count_operand" "M")))]
1385
  ""
1386
  "extr.u %0 = %1, %3, %2"
1387
  [(set_attr "itanium_class" "ishf")])
1388
 
1389
;; Insert a bit field.
1390
;; Can have 3 operands, source1 (inserter), source2 (insertee), dest.
1391
;; Source1 can be 0 or -1.
1392
;; Source2 can be 0.
1393
 
1394
;; ??? Actual dep instruction is more powerful than what these insv
1395
;; patterns support.  Unfortunately, combine is unable to create patterns
1396
;; where source2 != dest.
1397
 
1398
(define_expand "insv"
1399
  [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "")
1400
                         (match_operand:DI 1 "const_int_operand" "")
1401
                         (match_operand:DI 2 "const_int_operand" ""))
1402
        (match_operand:DI 3 "nonmemory_operand" ""))]
1403
  ""
1404
{
1405
  int width = INTVAL (operands[1]);
1406
  int shift = INTVAL (operands[2]);
1407
 
1408
  /* If operand[3] is a constant, and isn't 0 or -1, then load it into a
1409
     pseudo.  */
1410
  if (! register_operand (operands[3], DImode)
1411
      && operands[3] != const0_rtx && operands[3] != constm1_rtx)
1412
    operands[3] = force_reg (DImode, operands[3]);
1413
 
1414
  /* If this is a single dep instruction, we have nothing to do.  */
1415
  if (! ((register_operand (operands[3], DImode) && width <= 16)
1416
         || operands[3] == const0_rtx || operands[3] == constm1_rtx))
1417
    {
1418
      /* Check for cases that can be implemented with a mix instruction.  */
1419
      if (width == 32 && shift == 0)
1420
        {
1421
          /* Directly generating the mix4left instruction confuses
1422
             optimize_bit_field in function.c.  Since this is performing
1423
             a useful optimization, we defer generation of the complicated
1424
             mix4left RTL to the first splitting phase.  */
1425
          rtx tmp = gen_reg_rtx (DImode);
1426
          emit_insn (gen_shift_mix4left (operands[0], operands[3], tmp));
1427
          DONE;
1428
        }
1429
      else if (width == 32 && shift == 32)
1430
        {
1431
          emit_insn (gen_mix4right (operands[0], operands[3]));
1432
          DONE;
1433
        }
1434
 
1435
      /* We could handle remaining cases by emitting multiple dep
1436
         instructions.
1437
 
1438
         If we need more than two dep instructions then we lose.  A 6
1439
         insn sequence mov mask1,mov mask2,shl;;and,and;;or is better than
1440
         mov;;dep,shr;;dep,shr;;dep.  The former can be executed in 3 cycles,
1441
         the latter is 6 cycles on an Itanium (TM) processor, because there is
1442
         only one function unit that can execute dep and shr immed.
1443
 
1444
         If we only need two dep instruction, then we still lose.
1445
         mov;;dep,shr;;dep is still 4 cycles.  Even if we optimize away
1446
         the unnecessary mov, this is still undesirable because it will be
1447
         hard to optimize, and it creates unnecessary pressure on the I0
1448
         function unit.  */
1449
 
1450
      FAIL;
1451
 
1452
#if 0
1453
      /* This code may be useful for other IA-64 processors, so we leave it in
1454
         for now.  */
1455
      while (width > 16)
1456
        {
1457
          rtx tmp;
1458
 
1459
          emit_insn (gen_insv (operands[0], GEN_INT (16), GEN_INT (shift),
1460
                               operands[3]));
1461
          shift += 16;
1462
          width -= 16;
1463
          tmp = gen_reg_rtx (DImode);
1464
          emit_insn (gen_lshrdi3 (tmp, operands[3], GEN_INT (16)));
1465
          operands[3] = tmp;
1466
        }
1467
      operands[1] = GEN_INT (width);
1468
      operands[2] = GEN_INT (shift);
1469
#endif
1470
    }
1471
})
1472
 
1473
(define_insn "*insv_internal"
1474
  [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
1475
                         (match_operand:DI 1 "const_int_operand" "n")
1476
                         (match_operand:DI 2 "const_int_operand" "n"))
1477
        (match_operand:DI 3 "nonmemory_operand" "rP"))]
1478
  "(gr_register_operand (operands[3], DImode) && INTVAL (operands[1]) <= 16)
1479
   || operands[3] == const0_rtx || operands[3] == constm1_rtx"
1480
  "dep %0 = %3, %0, %2, %1"
1481
  [(set_attr "itanium_class" "ishf")])
1482
 
1483
;; Combine doesn't like to create bit-field insertions into zero.
1484
(define_insn "*shladdp4_internal"
1485
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
1486
        (and:DI (ashift:DI (match_operand:DI 1 "gr_register_operand" "r")
1487
                           (match_operand:DI 2 "shladd_log2_operand" "n"))
1488
                (match_operand:DI 3 "const_int_operand" "n")))]
1489
  "ia64_depz_field_mask (operands[3], operands[2]) + INTVAL (operands[2]) == 32"
1490
  "shladdp4 %0 = %1, %2, r0"
1491
  [(set_attr "itanium_class" "ialu")])
1492
 
1493
(define_insn "*depz_internal"
1494
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
1495
        (and:DI (ashift:DI (match_operand:DI 1 "gr_register_operand" "r")
1496
                           (match_operand:DI 2 "const_int_operand" "M"))
1497
                (match_operand:DI 3 "const_int_operand" "n")))]
1498
  "satisfies_constraint_M (operands[2])
1499
   && ia64_depz_field_mask (operands[3], operands[2]) > 0"
1500
{
1501
  operands[3] = GEN_INT (ia64_depz_field_mask (operands[3], operands[2]));
1502
  return "%,dep.z %0 = %1, %2, %3";
1503
}
1504
  [(set_attr "itanium_class" "ishf")])
1505
 
1506
(define_insn "shift_mix4left"
1507
  [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
1508
                         (const_int 32) (const_int 0))
1509
        (match_operand:DI 1 "gr_register_operand" "r"))
1510
   (clobber (match_operand:DI 2 "gr_register_operand" "=r"))]
1511
  ""
1512
  "#"
1513
  [(set_attr "itanium_class" "unknown")])
1514
 
1515
(define_split
1516
  [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "")
1517
                         (const_int 32) (const_int 0))
1518
        (match_operand:DI 1 "register_operand" ""))
1519
   (clobber (match_operand:DI 2 "register_operand" ""))]
1520
  ""
1521
  [(set (match_dup 3) (ashift:DI (match_dup 1) (const_int 32)))
1522
   (set (zero_extract:DI (match_dup 0) (const_int 32) (const_int 0))
1523
        (lshiftrt:DI (match_dup 3) (const_int 32)))]
1524
  "operands[3] = operands[2];")
1525
 
1526
(define_insn "*mix4left"
1527
  [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
1528
                         (const_int 32) (const_int 0))
1529
        (lshiftrt:DI (match_operand:DI 1 "gr_register_operand" "r")
1530
                     (const_int 32)))]
1531
  ""
1532
  "mix4.l %0 = %0, %r1"
1533
  [(set_attr "itanium_class" "mmshf")])
1534
 
1535
(define_insn "mix4right"
1536
  [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
1537
                         (const_int 32) (const_int 32))
1538
        (match_operand:DI 1 "gr_reg_or_0_operand" "rO"))]
1539
  ""
1540
  "mix4.r %0 = %r1, %0"
1541
  [(set_attr "itanium_class" "mmshf")])
1542
 
1543
;; This is used by the rotrsi3 pattern.
1544
 
1545
(define_insn "*mix4right_3op"
1546
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
1547
        (ior:DI (zero_extend:DI (match_operand:SI 1 "gr_register_operand" "r"))
1548
                (ashift:DI (zero_extend:DI
1549
                             (match_operand:SI 2 "gr_register_operand" "r"))
1550
                           (const_int 32))))]
1551
  ""
1552
  "mix4.r %0 = %2, %1"
1553
  [(set_attr "itanium_class" "mmshf")])
1554
 
1555
 
1556
;; ::::::::::::::::::::
1557
;; ::
1558
;; :: 1-bit Integer arithmetic
1559
;; ::
1560
;; ::::::::::::::::::::
1561
 
1562
(define_insn_and_split "andbi3"
1563
  [(set (match_operand:BI 0 "register_operand" "=c,c,r")
1564
        (and:BI (match_operand:BI 1 "register_operand" "%0,0,r")
1565
                (match_operand:BI 2 "register_operand" "c,r,r")))]
1566
  ""
1567
  "@
1568
   #
1569
   tbit.nz.and.orcm %0, %I0 = %2, 0
1570
   and %0 = %2, %1"
1571
  "reload_completed
1572
   && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1573
   && GET_CODE (operands[2]) == REG && PR_REGNO_P (REGNO (operands[2]))"
1574
  [(cond_exec (eq (match_dup 2) (const_int 0))
1575
     (set (match_dup 0) (and:BI (ne:BI (const_int 0) (const_int 0))
1576
                                (match_dup 0))))]
1577
  ""
1578
  [(set_attr "itanium_class" "unknown,tbit,ilog")])
1579
 
1580
(define_insn_and_split "*andcmbi3"
1581
  [(set (match_operand:BI 0 "register_operand" "=c,c,r")
1582
        (and:BI (not:BI (match_operand:BI 1 "register_operand" "c,r,r"))
1583
                (match_operand:BI 2 "register_operand" "0,0,r")))]
1584
  ""
1585
  "@
1586
   #
1587
   tbit.z.and.orcm %0, %I0 = %1, 0
1588
   andcm %0 = %2, %1"
1589
  "reload_completed
1590
   && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1591
   && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
1592
  [(cond_exec (ne (match_dup 1) (const_int 0))
1593
     (set (match_dup 0) (and:BI (ne:BI (const_int 0) (const_int 0))
1594
                                (match_dup 0))))]
1595
  ""
1596
  [(set_attr "itanium_class" "unknown,tbit,ilog")])
1597
 
1598
(define_insn_and_split "iorbi3"
1599
  [(set (match_operand:BI 0 "register_operand" "=c,c,r")
1600
        (ior:BI (match_operand:BI 1 "register_operand" "%0,0,r")
1601
                (match_operand:BI 2 "register_operand" "c,r,r")))]
1602
  ""
1603
  "@
1604
   #
1605
   tbit.nz.or.andcm %0, %I0 = %2, 0
1606
   or %0 = %2, %1"
1607
  "reload_completed
1608
   && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1609
   && GET_CODE (operands[2]) == REG && PR_REGNO_P (REGNO (operands[2]))"
1610
  [(cond_exec (ne (match_dup 2) (const_int 0))
1611
     (set (match_dup 0) (ior:BI (eq:BI (const_int 0) (const_int 0))
1612
                                (match_dup 0))))]
1613
  ""
1614
  [(set_attr "itanium_class" "unknown,tbit,ilog")])
1615
 
1616
(define_insn_and_split "*iorcmbi3"
1617
  [(set (match_operand:BI 0 "register_operand" "=c,c")
1618
        (ior:BI (not:BI (match_operand:BI 1 "register_operand" "c,r"))
1619
                (match_operand:BI 2 "register_operand" "0,0")))]
1620
  ""
1621
  "@
1622
   #
1623
   tbit.z.or.andcm %0, %I0 = %1, 0"
1624
  "reload_completed
1625
   && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1626
   && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
1627
  [(cond_exec (eq (match_dup 1) (const_int 0))
1628
     (set (match_dup 0) (ior:BI (eq:BI (const_int 0) (const_int 0))
1629
                                (match_dup 0))))]
1630
  ""
1631
  [(set_attr "itanium_class" "unknown,tbit")])
1632
 
1633
(define_insn "one_cmplbi2"
1634
  [(set (match_operand:BI 0 "register_operand" "=c,r,c,&c")
1635
        (not:BI (match_operand:BI 1 "register_operand" "r,r,0,c")))
1636
   (clobber (match_scratch:BI 2 "=X,X,c,X"))]
1637
  ""
1638
  "@
1639
   tbit.z %0, %I0 = %1, 0
1640
   xor %0 = 1, %1
1641
   #
1642
   #"
1643
  [(set_attr "itanium_class" "tbit,ilog,unknown,unknown")])
1644
 
1645
(define_split
1646
  [(set (match_operand:BI 0 "register_operand" "")
1647
        (not:BI (match_operand:BI 1 "register_operand" "")))
1648
   (clobber (match_scratch:BI 2 ""))]
1649
  "reload_completed
1650
   && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1651
   && rtx_equal_p (operands[0], operands[1])"
1652
  [(set (match_dup 4) (match_dup 3))
1653
   (set (match_dup 0) (const_int 1))
1654
   (cond_exec (ne (match_dup 2) (const_int 0))
1655
     (set (match_dup 0) (const_int 0)))
1656
   (set (match_dup 0) (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
1657
  "operands[3] = gen_rtx_REG (CCImode, REGNO (operands[1]));
1658
   operands[4] = gen_rtx_REG (CCImode, REGNO (operands[2]));")
1659
 
1660
(define_split
1661
  [(set (match_operand:BI 0 "register_operand" "")
1662
        (not:BI (match_operand:BI 1 "register_operand" "")))
1663
   (clobber (match_scratch:BI 2 ""))]
1664
  "reload_completed
1665
   && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1666
   && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))
1667
   && ! rtx_equal_p (operands[0], operands[1])"
1668
  [(cond_exec (ne (match_dup 1) (const_int 0))
1669
     (set (match_dup 0) (const_int 0)))
1670
   (cond_exec (eq (match_dup 1) (const_int 0))
1671
     (set (match_dup 0) (const_int 1)))
1672
   (set (match_dup 0) (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
1673
  "")
1674
 
1675
(define_insn "*cmpsi_and_0"
1676
  [(set (match_operand:BI 0 "register_operand" "=c")
1677
        (and:BI (match_operator:BI 4 "predicate_operator"
1678
                  [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1679
                   (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")])
1680
                (match_operand:BI 1 "register_operand" "0")))]
1681
  ""
1682
  "cmp4.%C4.and.orcm %0, %I0 = %3, %r2"
1683
  [(set_attr "itanium_class" "icmp")])
1684
 
1685
(define_insn "*cmpsi_and_1"
1686
  [(set (match_operand:BI 0 "register_operand" "=c")
1687
        (and:BI (match_operator:BI 3 "signed_inequality_operator"
1688
                  [(match_operand:SI 2 "gr_register_operand" "r")
1689
                   (const_int 0)])
1690
                (match_operand:BI 1 "register_operand" "0")))]
1691
  ""
1692
  "cmp4.%C3.and.orcm %0, %I0 = r0, %2"
1693
  [(set_attr "itanium_class" "icmp")])
1694
 
1695
(define_insn "*cmpsi_andnot_0"
1696
  [(set (match_operand:BI 0 "register_operand" "=c")
1697
        (and:BI (not:BI (match_operator:BI 4 "predicate_operator"
1698
                         [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1699
                          (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")]))
1700
                (match_operand:BI 1 "register_operand" "0")))]
1701
  ""
1702
  "cmp4.%C4.or.andcm %I0, %0 = %3, %r2"
1703
  [(set_attr "itanium_class" "icmp")])
1704
 
1705
(define_insn "*cmpsi_andnot_1"
1706
  [(set (match_operand:BI 0 "register_operand" "=c")
1707
        (and:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1708
                          [(match_operand:SI 2 "gr_register_operand" "r")
1709
                           (const_int 0)]))
1710
                (match_operand:BI 1 "register_operand" "0")))]
1711
  ""
1712
  "cmp4.%C3.or.andcm %I0, %0 = r0, %2"
1713
  [(set_attr "itanium_class" "icmp")])
1714
 
1715
(define_insn "*cmpdi_and_0"
1716
  [(set (match_operand:BI 0 "register_operand" "=c")
1717
        (and:BI (match_operator:BI 4 "predicate_operator"
1718
                  [(match_operand:DI 2 "gr_register_operand" "r")
1719
                   (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")])
1720
                (match_operand:BI 1 "register_operand" "0")))]
1721
  ""
1722
  "cmp.%C4.and.orcm %0, %I0 = %3, %2"
1723
  [(set_attr "itanium_class" "icmp")])
1724
 
1725
(define_insn "*cmpdi_and_1"
1726
  [(set (match_operand:BI 0 "register_operand" "=c")
1727
        (and:BI (match_operator:BI 3 "signed_inequality_operator"
1728
                  [(match_operand:DI 2 "gr_register_operand" "r")
1729
                   (const_int 0)])
1730
                (match_operand:BI 1 "register_operand" "0")))]
1731
  ""
1732
  "cmp.%C3.and.orcm %0, %I0 = r0, %2"
1733
  [(set_attr "itanium_class" "icmp")])
1734
 
1735
(define_insn "*cmpdi_andnot_0"
1736
  [(set (match_operand:BI 0 "register_operand" "=c")
1737
        (and:BI (not:BI (match_operator:BI 4 "predicate_operator"
1738
                         [(match_operand:DI 2 "gr_register_operand" "r")
1739
                          (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")]))
1740
                (match_operand:BI 1 "register_operand" "0")))]
1741
  ""
1742
  "cmp.%C4.or.andcm %I0, %0 = %3, %2"
1743
  [(set_attr "itanium_class" "icmp")])
1744
 
1745
(define_insn "*cmpdi_andnot_1"
1746
  [(set (match_operand:BI 0 "register_operand" "=c")
1747
        (and:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1748
                          [(match_operand:DI 2 "gr_register_operand" "r")
1749
                           (const_int 0)]))
1750
                (match_operand:BI 1 "register_operand" "0")))]
1751
  ""
1752
  "cmp.%C3.or.andcm %I0, %0 = r0, %2"
1753
  [(set_attr "itanium_class" "icmp")])
1754
 
1755
(define_insn "*tbit_and_0"
1756
  [(set (match_operand:BI 0 "register_operand" "=c")
1757
        (and:BI (ne:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1758
                               (const_int 1))
1759
                       (const_int 0))
1760
                (match_operand:BI 2 "register_operand" "0")))]
1761
  ""
1762
  "tbit.nz.and.orcm %0, %I0 = %1, 0"
1763
  [(set_attr "itanium_class" "tbit")])
1764
 
1765
(define_insn "*tbit_and_1"
1766
  [(set (match_operand:BI 0 "register_operand" "=c")
1767
        (and:BI (eq:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1768
                               (const_int 1))
1769
                       (const_int 0))
1770
                (match_operand:BI 2 "register_operand" "0")))]
1771
  ""
1772
  "tbit.z.and.orcm %0, %I0 = %1, 0"
1773
  [(set_attr "itanium_class" "tbit")])
1774
 
1775
(define_insn "*tbit_and_2"
1776
  [(set (match_operand:BI 0 "register_operand" "=c")
1777
        (and:BI (ne:BI (zero_extract:DI
1778
                         (match_operand:DI 1 "gr_register_operand" "r")
1779
                         (const_int 1)
1780
                         (match_operand:DI 2 "shift_count_operand" "M"))
1781
                       (const_int 0))
1782
                (match_operand:BI 3 "register_operand" "0")))]
1783
  ""
1784
  "tbit.nz.and.orcm %0, %I0 = %1, %2"
1785
  [(set_attr "itanium_class" "tbit")])
1786
 
1787
(define_insn "*tbit_and_3"
1788
  [(set (match_operand:BI 0 "register_operand" "=c")
1789
        (and:BI (eq:BI (zero_extract:DI
1790
                         (match_operand:DI 1 "gr_register_operand" "r")
1791
                         (const_int 1)
1792
                         (match_operand:DI 2 "shift_count_operand" "M"))
1793
                       (const_int 0))
1794
                (match_operand:BI 3 "register_operand" "0")))]
1795
  ""
1796
  "tbit.z.and.orcm %0, %I0 = %1, %2"
1797
  [(set_attr "itanium_class" "tbit")])
1798
 
1799
(define_insn "*cmpsi_or_0"
1800
  [(set (match_operand:BI 0 "register_operand" "=c")
1801
        (ior:BI (match_operator:BI 4 "predicate_operator"
1802
                  [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1803
                   (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")])
1804
                (match_operand:BI 1 "register_operand" "0")))]
1805
  ""
1806
  "cmp4.%C4.or.andcm %0, %I0 = %3, %r2"
1807
  [(set_attr "itanium_class" "icmp")])
1808
 
1809
(define_insn "*cmpsi_or_1"
1810
  [(set (match_operand:BI 0 "register_operand" "=c")
1811
        (ior:BI (match_operator:BI 3 "signed_inequality_operator"
1812
                  [(match_operand:SI 2 "gr_register_operand" "r")
1813
                   (const_int 0)])
1814
                (match_operand:BI 1 "register_operand" "0")))]
1815
  ""
1816
  "cmp4.%C3.or.andcm %0, %I0 = r0, %2"
1817
  [(set_attr "itanium_class" "icmp")])
1818
 
1819
(define_insn "*cmpsi_orcm_0"
1820
  [(set (match_operand:BI 0 "register_operand" "=c")
1821
        (ior:BI (not:BI (match_operator:BI 4 "predicate_operator"
1822
                         [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1823
                          (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")]))
1824
                (match_operand:BI 1 "register_operand" "0")))]
1825
  ""
1826
  "cmp4.%C4.and.orcm %I0, %0 = %3, %r2"
1827
  [(set_attr "itanium_class" "icmp")])
1828
 
1829
(define_insn "*cmpsi_orcm_1"
1830
  [(set (match_operand:BI 0 "register_operand" "=c")
1831
        (ior:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1832
                          [(match_operand:SI 2 "gr_register_operand" "r")
1833
                           (const_int 0)]))
1834
                (match_operand:BI 1 "register_operand" "0")))]
1835
  ""
1836
  "cmp4.%C3.and.orcm %I0, %0 = r0, %2"
1837
  [(set_attr "itanium_class" "icmp")])
1838
 
1839
(define_insn "*cmpdi_or_0"
1840
  [(set (match_operand:BI 0 "register_operand" "=c")
1841
        (ior:BI (match_operator:BI 4 "predicate_operator"
1842
                  [(match_operand:DI 2 "gr_register_operand" "r")
1843
                   (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")])
1844
                (match_operand:BI 1 "register_operand" "0")))]
1845
  ""
1846
  "cmp.%C4.or.andcm %0, %I0 = %3, %2"
1847
  [(set_attr "itanium_class" "icmp")])
1848
 
1849
(define_insn "*cmpdi_or_1"
1850
  [(set (match_operand:BI 0 "register_operand" "=c")
1851
        (ior:BI (match_operator:BI 3 "signed_inequality_operator"
1852
                  [(match_operand:DI 2 "gr_register_operand" "r")
1853
                   (const_int 0)])
1854
                (match_operand:BI 1 "register_operand" "0")))]
1855
  ""
1856
  "cmp.%C3.or.andcm %0, %I0 = r0, %2"
1857
  [(set_attr "itanium_class" "icmp")])
1858
 
1859
(define_insn "*cmpdi_orcm_0"
1860
  [(set (match_operand:BI 0 "register_operand" "=c")
1861
        (ior:BI (not:BI (match_operator:BI 4 "predicate_operator"
1862
                         [(match_operand:DI 2 "gr_register_operand" "r")
1863
                          (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")]))
1864
                (match_operand:BI 1 "register_operand" "0")))]
1865
  ""
1866
  "cmp.%C4.and.orcm %I0, %0 = %3, %2"
1867
  [(set_attr "itanium_class" "icmp")])
1868
 
1869
(define_insn "*cmpdi_orcm_1"
1870
  [(set (match_operand:BI 0 "register_operand" "=c")
1871
        (ior:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1872
                          [(match_operand:DI 2 "gr_register_operand" "r")
1873
                           (const_int 0)]))
1874
                (match_operand:BI 1 "register_operand" "0")))]
1875
  ""
1876
  "cmp.%C3.and.orcm %I0, %0 = r0, %2"
1877
  [(set_attr "itanium_class" "icmp")])
1878
 
1879
(define_insn "*tbit_or_0"
1880
  [(set (match_operand:BI 0 "register_operand" "=c")
1881
        (ior:BI (ne:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1882
                               (const_int 1))
1883
                       (const_int 0))
1884
                (match_operand:BI 2 "register_operand" "0")))]
1885
  ""
1886
  "tbit.nz.or.andcm %0, %I0 = %1, 0"
1887
  [(set_attr "itanium_class" "tbit")])
1888
 
1889
(define_insn "*tbit_or_1"
1890
  [(set (match_operand:BI 0 "register_operand" "=c")
1891
        (ior:BI (eq:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1892
                               (const_int 1))
1893
                       (const_int 0))
1894
                (match_operand:BI 2 "register_operand" "0")))]
1895
  ""
1896
  "tbit.z.or.andcm %0, %I0 = %1, 0"
1897
  [(set_attr "itanium_class" "tbit")])
1898
 
1899
(define_insn "*tbit_or_2"
1900
  [(set (match_operand:BI 0 "register_operand" "=c")
1901
        (ior:BI (ne:BI (zero_extract:DI
1902
                         (match_operand:DI 1 "gr_register_operand" "r")
1903
                         (const_int 1)
1904
                         (match_operand:DI 2 "shift_count_operand" "M"))
1905
                       (const_int 0))
1906
                (match_operand:BI 3 "register_operand" "0")))]
1907
  ""
1908
  "tbit.nz.or.andcm %0, %I0 = %1, %2"
1909
  [(set_attr "itanium_class" "tbit")])
1910
 
1911
(define_insn "*tbit_or_3"
1912
  [(set (match_operand:BI 0 "register_operand" "=c")
1913
        (ior:BI (eq:BI (zero_extract:DI
1914
                         (match_operand:DI 1 "gr_register_operand" "r")
1915
                         (const_int 1)
1916
                         (match_operand:DI 2 "shift_count_operand" "M"))
1917
                       (const_int 0))
1918
                (match_operand:BI 3 "register_operand" "0")))]
1919
  ""
1920
  "tbit.z.or.andcm %0, %I0 = %1, %2"
1921
  [(set_attr "itanium_class" "tbit")])
1922
 
1923
;; Transform test of and/or of setcc into parallel comparisons.
1924
 
1925
(define_split
1926
  [(set (match_operand:BI 0 "register_operand" "")
1927
        (ne:BI (and:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1928
                              (const_int 0))
1929
                       (match_operand:DI 3 "register_operand" ""))
1930
               (const_int 0)))]
1931
  ""
1932
  [(set (match_dup 0)
1933
        (and:BI (ne:BI (and:DI (match_dup 3) (const_int 1)) (const_int 0))
1934
                (match_dup 2)))]
1935
  "")
1936
 
1937
(define_split
1938
  [(set (match_operand:BI 0 "register_operand" "")
1939
        (eq:BI (and:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1940
                              (const_int 0))
1941
                       (match_operand:DI 3 "register_operand" ""))
1942
               (const_int 0)))]
1943
  ""
1944
  [(set (match_dup 0)
1945
        (and:BI (ne:BI (and:DI (match_dup 3) (const_int 1)) (const_int 0))
1946
                (match_dup 2)))
1947
   (parallel [(set (match_dup 0) (not:BI (match_dup 0)))
1948
              (clobber (scratch))])]
1949
  "")
1950
 
1951
(define_split
1952
  [(set (match_operand:BI 0 "register_operand" "")
1953
        (ne:BI (ior:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1954
                              (const_int 0))
1955
                       (match_operand:DI 3 "register_operand" ""))
1956
               (const_int 0)))]
1957
  ""
1958
  [(set (match_dup 0)
1959
        (ior:BI (ne:BI (match_dup 3) (const_int 0))
1960
                (match_dup 2)))]
1961
  "")
1962
 
1963
(define_split
1964
  [(set (match_operand:BI 0 "register_operand" "")
1965
        (eq:BI (ior:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1966
                              (const_int 0))
1967
                       (match_operand:DI 3 "register_operand" ""))
1968
               (const_int 0)))]
1969
  ""
1970
  [(set (match_dup 0)
1971
        (ior:BI (ne:BI (match_dup 3) (const_int 0))
1972
                (match_dup 2)))
1973
   (parallel [(set (match_dup 0) (not:BI (match_dup 0)))
1974
              (clobber (scratch))])]
1975
  "")
1976
 
1977
;; ??? Incredibly hackish.  Either need four proper patterns with all
1978
;; the alternatives, or rely on sched1 to split the insn and hope that
1979
;; nothing bad happens to the comparisons in the meantime.
1980
;;
1981
;; Alternately, adjust combine to allow 2->2 and 3->3 splits, assuming
1982
;; that we're doing height reduction.
1983
;
1984
;(define_insn_and_split ""
1985
;  [(set (match_operand:BI 0 "register_operand" "=c")
1986
;       (and:BI (and:BI (match_operator:BI 1 "comparison_operator"
1987
;                         [(match_operand 2 "" "")
1988
;                          (match_operand 3 "" "")])
1989
;                       (match_operator:BI 4 "comparison_operator"
1990
;                         [(match_operand 5 "" "")
1991
;                          (match_operand 6 "" "")]))
1992
;               (match_dup 0)))]
1993
;  "flag_schedule_insns"
1994
;  "#"
1995
;  ""
1996
;  [(set (match_dup 0) (and:BI (match_dup 1) (match_dup 0)))
1997
;   (set (match_dup 0) (and:BI (match_dup 4) (match_dup 0)))]
1998
;  "")
1999
;
2000
;(define_insn_and_split ""
2001
;  [(set (match_operand:BI 0 "register_operand" "=c")
2002
;       (ior:BI (ior:BI (match_operator:BI 1 "comparison_operator"
2003
;                         [(match_operand 2 "" "")
2004
;                          (match_operand 3 "" "")])
2005
;                       (match_operator:BI 4 "comparison_operator"
2006
;                         [(match_operand 5 "" "")
2007
;                          (match_operand 6 "" "")]))
2008
;               (match_dup 0)))]
2009
;  "flag_schedule_insns"
2010
;  "#"
2011
;  ""
2012
;  [(set (match_dup 0) (ior:BI (match_dup 1) (match_dup 0)))
2013
;   (set (match_dup 0) (ior:BI (match_dup 4) (match_dup 0)))]
2014
;  "")
2015
;
2016
;(define_split
2017
;  [(set (match_operand:BI 0 "register_operand" "")
2018
;       (and:BI (and:BI (match_operator:BI 1 "comparison_operator"
2019
;                         [(match_operand 2 "" "")
2020
;                          (match_operand 3 "" "")])
2021
;                       (match_operand:BI 7 "register_operand" ""))
2022
;               (and:BI (match_operator:BI 4 "comparison_operator"
2023
;                         [(match_operand 5 "" "")
2024
;                          (match_operand 6 "" "")])
2025
;                       (match_operand:BI 8 "register_operand" ""))))]
2026
;  ""
2027
;  [(set (match_dup 0) (and:BI (match_dup 7) (match_dup 8)))
2028
;   (set (match_dup 0) (and:BI (and:BI (match_dup 1) (match_dup 4))
2029
;                             (match_dup 0)))]
2030
;  "")
2031
;
2032
;(define_split
2033
;  [(set (match_operand:BI 0 "register_operand" "")
2034
;       (ior:BI (ior:BI (match_operator:BI 1 "comparison_operator"
2035
;                         [(match_operand 2 "" "")
2036
;                          (match_operand 3 "" "")])
2037
;                       (match_operand:BI 7 "register_operand" ""))
2038
;               (ior:BI (match_operator:BI 4 "comparison_operator"
2039
;                         [(match_operand 5 "" "")
2040
;                          (match_operand 6 "" "")])
2041
;                       (match_operand:BI 8 "register_operand" ""))))]
2042
;  ""
2043
;  [(set (match_dup 0) (ior:BI (match_dup 7) (match_dup 8)))
2044
;   (set (match_dup 0) (ior:BI (ior:BI (match_dup 1) (match_dup 4))
2045
;                             (match_dup 0)))]
2046
;  "")
2047
 
2048
;; Try harder to avoid predicate copies by duplicating compares.
2049
;; Note that we'll have already split the predicate copy, which
2050
;; is kind of a pain, but oh well.
2051
 
2052
(define_peephole2
2053
  [(set (match_operand:BI 0 "register_operand" "")
2054
        (match_operand:BI 1 "comparison_operator" ""))
2055
   (set (match_operand:CCI 2 "register_operand" "")
2056
        (match_operand:CCI 3 "register_operand" ""))
2057
   (set (match_operand:CCI 4 "register_operand" "")
2058
        (match_operand:CCI 5 "register_operand" ""))
2059
   (set (match_operand:BI 6 "register_operand" "")
2060
        (unspec:BI [(match_dup 6)] UNSPEC_PRED_REL_MUTEX))]
2061
  "REGNO (operands[3]) == REGNO (operands[0])
2062
   && REGNO (operands[4]) == REGNO (operands[0]) + 1
2063
   && REGNO (operands[4]) == REGNO (operands[2]) + 1
2064
   && REGNO (operands[6]) == REGNO (operands[2])"
2065
  [(set (match_dup 0) (match_dup 1))
2066
   (set (match_dup 6) (match_dup 7))]
2067
  "operands[7] = copy_rtx (operands[1]);")
2068
 
2069
;; ::::::::::::::::::::
2070
;; ::
2071
;; :: 16-bit Integer arithmetic
2072
;; ::
2073
;; ::::::::::::::::::::
2074
 
2075
(define_insn "mulhi3"
2076
  [(set (match_operand:HI 0 "gr_register_operand" "=r")
2077
        (mult:HI (match_operand:HI 1 "gr_register_operand" "r")
2078
                 (match_operand:HI 2 "gr_register_operand" "r")))]
2079
  ""
2080
  "pmpy2.r %0 = %1, %2"
2081
  [(set_attr "itanium_class" "mmmul")])
2082
 
2083
 
2084
;; ::::::::::::::::::::
2085
;; ::
2086
;; :: 32-bit Integer arithmetic
2087
;; ::
2088
;; ::::::::::::::::::::
2089
 
2090
(define_insn "addsi3"
2091
  [(set (match_operand:SI 0 "gr_register_operand" "=r,r,r")
2092
        (plus:SI (match_operand:SI 1 "gr_register_operand" "%r,r,a")
2093
                 (match_operand:SI 2 "gr_reg_or_22bit_operand" "r,I,J")))]
2094
  ""
2095
  "@
2096
   add %0 = %1, %2
2097
   adds %0 = %2, %1
2098
   addl %0 = %2, %1"
2099
  [(set_attr "itanium_class" "ialu")])
2100
 
2101
(define_insn "*addsi3_plus1"
2102
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
2103
        (plus:SI (plus:SI (match_operand:SI 1 "gr_register_operand" "r")
2104
                          (match_operand:SI 2 "gr_register_operand" "r"))
2105
                 (const_int 1)))]
2106
  ""
2107
  "add %0 = %1, %2, 1"
2108
  [(set_attr "itanium_class" "ialu")])
2109
 
2110
(define_insn "*addsi3_plus1_alt"
2111
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
2112
        (plus:SI (mult:SI (match_operand:SI 1 "gr_register_operand" "r")
2113
                          (const_int 2))
2114
                 (const_int 1)))]
2115
  ""
2116
  "add %0 = %1, %1, 1"
2117
  [(set_attr "itanium_class" "ialu")])
2118
 
2119
(define_insn "*addsi3_shladd"
2120
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
2121
        (plus:SI (mult:SI (match_operand:SI 1 "gr_register_operand" "r")
2122
                          (match_operand:SI 2 "shladd_operand" "n"))
2123
                 (match_operand:SI 3 "gr_register_operand" "r")))]
2124
  ""
2125
  "shladd %0 = %1, %S2, %3"
2126
  [(set_attr "itanium_class" "ialu")])
2127
 
2128
(define_insn "subsi3"
2129
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
2130
        (minus:SI (match_operand:SI 1 "gr_reg_or_8bit_operand" "rK")
2131
                  (match_operand:SI 2 "gr_register_operand" "r")))]
2132
  ""
2133
  "sub %0 = %1, %2"
2134
  [(set_attr "itanium_class" "ialu")])
2135
 
2136
(define_insn "*subsi3_minus1"
2137
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
2138
        (plus:SI (not:SI (match_operand:SI 1 "gr_register_operand" "r"))
2139
                 (match_operand:SI 2 "gr_register_operand" "r")))]
2140
  ""
2141
  "sub %0 = %2, %1, 1"
2142
  [(set_attr "itanium_class" "ialu")])
2143
 
2144
;; ??? Could add maddsi3 patterns patterned after the madddi3 patterns.
2145
 
2146
(define_insn "mulsi3"
2147
  [(set (match_operand:SI 0 "fr_register_operand" "=f")
2148
        (mult:SI (match_operand:SI 1 "grfr_register_operand" "f")
2149
                 (match_operand:SI 2 "grfr_register_operand" "f")))]
2150
  ""
2151
  "xmpy.l %0 = %1, %2"
2152
  [(set_attr "itanium_class" "xmpy")])
2153
 
2154
(define_insn "maddsi4"
2155
  [(set (match_operand:SI 0 "fr_register_operand" "=f")
2156
        (plus:SI (mult:SI (match_operand:SI 1 "grfr_register_operand" "f")
2157
                          (match_operand:SI 2 "grfr_register_operand" "f"))
2158
                 (match_operand:SI 3 "grfr_register_operand" "f")))]
2159
  ""
2160
  "xma.l %0 = %1, %2, %3"
2161
  [(set_attr "itanium_class" "xmpy")])
2162
 
2163
(define_insn "negsi2"
2164
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
2165
        (neg:SI (match_operand:SI 1 "gr_register_operand" "r")))]
2166
  ""
2167
  "sub %0 = r0, %1"
2168
  [(set_attr "itanium_class" "ialu")])
2169
 
2170
(define_expand "abssi2"
2171
  [(set (match_dup 2)
2172
        (ge:BI (match_operand:SI 1 "gr_register_operand" "") (const_int 0)))
2173
   (set (match_operand:SI 0 "gr_register_operand" "")
2174
        (if_then_else:SI (eq (match_dup 2) (const_int 0))
2175
                         (neg:SI (match_dup 1))
2176
                         (match_dup 1)))]
2177
  ""
2178
  { operands[2] = gen_reg_rtx (BImode); })
2179
 
2180
(define_expand "sminsi3"
2181
  [(set (match_dup 3)
2182
        (ge:BI (match_operand:SI 1 "gr_register_operand" "")
2183
               (match_operand:SI 2 "gr_register_operand" "")))
2184
   (set (match_operand:SI 0 "gr_register_operand" "")
2185
        (if_then_else:SI (ne (match_dup 3) (const_int 0))
2186
                         (match_dup 2) (match_dup 1)))]
2187
  ""
2188
  { operands[3] = gen_reg_rtx (BImode); })
2189
 
2190
(define_expand "smaxsi3"
2191
  [(set (match_dup 3)
2192
        (ge:BI (match_operand:SI 1 "gr_register_operand" "")
2193
               (match_operand:SI 2 "gr_register_operand" "")))
2194
   (set (match_operand:SI 0 "gr_register_operand" "")
2195
        (if_then_else:SI (ne (match_dup 3) (const_int 0))
2196
                         (match_dup 1) (match_dup 2)))]
2197
  ""
2198
  { operands[3] = gen_reg_rtx (BImode); })
2199
 
2200
(define_expand "uminsi3"
2201
  [(set (match_dup 3)
2202
        (geu:BI (match_operand:SI 1 "gr_register_operand" "")
2203
                (match_operand:SI 2 "gr_register_operand" "")))
2204
   (set (match_operand:SI 0 "gr_register_operand" "")
2205
        (if_then_else:SI (ne (match_dup 3) (const_int 0))
2206
                         (match_dup 2) (match_dup 1)))]
2207
  ""
2208
  { operands[3] = gen_reg_rtx (BImode); })
2209
 
2210
(define_expand "umaxsi3"
2211
  [(set (match_dup 3)
2212
        (geu:BI (match_operand:SI 1 "gr_register_operand" "")
2213
                (match_operand:SI 2 "gr_register_operand" "")))
2214
   (set (match_operand:SI 0 "gr_register_operand" "")
2215
        (if_then_else:SI (ne (match_dup 3) (const_int 0))
2216
                         (match_dup 1) (match_dup 2)))]
2217
  ""
2218
  { operands[3] = gen_reg_rtx (BImode); })
2219
 
2220
;; ::::::::::::::::::::
2221
;; ::
2222
;; :: 64-bit Integer arithmetic
2223
;; ::
2224
;; ::::::::::::::::::::
2225
 
2226
(define_insn "adddi3"
2227
  [(set (match_operand:DI 0 "gr_register_operand" "=r,r,r")
2228
        (plus:DI (match_operand:DI 1 "gr_register_operand" "%r,r,a")
2229
                 (match_operand:DI 2 "gr_reg_or_22bit_operand" "r,I,J")))]
2230
  ""
2231
  "@
2232
   add %0 = %1, %2
2233
   adds %0 = %2, %1
2234
   addl %0 = %2, %1"
2235
  [(set_attr "itanium_class" "ialu")])
2236
 
2237
(define_insn "*adddi3_plus1"
2238
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2239
        (plus:DI (plus:DI (match_operand:DI 1 "gr_register_operand" "r")
2240
                          (match_operand:DI 2 "gr_register_operand" "r"))
2241
                 (const_int 1)))]
2242
  ""
2243
  "add %0 = %1, %2, 1"
2244
  [(set_attr "itanium_class" "ialu")])
2245
 
2246
;; This has some of the same problems as shladd.  We let the shladd
2247
;; eliminator hack handle it, which results in the 1 being forced into
2248
;; a register, but not more ugliness here.
2249
(define_insn "*adddi3_plus1_alt"
2250
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2251
        (plus:DI (mult:DI (match_operand:DI 1 "gr_register_operand" "r")
2252
                          (const_int 2))
2253
                 (const_int 1)))]
2254
  ""
2255
  "add %0 = %1, %1, 1"
2256
  [(set_attr "itanium_class" "ialu")])
2257
 
2258
(define_insn "subdi3"
2259
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2260
        (minus:DI (match_operand:DI 1 "gr_reg_or_8bit_operand" "rK")
2261
                  (match_operand:DI 2 "gr_register_operand" "r")))]
2262
  ""
2263
  "sub %0 = %1, %2"
2264
  [(set_attr "itanium_class" "ialu")])
2265
 
2266
(define_insn "*subdi3_minus1"
2267
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2268
        (plus:DI (not:DI (match_operand:DI 1 "gr_register_operand" "r"))
2269
                 (match_operand:DI 2 "gr_register_operand" "r")))]
2270
  ""
2271
  "sub %0 = %2, %1, 1"
2272
  [(set_attr "itanium_class" "ialu")])
2273
 
2274
;; ??? Use grfr instead of fr because of virtual register elimination
2275
;; and silly test cases multiplying by the frame pointer.
2276
(define_insn "muldi3"
2277
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
2278
        (mult:DI (match_operand:DI 1 "grfr_register_operand" "f")
2279
                 (match_operand:DI 2 "grfr_register_operand" "f")))]
2280
  ""
2281
  "xmpy.l %0 = %1, %2"
2282
  [(set_attr "itanium_class" "xmpy")])
2283
 
2284
;; ??? If operand 3 is an eliminable reg, then register elimination causes the
2285
;; same problem that we have with shladd below.  Unfortunately, this case is
2286
;; much harder to fix because the multiply puts the result in an FP register,
2287
;; but the add needs inputs from a general register.  We add a spurious clobber
2288
;; here so that it will be present just in case register elimination gives us
2289
;; the funny result.
2290
 
2291
;; ??? Maybe validate_changes should try adding match_scratch clobbers?
2292
 
2293
;; ??? Maybe we should change how adds are canonicalized.
2294
 
2295
(define_insn "madddi4"
2296
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
2297
        (plus:DI (mult:DI (match_operand:DI 1 "grfr_register_operand" "f")
2298
                          (match_operand:DI 2 "grfr_register_operand" "f"))
2299
                 (match_operand:DI 3 "grfr_register_operand" "f")))
2300
   (clobber (match_scratch:DI 4 "=X"))]
2301
  ""
2302
  "xma.l %0 = %1, %2, %3"
2303
  [(set_attr "itanium_class" "xmpy")])
2304
 
2305
;; This can be created by register elimination if operand3 of shladd is an
2306
;; eliminable register or has reg_equiv_constant set.
2307
 
2308
;; We have to use nonmemory_operand for operand 4, to ensure that the
2309
;; validate_changes call inside eliminate_regs will always succeed.  If it
2310
;; doesn't succeed, then this remain a madddi4 pattern, and will be reloaded
2311
;; incorrectly.
2312
 
2313
(define_insn "*madddi4_elim"
2314
  [(set (match_operand:DI 0 "register_operand" "=&r")
2315
        (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "f")
2316
                                   (match_operand:DI 2 "register_operand" "f"))
2317
                          (match_operand:DI 3 "register_operand" "f"))
2318
                 (match_operand:DI 4 "nonmemory_operand" "rI")))
2319
   (clobber (match_scratch:DI 5 "=f"))]
2320
  "reload_in_progress"
2321
  "#"
2322
  [(set_attr "itanium_class" "unknown")])
2323
 
2324
(define_split
2325
  [(set (match_operand:DI 0 "register_operand" "")
2326
        (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
2327
                                   (match_operand:DI 2 "register_operand" ""))
2328
                          (match_operand:DI 3 "register_operand" ""))
2329
                 (match_operand:DI 4 "gr_reg_or_14bit_operand" "")))
2330
   (clobber (match_scratch:DI 5 ""))]
2331
  "reload_completed"
2332
  [(parallel [(set (match_dup 5) (plus:DI (mult:DI (match_dup 1) (match_dup 2))
2333
                                          (match_dup 3)))
2334
              (clobber (match_dup 0))])
2335
   (set (match_dup 0) (match_dup 5))
2336
   (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
2337
  "")
2338
 
2339
(define_insn "smuldi3_highpart"
2340
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
2341
        (truncate:DI
2342
         (lshiftrt:TI
2343
          (mult:TI (sign_extend:TI
2344
                     (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG"))
2345
                   (sign_extend:TI
2346
                     (match_operand:DI 2 "fr_reg_or_fp01_operand" "fG")))
2347
          (const_int 64))))]
2348
  ""
2349
  "xmpy.h %0 = %F1, %F2"
2350
  [(set_attr "itanium_class" "xmpy")])
2351
 
2352
(define_insn "umuldi3_highpart"
2353
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
2354
        (truncate:DI
2355
         (lshiftrt:TI
2356
          (mult:TI (zero_extend:TI
2357
                     (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG"))
2358
                   (zero_extend:TI
2359
                     (match_operand:DI 2 "fr_reg_or_fp01_operand" "fG")))
2360
          (const_int 64))))]
2361
  ""
2362
  "xmpy.hu %0 = %F1, %F2"
2363
  [(set_attr "itanium_class" "xmpy")])
2364
 
2365
(define_insn "negdi2"
2366
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2367
        (neg:DI (match_operand:DI 1 "gr_register_operand" "r")))]
2368
  ""
2369
  "sub %0 = r0, %1"
2370
  [(set_attr "itanium_class" "ialu")])
2371
 
2372
(define_expand "absdi2"
2373
  [(set (match_dup 2)
2374
        (ge:BI (match_operand:DI 1 "gr_register_operand" "") (const_int 0)))
2375
   (set (match_operand:DI 0 "gr_register_operand" "")
2376
        (if_then_else:DI (eq (match_dup 2) (const_int 0))
2377
                         (neg:DI (match_dup 1))
2378
                         (match_dup 1)))]
2379
  ""
2380
  { operands[2] = gen_reg_rtx (BImode); })
2381
 
2382
(define_expand "smindi3"
2383
  [(set (match_dup 3)
2384
        (ge:BI (match_operand:DI 1 "gr_register_operand" "")
2385
               (match_operand:DI 2 "gr_register_operand" "")))
2386
   (set (match_operand:DI 0 "gr_register_operand" "")
2387
        (if_then_else:DI (ne (match_dup 3) (const_int 0))
2388
                         (match_dup 2) (match_dup 1)))]
2389
  ""
2390
  { operands[3] = gen_reg_rtx (BImode); })
2391
 
2392
(define_expand "smaxdi3"
2393
  [(set (match_dup 3)
2394
        (ge:BI (match_operand:DI 1 "gr_register_operand" "")
2395
               (match_operand:DI 2 "gr_register_operand" "")))
2396
   (set (match_operand:DI 0 "gr_register_operand" "")
2397
        (if_then_else:DI (ne (match_dup 3) (const_int 0))
2398
                         (match_dup 1) (match_dup 2)))]
2399
  ""
2400
  { operands[3] = gen_reg_rtx (BImode); })
2401
 
2402
(define_expand "umindi3"
2403
  [(set (match_dup 3)
2404
        (geu:BI (match_operand:DI 1 "gr_register_operand" "")
2405
                (match_operand:DI 2 "gr_register_operand" "")))
2406
   (set (match_operand:DI 0 "gr_register_operand" "")
2407
        (if_then_else:DI (ne (match_dup 3) (const_int 0))
2408
                         (match_dup 2) (match_dup 1)))]
2409
  ""
2410
  { operands[3] = gen_reg_rtx (BImode); })
2411
 
2412
(define_expand "umaxdi3"
2413
  [(set (match_dup 3)
2414
        (geu:BI (match_operand:DI 1 "gr_register_operand" "")
2415
                (match_operand:DI 2 "gr_register_operand" "")))
2416
   (set (match_operand:DI 0 "gr_register_operand" "")
2417
        (if_then_else:DI (ne (match_dup 3) (const_int 0))
2418
                         (match_dup 1) (match_dup 2)))]
2419
  ""
2420
  { operands[3] = gen_reg_rtx (BImode); })
2421
 
2422
(define_expand "ffsdi2"
2423
  [(set (match_dup 6)
2424
        (eq:BI (match_operand:DI 1 "gr_register_operand" "") (const_int 0)))
2425
   (set (match_dup 2) (plus:DI (match_dup 1) (const_int -1)))
2426
   (set (match_dup 5) (const_int 0))
2427
   (set (match_dup 3) (xor:DI (match_dup 1) (match_dup 2)))
2428
   (set (match_dup 4) (popcount:DI (match_dup 3)))
2429
   (set (match_operand:DI 0 "gr_register_operand" "")
2430
        (if_then_else:DI (ne (match_dup 6) (const_int 0))
2431
                         (match_dup 5) (match_dup 4)))]
2432
  ""
2433
{
2434
  operands[2] = gen_reg_rtx (DImode);
2435
  operands[3] = gen_reg_rtx (DImode);
2436
  operands[4] = gen_reg_rtx (DImode);
2437
  operands[5] = gen_reg_rtx (DImode);
2438
  operands[6] = gen_reg_rtx (BImode);
2439
})
2440
 
2441
(define_expand "ctzdi2"
2442
  [(set (match_dup 2) (plus:DI (match_operand:DI 1 "gr_register_operand" "")
2443
                               (const_int -1)))
2444
   (set (match_dup 3) (not:DI (match_dup 1)))
2445
   (set (match_dup 4) (and:DI (match_dup 2) (match_dup 3)))
2446
   (set (match_operand:DI 0 "gr_register_operand" "")
2447
        (popcount:DI (match_dup 4)))]
2448
  ""
2449
{
2450
  operands[2] = gen_reg_rtx (DImode);
2451
  operands[3] = gen_reg_rtx (DImode);
2452
  operands[4] = gen_reg_rtx (DImode);
2453
})
2454
 
2455
;; Note the computation here is op0 = 63 - (exp - 0xffff).
2456
(define_expand "clzdi2"
2457
  [(set (match_dup 2)
2458
        (unsigned_float:XF (match_operand:DI 1 "fr_reg_or_fp01_operand" "")))
2459
   (set (match_dup 3)
2460
        (unspec:DI [(match_dup 2)] UNSPEC_GETF_EXP))
2461
   (set (match_dup 4) (const_int 65598))
2462
   (set (match_operand:DI 0 "gr_register_operand" "")
2463
        (minus:DI (match_dup 4) (match_dup 3)))]
2464
  ""
2465
{
2466
  operands[2] = gen_reg_rtx (XFmode);
2467
  operands[3] = gen_reg_rtx (DImode);
2468
  operands[4] = gen_reg_rtx (DImode);
2469
})
2470
 
2471
(define_insn "popcountdi2"
2472
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2473
        (popcount:DI (match_operand:DI 1 "gr_register_operand" "r")))]
2474
  ""
2475
  "popcnt %0 = %1"
2476
  [(set_attr "itanium_class" "mmmul")])
2477
 
2478
(define_insn "bswapdi2"
2479
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2480
        (bswap:DI (match_operand:DI 1 "gr_register_operand" "r")))]
2481
  ""
2482
  "mux1 %0 = %1, @rev"
2483
  [(set_attr "itanium_class" "mmshf")])
2484
 
2485
(define_insn "*getf_exp_xf"
2486
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2487
        (unspec:DI [(match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")]
2488
                   UNSPEC_GETF_EXP))]
2489
  ""
2490
  "getf.exp %0 = %F1"
2491
  [(set_attr "itanium_class" "frfr")])
2492
 
2493
;; ::::::::::::::::::::
2494
;; ::
2495
;; :: 128-bit Integer arithmetic
2496
;; ::
2497
;; ::::::::::::::::::::
2498
 
2499
(define_insn "addti3"
2500
  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
2501
        (plus:TI (match_operand:TI 1 "gr_register_operand" "%r")
2502
                 (match_operand:TI 2 "gr_reg_or_14bit_operand" "rI")))
2503
   (clobber (match_scratch:BI 3 "=&c"))]
2504
  ""
2505
  "#"
2506
  [(set_attr "itanium_class" "unknown")])
2507
 
2508
(define_split
2509
  [(set (match_operand:TI 0 "register_operand" "")
2510
        (plus:TI (match_operand:TI 1 "register_operand" "")
2511
                 (match_operand:TI 2 "register_operand" "")))
2512
   (clobber (match_scratch:BI 3 ""))]
2513
  "reload_completed"
2514
  [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
2515
   (set (match_dup 3) (ltu:BI (match_dup 0) (match_dup 1)))
2516
   (cond_exec (eq (match_dup 3) (const_int 0))
2517
              (set (match_dup 4) (plus:DI (match_dup 5) (match_dup 6))))
2518
   (cond_exec (ne (match_dup 3) (const_int 0))
2519
              (set (match_dup 4)
2520
                   (plus:DI (plus:DI (match_dup 5) (match_dup 6))
2521
                            (const_int 1))))]
2522
{
2523
  operands[4] = gen_highpart (DImode, operands[0]);
2524
  operands[0] = gen_lowpart (DImode, operands[0]);
2525
  operands[5] = gen_highpart (DImode, operands[1]);
2526
  operands[1] = gen_lowpart (DImode, operands[1]);
2527
  operands[6] = gen_highpart (DImode, operands[2]);
2528
  operands[2] = gen_lowpart (DImode, operands[2]);
2529
})
2530
 
2531
(define_split
2532
  [(set (match_operand:TI 0 "register_operand" "")
2533
        (plus:TI (match_operand:TI 1 "register_operand" "")
2534
                 (match_operand:TI 2 "immediate_operand" "")))
2535
   (clobber (match_scratch:BI 3 ""))]
2536
  "reload_completed"
2537
  [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
2538
   (set (match_dup 3) (ltu:BI (match_dup 0) (match_dup 1)))
2539
   (cond_exec (eq (match_dup 3) (const_int 0))
2540
              (set (match_dup 4)
2541
                   (plus:DI (match_dup 5) (match_dup 6))))
2542
   (cond_exec (ne (match_dup 3) (const_int 0))
2543
              (set (match_dup 4)
2544
                   (plus:DI (match_dup 5) (match_dup 7))))]
2545
{
2546
  operands[4] = gen_highpart (DImode, operands[0]);
2547
  operands[0] = gen_lowpart (DImode, operands[0]);
2548
  operands[5] = gen_highpart (DImode, operands[1]);
2549
  operands[1] = gen_lowpart (DImode, operands[1]);
2550
  operands[6] = INTVAL (operands[2]) < 0 ? constm1_rtx : const0_rtx;
2551
  operands[7] = INTVAL (operands[2]) < 0 ? const0_rtx : const1_rtx;
2552
})
2553
 
2554
(define_insn "subti3"
2555
  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
2556
        (minus:TI (match_operand:TI 1 "gr_reg_or_8bit_operand" "rK")
2557
                  (match_operand:TI 2 "gr_register_operand" "r")))
2558
   (clobber (match_scratch:BI 3 "=&c"))]
2559
  ""
2560
  "#"
2561
  [(set_attr "itanium_class" "unknown")])
2562
 
2563
(define_split
2564
  [(set (match_operand:TI 0 "register_operand" "")
2565
        (minus:TI (match_operand:TI 1 "register_operand" "")
2566
                  (match_operand:TI 2 "register_operand" "")))
2567
   (clobber (match_scratch:BI 3 "=&c"))]
2568
  "reload_completed"
2569
  [(set (match_dup 0) (minus:DI (match_dup 1) (match_dup 2)))
2570
   (set (match_dup 3) (ltu:BI (match_dup 1) (match_dup 0)))
2571
   (cond_exec (eq (match_dup 3) (const_int 0))
2572
              (set (match_dup 4) (minus:DI (match_dup 5) (match_dup 6))))
2573
   (cond_exec (ne (match_dup 3) (const_int 0))
2574
              (set (match_dup 4)
2575
                   (plus:DI (not:DI (match_dup 6)) (match_dup 5))))]
2576
{
2577
  operands[4] = gen_highpart (DImode, operands[0]);
2578
  operands[0] = gen_lowpart (DImode, operands[0]);
2579
  operands[5] = gen_highpart (DImode, operands[1]);
2580
  operands[1] = gen_lowpart (DImode, operands[1]);
2581
  operands[6] = gen_highpart (DImode, operands[2]);
2582
  operands[2] = gen_lowpart (DImode, operands[2]);
2583
})
2584
 
2585
(define_split
2586
  [(set (match_operand:TI 0 "register_operand" "")
2587
        (minus:TI (match_operand:TI 1 "immediate_operand" "")
2588
                  (match_operand:TI 2 "register_operand" "")))
2589
   (clobber (match_scratch:BI 3 "=&c"))]
2590
  "reload_completed && satisfies_constraint_K (operands[1])"
2591
  [(set (match_dup 0) (minus:DI (match_dup 1) (match_dup 2)))
2592
   (set (match_dup 3) (gtu:BI (match_dup 0) (match_dup 1)))
2593
   (cond_exec (ne (match_dup 3) (const_int 0))
2594
              (set (match_dup 4) (minus:DI (match_dup 6) (match_dup 5))))
2595
   (cond_exec (eq (match_dup 3) (const_int 0))
2596
              (set (match_dup 4) (minus:DI (match_dup 7) (match_dup 5))))]
2597
{
2598
  operands[4] = gen_highpart (DImode, operands[0]);
2599
  operands[0] = gen_lowpart (DImode, operands[0]);
2600
  operands[5] = gen_highpart (DImode, operands[2]);
2601
  operands[2] = gen_lowpart (DImode, operands[2]);
2602
  operands[6] = INTVAL (operands[1]) < 0 ? GEN_INT (-2) : constm1_rtx;
2603
  operands[7] = INTVAL (operands[1]) < 0 ? constm1_rtx : const0_rtx;
2604
})
2605
 
2606
(define_expand "mulditi3"
2607
  [(set (match_operand:TI 0 "fr_register_operand" "")
2608
        (mult:TI (sign_extend:TI
2609
                   (match_operand:DI 1 "fr_reg_or_fp01_operand" ""))
2610
                 (sign_extend:TI
2611
                   (match_operand:DI 2 "fr_reg_or_fp01_operand" ""))))]
2612
  ""
2613
  "")
2614
 
2615
(define_insn_and_split "*mulditi3_internal"
2616
  [(set (match_operand:TI 0 "fr_register_operand" "=&f")
2617
        (mult:TI (sign_extend:TI
2618
                   (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG"))
2619
                 (sign_extend:TI
2620
                   (match_operand:DI 2 "fr_reg_or_fp01_operand" "fG"))))]
2621
  ""
2622
  "#"
2623
  "reload_completed"
2624
  [(set (match_dup 0) (mult:DI (match_dup 1) (match_dup 2)))
2625
   (set (match_dup 3) (truncate:DI
2626
                        (lshiftrt:TI
2627
                          (mult:TI (sign_extend:TI (match_dup 1))
2628
                                   (sign_extend:TI (match_dup 2)))
2629
                          (const_int 64))))]
2630
{
2631
  operands[3] = gen_highpart (DImode, operands[0]);
2632
  operands[0] = gen_lowpart (DImode, operands[0]);
2633
}
2634
  [(set_attr "itanium_class" "unknown")])
2635
 
2636
(define_expand "umulditi3"
2637
  [(set (match_operand:TI 0 "fr_register_operand" "")
2638
        (mult:TI (zero_extend:TI
2639
                   (match_operand:DI 1 "fr_reg_or_fp01_operand" ""))
2640
                 (zero_extend:TI
2641
                   (match_operand:DI 2 "fr_reg_or_fp01_operand" ""))))]
2642
  ""
2643
  "")
2644
 
2645
(define_insn_and_split "*umulditi3_internal"
2646
  [(set (match_operand:TI 0 "fr_register_operand" "=&f")
2647
        (mult:TI (zero_extend:TI
2648
                   (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG"))
2649
                 (zero_extend:TI
2650
                   (match_operand:DI 2 "fr_reg_or_fp01_operand" "fG"))))]
2651
  ""
2652
  "#"
2653
  "reload_completed"
2654
  [(set (match_dup 0) (mult:DI (match_dup 1) (match_dup 2)))
2655
   (set (match_dup 3) (truncate:DI
2656
                        (lshiftrt:TI
2657
                          (mult:TI (zero_extend:TI (match_dup 1))
2658
                                   (zero_extend:TI (match_dup 2)))
2659
                          (const_int 64))))]
2660
{
2661
  operands[3] = gen_highpart (DImode, operands[0]);
2662
  operands[0] = gen_lowpart (DImode, operands[0]);
2663
}
2664
  [(set_attr "itanium_class" "unknown")])
2665
 
2666
(define_insn_and_split "negti2"
2667
  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
2668
        (neg:TI (match_operand:TI 1 "gr_register_operand" "r")))
2669
   (clobber (match_scratch:BI 2 "=&c"))]
2670
  ""
2671
  "#"
2672
  "reload_completed"
2673
  [(set (match_dup 2) (eq:BI (match_dup 1) (const_int 0)))
2674
   (set (match_dup 0) (minus:DI (const_int 0) (match_dup 1)))
2675
   (cond_exec (eq (match_dup 2) (const_int 0))
2676
              (set (match_dup 3) (minus:DI (const_int -1) (match_dup 4))))
2677
   (cond_exec (ne (match_dup 2) (const_int 0))
2678
              (set (match_dup 3) (minus:DI (const_int 0) (match_dup 4))))]
2679
{
2680
  operands[3] = gen_highpart (DImode, operands[0]);
2681
  operands[0] = gen_lowpart (DImode, operands[0]);
2682
  operands[4] = gen_highpart (DImode, operands[1]);
2683
  operands[1] = gen_lowpart (DImode, operands[1]);
2684
}
2685
  [(set_attr "itanium_class" "unknown")])
2686
 
2687
;; ::::::::::::::::::::
2688
;; ::
2689
;; :: 32-bit floating point arithmetic
2690
;; ::
2691
;; ::::::::::::::::::::
2692
 
2693
(define_insn "addsf3"
2694
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2695
        (plus:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "%fG")
2696
                 (match_operand:SF 2 "fr_reg_or_signed_fp01_operand" "fZ")))]
2697
  ""
2698
  "fadd.s %0 = %F1, %F2"
2699
  [(set_attr "itanium_class" "fmac")])
2700
 
2701
(define_insn "subsf3"
2702
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2703
        (minus:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2704
                  (match_operand:SF 2 "fr_reg_or_signed_fp01_operand" "fZ")))]
2705
  ""
2706
  "fsub.s %0 = %F1, %F2"
2707
  [(set_attr "itanium_class" "fmac")])
2708
 
2709
(define_insn "mulsf3"
2710
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2711
        (mult:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2712
                 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
2713
  ""
2714
  "fmpy.s %0 = %F1, %F2"
2715
  [(set_attr "itanium_class" "fmac")])
2716
 
2717
(define_insn "abssf2"
2718
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2719
        (abs:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")))]
2720
  ""
2721
  "fabs %0 = %F1"
2722
  [(set_attr "itanium_class" "fmisc")])
2723
 
2724
(define_insn "negsf2"
2725
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2726
        (neg:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")))]
2727
  ""
2728
  "fneg %0 = %F1"
2729
  [(set_attr "itanium_class" "fmisc")])
2730
 
2731
(define_insn "*nabssf2"
2732
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2733
        (neg:SF (abs:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG"))))]
2734
  ""
2735
  "fnegabs %0 = %F1"
2736
  [(set_attr "itanium_class" "fmisc")])
2737
 
2738
(define_insn "copysignsf3"
2739
  [(set (match_operand:SF 0 "register_operand" "=f")
2740
        (unspec:SF [(match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2741
                    (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")]
2742
                   UNSPEC_COPYSIGN))]
2743
  ""
2744
  "fmerge.s %0 = %F2, %F1"
2745
  [(set_attr "itanium_class" "fmisc")])
2746
 
2747
(define_insn "*ncopysignsf3"
2748
  [(set (match_operand:SF 0 "register_operand" "=f")
2749
        (neg:SF (unspec:SF [(match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2750
                            (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")]
2751
                           UNSPEC_COPYSIGN)))]
2752
  ""
2753
  "fmerge.ns %0 = %F2, %F1"
2754
  [(set_attr "itanium_class" "fmisc")])
2755
 
2756
(define_insn "sminsf3"
2757
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2758
        (smin:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2759
                 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
2760
  ""
2761
  "fmin %0 = %F1, %F2"
2762
  [(set_attr "itanium_class" "fmisc")])
2763
 
2764
(define_insn "smaxsf3"
2765
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2766
        (smax:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2767
                 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
2768
  ""
2769
  "fmax %0 = %F1, %F2"
2770
  [(set_attr "itanium_class" "fmisc")])
2771
 
2772
(define_insn "*nmulsf3"
2773
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2774
        (neg:SF (mult:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2775
                         (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG"))))]
2776
  ""
2777
  "fnmpy.s %0 = %F1, %F2"
2778
  [(set_attr "itanium_class" "fmac")])
2779
 
2780
(define_insn "fmasf4"
2781
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2782
        (fma:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2783
                (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")
2784
                (match_operand:SF 3 "fr_reg_or_signed_fp01_operand" "fZ")))]
2785
  ""
2786
  "fma.s %0 = %F1, %F2, %F3"
2787
  [(set_attr "itanium_class" "fmac")])
2788
 
2789
(define_insn "fmssf4"
2790
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2791
        (fma:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2792
                (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")
2793
                (neg:SF
2794
                  (match_operand:SF 3 "fr_reg_or_signed_fp01_operand" "fZ"))))]
2795
  ""
2796
  "fms.s %0 = %F1, %F2, %F3"
2797
  [(set_attr "itanium_class" "fmac")])
2798
 
2799
(define_insn "fnmasf4"
2800
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2801
        (fma:SF (neg:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG"))
2802
                (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")
2803
                (match_operand:SF 3 "fr_reg_or_signed_fp01_operand" "fZ")))]
2804
  ""
2805
  "fnma.s %0 = %F1, %F2, %F3"
2806
  [(set_attr "itanium_class" "fmac")])
2807
 
2808
;; ::::::::::::::::::::
2809
;; ::
2810
;; :: 64-bit floating point arithmetic
2811
;; ::
2812
;; ::::::::::::::::::::
2813
 
2814
(define_insn "adddf3"
2815
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
2816
        (plus:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "%fG")
2817
                 (match_operand:DF 2 "fr_reg_or_signed_fp01_operand" "fZ")))]
2818
  ""
2819
  "fadd.d %0 = %F1, %F2"
2820
  [(set_attr "itanium_class" "fmac")])
2821
 
2822
(define_insn "*adddf3_trunc"
2823
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2824
        (float_truncate:SF
2825
          (plus:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "%fG")
2826
                   (match_operand:DF 2 "fr_reg_or_signed_fp01_operand" "fZ"))))]
2827
  ""
2828
  "fadd.s %0 = %F1, %F2"
2829
  [(set_attr "itanium_class" "fmac")])
2830
 
2831
(define_insn "subdf3"
2832
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
2833
        (minus:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2834
                  (match_operand:DF 2 "fr_reg_or_signed_fp01_operand" "fZ")))]
2835
  ""
2836
  "fsub.d %0 = %F1, %F2"
2837
  [(set_attr "itanium_class" "fmac")])
2838
 
2839
(define_insn "*subdf3_trunc"
2840
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2841
        (float_truncate:SF
2842
          (minus:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2843
                    (match_operand:DF 2 "fr_reg_or_signed_fp01_operand" "fZ"))))]
2844
  ""
2845
  "fsub.s %0 = %F1, %F2"
2846
  [(set_attr "itanium_class" "fmac")])
2847
 
2848
(define_insn "muldf3"
2849
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
2850
        (mult:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2851
                 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
2852
  ""
2853
  "fmpy.d %0 = %F1, %F2"
2854
  [(set_attr "itanium_class" "fmac")])
2855
 
2856
(define_insn "*muldf3_trunc"
2857
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2858
        (float_truncate:SF
2859
          (mult:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2860
                   (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG"))))]
2861
  ""
2862
  "fmpy.s %0 = %F1, %F2"
2863
  [(set_attr "itanium_class" "fmac")])
2864
 
2865
(define_insn "absdf2"
2866
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
2867
        (abs:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")))]
2868
  ""
2869
  "fabs %0 = %F1"
2870
  [(set_attr "itanium_class" "fmisc")])
2871
 
2872
(define_insn "negdf2"
2873
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
2874
        (neg:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")))]
2875
  ""
2876
  "fneg %0 = %F1"
2877
  [(set_attr "itanium_class" "fmisc")])
2878
 
2879
(define_insn "*nabsdf2"
2880
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
2881
        (neg:DF (abs:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG"))))]
2882
  ""
2883
  "fnegabs %0 = %F1"
2884
  [(set_attr "itanium_class" "fmisc")])
2885
 
2886
(define_insn "copysigndf3"
2887
  [(set (match_operand:DF 0 "register_operand" "=f")
2888
        (unspec:DF [(match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2889
                    (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")]
2890
                   UNSPEC_COPYSIGN))]
2891
  ""
2892
  "fmerge.s %0 = %F2, %F1"
2893
  [(set_attr "itanium_class" "fmisc")])
2894
 
2895
(define_insn "*ncopysigndf3"
2896
  [(set (match_operand:DF 0 "register_operand" "=f")
2897
        (neg:DF (unspec:DF [(match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2898
                            (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")]
2899
                           UNSPEC_COPYSIGN)))]
2900
  ""
2901
  "fmerge.ns %0 = %F2, %F1"
2902
  [(set_attr "itanium_class" "fmisc")])
2903
 
2904
(define_insn "smindf3"
2905
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
2906
        (smin:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2907
                 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
2908
  ""
2909
  "fmin %0 = %F1, %F2"
2910
  [(set_attr "itanium_class" "fmisc")])
2911
 
2912
(define_insn "smaxdf3"
2913
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
2914
        (smax:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2915
                 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
2916
  ""
2917
  "fmax %0 = %F1, %F2"
2918
  [(set_attr "itanium_class" "fmisc")])
2919
 
2920
(define_insn "*nmuldf3"
2921
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
2922
        (neg:DF (mult:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2923
                         (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG"))))]
2924
  ""
2925
  "fnmpy.d %0 = %F1, %F2"
2926
  [(set_attr "itanium_class" "fmac")])
2927
 
2928
(define_insn "*nmuldf3_trunc"
2929
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2930
        (float_truncate:SF
2931
          (neg:DF (mult:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2932
                           (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))))]
2933
  ""
2934
  "fnmpy.s %0 = %F1, %F2"
2935
  [(set_attr "itanium_class" "fmac")])
2936
 
2937
(define_insn "fmadf4"
2938
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
2939
        (fma:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2940
                (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")
2941
                (match_operand:DF 3 "fr_reg_or_signed_fp01_operand" "fZ")))]
2942
  ""
2943
  "fma.d %0 = %F1, %F2, %F3"
2944
  [(set_attr "itanium_class" "fmac")])
2945
 
2946
(define_insn "*fmadf_trunc_sf"
2947
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2948
        (float_truncate:SF
2949
          (fma:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2950
                  (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")
2951
                  (match_operand:DF 3 "fr_reg_or_signed_fp01_operand" "fZ"))))]
2952
  ""
2953
  "fma.s %0 = %F1, %F2, %F3"
2954
  [(set_attr "itanium_class" "fmac")])
2955
 
2956
(define_insn "fmsdf4"
2957
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
2958
        (fma:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2959
                (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")
2960
                (neg:DF
2961
                  (match_operand:DF 3 "fr_reg_or_signed_fp01_operand" "fZ"))))]
2962
  ""
2963
  "fms.d %0 = %F1, %F2, %F3"
2964
  [(set_attr "itanium_class" "fmac")])
2965
 
2966
(define_insn "*fmsdf_trunc_sf"
2967
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2968
        (float_truncate:SF
2969
          (fma:DF
2970
            (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2971
            (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")
2972
            (neg:DF
2973
              (match_operand:DF 3 "fr_reg_or_signed_fp01_operand" "fZ")))))]
2974
  ""
2975
  "fms.s %0 = %F1, %F2, %F3"
2976
  [(set_attr "itanium_class" "fmac")])
2977
 
2978
(define_insn "fnmadf4"
2979
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
2980
        (fma:DF (neg:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG"))
2981
                (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")
2982
                (match_operand:DF 3 "fr_reg_or_signed_fp01_operand" "fZ")))]
2983
  ""
2984
  "fnma.d %0 = %F1, %F2, %F3"
2985
  [(set_attr "itanium_class" "fmac")])
2986
 
2987
(define_insn "*fnmadf_trunc_sf"
2988
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2989
        (float_truncate:SF
2990
          (fma:DF
2991
            (neg:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG"))
2992
            (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")
2993
            (match_operand:DF 3 "fr_reg_or_signed_fp01_operand" "fZ"))))]
2994
  ""
2995
  "fnma.s %0 = %F1, %F2, %F3"
2996
  [(set_attr "itanium_class" "fmac")])
2997
 
2998
;; ::::::::::::::::::::
2999
;; ::
3000
;; :: 80-bit floating point arithmetic
3001
;; ::
3002
;; ::::::::::::::::::::
3003
 
3004
(define_insn "addxf3"
3005
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3006
        (plus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "%fG")
3007
                 (match_operand:XF 2 "xfreg_or_signed_fp01_operand" "fZ")))]
3008
  ""
3009
  "fadd %0 = %F1, %F2"
3010
  [(set_attr "itanium_class" "fmac")])
3011
 
3012
(define_insn "*addxf3_truncsf"
3013
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3014
        (float_truncate:SF
3015
          (plus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "%fG")
3016
                   (match_operand:XF 2 "xfreg_or_signed_fp01_operand" "fZ"))))]
3017
  ""
3018
  "fadd.s %0 = %F1, %F2"
3019
  [(set_attr "itanium_class" "fmac")])
3020
 
3021
(define_insn "*addxf3_truncdf"
3022
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3023
        (float_truncate:DF
3024
          (plus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "%fG")
3025
                   (match_operand:XF 2 "xfreg_or_signed_fp01_operand" "fZ"))))]
3026
  ""
3027
  "fadd.d %0 = %F1, %F2"
3028
  [(set_attr "itanium_class" "fmac")])
3029
 
3030
(define_insn "subxf3"
3031
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3032
        (minus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3033
                  (match_operand:XF 2 "xfreg_or_signed_fp01_operand" "fZ")))]
3034
  ""
3035
  "fsub %0 = %F1, %F2"
3036
  [(set_attr "itanium_class" "fmac")])
3037
 
3038
(define_insn "*subxf3_truncsf"
3039
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3040
        (float_truncate:SF
3041
          (minus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3042
                    (match_operand:XF 2 "xfreg_or_signed_fp01_operand" "fZ"))))]
3043
  ""
3044
  "fsub.s %0 = %F1, %F2"
3045
  [(set_attr "itanium_class" "fmac")])
3046
 
3047
(define_insn "*subxf3_truncdf"
3048
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3049
        (float_truncate:DF
3050
          (minus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3051
                    (match_operand:XF 2 "xfreg_or_signed_fp01_operand" "fZ"))))]
3052
  ""
3053
  "fsub.d %0 = %F1, %F2"
3054
  [(set_attr "itanium_class" "fmac")])
3055
 
3056
(define_insn "mulxf3"
3057
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3058
        (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3059
                 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3060
  ""
3061
  "fmpy %0 = %F1, %F2"
3062
  [(set_attr "itanium_class" "fmac")])
3063
 
3064
(define_insn "*mulxf3_truncsf"
3065
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3066
        (float_truncate:SF
3067
          (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3068
                   (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3069
  ""
3070
  "fmpy.s %0 = %F1, %F2"
3071
  [(set_attr "itanium_class" "fmac")])
3072
 
3073
(define_insn "*mulxf3_truncdf"
3074
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3075
        (float_truncate:DF
3076
          (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3077
                   (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3078
  ""
3079
  "fmpy.d %0 = %F1, %F2"
3080
  [(set_attr "itanium_class" "fmac")])
3081
 
3082
(define_insn "absxf2"
3083
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3084
        (abs:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")))]
3085
  ""
3086
  "fabs %0 = %F1"
3087
  [(set_attr "itanium_class" "fmisc")])
3088
 
3089
(define_insn "negxf2"
3090
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3091
        (neg:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")))]
3092
  ""
3093
  "fneg %0 = %F1"
3094
  [(set_attr "itanium_class" "fmisc")])
3095
 
3096
(define_insn "*nabsxf2"
3097
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3098
        (neg:XF (abs:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG"))))]
3099
  ""
3100
  "fnegabs %0 = %F1"
3101
  [(set_attr "itanium_class" "fmisc")])
3102
 
3103
(define_insn "copysignxf3"
3104
  [(set (match_operand:XF 0 "register_operand" "=f")
3105
        (unspec:XF [(match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
3106
                    (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")]
3107
                   UNSPEC_COPYSIGN))]
3108
  ""
3109
  "fmerge.s %0 = %F2, %F1"
3110
  [(set_attr "itanium_class" "fmisc")])
3111
 
3112
(define_insn "*ncopysignxf3"
3113
  [(set (match_operand:XF 0 "register_operand" "=f")
3114
        (neg:XF (unspec:XF [(match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
3115
                            (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")]
3116
                           UNSPEC_COPYSIGN)))]
3117
  ""
3118
  "fmerge.ns %0 = %F2, %F1"
3119
  [(set_attr "itanium_class" "fmisc")])
3120
 
3121
(define_insn "sminxf3"
3122
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3123
        (smin:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3124
                 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3125
  ""
3126
  "fmin %0 = %F1, %F2"
3127
  [(set_attr "itanium_class" "fmisc")])
3128
 
3129
(define_insn "smaxxf3"
3130
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3131
        (smax:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3132
                 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3133
  ""
3134
  "fmax %0 = %F1, %F2"
3135
  [(set_attr "itanium_class" "fmisc")])
3136
 
3137
(define_insn "*nmulxf3"
3138
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3139
        (neg:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3140
                         (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3141
  ""
3142
  "fnmpy %0 = %F1, %F2"
3143
  [(set_attr "itanium_class" "fmac")])
3144
 
3145
(define_insn "*nmulxf3_truncsf"
3146
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3147
        (float_truncate:SF
3148
          (neg:XF (mult:XF
3149
                    (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3150
                    (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))))]
3151
  ""
3152
  "fnmpy.s %0 = %F1, %F2"
3153
  [(set_attr "itanium_class" "fmac")])
3154
 
3155
(define_insn "*nmulxf3_truncdf"
3156
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3157
        (float_truncate:DF
3158
          (neg:XF (mult:XF
3159
                    (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3160
                    (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))))]
3161
  ""
3162
  "fnmpy.d %0 = %F1, %F2"
3163
  [(set_attr "itanium_class" "fmac")])
3164
 
3165
(define_insn "fmaxf4"
3166
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3167
        (fma:XF (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
3168
                (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")
3169
                (match_operand:XF 3 "fr_reg_or_signed_fp01_operand" "fZ")))]
3170
  ""
3171
  "fma %0 = %F1, %F2, %F3"
3172
  [(set_attr "itanium_class" "fmac")])
3173
 
3174
(define_insn "*fmaxf_trunc_"
3175
  [(set (match_operand:MODE_SDF 0 "fr_register_operand" "=f")
3176
        (float_truncate:MODE_SDF
3177
          (fma:XF
3178
            (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
3179
            (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")
3180
            (match_operand:XF 3 "fr_reg_or_signed_fp01_operand" "fZ"))))]
3181
  ""
3182
  "fma %0 = %F1, %F2, %F3"
3183
  [(set_attr "itanium_class" "fmac")])
3184
 
3185
(define_insn "fmsxf4"
3186
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3187
        (fma:XF (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
3188
                (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")
3189
                (neg:XF
3190
                  (match_operand:XF 3 "fr_reg_or_signed_fp01_operand" "fZ"))))]
3191
  ""
3192
  "fms %0 = %F1, %F2, %F3"
3193
  [(set_attr "itanium_class" "fmac")])
3194
 
3195
(define_insn "*fmsxf_trunc_"
3196
  [(set (match_operand:MODE_SDF 0 "fr_register_operand" "=f")
3197
        (float_truncate:MODE_SDF
3198
          (fma:XF
3199
            (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
3200
            (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")
3201
            (neg:XF
3202
              (match_operand:XF 3 "fr_reg_or_signed_fp01_operand" "fZ")))))]
3203
  ""
3204
  "fms %0 = %F1, %F2, %F3"
3205
  [(set_attr "itanium_class" "fmac")])
3206
 
3207
(define_insn "fnmaxf4"
3208
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3209
        (fma:XF (neg:XF (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG"))
3210
                (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")
3211
                (match_operand:XF 3 "fr_reg_or_signed_fp01_operand" "fZ")))]
3212
  ""
3213
  "fnma %0 = %F1, %F2, %F3"
3214
  [(set_attr "itanium_class" "fmac")])
3215
 
3216
(define_insn "*fnmaxf_trunc_"
3217
  [(set (match_operand:MODE_SDF 0 "fr_register_operand" "=f")
3218
        (float_truncate:MODE_SDF
3219
          (fma:XF
3220
            (neg:XF (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG"))
3221
            (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")
3222
            (match_operand:XF 3 "fr_reg_or_signed_fp01_operand" "fZ"))))]
3223
  ""
3224
  "fnma %0 = %F1, %F2, %F3"
3225
  [(set_attr "itanium_class" "fmac")])
3226
 
3227
;; ::::::::::::::::::::
3228
;; ::
3229
;; :: 32-bit Integer Shifts and Rotates
3230
;; ::
3231
;; ::::::::::::::::::::
3232
 
3233
(define_expand "ashlsi3"
3234
  [(set (match_operand:SI 0 "gr_register_operand" "")
3235
        (ashift:SI (match_operand:SI 1 "gr_register_operand" "")
3236
                   (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
3237
  ""
3238
{
3239
  if (GET_CODE (operands[2]) != CONST_INT)
3240
    {
3241
      /* Why oh why didn't Intel arrange for SHIFT_COUNT_TRUNCATED?  Now
3242
         we've got to get rid of stray bits outside the SImode register.  */
3243
      rtx subshift = gen_reg_rtx (DImode);
3244
      emit_insn (gen_zero_extendsidi2 (subshift, operands[2]));
3245
      operands[2] = subshift;
3246
    }
3247
})
3248
 
3249
(define_insn "*ashlsi3_internal"
3250
  [(set (match_operand:SI 0 "gr_register_operand" "=r,r,r")
3251
        (ashift:SI (match_operand:SI 1 "gr_register_operand" "r,r,r")
3252
                   (match_operand:DI 2 "gr_reg_or_5bit_operand" "R,n,r")))]
3253
  ""
3254
  "@
3255
   shladd %0 = %1, %2, r0
3256
   dep.z %0 = %1, %2, %E2
3257
   shl %0 = %1, %2"
3258
  [(set_attr "itanium_class" "ialu,ishf,mmshf")])
3259
 
3260
(define_expand "ashrsi3"
3261
  [(set (match_operand:SI 0 "gr_register_operand" "")
3262
        (ashiftrt:SI (match_operand:SI 1 "gr_register_operand" "")
3263
                     (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
3264
  ""
3265
{
3266
  rtx subtarget = gen_reg_rtx (DImode);
3267
  if (GET_CODE (operands[2]) == CONST_INT)
3268
    emit_insn (gen_extv (subtarget, gen_lowpart (DImode, operands[1]),
3269
                         GEN_INT (32 - INTVAL (operands[2])), operands[2]));
3270
  else
3271
    {
3272
      rtx subshift = gen_reg_rtx (DImode);
3273
      emit_insn (gen_extendsidi2 (subtarget, operands[1]));
3274
      emit_insn (gen_zero_extendsidi2 (subshift, operands[2]));
3275
      emit_insn (gen_ashrdi3 (subtarget, subtarget, subshift));
3276
    }
3277
  emit_move_insn (gen_lowpart (DImode, operands[0]), subtarget);
3278
  DONE;
3279
})
3280
 
3281
(define_expand "lshrsi3"
3282
  [(set (match_operand:SI 0 "gr_register_operand" "")
3283
        (lshiftrt:SI (match_operand:SI 1 "gr_register_operand" "")
3284
                     (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
3285
  ""
3286
{
3287
  rtx subtarget = gen_reg_rtx (DImode);
3288
  if (GET_CODE (operands[2]) == CONST_INT)
3289
    emit_insn (gen_extzv (subtarget, gen_lowpart (DImode, operands[1]),
3290
                          GEN_INT (32 - INTVAL (operands[2])), operands[2]));
3291
  else
3292
    {
3293
      rtx subshift = gen_reg_rtx (DImode);
3294
      emit_insn (gen_zero_extendsidi2 (subtarget, operands[1]));
3295
      emit_insn (gen_zero_extendsidi2 (subshift, operands[2]));
3296
      emit_insn (gen_lshrdi3 (subtarget, subtarget, subshift));
3297
    }
3298
  emit_move_insn (gen_lowpart (DImode, operands[0]), subtarget);
3299
  DONE;
3300
})
3301
 
3302
;; Use mix4.r/shr to implement rotrsi3.  We only get 32 bits of valid result
3303
;; here, instead of 64 like the patterns above.  Keep the pattern together
3304
;; until after combine; otherwise it won't get matched often.
3305
 
3306
(define_expand "rotrsi3"
3307
  [(set (match_operand:SI 0 "gr_register_operand" "")
3308
        (rotatert:SI (match_operand:SI 1 "gr_register_operand" "")
3309
                     (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
3310
  ""
3311
{
3312
  if (GET_MODE (operands[2]) != VOIDmode)
3313
    {
3314
      rtx tmp = gen_reg_rtx (DImode);
3315
      emit_insn (gen_zero_extendsidi2 (tmp, operands[2]));
3316
      operands[2] = tmp;
3317
    }
3318
})
3319
 
3320
(define_insn_and_split "*rotrsi3_internal"
3321
  [(set (match_operand:SI 0 "gr_register_operand" "=&r")
3322
        (rotatert:SI (match_operand:SI 1 "gr_register_operand" "r")
3323
                     (match_operand:DI 2 "gr_reg_or_5bit_operand" "rM")))]
3324
  ""
3325
  "#"
3326
  "reload_completed"
3327
  [(set (match_dup 3)
3328
        (ior:DI (zero_extend:DI (match_dup 1))
3329
                (ashift:DI (zero_extend:DI (match_dup 1)) (const_int 32))))
3330
   (set (match_dup 3)
3331
        (lshiftrt:DI (match_dup 3) (match_dup 2)))]
3332
  "operands[3] = gen_rtx_REG (DImode, REGNO (operands[0]));")
3333
 
3334
(define_expand "rotlsi3"
3335
  [(set (match_operand:SI 0 "gr_register_operand" "")
3336
        (rotate:SI (match_operand:SI 1 "gr_register_operand" "")
3337
                   (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
3338
  ""
3339
{
3340
  if (! shift_32bit_count_operand (operands[2], SImode))
3341
    {
3342
      rtx tmp = gen_reg_rtx (SImode);
3343
      emit_insn (gen_subsi3 (tmp, GEN_INT (32), operands[2]));
3344
      emit_insn (gen_rotrsi3 (operands[0], operands[1], tmp));
3345
      DONE;
3346
    }
3347
})
3348
 
3349
(define_insn_and_split "*rotlsi3_internal"
3350
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
3351
        (rotate:SI (match_operand:SI 1 "gr_register_operand" "r")
3352
                   (match_operand:SI 2 "shift_32bit_count_operand" "n")))]
3353
  ""
3354
  "mux2 %0 = %1, 0xe1"
3355
  "reload_completed && INTVAL (operands[2]) != 16"
3356
  [(set (match_dup 3)
3357
        (ior:DI (zero_extend:DI (match_dup 1))
3358
                (ashift:DI (zero_extend:DI (match_dup 1)) (const_int 32))))
3359
   (set (match_dup 3)
3360
        (lshiftrt:DI (match_dup 3) (match_dup 2)))]
3361
{
3362
  operands[3] = gen_rtx_REG (DImode, REGNO (operands[0]));
3363
  operands[2] = GEN_INT (32 - INTVAL (operands[2]));
3364
}
3365
  [(set_attr "itanium_class" "mmshf")])
3366
 
3367
;; ::::::::::::::::::::
3368
;; ::
3369
;; :: 64-bit Integer Shifts and Rotates
3370
;; ::
3371
;; ::::::::::::::::::::
3372
 
3373
(define_insn "ashldi3"
3374
  [(set (match_operand:DI 0 "gr_register_operand" "=r,r,r")
3375
        (ashift:DI (match_operand:DI 1 "gr_register_operand" "r,r,r")
3376
                   (match_operand:DI 2 "gr_reg_or_6bit_operand" "R,r,rM")))]
3377
  ""
3378
  "@
3379
   shladd %0 = %1, %2, r0
3380
   shl %0 = %1, %2
3381
   shl %0 = %1, %2"
3382
  [(set_attr "itanium_class" "ialu,mmshf,mmshfi")])
3383
 
3384
;; ??? Maybe combine this with the multiply and add instruction?
3385
 
3386
(define_insn "*shladd"
3387
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
3388
        (plus:DI (mult:DI (match_operand:DI 1 "gr_register_operand" "r")
3389
                          (match_operand:DI 2 "shladd_operand" "n"))
3390
                 (match_operand:DI 3 "gr_register_operand" "r")))]
3391
  ""
3392
  "shladd %0 = %1, %S2, %3"
3393
  [(set_attr "itanium_class" "ialu")])
3394
 
3395
;; This can be created by register elimination if operand3 of shladd is an
3396
;; eliminable register or has reg_equiv_constant set.
3397
 
3398
;; We have to use nonmemory_operand for operand 4, to ensure that the
3399
;; validate_changes call inside eliminate_regs will always succeed.  If it
3400
;; doesn't succeed, then this remain a shladd pattern, and will be reloaded
3401
;; incorrectly.
3402
 
3403
(define_insn_and_split "*shladd_elim"
3404
  [(set (match_operand:DI 0 "gr_register_operand" "=&r")
3405
        (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "gr_register_operand" "r")
3406
                                   (match_operand:DI 2 "shladd_operand" "n"))
3407
                          (match_operand:DI 3 "nonmemory_operand" "r"))
3408
                 (match_operand:DI 4 "nonmemory_operand" "rI")))]
3409
  "reload_in_progress"
3410
  "* gcc_unreachable ();"
3411
  "reload_completed"
3412
  [(set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (match_dup 2))
3413
                               (match_dup 3)))
3414
   (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
3415
  ""
3416
  [(set_attr "itanium_class" "unknown")])
3417
 
3418
(define_insn "ashrdi3"
3419
  [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
3420
        (ashiftrt:DI (match_operand:DI 1 "gr_register_operand" "r,r")
3421
                     (match_operand:DI 2 "gr_reg_or_6bit_operand" "r,rM")))]
3422
  ""
3423
  "@
3424
   shr %0 = %1, %2
3425
   shr %0 = %1, %2"
3426
  [(set_attr "itanium_class" "mmshf,mmshfi")])
3427
 
3428
(define_insn "lshrdi3"
3429
  [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
3430
        (lshiftrt:DI (match_operand:DI 1 "gr_register_operand" "r,r")
3431
                     (match_operand:DI 2 "gr_reg_or_6bit_operand" "r,rM")))]
3432
  ""
3433
  "@
3434
   shr.u %0 = %1, %2
3435
   shr.u %0 = %1, %2"
3436
  [(set_attr "itanium_class" "mmshf,mmshfi")])
3437
 
3438
;; Using a predicate that accepts only constants doesn't work, because optabs
3439
;; will load the operand into a register and call the pattern if the predicate
3440
;; did not accept it on the first try.  So we use nonmemory_operand and then
3441
;; verify that we have an appropriate constant in the expander.
3442
 
3443
(define_expand "rotrdi3"
3444
  [(set (match_operand:DI 0 "gr_register_operand" "")
3445
        (rotatert:DI (match_operand:DI 1 "gr_register_operand" "")
3446
                     (match_operand:DI 2 "nonmemory_operand" "")))]
3447
  ""
3448
{
3449
  if (! shift_count_operand (operands[2], DImode))
3450
    FAIL;
3451
})
3452
 
3453
(define_insn "*rotrdi3_internal"
3454
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
3455
        (rotatert:DI (match_operand:DI 1 "gr_register_operand" "r")
3456
                     (match_operand:DI 2 "shift_count_operand" "M")))]
3457
  ""
3458
  "shrp %0 = %1, %1, %2"
3459
  [(set_attr "itanium_class" "ishf")])
3460
 
3461
(define_expand "rotldi3"
3462
  [(set (match_operand:DI 0 "gr_register_operand" "")
3463
        (rotate:DI (match_operand:DI 1 "gr_register_operand" "")
3464
                   (match_operand:DI 2 "nonmemory_operand" "")))]
3465
  ""
3466
{
3467
  if (! shift_count_operand (operands[2], DImode))
3468
    FAIL;
3469
})
3470
 
3471
(define_insn "*rotldi3_internal"
3472
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
3473
        (rotate:DI (match_operand:DI 1 "gr_register_operand" "r")
3474
                   (match_operand:DI 2 "shift_count_operand" "M")))]
3475
  ""
3476
  "shrp %0 = %1, %1, %e2"
3477
  [(set_attr "itanium_class" "ishf")])
3478
 
3479
;; ::::::::::::::::::::
3480
;; ::
3481
;; :: 128-bit Integer Shifts and Rotates
3482
;; ::
3483
;; ::::::::::::::::::::
3484
 
3485
(define_expand "ashlti3"
3486
  [(set (match_operand:TI 0 "gr_register_operand" "")
3487
        (ashift:TI (match_operand:TI 1 "gr_register_operand" "")
3488
                   (match_operand:DI 2 "nonmemory_operand" "")))]
3489
  ""
3490
{
3491
  if (!dshift_count_operand (operands[2], DImode))
3492
    FAIL;
3493
})
3494
 
3495
(define_insn_and_split "*ashlti3_internal"
3496
  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
3497
        (ashift:TI (match_operand:TI 1 "gr_register_operand" "r")
3498
                   (match_operand:DI 2 "dshift_count_operand" "n")))]
3499
  ""
3500
  "#"
3501
  "reload_completed"
3502
  [(const_int 0)]
3503
{
3504
  HOST_WIDE_INT shift = INTVAL (operands[2]);
3505
  rtx rl = gen_lowpart (DImode, operands[0]);
3506
  rtx rh = gen_highpart (DImode, operands[0]);
3507
  rtx lo = gen_lowpart (DImode, operands[1]);
3508
  rtx shiftlo = GEN_INT (shift & 63);
3509
 
3510
  if (shift & 64)
3511
    {
3512
      emit_move_insn (rl, const0_rtx);
3513
      if (shift & 63)
3514
        emit_insn (gen_ashldi3 (rh, lo, shiftlo));
3515
      else
3516
        emit_move_insn (rh, lo);
3517
    }
3518
  else
3519
    {
3520
      rtx hi = gen_highpart (DImode, operands[1]);
3521
 
3522
      emit_insn (gen_shrp (rh, hi, lo, GEN_INT (-shift & 63)));
3523
      emit_insn (gen_ashldi3 (rl, lo, shiftlo));
3524
    }
3525
  DONE;
3526
})
3527
 
3528
(define_expand "ashrti3"
3529
  [(set (match_operand:TI 0 "gr_register_operand" "")
3530
        (ashiftrt:TI (match_operand:TI 1 "gr_register_operand" "")
3531
                     (match_operand:DI 2 "nonmemory_operand" "")))]
3532
  ""
3533
{
3534
  if (!dshift_count_operand (operands[2], DImode))
3535
    FAIL;
3536
})
3537
 
3538
(define_insn_and_split "*ashrti3_internal"
3539
  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
3540
        (ashiftrt:TI (match_operand:TI 1 "gr_register_operand" "r")
3541
                     (match_operand:DI 2 "dshift_count_operand" "n")))]
3542
  ""
3543
  "#"
3544
  "reload_completed"
3545
  [(const_int 0)]
3546
{
3547
  HOST_WIDE_INT shift = INTVAL (operands[2]);
3548
  rtx rl = gen_lowpart (DImode, operands[0]);
3549
  rtx rh = gen_highpart (DImode, operands[0]);
3550
  rtx hi = gen_highpart (DImode, operands[1]);
3551
  rtx shiftlo = GEN_INT (shift & 63);
3552
 
3553
  if (shift & 64)
3554
    {
3555
      if (shift & 63)
3556
        emit_insn (gen_ashrdi3 (rl, hi, shiftlo));
3557
      else
3558
        emit_move_insn (rl, hi);
3559
      emit_insn (gen_ashrdi3 (rh, hi, GEN_INT (63)));
3560
    }
3561
  else
3562
    {
3563
      rtx lo = gen_lowpart (DImode, operands[1]);
3564
 
3565
      emit_insn (gen_shrp (rl, hi, lo, shiftlo));
3566
      emit_insn (gen_ashrdi3 (rh, hi, shiftlo));
3567
    }
3568
  DONE;
3569
})
3570
 
3571
(define_expand "lshrti3"
3572
  [(set (match_operand:TI 0 "gr_register_operand" "")
3573
        (lshiftrt:TI (match_operand:TI 1 "gr_register_operand" "")
3574
                     (match_operand:DI 2 "nonmemory_operand" "")))]
3575
  ""
3576
{
3577
  if (!dshift_count_operand (operands[2], DImode))
3578
    FAIL;
3579
})
3580
 
3581
(define_insn_and_split "*lshrti3_internal"
3582
  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
3583
        (lshiftrt:TI (match_operand:TI 1 "gr_register_operand" "r")
3584
                     (match_operand:DI 2 "dshift_count_operand" "n")))]
3585
  ""
3586
  "#"
3587
  "reload_completed"
3588
  [(const_int 0)]
3589
{
3590
  HOST_WIDE_INT shift = INTVAL (operands[2]);
3591
  rtx rl = gen_lowpart (DImode, operands[0]);
3592
  rtx rh = gen_highpart (DImode, operands[0]);
3593
  rtx hi = gen_highpart (DImode, operands[1]);
3594
  rtx shiftlo = GEN_INT (shift & 63);
3595
 
3596
  if (shift & 64)
3597
    {
3598
      if (shift & 63)
3599
        emit_insn (gen_lshrdi3 (rl, hi, shiftlo));
3600
      else
3601
        emit_move_insn (rl, hi);
3602
      emit_move_insn (rh, const0_rtx);
3603
    }
3604
  else
3605
    {
3606
      rtx lo = gen_lowpart (DImode, operands[1]);
3607
 
3608
      emit_insn (gen_shrp (rl, hi, lo, shiftlo));
3609
      emit_insn (gen_lshrdi3 (rh, hi, shiftlo));
3610
    }
3611
  DONE;
3612
})
3613
 
3614
(define_expand "rotlti3"
3615
  [(set (match_operand:TI 0 "gr_register_operand" "")
3616
        (rotate:TI (match_operand:TI 1 "gr_register_operand" "")
3617
                   (match_operand:DI 2 "nonmemory_operand" "")))]
3618
  ""
3619
{
3620
  if (! dshift_count_operand (operands[2], DImode))
3621
    FAIL;
3622
})
3623
 
3624
(define_insn_and_split "*rotlti3_internal"
3625
  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
3626
        (rotate:TI (match_operand:TI 1 "gr_register_operand" "r")
3627
                   (match_operand:DI 2 "dshift_count_operand" "n")))]
3628
  ""
3629
  "#"
3630
  "reload_completed"
3631
  [(const_int 0)]
3632
{
3633
  HOST_WIDE_INT count = INTVAL (operands[2]);
3634
  rtx rl = gen_lowpart (DImode, operands[0]);
3635
  rtx rh = gen_highpart (DImode, operands[0]);
3636
  rtx lo = gen_lowpart (DImode, operands[1]);
3637
  rtx hi = gen_highpart (DImode, operands[1]);
3638
  rtx countlo = GEN_INT (-count & 63);
3639
 
3640
  if (count & 64)
3641
    {
3642
      if (count & 63)
3643
        {
3644
          emit_insn (gen_shrp (rl, hi, lo, countlo));
3645
          emit_insn (gen_shrp (rh, lo, hi, countlo));
3646
        }
3647
      else
3648
        {
3649
          emit_move_insn (rl, hi);
3650
          emit_move_insn (rh, lo);
3651
        }
3652
    }
3653
  else
3654
    {
3655
      emit_insn (gen_shrp (rl, lo, hi, countlo));
3656
      emit_insn (gen_shrp (rh, hi, lo, countlo));
3657
    }
3658
  DONE;
3659
}
3660
  [(set_attr "itanium_class" "unknown")])
3661
 
3662
(define_insn "shrp"
3663
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
3664
        (unspec:DI [(match_operand:DI 1 "gr_register_operand" "r")
3665
                    (match_operand:DI 2 "gr_register_operand" "r")
3666
                    (match_operand:DI 3 "shift_count_operand" "M")]
3667
                   UNSPEC_SHRP))]
3668
  ""
3669
  "shrp %0 = %1, %2, %3"
3670
  [(set_attr "itanium_class" "ishf")])
3671
 
3672
;; ::::::::::::::::::::
3673
;; ::
3674
;; :: 32-bit Integer Logical operations
3675
;; ::
3676
;; ::::::::::::::::::::
3677
 
3678
;; We don't seem to need any other 32-bit logical operations, because gcc
3679
;; generates zero-extend;zero-extend;DImode-op, which combine optimizes to
3680
;; DImode-op;zero-extend, and then we can optimize away the zero-extend.
3681
;; This doesn't work for unary logical operations, because we don't call
3682
;; apply_distributive_law for them.
3683
 
3684
;; ??? Likewise, this doesn't work for andnot, which isn't handled by
3685
;; apply_distributive_law.  We get inefficient code for
3686
;; int sub4 (int i, int j) { return i & ~j; }
3687
;; We could convert (and (not (sign_extend A)) (sign_extend B)) to
3688
;; (zero_extend (and (not A) B)) in combine.
3689
;; Or maybe fix this by adding andsi3/iorsi3/xorsi3 patterns like the
3690
;; one_cmplsi2 pattern.
3691
 
3692
(define_insn "one_cmplsi2"
3693
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
3694
        (not:SI (match_operand:SI 1 "gr_register_operand" "r")))]
3695
  ""
3696
  "andcm %0 = -1, %1"
3697
  [(set_attr "itanium_class" "ilog")])
3698
 
3699
;; ::::::::::::::::::::
3700
;; ::
3701
;; :: 64-bit Integer Logical operations
3702
;; ::
3703
;; ::::::::::::::::::::
3704
 
3705
(define_insn "anddi3"
3706
  [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
3707
        (and:DI (match_operand:DI 1 "grfr_register_operand" "%r,*f")
3708
                (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
3709
  ""
3710
  "@
3711
   and %0 = %2, %1
3712
   fand %0 = %2, %1"
3713
  [(set_attr "itanium_class" "ilog,fmisc")])
3714
 
3715
(define_insn "*andnot"
3716
  [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
3717
        (and:DI (not:DI (match_operand:DI 1 "grfr_register_operand" "r,*f"))
3718
                (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
3719
  ""
3720
  "@
3721
   andcm %0 = %2, %1
3722
   fandcm %0 = %2, %1"
3723
  [(set_attr "itanium_class" "ilog,fmisc")])
3724
 
3725
(define_insn "iordi3"
3726
  [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
3727
        (ior:DI (match_operand:DI 1 "grfr_register_operand" "%r,*f")
3728
                (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
3729
  ""
3730
  "@
3731
   or %0 = %2, %1
3732
   for %0 = %2, %1"
3733
  [(set_attr "itanium_class" "ilog,fmisc")])
3734
 
3735
(define_insn "xordi3"
3736
  [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
3737
        (xor:DI (match_operand:DI 1 "grfr_register_operand" "%r,*f")
3738
                (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
3739
  ""
3740
  "@
3741
   xor %0 = %2, %1
3742
   fxor %0 = %2, %1"
3743
  [(set_attr "itanium_class" "ilog,fmisc")])
3744
 
3745
(define_insn "one_cmpldi2"
3746
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
3747
        (not:DI (match_operand:DI 1 "gr_register_operand" "r")))]
3748
  ""
3749
  "andcm %0 = -1, %1"
3750
  [(set_attr "itanium_class" "ilog")])
3751
 
3752
;; ::::::::::::::::::::
3753
;; ::
3754
;; :: Comparisons
3755
;; ::
3756
;; ::::::::::::::::::::
3757
 
3758
(define_expand "cbranchbi4"
3759
  [(set (pc)
3760
        (if_then_else (match_operator 0 "ia64_cbranch_operator"
3761
                       [(match_operand:BI 1 "register_operand" "")
3762
                        (match_operand:BI 2 "const_int_operand" "")])
3763
                      (label_ref (match_operand 3 "" ""))
3764
                      (pc)))]
3765
  ""
3766
  "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
3767
 
3768
(define_expand "cbranchsi4"
3769
  [(set (pc)
3770
        (if_then_else (match_operator 0 "ia64_cbranch_operator"
3771
                       [(match_operand:SI 1 "gr_register_operand" "")
3772
                        (match_operand:SI 2 "gr_reg_or_8bit_and_adjusted_operand" "")])
3773
                      (label_ref (match_operand 3 "" ""))
3774
                      (pc)))]
3775
  ""
3776
  "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
3777
 
3778
(define_expand "cbranchdi4"
3779
  [(set (pc)
3780
        (if_then_else (match_operator 0 "ia64_cbranch_operator"
3781
                       [(match_operand:DI 1 "gr_register_operand" "")
3782
                        (match_operand:DI 2 "gr_reg_or_8bit_and_adjusted_operand" "")])
3783
                      (label_ref (match_operand 3 "" ""))
3784
                      (pc)))]
3785
  ""
3786
  "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
3787
 
3788
(define_expand "cbranchsf4"
3789
  [(set (pc)
3790
        (if_then_else (match_operator 0 "ia64_cbranch_operator"
3791
                       [(match_operand:SF 1 "fr_reg_or_fp01_operand" "")
3792
                        (match_operand:SF 2 "fr_reg_or_fp01_operand" "")])
3793
                      (label_ref (match_operand 3 "" ""))
3794
                      (pc)))]
3795
  ""
3796
  "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
3797
 
3798
(define_expand "cbranchdf4"
3799
  [(set (pc)
3800
        (if_then_else (match_operator 0 "ia64_cbranch_operator"
3801
                       [(match_operand:DF 1 "fr_reg_or_fp01_operand" "")
3802
                        (match_operand:DF 2 "fr_reg_or_fp01_operand" "")])
3803
                      (label_ref (match_operand 3 "" ""))
3804
                      (pc)))]
3805
  ""
3806
  "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
3807
 
3808
(define_expand "cbranchxf4"
3809
  [(set (pc)
3810
        (if_then_else (match_operator 0 "ia64_cbranch_operator"
3811
                       [(match_operand:XF 1 "xfreg_or_fp01_operand" "")
3812
                        (match_operand:XF 2 "xfreg_or_fp01_operand" "")])
3813
                      (label_ref (match_operand 3 "" ""))
3814
                      (pc)))]
3815
  ""
3816
  "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
3817
 
3818
(define_expand "cbranchtf4"
3819
  [(set (pc)
3820
        (if_then_else (match_operator 0 "ia64_cbranch_operator"
3821
                       [(match_operand:TF 1 "gr_register_operand" "")
3822
                        (match_operand:TF 2 "gr_register_operand" "")])
3823
                      (label_ref (match_operand 3 "" ""))
3824
                      (pc)))]
3825
  "TARGET_HPUX"
3826
  "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
3827
 
3828
 
3829
(define_insn "*cmpsi_normal"
3830
  [(set (match_operand:BI 0 "register_operand" "=c")
3831
        (match_operator:BI 1 "normal_comparison_operator"
3832
           [(match_operand:SI 2 "gr_register_operand" "r")
3833
            (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")]))]
3834
  ""
3835
  "cmp4.%C1 %0, %I0 = %3, %2"
3836
  [(set_attr "itanium_class" "icmp")])
3837
 
3838
;; We use %r3 because it is possible for us to match a 0, and two of the
3839
;; unsigned comparisons don't accept immediate operands of zero.
3840
 
3841
(define_insn "*cmpsi_adjusted"
3842
  [(set (match_operand:BI 0 "register_operand" "=c")
3843
        (match_operator:BI 1 "adjusted_comparison_operator"
3844
           [(match_operand:SI 2 "gr_register_operand" "r")
3845
            (match_operand:SI 3 "gr_reg_or_8bit_adjusted_operand" "rL")]))]
3846
  ""
3847
  "cmp4.%C1 %0, %I0 = %r3, %2"
3848
  [(set_attr "itanium_class" "icmp")])
3849
 
3850
(define_insn "*cmpdi_normal"
3851
  [(set (match_operand:BI 0 "register_operand" "=c")
3852
        (match_operator:BI 1 "normal_comparison_operator"
3853
           [(match_operand:DI 2 "gr_reg_or_0_operand" "rO")
3854
            (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")]))]
3855
  ""
3856
  "cmp.%C1 %0, %I0 = %3, %r2"
3857
  [(set_attr "itanium_class" "icmp")])
3858
 
3859
;; We use %r3 because it is possible for us to match a 0, and two of the
3860
;; unsigned comparisons don't accept immediate operands of zero.
3861
 
3862
(define_insn "*cmpdi_adjusted"
3863
  [(set (match_operand:BI 0 "register_operand" "=c")
3864
        (match_operator:BI 1 "adjusted_comparison_operator"
3865
           [(match_operand:DI 2 "gr_register_operand" "r")
3866
            (match_operand:DI 3 "gr_reg_or_8bit_adjusted_operand" "rL")]))]
3867
  ""
3868
  "cmp.%C1 %0, %I0 = %r3, %2"
3869
  [(set_attr "itanium_class" "icmp")])
3870
 
3871
(define_insn "*cmpsf_internal"
3872
  [(set (match_operand:BI 0 "register_operand" "=c")
3873
        (match_operator:BI 1 "comparison_operator"
3874
           [(match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")
3875
            (match_operand:SF 3 "fr_reg_or_fp01_operand" "fG")]))]
3876
  ""
3877
  "fcmp.%D1 %0, %I0 = %F2, %F3"
3878
  [(set_attr "itanium_class" "fcmp")])
3879
 
3880
(define_insn "*cmpdf_internal"
3881
  [(set (match_operand:BI 0 "register_operand" "=c")
3882
        (match_operator:BI 1 "comparison_operator"
3883
           [(match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")
3884
            (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")]))]
3885
  ""
3886
  "fcmp.%D1 %0, %I0 = %F2, %F3"
3887
  [(set_attr "itanium_class" "fcmp")])
3888
 
3889
(define_insn "*cmpxf_internal"
3890
  [(set (match_operand:BI 0 "register_operand" "=c")
3891
        (match_operator:BI 1 "comparison_operator"
3892
                   [(match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
3893
                    (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")]))]
3894
  ""
3895
  "fcmp.%D1 %0, %I0 = %F2, %F3"
3896
  [(set_attr "itanium_class" "fcmp")])
3897
 
3898
;; ??? Can this pattern be generated?
3899
 
3900
(define_insn "*bit_zero"
3901
  [(set (match_operand:BI 0 "register_operand" "=c")
3902
        (eq:BI (zero_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
3903
                                (const_int 1)
3904
                                (match_operand:DI 2 "shift_count_operand" "M"))
3905
               (const_int 0)))]
3906
  ""
3907
  "tbit.z %0, %I0 = %1, %2"
3908
  [(set_attr "itanium_class" "tbit")])
3909
 
3910
(define_insn "*bit_one"
3911
  [(set (match_operand:BI 0 "register_operand" "=c")
3912
        (ne:BI (zero_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
3913
                                (const_int 1)
3914
                                (match_operand:DI 2 "shift_count_operand" "M"))
3915
               (const_int 0)))]
3916
  ""
3917
  "tbit.nz %0, %I0 = %1, %2"
3918
  [(set_attr "itanium_class" "tbit")])
3919
 
3920
;; ::::::::::::::::::::
3921
;; ::
3922
;; :: Branches
3923
;; ::
3924
;; ::::::::::::::::::::
3925
 
3926
(define_insn "*br_true"
3927
  [(set (pc)
3928
        (if_then_else (match_operator 0 "predicate_operator"
3929
                        [(match_operand:BI 1 "register_operand" "c")
3930
                         (const_int 0)])
3931
                      (label_ref (match_operand 2 "" ""))
3932
                      (pc)))]
3933
  ""
3934
  "(%J0) br.cond%+ %l2"
3935
  [(set_attr "itanium_class" "br")
3936
   (set_attr "predicable" "no")])
3937
 
3938
(define_insn "*br_false"
3939
  [(set (pc)
3940
        (if_then_else (match_operator 0 "predicate_operator"
3941
                        [(match_operand:BI 1 "register_operand" "c")
3942
                         (const_int 0)])
3943
                      (pc)
3944
                      (label_ref (match_operand 2 "" ""))))]
3945
  ""
3946
  "(%j0) br.cond%+ %l2"
3947
  [(set_attr "itanium_class" "br")
3948
   (set_attr "predicable" "no")])
3949
 
3950
;; ::::::::::::::::::::
3951
;; ::
3952
;; :: Counted loop operations
3953
;; ::
3954
;; ::::::::::::::::::::
3955
 
3956
(define_expand "doloop_end"
3957
  [(use (match_operand 0 "" ""))        ; loop pseudo
3958
   (use (match_operand 1 "" ""))        ; iterations; zero if unknown
3959
   (use (match_operand 2 "" ""))        ; max iterations
3960
   (use (match_operand 3 "" ""))        ; loop level
3961
   (use (match_operand 4 "" ""))]       ; label
3962
  ""
3963
{
3964
  /* Only use cloop on innermost loops.  */
3965
  if (INTVAL (operands[3]) > 1)
3966
    FAIL;
3967
  emit_jump_insn (gen_doloop_end_internal (gen_rtx_REG (DImode, AR_LC_REGNUM),
3968
                                           operands[4]));
3969
  DONE;
3970
})
3971
 
3972
(define_insn "doloop_end_internal"
3973
  [(set (pc) (if_then_else (ne (match_operand:DI 0 "ar_lc_reg_operand" "")
3974
                               (const_int 0))
3975
                (label_ref (match_operand 1 "" ""))
3976
                (pc)))
3977
   (set (match_dup 0) (if_then_else:DI (ne (match_dup 0) (const_int 0))
3978
                         (plus:DI (match_dup 0) (const_int -1))
3979
                         (match_dup 0)))]
3980
  ""
3981
  "br.cloop.sptk.few %l1"
3982
  [(set_attr "itanium_class" "br")
3983
   (set_attr "predicable" "no")])
3984
 
3985
;; ::::::::::::::::::::
3986
;; ::
3987
;; :: Set flag operations
3988
;; ::
3989
;; ::::::::::::::::::::
3990
 
3991
(define_expand "cstorebi4"
3992
  [(set (match_operand:DI 0 "gr_register_operand" "")
3993
        (match_operator:DI 1 "ia64_cbranch_operator"
3994
                       [(match_operand:BI 2 "register_operand" "")
3995
                        (match_operand:BI 3 "const_int_operand" "")]))]
3996
  ""
3997
  "ia64_expand_compare (&operands[1], &operands[2], &operands[3]);")
3998
 
3999
(define_expand "cstoresi4"
4000
  [(set (match_operand:DI 0 "gr_register_operand" "")
4001
        (match_operator:DI 1 "ia64_cbranch_operator"
4002
                       [(match_operand:SI 2 "gr_register_operand" "")
4003
                        (match_operand:SI 3 "gr_reg_or_8bit_and_adjusted_operand" "")]))]
4004
  ""
4005
  "ia64_expand_compare (&operands[1], &operands[2], &operands[3]);")
4006
 
4007
(define_expand "cstoredi4"
4008
  [(set (match_operand:DI 0 "gr_register_operand" "")
4009
        (match_operator:DI 1 "ia64_cbranch_operator"
4010
                       [(match_operand:DI 2 "gr_register_operand" "")
4011
                        (match_operand:DI 3 "gr_reg_or_8bit_and_adjusted_operand" "")]))]
4012
  ""
4013
  "ia64_expand_compare (&operands[1], &operands[2], &operands[3]);")
4014
 
4015
(define_expand "cstoresf4"
4016
  [(set (match_operand:DI 0 "gr_register_operand" "")
4017
        (match_operator:DI 1 "ia64_cbranch_operator"
4018
                       [(match_operand:SF 2 "fr_reg_or_fp01_operand" "")
4019
                        (match_operand:SF 3 "fr_reg_or_fp01_operand" "")]))]
4020
  ""
4021
  "ia64_expand_compare (&operands[1], &operands[2], &operands[3]);")
4022
 
4023
(define_expand "cstoredf4"
4024
  [(set (match_operand:DI 0 "gr_register_operand" "")
4025
        (match_operator:DI 1 "ia64_cbranch_operator"
4026
                       [(match_operand:DF 2 "fr_reg_or_fp01_operand" "")
4027
                        (match_operand:DF 3 "fr_reg_or_fp01_operand" "")]))]
4028
  ""
4029
  "ia64_expand_compare (&operands[1], &operands[2], &operands[3]);")
4030
 
4031
(define_expand "cstorexf4"
4032
  [(set (match_operand:DI 0 "gr_register_operand" "")
4033
        (match_operator:DI 1 "ia64_cbranch_operator"
4034
                       [(match_operand:XF 2 "xfreg_or_fp01_operand" "")
4035
                        (match_operand:XF 3 "xfreg_or_fp01_operand" "")]))]
4036
  ""
4037
  "ia64_expand_compare (&operands[1], &operands[2], &operands[3]);")
4038
 
4039
(define_expand "cstoretf4"
4040
  [(set (match_operand:DI 0 "gr_register_operand" "")
4041
        (match_operator:DI 1 "ia64_cbranch_operator"
4042
                       [(match_operand:TF 2 "gr_register_operand" "")
4043
                        (match_operand:TF 3 "gr_register_operand" "")]))]
4044
  "TARGET_HPUX"
4045
  "ia64_expand_compare (&operands[1], &operands[2], &operands[3]);")
4046
 
4047
;; Don't allow memory as destination here, because cmov/cmov/st is more
4048
;; efficient than mov/mov/cst/cst.
4049
 
4050
(define_insn_and_split "*sne_internal"
4051
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
4052
        (ne:DI (match_operand:BI 1 "register_operand" "c")
4053
               (const_int 0)))]
4054
  ""
4055
  "#"
4056
  "reload_completed"
4057
  [(cond_exec (ne (match_dup 1) (const_int 0))
4058
     (set (match_dup 0) (const_int 1)))
4059
   (cond_exec (eq (match_dup 1) (const_int 0))
4060
     (set (match_dup 0) (const_int 0)))]
4061
  ""
4062
  [(set_attr "itanium_class" "unknown")])
4063
 
4064
(define_insn_and_split "*seq_internal"
4065
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
4066
        (eq:DI (match_operand:BI 1 "register_operand" "c")
4067
               (const_int 0)))]
4068
  ""
4069
  "#"
4070
  "reload_completed"
4071
  [(cond_exec (ne (match_dup 1) (const_int 0))
4072
     (set (match_dup 0) (const_int 0)))
4073
   (cond_exec (eq (match_dup 1) (const_int 0))
4074
     (set (match_dup 0) (const_int 1)))]
4075
  ""
4076
  [(set_attr "itanium_class" "unknown")])
4077
 
4078
;; ::::::::::::::::::::
4079
;; ::
4080
;; :: Conditional move instructions.
4081
;; ::
4082
;; ::::::::::::::::::::
4083
 
4084
;; ??? Add movXXcc patterns?
4085
 
4086
;;
4087
;; DImode if_then_else patterns.
4088
;;
4089
 
4090
(define_insn "*cmovdi_internal"
4091
  [(set (match_operand:DI 0 "not_postinc_destination_operand"
4092
           "= r,  r,  r,   r,  r,  r,   r, r, r,   r, m, Q, *f,*b,*d*e")
4093
        (if_then_else:DI
4094
          (match_operator 4 "predicate_operator"
4095
            [(match_operand:BI 1 "register_operand"
4096
                "c,c,c,c,c,c,c,c,c,c,c,c,c,c,c")
4097
             (const_int 0)])
4098
          (match_operand:DI 2 "not_postinc_move_operand"
4099
           "rim, *f, *b,*d*e,rim,rim, rim,*f,*b,*d*e,rO,*f,rOQ,rO,  rK")
4100
          (match_operand:DI 3 "not_postinc_move_operand"
4101
           "rim,rim,rim, rim, *f, *b,*d*e,*f,*b,*d*e,rO,*f,rOQ,rO,  rK")))]
4102
  "ia64_move_ok (operands[0], operands[2])
4103
   && ia64_move_ok (operands[0], operands[3])"
4104
  { gcc_unreachable (); }
4105
  [(set_attr "predicable" "no")])
4106
 
4107
(define_split
4108
  [(set (match_operand 0 "not_postinc_destination_operand" "")
4109
        (if_then_else
4110
          (match_operator 4 "predicate_operator"
4111
            [(match_operand:BI 1 "register_operand" "")
4112
             (const_int 0)])
4113
          (match_operand 2 "not_postinc_move_operand" "")
4114
          (match_operand 3 "not_postinc_move_operand" "")))]
4115
  "reload_completed"
4116
  [(const_int 0)]
4117
{
4118
  bool emitted_something = false;
4119
  rtx dest = operands[0];
4120
  rtx srct = operands[2];
4121
  rtx srcf = operands[3];
4122
  rtx cond = operands[4];
4123
 
4124
  if (! rtx_equal_p (dest, srct))
4125
    {
4126
      ia64_emit_cond_move (dest, srct, cond);
4127
      emitted_something = true;
4128
    }
4129
  if (! rtx_equal_p (dest, srcf))
4130
    {
4131
      cond = gen_rtx_fmt_ee (GET_CODE (cond) == NE ? EQ : NE,
4132
                             VOIDmode, operands[1], const0_rtx);
4133
      ia64_emit_cond_move (dest, srcf, cond);
4134
      emitted_something = true;
4135
    }
4136
  if (! emitted_something)
4137
    emit_note (NOTE_INSN_DELETED);
4138
  DONE;
4139
})
4140
 
4141
;; Absolute value pattern.
4142
 
4143
(define_insn "*absdi2_internal"
4144
  [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
4145
        (if_then_else:DI
4146
          (match_operator 4 "predicate_operator"
4147
            [(match_operand:BI 1 "register_operand" "c,c")
4148
             (const_int 0)])
4149
          (neg:DI (match_operand:DI 2 "gr_reg_or_22bit_operand" "rI,rI"))
4150
          (match_operand:DI 3 "gr_reg_or_22bit_operand" "0,rI")))]
4151
  ""
4152
  "#"
4153
  [(set_attr "itanium_class" "ialu,unknown")
4154
   (set_attr "predicable" "no")])
4155
 
4156
(define_split
4157
  [(set (match_operand:DI 0 "register_operand" "")
4158
        (if_then_else:DI
4159
          (match_operator 4 "predicate_operator"
4160
            [(match_operand:BI 1 "register_operand" "c,c")
4161
             (const_int 0)])
4162
          (neg:DI (match_operand:DI 2 "gr_reg_or_22bit_operand" ""))
4163
          (match_operand:DI 3 "gr_reg_or_22bit_operand" "")))]
4164
  "reload_completed && rtx_equal_p (operands[0], operands[3])"
4165
  [(cond_exec
4166
     (match_dup 4)
4167
     (set (match_dup 0)
4168
          (neg:DI (match_dup 2))))]
4169
  "")
4170
 
4171
(define_split
4172
  [(set (match_operand:DI 0 "register_operand" "")
4173
        (if_then_else:DI
4174
          (match_operator 4 "predicate_operator"
4175
            [(match_operand:BI 1 "register_operand" "c,c")
4176
             (const_int 0)])
4177
          (neg:DI (match_operand:DI 2 "gr_reg_or_22bit_operand" ""))
4178
          (match_operand:DI 3 "gr_reg_or_22bit_operand" "")))]
4179
  "reload_completed"
4180
  [(cond_exec
4181
     (match_dup 4)
4182
     (set (match_dup 0) (neg:DI (match_dup 2))))
4183
   (cond_exec
4184
     (match_dup 5)
4185
     (set (match_dup 0) (match_dup 3)))]
4186
{
4187
  operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[4]) == NE ? EQ : NE,
4188
                                VOIDmode, operands[1], const0_rtx);
4189
})
4190
 
4191
;;
4192
;; SImode if_then_else patterns.
4193
;;
4194
 
4195
(define_insn "*cmovsi_internal"
4196
  [(set (match_operand:SI 0 "not_postinc_destination_operand"
4197
                "=r,m,*f,r,m,*f,r,m,*f")
4198
        (if_then_else:SI
4199
          (match_operator 4 "predicate_operator"
4200
            [(match_operand:BI 1 "register_operand" "c,c,c,c,c,c,c,c,c")
4201
             (const_int 0)])
4202
          (match_operand:SI 2 "not_postinc_move_operand"
4203
                    "0,0,0,rim*f,rO,rO,rim*f,rO,rO")
4204
          (match_operand:SI 3 "not_postinc_move_operand"
4205
                    "rim*f,rO,rO,0,0,0,rim*f,rO,rO")))]
4206
  "ia64_move_ok (operands[0], operands[2])
4207
   && ia64_move_ok (operands[0], operands[3])"
4208
  { gcc_unreachable (); }
4209
  [(set_attr "predicable" "no")])
4210
 
4211
(define_insn "*abssi2_internal"
4212
  [(set (match_operand:SI 0 "gr_register_operand" "=r,r")
4213
        (if_then_else:SI
4214
          (match_operator 4 "predicate_operator"
4215
            [(match_operand:BI 1 "register_operand" "c,c")
4216
             (const_int 0)])
4217
          (neg:SI (match_operand:SI 3 "gr_reg_or_22bit_operand" "rI,rI"))
4218
          (match_operand:SI 2 "gr_reg_or_22bit_operand" "0,rI")))]
4219
  ""
4220
  "#"
4221
  [(set_attr "itanium_class" "ialu,unknown")
4222
   (set_attr "predicable" "no")])
4223
 
4224
(define_split
4225
  [(set (match_operand:SI 0 "register_operand" "")
4226
        (if_then_else:SI
4227
          (match_operator 4 "predicate_operator"
4228
            [(match_operand:BI 1 "register_operand" "c,c")
4229
             (const_int 0)])
4230
          (neg:SI (match_operand:SI 2 "gr_reg_or_22bit_operand" ""))
4231
          (match_operand:SI 3 "gr_reg_or_22bit_operand" "")))]
4232
  "reload_completed && rtx_equal_p (operands[0], operands[3])"
4233
  [(cond_exec
4234
     (match_dup 4)
4235
     (set (match_dup 0)
4236
          (neg:SI (match_dup 2))))]
4237
  "")
4238
 
4239
(define_split
4240
  [(set (match_operand:SI 0 "register_operand" "")
4241
        (if_then_else:SI
4242
          (match_operator 4 "predicate_operator"
4243
            [(match_operand:BI 1 "register_operand" "c,c")
4244
             (const_int 0)])
4245
          (neg:SI (match_operand:SI 2 "gr_reg_or_22bit_operand" ""))
4246
          (match_operand:SI 3 "gr_reg_or_22bit_operand" "")))]
4247
  "reload_completed"
4248
  [(cond_exec
4249
     (match_dup 4)
4250
     (set (match_dup 0) (neg:SI (match_dup 2))))
4251
   (cond_exec
4252
     (match_dup 5)
4253
     (set (match_dup 0) (match_dup 3)))]
4254
{
4255
  operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[4]) == NE ? EQ : NE,
4256
                                VOIDmode, operands[1], const0_rtx);
4257
})
4258
 
4259
(define_insn_and_split "*cond_opsi2_internal"
4260
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
4261
        (match_operator:SI 5 "condop_operator"
4262
          [(if_then_else:SI
4263
             (match_operator 6 "predicate_operator"
4264
               [(match_operand:BI 1 "register_operand" "c")
4265
                (const_int 0)])
4266
             (match_operand:SI 2 "gr_register_operand" "r")
4267
             (match_operand:SI 3 "gr_register_operand" "r"))
4268
           (match_operand:SI 4 "gr_register_operand" "r")]))]
4269
  ""
4270
  "#"
4271
  "reload_completed"
4272
  [(cond_exec
4273
     (match_dup 6)
4274
     (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 2) (match_dup 4)])))
4275
   (cond_exec
4276
     (match_dup 7)
4277
     (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 3) (match_dup 4)])))]
4278
{
4279
  operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[6]) == NE ? EQ : NE,
4280
                                VOIDmode, operands[1], const0_rtx);
4281
}
4282
  [(set_attr "itanium_class" "ialu")
4283
   (set_attr "predicable" "no")])
4284
 
4285
 
4286
(define_insn_and_split "*cond_opsi2_internal_b"
4287
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
4288
        (match_operator:SI 5 "condop_operator"
4289
          [(match_operand:SI 4 "gr_register_operand" "r")
4290
           (if_then_else:SI
4291
             (match_operator 6 "predicate_operator"
4292
               [(match_operand:BI 1 "register_operand" "c")
4293
                (const_int 0)])
4294
             (match_operand:SI 2 "gr_register_operand" "r")
4295
             (match_operand:SI 3 "gr_register_operand" "r"))]))]
4296
  ""
4297
  "#"
4298
  "reload_completed"
4299
  [(cond_exec
4300
     (match_dup 6)
4301
     (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 4) (match_dup 2)])))
4302
   (cond_exec
4303
     (match_dup 7)
4304
     (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 4) (match_dup 3)])))]
4305
{
4306
  operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[6]) == NE ? EQ : NE,
4307
                                VOIDmode, operands[1], const0_rtx);
4308
}
4309
  [(set_attr "itanium_class" "ialu")
4310
   (set_attr "predicable" "no")])
4311
 
4312
 
4313
;; ::::::::::::::::::::
4314
;; ::
4315
;; :: Call and branch instructions
4316
;; ::
4317
;; ::::::::::::::::::::
4318
 
4319
;; Subroutine call instruction returning no value.  Operand 0 is the function
4320
;; to call; operand 1 is the number of bytes of arguments pushed (in mode
4321
;; `SImode', except it is normally a `const_int'); operand 2 is the number of
4322
;; registers used as operands.
4323
 
4324
;; On most machines, operand 2 is not actually stored into the RTL pattern.  It
4325
;; is supplied for the sake of some RISC machines which need to put this
4326
;; information into the assembler code; they can put it in the RTL instead of
4327
;; operand 1.
4328
 
4329
(define_expand "call"
4330
  [(use (match_operand:DI 0 "" ""))
4331
   (use (match_operand 1 "" ""))
4332
   (use (match_operand 2 "" ""))
4333
   (use (match_operand 3 "" ""))]
4334
  ""
4335
{
4336
  ia64_expand_call (NULL_RTX, operands[0], operands[2], false);
4337
  DONE;
4338
})
4339
 
4340
(define_expand "sibcall"
4341
  [(use (match_operand:DI 0 "" ""))
4342
   (use (match_operand 1 "" ""))
4343
   (use (match_operand 2 "" ""))
4344
   (use (match_operand 3 "" ""))]
4345
  ""
4346
{
4347
  ia64_expand_call (NULL_RTX, operands[0], operands[2], true);
4348
  DONE;
4349
})
4350
 
4351
;; Subroutine call instruction returning a value.  Operand 0 is the hard
4352
;; register in which the value is returned.  There are three more operands,
4353
;; the same as the three operands of the `call' instruction (but with numbers
4354
;; increased by one).
4355
;;
4356
;; Subroutines that return `BLKmode' objects use the `call' insn.
4357
 
4358
(define_expand "call_value"
4359
  [(use (match_operand 0 "" ""))
4360
   (use (match_operand:DI 1 "" ""))
4361
   (use (match_operand 2 "" ""))
4362
   (use (match_operand 3 "" ""))
4363
   (use (match_operand 4 "" ""))]
4364
  ""
4365
{
4366
  ia64_expand_call (operands[0], operands[1], operands[3], false);
4367
  DONE;
4368
})
4369
 
4370
(define_expand "sibcall_value"
4371
  [(use (match_operand 0 "" ""))
4372
   (use (match_operand:DI 1 "" ""))
4373
   (use (match_operand 2 "" ""))
4374
   (use (match_operand 3 "" ""))
4375
   (use (match_operand 4 "" ""))]
4376
  ""
4377
{
4378
  ia64_expand_call (operands[0], operands[1], operands[3], true);
4379
  DONE;
4380
})
4381
 
4382
;; Call subroutine returning any type.
4383
 
4384
(define_expand "untyped_call"
4385
  [(parallel [(call (match_operand 0 "" "")
4386
                    (const_int 0))
4387
              (match_operand 1 "" "")
4388
              (match_operand 2 "" "")])]
4389
  ""
4390
{
4391
  int i;
4392
 
4393
  emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx));
4394
 
4395
  for (i = 0; i < XVECLEN (operands[2], 0); i++)
4396
    {
4397
      rtx set = XVECEXP (operands[2], 0, i);
4398
      emit_move_insn (SET_DEST (set), SET_SRC (set));
4399
    }
4400
 
4401
  /* The optimizer does not know that the call sets the function value
4402
     registers we stored in the result block.  We avoid problems by
4403
     claiming that all hard registers are used and clobbered at this
4404
     point.  */
4405
  emit_insn (gen_blockage ());
4406
 
4407
  DONE;
4408
})
4409
 
4410
(define_insn "call_nogp"
4411
  [(call (mem:DI (match_operand:DI 0 "call_operand" "?b,s"))
4412
         (const_int 0))
4413
   (clobber (match_operand:DI 1 "register_operand" "=b,b"))]
4414
  ""
4415
  "br.call%+.many %1 = %0"
4416
  [(set_attr "itanium_class" "br,scall")])
4417
 
4418
(define_insn "call_value_nogp"
4419
  [(set (match_operand 0 "" "=X,X")
4420
        (call (mem:DI (match_operand:DI 1 "call_operand" "?b,s"))
4421
              (const_int 0)))
4422
   (clobber (match_operand:DI 2 "register_operand" "=b,b"))]
4423
  ""
4424
  "br.call%+.many %2 = %1"
4425
  [(set_attr "itanium_class" "br,scall")])
4426
 
4427
(define_insn "sibcall_nogp"
4428
  [(call (mem:DI (match_operand:DI 0 "call_operand" "?b,s"))
4429
         (const_int 0))]
4430
  ""
4431
  "br%+.many %0"
4432
  [(set_attr "itanium_class" "br,scall")])
4433
 
4434
(define_insn "call_gp"
4435
  [(call (mem:DI (match_operand:DI 0 "call_operand" "?r,s"))
4436
         (const_int 1))
4437
   (clobber (match_operand:DI 1 "register_operand" "=b,b"))
4438
   (clobber (match_scratch:DI 2 "=&r,X"))
4439
   (clobber (match_scratch:DI 3 "=b,X"))]
4440
  ""
4441
  "#"
4442
  [(set_attr "itanium_class" "br,scall")])
4443
 
4444
;; Irritatingly, we don't have access to INSN within the split body.
4445
;; See commentary in ia64_split_call as to why these aren't peep2.
4446
(define_split
4447
  [(call (mem (match_operand 0 "call_operand" ""))
4448
         (const_int 1))
4449
   (clobber (match_operand:DI 1 "register_operand" ""))
4450
   (clobber (match_scratch:DI 2 ""))
4451
   (clobber (match_scratch:DI 3 ""))]
4452
  "reload_completed && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
4453
  [(const_int 0)]
4454
{
4455
  ia64_split_call (NULL_RTX, operands[0], operands[1], operands[2],
4456
                   operands[3], true, false);
4457
  DONE;
4458
})
4459
 
4460
(define_split
4461
  [(call (mem (match_operand 0 "call_operand" ""))
4462
         (const_int 1))
4463
   (clobber (match_operand:DI 1 "register_operand" ""))
4464
   (clobber (match_scratch:DI 2 ""))
4465
   (clobber (match_scratch:DI 3 ""))]
4466
  "reload_completed"
4467
  [(const_int 0)]
4468
{
4469
  ia64_split_call (NULL_RTX, operands[0], operands[1], operands[2],
4470
                   operands[3], false, false);
4471
  DONE;
4472
})
4473
 
4474
(define_insn "call_value_gp"
4475
  [(set (match_operand 0 "" "=X,X")
4476
        (call (mem:DI (match_operand:DI 1 "call_operand" "?r,s"))
4477
              (const_int 1)))
4478
   (clobber (match_operand:DI 2 "register_operand" "=b,b"))
4479
   (clobber (match_scratch:DI 3 "=&r,X"))
4480
   (clobber (match_scratch:DI 4 "=b,X"))]
4481
  ""
4482
  "#"
4483
  [(set_attr "itanium_class" "br,scall")])
4484
 
4485
(define_split
4486
  [(set (match_operand 0 "" "")
4487
        (call (mem:DI (match_operand:DI 1 "call_operand" ""))
4488
              (const_int 1)))
4489
   (clobber (match_operand:DI 2 "register_operand" ""))
4490
   (clobber (match_scratch:DI 3 ""))
4491
   (clobber (match_scratch:DI 4 ""))]
4492
  "reload_completed && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
4493
  [(const_int 0)]
4494
{
4495
  ia64_split_call (operands[0], operands[1], operands[2], operands[3],
4496
                   operands[4], true, false);
4497
  DONE;
4498
})
4499
 
4500
(define_split
4501
  [(set (match_operand 0 "" "")
4502
        (call (mem:DI (match_operand:DI 1 "call_operand" ""))
4503
              (const_int 1)))
4504
   (clobber (match_operand:DI 2 "register_operand" ""))
4505
   (clobber (match_scratch:DI 3 ""))
4506
   (clobber (match_scratch:DI 4 ""))]
4507
  "reload_completed"
4508
  [(const_int 0)]
4509
{
4510
  ia64_split_call (operands[0], operands[1], operands[2], operands[3],
4511
                   operands[4], false, false);
4512
  DONE;
4513
})
4514
 
4515
(define_insn_and_split "sibcall_gp"
4516
  [(call (mem:DI (match_operand:DI 0 "call_operand" "?r,s"))
4517
         (const_int 1))
4518
   (clobber (match_scratch:DI 1 "=&r,X"))
4519
   (clobber (match_scratch:DI 2 "=b,X"))]
4520
  ""
4521
  "#"
4522
  "reload_completed"
4523
  [(const_int 0)]
4524
{
4525
  ia64_split_call (NULL_RTX, operands[0], NULL_RTX, operands[1],
4526
                   operands[2], true, true);
4527
  DONE;
4528
}
4529
  [(set_attr "itanium_class" "br")])
4530
 
4531
(define_insn "return_internal"
4532
  [(return)
4533
   (use (match_operand:DI 0 "register_operand" "b"))]
4534
  ""
4535
  "br.ret.sptk.many %0"
4536
  [(set_attr "itanium_class" "br")])
4537
 
4538
(define_insn "return"
4539
  [(return)]
4540
  "ia64_direct_return ()"
4541
  "br.ret.sptk.many rp"
4542
  [(set_attr "itanium_class" "br")])
4543
 
4544
(define_insn "*return_true"
4545
  [(set (pc)
4546
        (if_then_else (match_operator 0 "predicate_operator"
4547
                        [(match_operand:BI 1 "register_operand" "c")
4548
                         (const_int 0)])
4549
                      (return)
4550
                      (pc)))]
4551
  "ia64_direct_return ()"
4552
  "(%J0) br.ret%+.many rp"
4553
  [(set_attr "itanium_class" "br")
4554
   (set_attr "predicable" "no")])
4555
 
4556
(define_insn "*return_false"
4557
  [(set (pc)
4558
        (if_then_else (match_operator 0 "predicate_operator"
4559
                        [(match_operand:BI 1 "register_operand" "c")
4560
                         (const_int 0)])
4561
                      (pc)
4562
                      (return)))]
4563
  "ia64_direct_return ()"
4564
  "(%j0) br.ret%+.many rp"
4565
  [(set_attr "itanium_class" "br")
4566
   (set_attr "predicable" "no")])
4567
 
4568
(define_insn "jump"
4569
  [(set (pc) (label_ref (match_operand 0 "" "")))]
4570
  ""
4571
  "br %l0"
4572
  [(set_attr "itanium_class" "br")])
4573
 
4574
(define_insn "indirect_jump"
4575
  [(set (pc) (match_operand:DI 0 "register_operand" "b"))]
4576
  ""
4577
  "br %0"
4578
  [(set_attr "itanium_class" "br")])
4579
 
4580
(define_expand "tablejump"
4581
  [(parallel [(set (pc) (match_operand:DI 0 "memory_operand" ""))
4582
              (use (label_ref (match_operand 1 "" "")))])]
4583
  ""
4584
{
4585
  rtx op0 = operands[0];
4586
  rtx addr;
4587
 
4588
  /* ??? Bother -- do_tablejump is "helpful" and pulls the table
4589
     element into a register without bothering to see whether that
4590
     is necessary given the operand predicate.  Check for MEM just
4591
     in case someone fixes this.  */
4592
  if (GET_CODE (op0) == MEM)
4593
    addr = XEXP (op0, 0);
4594
  else
4595
    {
4596
      /* Otherwise, cheat and guess that the previous insn in the
4597
         stream was the memory load.  Grab the address from that.
4598
         Note we have to momentarily pop out of the sequence started
4599
         by the insn-emit wrapper in order to grab the last insn.  */
4600
      rtx last, set;
4601
 
4602
      end_sequence ();
4603
      last = get_last_insn ();
4604
      start_sequence ();
4605
      set = single_set (last);
4606
 
4607
      gcc_assert (rtx_equal_p (SET_DEST (set), op0)
4608
                  && GET_CODE (SET_SRC (set)) == MEM);
4609
      addr = XEXP (SET_SRC (set), 0);
4610
      gcc_assert (!rtx_equal_p (addr, op0));
4611
    }
4612
 
4613
  /* Jump table elements are stored pc-relative.  That is, a displacement
4614
     from the entry to the label.  Thus to convert to an absolute address
4615
     we add the address of the memory from which the value is loaded.  */
4616
  operands[0] = expand_simple_binop (DImode, PLUS, op0, addr,
4617
                                     NULL_RTX, 1, OPTAB_DIRECT);
4618
})
4619
 
4620
(define_insn "*tablejump_internal"
4621
  [(set (pc) (match_operand:DI 0 "register_operand" "b"))
4622
   (use (label_ref (match_operand 1 "" "")))]
4623
  ""
4624
  "br %0"
4625
  [(set_attr "itanium_class" "br")])
4626
 
4627
 
4628
;; ::::::::::::::::::::
4629
;; ::
4630
;; :: Prologue and Epilogue instructions
4631
;; ::
4632
;; ::::::::::::::::::::
4633
 
4634
(define_expand "prologue"
4635
  [(const_int 1)]
4636
  ""
4637
{
4638
  ia64_expand_prologue ();
4639
  DONE;
4640
})
4641
 
4642
(define_expand "epilogue"
4643
  [(return)]
4644
  ""
4645
{
4646
  ia64_expand_epilogue (0);
4647
  DONE;
4648
})
4649
 
4650
(define_expand "sibcall_epilogue"
4651
  [(return)]
4652
  ""
4653
{
4654
  ia64_expand_epilogue (1);
4655
  DONE;
4656
})
4657
 
4658
;; This prevents the scheduler from moving the SP decrement past FP-relative
4659
;; stack accesses.  This is the same as adddi3 plus the extra set.
4660
 
4661
(define_insn "prologue_allocate_stack"
4662
  [(set (match_operand:DI 0 "register_operand" "=r,r,r")
4663
        (plus:DI (match_operand:DI 1 "register_operand" "%r,r,a")
4664
                 (match_operand:DI 2 "gr_reg_or_22bit_operand" "r,I,J")))
4665
   (set (match_operand:DI 3 "register_operand" "+r,r,r")
4666
        (match_dup 3))]
4667
  ""
4668
  "@
4669
   add %0 = %1, %2
4670
   adds %0 = %2, %1
4671
   addl %0 = %2, %1"
4672
  [(set_attr "itanium_class" "ialu")])
4673
 
4674
;; This prevents the scheduler from moving the SP restore past FP-relative
4675
;; stack accesses.  This is similar to movdi plus the extra set.
4676
 
4677
(define_insn "epilogue_deallocate_stack"
4678
  [(set (match_operand:DI 0 "register_operand" "=r")
4679
        (match_operand:DI 1 "register_operand" "+r"))
4680
   (set (match_dup 1) (match_dup 1))]
4681
  ""
4682
  "mov %0 = %1"
4683
  [(set_attr "itanium_class" "ialu")])
4684
 
4685
;; As USE insns aren't meaningful after reload, this is used instead
4686
;; to prevent deleting instructions setting registers for EH handling
4687
(define_insn "prologue_use"
4688
  [(unspec:DI [(match_operand:DI 0 "register_operand" "")]
4689
              UNSPEC_PROLOGUE_USE)]
4690
  ""
4691
  ""
4692
  [(set_attr "itanium_class" "ignore")
4693
   (set_attr "predicable" "no")
4694
   (set_attr "empty" "yes")])
4695
 
4696
;; Allocate a new register frame.
4697
 
4698
(define_insn "alloc"
4699
  [(set (match_operand:DI 0 "register_operand" "=r")
4700
        (unspec_volatile:DI [(const_int 0)] UNSPECV_ALLOC))
4701
   (use (match_operand:DI 1 "const_int_operand" "i"))
4702
   (use (match_operand:DI 2 "const_int_operand" "i"))
4703
   (use (match_operand:DI 3 "const_int_operand" "i"))
4704
   (use (match_operand:DI 4 "const_int_operand" "i"))]
4705
  ""
4706
  "alloc %0 = ar.pfs, %1, %2, %3, %4"
4707
  [(set_attr "itanium_class" "syst_m0")
4708
   (set_attr "predicable" "no")
4709
   (set_attr "first_insn" "yes")])
4710
 
4711
;; Modifies ar.unat
4712
(define_expand "gr_spill"
4713
  [(parallel [(set (match_operand:DI 0 "memory_operand" "=m")
4714
                   (unspec:DI [(match_operand:DI 1 "register_operand" "r")
4715
                               (match_operand:DI 2 "const_int_operand" "")]
4716
                              UNSPEC_GR_SPILL))
4717
              (clobber (match_dup 3))])]
4718
  ""
4719
  "operands[3] = gen_rtx_REG (DImode, AR_UNAT_REGNUM);")
4720
 
4721
(define_insn "gr_spill_internal"
4722
  [(set (match_operand:DI 0 "destination_operand" "=m")
4723
        (unspec:DI [(match_operand:DI 1 "register_operand" "r")
4724
                    (match_operand:DI 2 "const_int_operand" "")]
4725
                   UNSPEC_GR_SPILL))
4726
   (clobber (match_operand:DI 3 "register_operand" ""))]
4727
  ""
4728
{
4729
  /* Note that we use a C output pattern here to avoid the predicate
4730
     being automatically added before the .mem.offset directive.  */
4731
  return ".mem.offset %2, 0\;%,st8.spill %0 = %1%P0";
4732
}
4733
  [(set_attr "itanium_class" "st")])
4734
 
4735
;; Reads ar.unat
4736
(define_expand "gr_restore"
4737
  [(parallel [(set (match_operand:DI 0 "register_operand" "=r")
4738
                   (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
4739
                               (match_operand:DI 2 "const_int_operand" "")]
4740
                              UNSPEC_GR_RESTORE))
4741
              (use (match_dup 3))])]
4742
  ""
4743
  "operands[3] = gen_rtx_REG (DImode, AR_UNAT_REGNUM);")
4744
 
4745
(define_insn "gr_restore_internal"
4746
  [(set (match_operand:DI 0 "register_operand" "=r")
4747
        (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
4748
                    (match_operand:DI 2 "const_int_operand" "")]
4749
                   UNSPEC_GR_RESTORE))
4750
   (use (match_operand:DI 3 "register_operand" ""))]
4751
  ""
4752
  { return ".mem.offset %2, 0\;%,ld8.fill %0 = %1%P1"; }
4753
  [(set_attr "itanium_class" "ld")])
4754
 
4755
(define_insn "fr_spill"
4756
  [(set (match_operand:XF 0 "destination_operand" "=m")
4757
        (unspec:XF [(match_operand:XF 1 "register_operand" "f")]
4758
                   UNSPEC_FR_SPILL))]
4759
  ""
4760
  "stf.spill %0 = %1%P0"
4761
  [(set_attr "itanium_class" "stf")])
4762
 
4763
(define_insn "fr_restore"
4764
  [(set (match_operand:XF 0 "register_operand" "=f")
4765
        (unspec:XF [(match_operand:XF 1 "memory_operand" "m")]
4766
                   UNSPEC_FR_RESTORE))]
4767
  ""
4768
  "ldf.fill %0 = %1%P1"
4769
  [(set_attr "itanium_class" "fld")])
4770
 
4771
;; ??? The explicit stop is not ideal.  It would be better if
4772
;; rtx_needs_barrier took care of this, but this is something that can be
4773
;; fixed later.  This avoids an RSE DV.
4774
 
4775
(define_insn "bsp_value"
4776
  [(set (match_operand:DI 0 "register_operand" "=r")
4777
        (unspec:DI [(const_int 0)] UNSPEC_BSP_VALUE))]
4778
  ""
4779
  "*
4780
{
4781
  return \";;\;%,mov %0 = ar.bsp\";
4782
}"
4783
  [(set_attr "itanium_class" "frar_i")])
4784
 
4785
(define_insn "set_bsp"
4786
  [(unspec_volatile [(match_operand:DI 0 "register_operand" "r")]
4787
                    UNSPECV_SET_BSP)]
4788
  ""
4789
  "flushrs
4790
        mov r19=ar.rsc
4791
        ;;
4792
        and r19=0x1c,r19
4793
        ;;
4794
        mov ar.rsc=r19
4795
        ;;
4796
        mov ar.bspstore=%0
4797
        ;;
4798
        or r19=0x3,r19
4799
        ;;
4800
        loadrs
4801
        invala
4802
        ;;
4803
        mov ar.rsc=r19"
4804
  [(set_attr "itanium_class" "unknown")
4805
   (set_attr "predicable" "no")])
4806
 
4807
;; ??? The explicit stops are not ideal.  It would be better if
4808
;; rtx_needs_barrier took care of this, but this is something that can be
4809
;; fixed later.  This avoids an RSE DV.
4810
 
4811
(define_insn "flushrs"
4812
  [(unspec [(const_int 0)] UNSPEC_FLUSHRS)]
4813
  ""
4814
  ";;\;flushrs\;;;"
4815
  [(set_attr "itanium_class" "rse_m")
4816
   (set_attr "predicable" "no")])
4817
 
4818
;; ::::::::::::::::::::
4819
;; ::
4820
;; :: Miscellaneous instructions
4821
;; ::
4822
;; ::::::::::::::::::::
4823
 
4824
;; ??? Emitting a NOP instruction isn't very useful.  This should probably
4825
;; be emitting ";;" to force a break in the instruction packing.
4826
 
4827
;; No operation, needed in case the user uses -g but not -O.
4828
(define_insn "nop"
4829
  [(const_int 0)]
4830
  ""
4831
  "nop 0"
4832
  [(set_attr "itanium_class" "nop")])
4833
 
4834
(define_insn "nop_m"
4835
  [(const_int 1)]
4836
  ""
4837
  "nop.m 0"
4838
  [(set_attr "itanium_class" "nop_m")])
4839
 
4840
(define_insn "nop_i"
4841
  [(const_int 2)]
4842
  ""
4843
  "nop.i 0"
4844
  [(set_attr "itanium_class" "nop_i")])
4845
 
4846
(define_insn "nop_f"
4847
  [(const_int 3)]
4848
  ""
4849
  "nop.f 0"
4850
  [(set_attr "itanium_class" "nop_f")])
4851
 
4852
(define_insn "nop_b"
4853
  [(const_int 4)]
4854
  ""
4855
  "nop.b 0"
4856
  [(set_attr "itanium_class" "nop_b")])
4857
 
4858
(define_insn "nop_x"
4859
  [(const_int 5)]
4860
  ""
4861
  ""
4862
  [(set_attr "itanium_class" "nop_x")
4863
   (set_attr "empty" "yes")])
4864
 
4865
;; The following insn will be never generated.  It is used only by
4866
;; insn scheduler to change state before advancing cycle.
4867
(define_insn "pre_cycle"
4868
  [(const_int 6)]
4869
  ""
4870
  ""
4871
  [(set_attr "itanium_class" "pre_cycle")])
4872
 
4873
(define_insn "bundle_selector"
4874
  [(unspec [(match_operand 0 "const_int_operand" "")] UNSPEC_BUNDLE_SELECTOR)]
4875
  ""
4876
  { return get_bundle_name (INTVAL (operands[0])); }
4877
  [(set_attr "itanium_class" "ignore")
4878
   (set_attr "predicable" "no")])
4879
 
4880
;; Pseudo instruction that prevents the scheduler from moving code above this
4881
;; point.
4882
(define_insn "blockage"
4883
  [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
4884
  ""
4885
  ""
4886
  [(set_attr "itanium_class" "ignore")
4887
   (set_attr "predicable" "no")])
4888
 
4889
(define_insn "insn_group_barrier"
4890
  [(unspec_volatile [(match_operand 0 "const_int_operand" "")]
4891
                    UNSPECV_INSN_GROUP_BARRIER)]
4892
  ""
4893
  ";;"
4894
  [(set_attr "itanium_class" "stop_bit")
4895
   (set_attr "predicable" "no")
4896
   (set_attr "empty" "yes")])
4897
 
4898
(define_expand "trap"
4899
  [(trap_if (const_int 1) (const_int 0))]
4900
  ""
4901
  "")
4902
 
4903
;; ??? We don't have a match-any slot type.  Setting the type to unknown
4904
;; produces worse code that setting the slot type to A.
4905
 
4906
(define_insn "*trap"
4907
  [(trap_if (const_int 1) (match_operand 0 "const_int_operand" ""))]
4908
  ""
4909
  "break %0"
4910
  [(set_attr "itanium_class" "chk_s_i")])
4911
 
4912
(define_expand "ctrapbi4"
4913
  [(trap_if (match_operator 0 "ia64_cbranch_operator"
4914
                       [(match_operand:BI 1 "register_operand" "")
4915
                        (match_operand:BI 2 "const_int_operand" "")])
4916
                      (match_operand 3 "" ""))]
4917
  ""
4918
  "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
4919
 
4920
(define_expand "ctrapsi4"
4921
  [(trap_if (match_operator 0 "ia64_cbranch_operator"
4922
                       [(match_operand:SI 1 "gr_register_operand" "")
4923
                        (match_operand:SI 2 "gr_reg_or_8bit_and_adjusted_operand" "")])
4924
                       (match_operand 3 "" ""))]
4925
  ""
4926
  "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
4927
 
4928
(define_expand "ctrapdi4"
4929
  [(trap_if (match_operator 0 "ia64_cbranch_operator"
4930
                       [(match_operand:DI 1 "gr_register_operand" "")
4931
                        (match_operand:DI 2 "gr_reg_or_8bit_and_adjusted_operand" "")])
4932
                       (match_operand 3 "" ""))]
4933
  ""
4934
  "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
4935
 
4936
(define_expand "ctrapsf4"
4937
  [(trap_if (match_operator 0 "ia64_cbranch_operator"
4938
                       [(match_operand:SF 1 "fr_reg_or_fp01_operand" "")
4939
                        (match_operand:SF 2 "fr_reg_or_fp01_operand" "")])
4940
                       (match_operand 3 "" ""))]
4941
  ""
4942
  "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
4943
 
4944
(define_expand "ctrapdf4"
4945
  [(trap_if (match_operator 0 "ia64_cbranch_operator"
4946
                       [(match_operand:DF 1 "fr_reg_or_fp01_operand" "")
4947
                        (match_operand:DF 2 "fr_reg_or_fp01_operand" "")])
4948
                       (match_operand 3 "" ""))]
4949
  ""
4950
  "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
4951
 
4952
(define_expand "ctrapxf4"
4953
  [(trap_if (match_operator 0 "ia64_cbranch_operator"
4954
                       [(match_operand:XF 1 "xfreg_or_fp01_operand" "")
4955
                        (match_operand:XF 2 "xfreg_or_fp01_operand" "")])
4956
                       (match_operand 3 "" ""))]
4957
  ""
4958
  "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
4959
 
4960
(define_expand "ctraptf4"
4961
  [(trap_if (match_operator 0 "ia64_cbranch_operator"
4962
                       [(match_operand:TF 1 "gr_register_operand" "")
4963
                        (match_operand:TF 2 "gr_register_operand" "")])
4964
                       (match_operand 3 "" ""))]
4965
  "TARGET_HPUX"
4966
  "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
4967
 
4968
 
4969
(define_insn "*conditional_trap"
4970
  [(trap_if (match_operator 0 "predicate_operator"
4971
              [(match_operand:BI 1 "register_operand" "c")
4972
               (const_int 0)])
4973
            (match_operand 2 "const_int_operand" ""))]
4974
  ""
4975
  "(%J0) break %2"
4976
  [(set_attr "itanium_class" "chk_s_i")
4977
   (set_attr "predicable" "no")])
4978
 
4979
(define_insn "break_f"
4980
  [(unspec_volatile [(const_int 0)] UNSPECV_BREAK)]
4981
  ""
4982
  "break.f 0"
4983
  [(set_attr "itanium_class" "nop_f")])
4984
 
4985
(define_insn "prefetch"
4986
  [(prefetch (match_operand:DI 0 "address_operand" "p")
4987
             (match_operand:DI 1 "const_int_operand" "n")
4988
             (match_operand:DI 2 "const_int_operand" "n"))]
4989
  ""
4990
{
4991
  static const char * const alt[2][4] = {
4992
    {
4993
      "%,lfetch.nta [%0]",
4994
      "%,lfetch.nt1 [%0]",
4995
      "%,lfetch.nt2 [%0]",
4996
      "%,lfetch [%0]"
4997
    },
4998
    {
4999
      "%,lfetch.excl.nta [%0]",
5000
      "%,lfetch.excl.nt1 [%0]",
5001
      "%,lfetch.excl.nt2 [%0]",
5002
      "%,lfetch.excl [%0]"
5003
    }
5004
  };
5005
  int i = (INTVAL (operands[1]));
5006
  int j = (INTVAL (operands[2]));
5007
 
5008
  gcc_assert (i == 0 || i == 1);
5009
  gcc_assert (j >= 0 && j <= 3);
5010
  return alt[i][j];
5011
}
5012
  [(set_attr "itanium_class" "lfetch")])
5013
 
5014
;; Non-local goto support.
5015
 
5016
(define_expand "save_stack_nonlocal"
5017
  [(use (match_operand:OI 0 "memory_operand" ""))
5018
   (use (match_operand:DI 1 "register_operand" ""))]
5019
  ""
5020
{
5021
  emit_library_call (gen_rtx_SYMBOL_REF (Pmode,
5022
                                         \"__ia64_save_stack_nonlocal\"),
5023
                     LCT_NORMAL, VOIDmode, 2, XEXP (operands[0], 0), Pmode,
5024
                     operands[1], Pmode);
5025
  DONE;
5026
})
5027
 
5028
(define_expand "nonlocal_goto"
5029
  [(use (match_operand 0 "general_operand" ""))
5030
   (use (match_operand 1 "general_operand" ""))
5031
   (use (match_operand 2 "general_operand" ""))
5032
   (use (match_operand 3 "general_operand" ""))]
5033
  ""
5034
{
5035
  emit_library_call (gen_rtx_SYMBOL_REF (Pmode, \"__ia64_nonlocal_goto\"),
5036
                     LCT_NORETURN, VOIDmode, 3,
5037
                     operands[1], Pmode,
5038
                     copy_to_reg (XEXP (operands[2], 0)), Pmode,
5039
                     operands[3], Pmode);
5040
  emit_barrier ();
5041
  DONE;
5042
})
5043
 
5044
(define_insn_and_split "nonlocal_goto_receiver"
5045
  [(unspec_volatile [(const_int 0)] UNSPECV_GOTO_RECEIVER)]
5046
  ""
5047
  "#"
5048
  "reload_completed"
5049
  [(const_int 0)]
5050
{
5051
  ia64_reload_gp ();
5052
  DONE;
5053
})
5054
 
5055
(define_insn_and_split "builtin_setjmp_receiver"
5056
  [(unspec_volatile [(match_operand:DI 0 "" "")] UNSPECV_SETJMP_RECEIVER)]
5057
  ""
5058
  "#"
5059
  "reload_completed"
5060
  [(const_int 0)]
5061
{
5062
  ia64_reload_gp ();
5063
  DONE;
5064
})
5065
 
5066
(define_expand "eh_epilogue"
5067
  [(use (match_operand:DI 0 "register_operand" "r"))
5068
   (use (match_operand:DI 1 "register_operand" "r"))
5069
   (use (match_operand:DI 2 "register_operand" "r"))]
5070
  ""
5071
{
5072
  rtx bsp = gen_rtx_REG (Pmode, 10);
5073
  rtx sp = gen_rtx_REG (Pmode, 9);
5074
 
5075
  if (GET_CODE (operands[0]) != REG || REGNO (operands[0]) != 10)
5076
    {
5077
      emit_move_insn (bsp, operands[0]);
5078
      operands[0] = bsp;
5079
    }
5080
  if (GET_CODE (operands[2]) != REG || REGNO (operands[2]) != 9)
5081
    {
5082
      emit_move_insn (sp, operands[2]);
5083
      operands[2] = sp;
5084
    }
5085
  emit_use (sp);
5086
  emit_use (bsp);
5087
 
5088
  cfun->machine->ia64_eh_epilogue_sp = sp;
5089
  cfun->machine->ia64_eh_epilogue_bsp = bsp;
5090
})
5091
 
5092
;; Builtin apply support.
5093
 
5094
(define_expand "restore_stack_nonlocal"
5095
  [(use (match_operand:DI 0 "register_operand" ""))
5096
   (use (match_operand:OI 1 "memory_operand" ""))]
5097
  ""
5098
{
5099
  emit_library_call (gen_rtx_SYMBOL_REF (Pmode,
5100
                                         "__ia64_restore_stack_nonlocal"),
5101
                     LCT_NORMAL, VOIDmode, 1,
5102
                     copy_to_reg (XEXP (operands[1], 0)), Pmode);
5103
  DONE;
5104
})
5105
 
5106
 
5107
;; Predication.
5108
 
5109
(define_cond_exec
5110
  [(match_operator 0 "predicate_operator"
5111
     [(match_operand:BI 1 "register_operand" "c")
5112
      (const_int 0)])]
5113
  ""
5114
  "(%J0)")
5115
 
5116
(define_insn "pred_rel_mutex"
5117
  [(set (match_operand:BI 0 "register_operand" "+c")
5118
       (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
5119
  ""
5120
  ".pred.rel.mutex %0, %I0"
5121
  [(set_attr "itanium_class" "ignore")
5122
   (set_attr "predicable" "no")])
5123
 
5124
(define_insn "safe_across_calls_all"
5125
  [(unspec_volatile [(const_int 0)] UNSPECV_PSAC_ALL)]
5126
  ""
5127
  ".pred.safe_across_calls p1-p63"
5128
  [(set_attr "itanium_class" "ignore")
5129
   (set_attr "predicable" "no")])
5130
 
5131
(define_insn "safe_across_calls_normal"
5132
  [(unspec_volatile [(const_int 0)] UNSPECV_PSAC_NORMAL)]
5133
  ""
5134
{
5135
  emit_safe_across_calls ();
5136
  return "";
5137
}
5138
  [(set_attr "itanium_class" "ignore")
5139
   (set_attr "predicable" "no")])
5140
 
5141
;; UNSPEC instruction definition to "swizzle" 32-bit pointer into 64-bit
5142
;; pointer.  This is used by the HP-UX 32 bit mode.
5143
 
5144
(define_insn "ptr_extend"
5145
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
5146
        (unspec:DI [(match_operand:SI 1 "gr_register_operand" "r")]
5147
                   UNSPEC_ADDP4))]
5148
  ""
5149
  "addp4 %0 = 0,%1"
5150
  [(set_attr "itanium_class" "ialu")])
5151
 
5152
;;
5153
;; Optimizations for ptr_extend
5154
 
5155
(define_insn "ptr_extend_plus_imm"
5156
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
5157
        (unspec:DI
5158
         [(plus:SI (match_operand:SI 1 "basereg_operand" "r")
5159
                   (match_operand:SI 2 "gr_reg_or_14bit_operand" "rI"))]
5160
         UNSPEC_ADDP4))]
5161
  "addp4_optimize_ok (operands[1], operands[2])"
5162
  "addp4 %0 = %2, %1"
5163
  [(set_attr "itanium_class" "ialu")])
5164
 
5165
(define_insn "*ptr_extend_plus_2"
5166
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
5167
        (unspec:DI
5168
         [(plus:SI (match_operand:SI 1 "gr_register_operand" "r")
5169
                   (match_operand:SI 2 "basereg_operand" "r"))]
5170
         UNSPEC_ADDP4))]
5171
  "addp4_optimize_ok (operands[1], operands[2])"
5172
  "addp4 %0 = %1, %2"
5173
  [(set_attr "itanium_class" "ialu")])
5174
 
5175
;;
5176
;; Get instruction pointer
5177
 
5178
(define_insn "ip_value"
5179
  [(set (match_operand:DI 0 "register_operand" "=r")
5180
        (pc))]
5181
 ""
5182
 "mov %0 = ip"
5183
  [(set_attr "itanium_class" "frbr")])
5184
 
5185
;; Vector operations
5186
(include "vect.md")
5187
;; Atomic operations
5188
(include "sync.md")
5189
;; New division operations
5190
(include "div.md")

powered by: WebSVN 2.1.0

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