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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [config/] [ia64/] [ia64.md] - Blame information for rev 455

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

Line No. Rev Author Line
1 38 julius
;; IA-64 Machine description template
2
;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
3
;; 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_constants
52
  [; Relocations
53
   (UNSPEC_LTOFF_DTPMOD         0)
54
   (UNSPEC_LTOFF_DTPREL         1)
55
   (UNSPEC_DTPREL               2)
56
   (UNSPEC_LTOFF_TPREL          3)
57
   (UNSPEC_TPREL                4)
58
   (UNSPEC_DTPMOD               5)
59
 
60
   (UNSPEC_LD_BASE              9)
61
   (UNSPEC_GR_SPILL             10)
62
   (UNSPEC_GR_RESTORE           11)
63
   (UNSPEC_FR_SPILL             12)
64
   (UNSPEC_FR_RESTORE           13)
65
   (UNSPEC_FR_RECIP_APPROX      14)
66
   (UNSPEC_PRED_REL_MUTEX       15)
67
   (UNSPEC_GETF_EXP             16)
68
   (UNSPEC_PIC_CALL             17)
69
   (UNSPEC_MF                   18)
70
   (UNSPEC_CMPXCHG_ACQ          19)
71
   (UNSPEC_FETCHADD_ACQ         20)
72
   (UNSPEC_BSP_VALUE            21)
73
   (UNSPEC_FLUSHRS              22)
74
   (UNSPEC_BUNDLE_SELECTOR      23)
75
   (UNSPEC_ADDP4                24)
76
   (UNSPEC_PROLOGUE_USE         25)
77
   (UNSPEC_RET_ADDR             26)
78
   (UNSPEC_SETF_EXP             27)
79
   (UNSPEC_FR_SQRT_RECIP_APPROX 28)
80
   (UNSPEC_SHRP                 29)
81
   (UNSPEC_COPYSIGN             30)
82
   (UNSPEC_VECT_EXTR            31)
83
   (UNSPEC_LDA                  40)
84
   (UNSPEC_LDS                  41)
85
   (UNSPEC_LDSA                 42)
86
   (UNSPEC_LDCCLR               43)
87
   (UNSPEC_CHKACLR              45)
88
   (UNSPEC_CHKS                 47)
89
  ])
90
 
91
(define_constants
92
  [(UNSPECV_ALLOC               0)
93
   (UNSPECV_BLOCKAGE            1)
94
   (UNSPECV_INSN_GROUP_BARRIER  2)
95
   (UNSPECV_BREAK               3)
96
   (UNSPECV_SET_BSP             4)
97
   (UNSPECV_PSAC_ALL            5)      ; pred.safe_across_calls
98
   (UNSPECV_PSAC_NORMAL         6)
99
   (UNSPECV_SETJMP_RECEIVER     7)
100
  ])
101
 
102
(include "predicates.md")
103
 
104
;; ::::::::::::::::::::
105
;; ::
106
;; :: Attributes
107
;; ::
108
;; ::::::::::::::::::::
109
 
110
;; Processor type.  This attribute must exactly match the processor_type
111
;; enumeration in ia64.h.
112
(define_attr "cpu" "itanium,itanium2" (const (symbol_ref "ia64_tune")))
113
 
114
;; Instruction type.  This primarily determines how instructions can be
115
;; packed in bundles, and secondarily affects scheduling to function units.
116
 
117
;; A alu, can go in I or M syllable of a bundle
118
;; I integer
119
;; M memory
120
;; F floating-point
121
;; B branch
122
;; L long immediate, takes two syllables
123
;; S stop bit
124
 
125
;; ??? Should not have any pattern with type unknown.  Perhaps add code to
126
;; check this in md_reorg?  Currently use unknown for patterns which emit
127
;; multiple instructions, patterns which emit 0 instructions, and patterns
128
;; which emit instruction that can go in any slot (e.g. nop).
129
 
130
(define_attr "itanium_class" "unknown,ignore,stop_bit,br,fcmp,fcvtfx,fld,
131
        fldp,fmac,fmisc,frar_i,frar_m,frbr,frfr,frpr,ialu,icmp,ilog,ishf,
132
        ld,chk_s_i,chk_s_f,chk_a,long_i,mmalua,mmmul,mmshf,mmshfi,rse_m,scall,sem,stf,
133
        st,syst_m0, syst_m,tbit,toar_i,toar_m,tobr,tofr,topr,xmpy,xtd,nop,
134
        nop_b,nop_f,nop_i,nop_m,nop_x,lfetch,pre_cycle"
135
  (const_string "unknown"))
136
 
137
;; chk_s_i has an I and an M form; use type A for convenience.
138
(define_attr "type" "unknown,A,I,M,F,B,L,X,S"
139
  (cond [(eq_attr "itanium_class" "ld,st,fld,fldp,stf,sem,nop_m") (const_string "M")
140
         (eq_attr "itanium_class" "rse_m,syst_m,syst_m0") (const_string "M")
141
         (eq_attr "itanium_class" "frar_m,toar_m,frfr,tofr") (const_string "M")
142
         (eq_attr "itanium_class" "lfetch") (const_string "M")
143
         (eq_attr "itanium_class" "chk_s_f,chk_a") (const_string "M")
144
         (eq_attr "itanium_class" "chk_s_i,ialu,icmp,ilog,mmalua")
145
           (const_string "A")
146
         (eq_attr "itanium_class" "fmisc,fmac,fcmp,xmpy") (const_string "F")
147
         (eq_attr "itanium_class" "fcvtfx,nop_f") (const_string "F")
148
         (eq_attr "itanium_class" "frar_i,toar_i,frbr,tobr") (const_string "I")
149
         (eq_attr "itanium_class" "frpr,topr,ishf,xtd,tbit") (const_string "I")
150
         (eq_attr "itanium_class" "mmmul,mmshf,mmshfi,nop_i") (const_string "I")
151
         (eq_attr "itanium_class" "br,scall,nop_b") (const_string "B")
152
         (eq_attr "itanium_class" "stop_bit") (const_string "S")
153
         (eq_attr "itanium_class" "nop_x") (const_string "X")
154
         (eq_attr "itanium_class" "long_i") (const_string "L")]
155
        (const_string "unknown")))
156
 
157
(define_attr "itanium_requires_unit0" "no,yes"
158
  (cond [(eq_attr "itanium_class" "syst_m0,sem,frfr,rse_m") (const_string "yes")
159
         (eq_attr "itanium_class" "toar_m,frar_m") (const_string "yes")
160
         (eq_attr "itanium_class" "frbr,tobr,mmmul") (const_string "yes")
161
         (eq_attr "itanium_class" "tbit,ishf,topr,frpr") (const_string "yes")
162
         (eq_attr "itanium_class" "toar_i,frar_i") (const_string "yes")
163
         (eq_attr "itanium_class" "fmisc,fcmp") (const_string "yes")]
164
        (const_string "no")))
165
 
166
;; Predication.  True iff this instruction can be predicated.
167
 
168
(define_attr "predicable" "no,yes" (const_string "yes"))
169
 
170
;; Empty.  True iff this insn does not generate any code.
171
 
172
(define_attr "empty" "no,yes" (const_string "no"))
173
 
174
;; True iff this insn must be the first insn of an instruction group.
175
;; This is true for the alloc instruction, and will also be true of others
176
;; when we have full intrinsics support.
177
 
178
(define_attr "first_insn" "no,yes" (const_string "no"))
179
 
180
(define_attr "data_speculative" "no,yes" (const_string "no"))
181
 
182
(define_attr "control_speculative" "no,yes" (const_string "no"))
183
 
184
(define_attr "check_load" "no,yes" (const_string "no"))
185
 
186
;; DFA descriptions of ia64 processors used for insn scheduling and
187
;; bundling.
188
 
189
(automata_option "ndfa")
190
 
191
;; Uncomment the following line to output automata for debugging.
192
;; (automata_option "v")
193
 
194
(automata_option "w")
195
 
196
(include "itanium1.md")
197
(include "itanium2.md")
198
 
199
 
200
;; ::::::::::::::::::::
201
;; ::
202
;; :: Moves
203
;; ::
204
;; ::::::::::::::::::::
205
 
206
;; Set of a single predicate register.  This is only used to implement
207
;; pr-to-pr move and complement.
208
 
209
(define_insn "*movcci"
210
  [(set (match_operand:CCI 0 "register_operand" "=c,c,c")
211
        (match_operand:CCI 1 "nonmemory_operand" "O,n,c"))]
212
  ""
213
  "@
214
   cmp.ne %0, p0 = r0, r0
215
   cmp.eq %0, p0 = r0, r0
216
   (%1) cmp.eq.unc %0, p0 = r0, r0"
217
  [(set_attr "itanium_class" "icmp")
218
   (set_attr "predicable" "no")])
219
 
220
(define_insn "movbi"
221
  [(set (match_operand:BI 0 "destination_operand" "=c,c,?c,?*r, c,*r,*r,*m,*r")
222
        (match_operand:BI 1 "move_operand"        " O,n, c,  c,*r, n,*m,*r,*r"))]
223
  ""
224
  "@
225
   cmp.ne %0, %I0 = r0, r0
226
   cmp.eq %0, %I0 = r0, r0
227
   #
228
   #
229
   tbit.nz %0, %I0 = %1, 0
230
   adds %0 = %1, r0
231
   ld1%O1 %0 = %1%P1
232
   st1%Q0 %0 = %1%P0
233
   mov %0 = %1"
234
  [(set_attr "itanium_class" "icmp,icmp,unknown,unknown,tbit,ialu,ld,st,ialu")])
235
 
236
(define_split
237
  [(set (match_operand:BI 0 "register_operand" "")
238
        (match_operand:BI 1 "register_operand" ""))]
239
  "reload_completed
240
   && GET_CODE (operands[0]) == REG && GR_REGNO_P (REGNO (operands[0]))
241
   && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
242
  [(cond_exec (ne (match_dup 1) (const_int 0))
243
     (set (match_dup 0) (const_int 1)))
244
   (cond_exec (eq (match_dup 1) (const_int 0))
245
     (set (match_dup 0) (const_int 0)))]
246
  "")
247
 
248
(define_split
249
  [(set (match_operand:BI 0 "register_operand" "")
250
        (match_operand:BI 1 "register_operand" ""))]
251
  "reload_completed
252
   && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
253
   && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
254
  [(set (match_dup 2) (match_dup 4))
255
   (set (match_dup 3) (match_dup 5))
256
   (set (match_dup 0) (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
257
  "operands[2] = gen_rtx_REG (CCImode, REGNO (operands[0]));
258
   operands[3] = gen_rtx_REG (CCImode, REGNO (operands[0]) + 1);
259
   operands[4] = gen_rtx_REG (CCImode, REGNO (operands[1]));
260
   operands[5] = gen_rtx_REG (CCImode, REGNO (operands[1]) + 1);")
261
 
262
(define_expand "movqi"
263
  [(set (match_operand:QI 0 "general_operand" "")
264
        (match_operand:QI 1 "general_operand" ""))]
265
  ""
266
{
267
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
268
  if (!op1)
269
    DONE;
270
  operands[1] = op1;
271
})
272
 
273
(define_insn "*movqi_internal"
274
  [(set (match_operand:QI 0 "destination_operand" "=r,r,r, m, r,*f,*f")
275
        (match_operand:QI 1 "move_operand"        "rO,J,m,rO,*f,rO,*f"))]
276
  "ia64_move_ok (operands[0], operands[1])"
277
  "@
278
   mov %0 = %r1
279
   addl %0 = %1, r0
280
   ld1%O1 %0 = %1%P1
281
   st1%Q0 %0 = %r1%P0
282
   getf.sig %0 = %1
283
   setf.sig %0 = %r1
284
   mov %0 = %1"
285
  [(set_attr "itanium_class" "ialu,ialu,ld,st,frfr,tofr,fmisc")])
286
 
287
(define_expand "movhi"
288
  [(set (match_operand:HI 0 "general_operand" "")
289
        (match_operand:HI 1 "general_operand" ""))]
290
  ""
291
{
292
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
293
  if (!op1)
294
    DONE;
295
  operands[1] = op1;
296
})
297
 
298
(define_insn "*movhi_internal"
299
  [(set (match_operand:HI 0 "destination_operand" "=r,r,r, m, r,*f,*f")
300
        (match_operand:HI 1 "move_operand"        "rO,J,m,rO,*f,rO,*f"))]
301
  "ia64_move_ok (operands[0], operands[1])"
302
  "@
303
   mov %0 = %r1
304
   addl %0 = %1, r0
305
   ld2%O1 %0 = %1%P1
306
   st2%Q0 %0 = %r1%P0
307
   getf.sig %0 = %1
308
   setf.sig %0 = %r1
309
   mov %0 = %1"
310
  [(set_attr "itanium_class" "ialu,ialu,ld,st,frfr,tofr,fmisc")])
311
 
312
(define_expand "movsi"
313
  [(set (match_operand:SI 0 "general_operand" "")
314
        (match_operand:SI 1 "general_operand" ""))]
315
  ""
316
{
317
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
318
  if (!op1)
319
    DONE;
320
  operands[1] = op1;
321
})
322
 
323
(define_insn "*movsi_internal"
324
  [(set (match_operand:SI 0 "destination_operand" "=r,r,r,r, m, r,*f,*f, r,*d")
325
        (match_operand:SI 1 "move_operand"        "rO,J,i,m,rO,*f,rO,*f,*d,rK"))]
326
  "ia64_move_ok (operands[0], operands[1])"
327
  "@
328
  mov %0 = %r1
329
  addl %0 = %1, r0
330
  movl %0 = %1
331
  ld4%O1 %0 = %1%P1
332
  st4%Q0 %0 = %r1%P0
333
  getf.sig %0 = %1
334
  setf.sig %0 = %r1
335
  mov %0 = %1
336
  mov %0 = %1
337
  mov %0 = %r1"
338
  ;; frar_m, toar_m ??? why not frar_i and toar_i
339
  [(set_attr "itanium_class" "ialu,ialu,long_i,ld,st,frfr,tofr,fmisc,frar_m,toar_m")])
340
 
341
(define_expand "movdi"
342
  [(set (match_operand:DI 0 "general_operand" "")
343
        (match_operand:DI 1 "general_operand" ""))]
344
  ""
345
{
346
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
347
  if (!op1)
348
    DONE;
349
  operands[1] = op1;
350
})
351
 
352
(define_insn "*movdi_internal"
353
  [(set (match_operand:DI 0 "destination_operand"
354
                    "=r,r,r,r, m, r,*f,*f,*f, Q, r,*b, r,*e, r,*d, r,*c")
355
        (match_operand:DI 1 "move_operand"
356
                    "rO,JT,i,m,rO,*f,rO,*f, Q,*f,*b,rO,*e,rK,*d,rK,*c,rO"))]
357
  "ia64_move_ok (operands[0], operands[1])"
358
{
359
  static const char * const alt[] = {
360
    "%,mov %0 = %r1",
361
    "%,addl %0 = %1, r0",
362
    "%,movl %0 = %1",
363
    "%,ld8%O1 %0 = %1%P1",
364
    "%,st8%Q0 %0 = %r1%P0",
365
    "%,getf.sig %0 = %1",
366
    "%,setf.sig %0 = %r1",
367
    "%,mov %0 = %1",
368
    "%,ldf8 %0 = %1%P1",
369
    "%,stf8 %0 = %1%P0",
370
    "%,mov %0 = %1",
371
    "%,mov %0 = %r1",
372
    "%,mov %0 = %1",
373
    "%,mov %0 = %1",
374
    "%,mov %0 = %1",
375
    "%,mov %0 = %1",
376
    "mov %0 = pr",
377
    "mov pr = %1, -1"
378
  };
379
 
380
  gcc_assert (which_alternative != 2 || TARGET_NO_PIC
381
              || !symbolic_operand (operands[1], VOIDmode));
382
 
383
  return alt[which_alternative];
384
}
385
  [(set_attr "itanium_class" "ialu,ialu,long_i,ld,st,frfr,tofr,fmisc,fld,stf,frbr,tobr,frar_i,toar_i,frar_m,toar_m,frpr,topr")])
386
 
387
(define_mode_macro MODE [BI QI HI SI DI SF DF XF TI])
388
(define_mode_macro MODE_FOR_EXTEND [QI HI SI])
389
 
390
(define_mode_attr output_a [
391
  (BI "ld1.a %0 = %1%P1")
392
  (QI "ld1.a %0 = %1%P1")
393
  (HI "ld2.a %0 = %1%P1")
394
  (SI "ld4.a %0 = %1%P1")
395
  (DI
396
   "@
397
    ld8.a %0 = %1%P1
398
    ldf8.a %0 = %1%P1")
399
  (SF
400
   "@
401
    ldfs.a %0 = %1%P1
402
    ld4.a %0 = %1%P1")
403
  (DF
404
   "@
405
    ldfd.a %0 = %1%P1
406
    ld8.a %0 = %1%P1")
407
  (XF "ldfe.a %0 = %1%P1")
408
  (TI "ldfp8.a %X0 = %1%P1")])
409
 
410
(define_mode_attr output_s [
411
  (BI "ld1.s %0 = %1%P1")
412
  (QI "ld1.s %0 = %1%P1")
413
  (HI "ld2.s %0 = %1%P1")
414
  (SI "ld4.s %0 = %1%P1")
415
  (DI
416
   "@
417
    ld8.s %0 = %1%P1
418
    ldf8.s %0 = %1%P1")
419
  (SF
420
   "@
421
    ldfs.s %0 = %1%P1
422
    ld4.s %0 = %1%P1")
423
  (DF
424
   "@
425
    ldfd.s %0 = %1%P1
426
    ld8.s %0 = %1%P1")
427
  (XF "ldfe.s %0 = %1%P1")
428
  (TI "ldfp8.s %X0 = %1%P1")])
429
 
430
(define_mode_attr output_sa [
431
  (BI "ld1.sa %0 = %1%P1")
432
  (QI "ld1.sa %0 = %1%P1")
433
  (HI "ld2.sa %0 = %1%P1")
434
  (SI "ld4.sa %0 = %1%P1")
435
  (DI
436
   "@
437
    ld8.sa %0 = %1%P1
438
    ldf8.sa %0 = %1%P1")
439
  (SF
440
   "@
441
    ldfs.sa %0 = %1%P1
442
    ld4.sa %0 = %1%P1")
443
  (DF
444
   "@
445
    ldfd.sa %0 = %1%P1
446
    ld8.sa %0 = %1%P1")
447
  (XF "ldfe.sa %0 = %1%P1")
448
  (TI "ldfp8.sa %X0 = %1%P1")])
449
 
450
(define_mode_attr output_c_clr [
451
  (BI "ld1.c.clr%O1 %0 = %1%P1")
452
  (QI "ld1.c.clr%O1 %0 = %1%P1")
453
  (HI "ld2.c.clr%O1 %0 = %1%P1")
454
  (SI "ld4.c.clr%O1 %0 = %1%P1")
455
  (DI
456
   "@
457
    ld8.c.clr%O1 %0 = %1%P1
458
    ldf8.c.clr %0 = %1%P1")
459
  (SF
460
   "@
461
    ldfs.c.clr %0 = %1%P1
462
    ld4.c.clr%O1 %0 = %1%P1")
463
  (DF
464
   "@
465
    ldfd.c.clr %0 = %1%P1
466
    ld8.c.clr%O1 %0 = %1%P1")
467
  (XF "ldfe.c.clr %0 = %1%P1")
468
  (TI "ldfp8.c.clr %X0 = %1%P1")])
469
 
470
(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")])
471
(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")])
472
(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")])
473
 
474
(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")])
475
 
476
;; Define register predicate prefix.
477
;; We can generate speculative loads only for general and fp registers - this
478
;; is constrainted in ia64.c: ia64_speculate_insn ().
479
(define_mode_attr reg_pred_prefix [(BI "gr") (QI "gr") (HI "gr") (SI "gr") (DI "grfr") (SF "grfr") (DF "grfr") (XF "fr") (TI "fr")])
480
 
481
(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")])
482
(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")])
483
(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")])
484
 
485
(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")])
486
 
487
(define_insn "mov_advanced"
488
  [(set (match_operand:MODE 0 "_register_operand" "")
489
        (unspec:MODE [(match_operand:MODE 1 "memory_operand" "")] UNSPEC_LDA))]
490
  "ia64_move_ok (operands[0], operands[1])"
491
  ""
492
  [(set_attr "itanium_class" "")
493
   (set_attr "data_speculative" "")])
494
 
495
(define_insn "zero_extenddi2_advanced"
496
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
497
        (zero_extend:DI (unspec:MODE_FOR_EXTEND [(match_operand:MODE_FOR_EXTEND 1 "memory_operand" "")] UNSPEC_LDA)))]
498
  ""
499
  ""
500
  [(set_attr "itanium_class" "")
501
   (set_attr "data_speculative" "")])
502
 
503
(define_insn "mov_speculative"
504
  [(set (match_operand:MODE 0 "_register_operand" "")
505
        (unspec:MODE [(match_operand:MODE 1 "memory_operand" "")] UNSPEC_LDS))]
506
  "ia64_move_ok (operands[0], operands[1])"
507
  ""
508
  [(set_attr "itanium_class" "")
509
   (set_attr "control_speculative" "")])
510
 
511
(define_insn "zero_extenddi2_speculative"
512
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
513
        (zero_extend:DI (unspec:MODE_FOR_EXTEND [(match_operand:MODE_FOR_EXTEND 1 "memory_operand" "")] UNSPEC_LDS)))]
514
  ""
515
  ""
516
  [(set_attr "itanium_class" "")
517
   (set_attr "control_speculative" "")])
518
 
519
(define_insn "mov_speculative_advanced"
520
  [(set (match_operand:MODE 0 "_register_operand" "")
521
        (unspec:MODE [(match_operand:MODE 1 "memory_operand" "")] UNSPEC_LDSA))]
522
  "ia64_move_ok (operands[0], operands[1])"
523
  ""
524
  [(set_attr "itanium_class" "")
525
   (set_attr "data_speculative" "")
526
   (set_attr "control_speculative" "")])
527
 
528
(define_insn "zero_extenddi2_speculative_advanced"
529
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
530
        (zero_extend:DI (unspec:MODE_FOR_EXTEND [(match_operand:MODE_FOR_EXTEND 1 "memory_operand" "")] UNSPEC_LDSA)))]
531
  ""
532
  ""
533
  [(set_attr "itanium_class" "")
534
   (set_attr "data_speculative" "")
535
   (set_attr "control_speculative" "")])
536
 
537
(define_insn "mov_clr"
538
  [(set (match_operand:MODE 0 "_register_operand" "")
539
        (if_then_else:MODE (ne (unspec [(match_dup 0)] UNSPEC_LDCCLR) (const_int 0))
540
                           (match_operand:MODE 1 "memory_operand" "")
541
                           (match_dup 0)))]
542
  "ia64_move_ok (operands[0], operands[1])"
543
  ""
544
  [(set_attr "itanium_class" "")
545
   (set_attr "check_load" "")])
546
 
547
(define_insn "zero_extenddi2_clr"
548
  [(set (match_operand:DI 0 "gr_register_operand" "+r")
549
        (if_then_else:DI (ne (unspec [(match_dup 0)] UNSPEC_LDCCLR) (const_int 0))
550
                         (zero_extend:DI (match_operand:MODE_FOR_EXTEND 1 "memory_operand" ""))
551
                         (match_dup 0)))]
552
  ""
553
  ""
554
  [(set_attr "itanium_class" "")
555
   (set_attr "check_load" "")])
556
 
557
(define_insn "advanced_load_check_clr_"
558
  [(set (pc)
559
        (if_then_else (ne (unspec [(match_operand:MODE 0 "_register_operand" "")] UNSPEC_CHKACLR) (const_int 0))
560
                      (pc)
561
                      (label_ref (match_operand 1 "" ""))))]
562
  ""
563
  "chk.a.clr %0, %l1"
564
  [(set_attr "itanium_class" "")])
565
 
566
(define_insn "speculation_check_"
567
  [(set (pc)
568
        (if_then_else (ne (unspec [(match_operand:MODE 0 "_register_operand" "")] UNSPEC_CHKS) (const_int 0))
569
                      (pc)
570
                      (label_ref (match_operand 1 "" ""))))]
571
  ""
572
  "chk.s %0, %l1"
573
  [(set_attr "itanium_class" "")])
574
 
575
(define_split
576
  [(set (match_operand 0 "register_operand" "")
577
        (match_operand 1 "symbolic_operand" ""))]
578
  "reload_completed"
579
  [(const_int 0)]
580
{
581
  if (ia64_expand_load_address (operands[0], operands[1]))
582
    DONE;
583
  else
584
    FAIL;
585
})
586
 
587
(define_expand "load_fptr"
588
  [(set (match_operand:DI 0 "register_operand" "")
589
        (plus:DI (match_dup 2) (match_operand 1 "function_operand" "")))
590
   (set (match_dup 0) (match_dup 3))]
591
  "reload_completed"
592
{
593
  operands[2] = pic_offset_table_rtx;
594
  operands[3] = gen_const_mem (DImode, operands[0]);
595
})
596
 
597
(define_insn "*load_fptr_internal1"
598
  [(set (match_operand:DI 0 "register_operand" "=r")
599
        (plus:DI (reg:DI 1) (match_operand 1 "function_operand" "s")))]
600
  "reload_completed"
601
  "addl %0 = @ltoff(@fptr(%1)), gp"
602
  [(set_attr "itanium_class" "ialu")])
603
 
604
(define_insn "load_gprel"
605
  [(set (match_operand:DI 0 "register_operand" "=r")
606
        (plus:DI (reg:DI 1) (match_operand 1 "sdata_symbolic_operand" "s")))]
607
  "reload_completed"
608
  "addl %0 = @gprel(%1), gp"
609
  [(set_attr "itanium_class" "ialu")])
610
 
611
(define_insn "*gprel64_offset"
612
  [(set (match_operand:DI 0 "register_operand" "=r")
613
        (minus:DI (match_operand:DI 1 "symbolic_operand" "") (reg:DI 1)))]
614
  "reload_completed"
615
  "movl %0 = @gprel(%1)"
616
  [(set_attr "itanium_class" "long_i")])
617
 
618
(define_expand "load_gprel64"
619
  [(set (match_operand:DI 0 "register_operand" "")
620
        (minus:DI (match_operand:DI 1 "symbolic_operand" "") (match_dup 2)))
621
   (set (match_dup 0)
622
        (plus:DI (match_dup 2) (match_dup 0)))]
623
  "reload_completed"
624
{
625
  operands[2] = pic_offset_table_rtx;
626
})
627
 
628
;; This is used as a placeholder for the return address during early
629
;; compilation.  We won't know where we've placed this until during
630
;; reload, at which point it can wind up in b0, a general register,
631
;; or memory.  The only safe destination under these conditions is a
632
;; general register.
633
 
634
(define_insn_and_split "*movdi_ret_addr"
635
  [(set (match_operand:DI 0 "register_operand" "=r")
636
        (unspec:DI [(const_int 0)] UNSPEC_RET_ADDR))]
637
  ""
638
  "#"
639
  "reload_completed"
640
  [(const_int 0)]
641
{
642
  ia64_split_return_addr_rtx (operands[0]);
643
  DONE;
644
}
645
  [(set_attr "itanium_class" "ialu")])
646
 
647
(define_insn "*load_symptr_high"
648
  [(set (match_operand:DI 0 "register_operand" "=r")
649
        (plus:DI (high:DI (match_operand 1 "got_symbolic_operand" "s"))
650
                 (match_operand:DI 2 "register_operand" "a")))]
651
  "reload_completed"
652
{
653
  if (HAVE_AS_LTOFFX_LDXMOV_RELOCS)
654
    return "%,addl %0 = @ltoffx(%1), %2";
655
  else
656
    return "%,addl %0 = @ltoff(%1), %2";
657
}
658
  [(set_attr "itanium_class" "ialu")])
659
 
660
(define_insn "*load_symptr_low"
661
  [(set (match_operand:DI 0 "register_operand" "=r")
662
        (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
663
                   (match_operand 2 "got_symbolic_operand" "s")))]
664
  "reload_completed"
665
{
666
  if (HAVE_AS_LTOFFX_LDXMOV_RELOCS)
667
    return "%,ld8.mov %0 = [%1], %2";
668
  else
669
    return "%,ld8 %0 = [%1]";
670
}
671
  [(set_attr "itanium_class" "ld")])
672
 
673
(define_insn_and_split "load_dtpmod"
674
  [(set (match_operand:DI 0 "register_operand" "=r")
675
        (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
676
                   UNSPEC_DTPMOD))]
677
  ""
678
  "#"
679
  "reload_completed"
680
  [(set (match_dup 0)
681
        (plus:DI (unspec:DI [(match_dup 1)] UNSPEC_LTOFF_DTPMOD)
682
                 (match_dup 2)))
683
   (set (match_dup 0) (match_dup 3))]
684
{
685
  operands[2] = pic_offset_table_rtx;
686
  operands[3] = gen_const_mem (DImode, operands[0]);
687
})
688
 
689
(define_insn "*load_ltoff_dtpmod"
690
  [(set (match_operand:DI 0 "register_operand" "=r")
691
        (plus:DI (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
692
                            UNSPEC_LTOFF_DTPMOD)
693
                 (match_operand:DI 2 "register_operand" "a")))]
694
  "reload_completed"
695
  "addl %0 = @ltoff(@dtpmod(%1)), %2"
696
  [(set_attr "itanium_class" "ialu")])
697
 
698
(define_expand "load_dtprel"
699
  [(set (match_operand:DI 0 "register_operand" "")
700
        (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
701
                   UNSPEC_DTPREL))]
702
  ""
703
  "")
704
 
705
(define_insn "*load_dtprel64"
706
  [(set (match_operand:DI 0 "register_operand" "=r")
707
        (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
708
                   UNSPEC_DTPREL))]
709
  "TARGET_TLS64"
710
  "movl %0 = @dtprel(%1)"
711
  [(set_attr "itanium_class" "long_i")])
712
 
713
(define_insn "*load_dtprel22"
714
  [(set (match_operand:DI 0 "register_operand" "=r")
715
        (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
716
                   UNSPEC_DTPREL))]
717
  ""
718
  "addl %0 = @dtprel(%1), r0"
719
  [(set_attr "itanium_class" "ialu")])
720
 
721
(define_insn_and_split "*load_dtprel_gd"
722
  [(set (match_operand:DI 0 "register_operand" "=r")
723
        (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
724
                   UNSPEC_DTPREL))]
725
  ""
726
  "#"
727
  "reload_completed"
728
  [(set (match_dup 0)
729
        (plus:DI (unspec:DI [(match_dup 1)] UNSPEC_LTOFF_DTPREL)
730
                 (match_dup 2)))
731
   (set (match_dup 0) (match_dup 3))]
732
{
733
  operands[2] = pic_offset_table_rtx;
734
  operands[3] = gen_const_mem (DImode, operands[0]);
735
})
736
 
737
(define_insn "*load_ltoff_dtprel"
738
  [(set (match_operand:DI 0 "register_operand" "=r")
739
        (plus:DI (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
740
                            UNSPEC_LTOFF_DTPREL)
741
                 (match_operand:DI 2 "register_operand" "a")))]
742
  ""
743
  "addl %0 = @ltoff(@dtprel(%1)), %2"
744
  [(set_attr "itanium_class" "ialu")])
745
 
746
(define_expand "add_dtprel"
747
  [(set (match_operand:DI 0 "register_operand" "")
748
        (plus:DI (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
749
                            UNSPEC_DTPREL)
750
                 (match_operand:DI 2 "register_operand" "")))]
751
  "!TARGET_TLS64"
752
  "")
753
 
754
(define_insn "*add_dtprel14"
755
  [(set (match_operand:DI 0 "register_operand" "=r")
756
        (plus:DI (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
757
                            UNSPEC_DTPREL)
758
                 (match_operand:DI 2 "register_operand" "r")))]
759
  "TARGET_TLS14"
760
  "adds %0 = @dtprel(%1), %2"
761
  [(set_attr "itanium_class" "ialu")])
762
 
763
(define_insn "*add_dtprel22"
764
  [(set (match_operand:DI 0 "register_operand" "=r")
765
        (plus:DI (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
766
                            UNSPEC_DTPREL)
767
                 (match_operand:DI 2 "register_operand" "a")))]
768
  "TARGET_TLS22"
769
  "addl %0 = @dtprel(%1), %2"
770
  [(set_attr "itanium_class" "ialu")])
771
 
772
(define_expand "load_tprel"
773
  [(set (match_operand:DI 0 "register_operand" "")
774
        (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
775
                   UNSPEC_TPREL))]
776
  ""
777
  "")
778
 
779
(define_insn "*load_tprel64"
780
  [(set (match_operand:DI 0 "register_operand" "=r")
781
        (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
782
                   UNSPEC_TPREL))]
783
  "TARGET_TLS64"
784
  "movl %0 = @tprel(%1)"
785
  [(set_attr "itanium_class" "long_i")])
786
 
787
(define_insn "*load_tprel22"
788
  [(set (match_operand:DI 0 "register_operand" "=r")
789
        (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
790
                   UNSPEC_TPREL))]
791
  ""
792
  "addl %0 = @tprel(%1), r0"
793
  [(set_attr "itanium_class" "ialu")])
794
 
795
(define_insn_and_split "*load_tprel_ie"
796
  [(set (match_operand:DI 0 "register_operand" "=r")
797
        (unspec:DI [(match_operand 1 "ie_tls_symbolic_operand" "")]
798
                   UNSPEC_TPREL))]
799
  ""
800
  "#"
801
  "reload_completed"
802
  [(set (match_dup 0)
803
        (plus:DI (unspec:DI [(match_dup 1)] UNSPEC_LTOFF_TPREL)
804
                 (match_dup 2)))
805
   (set (match_dup 0) (match_dup 3))]
806
{
807
  operands[2] = pic_offset_table_rtx;
808
  operands[3] = gen_const_mem (DImode, operands[0]);
809
})
810
 
811
(define_insn "*load_ltoff_tprel"
812
  [(set (match_operand:DI 0 "register_operand" "=r")
813
        (plus:DI (unspec:DI [(match_operand 1 "ie_tls_symbolic_operand" "")]
814
                            UNSPEC_LTOFF_TPREL)
815
                 (match_operand:DI 2 "register_operand" "a")))]
816
  ""
817
  "addl %0 = @ltoff(@tprel(%1)), %2"
818
  [(set_attr "itanium_class" "ialu")])
819
 
820
(define_expand "add_tprel"
821
  [(set (match_operand:DI 0 "register_operand" "")
822
        (plus:DI (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
823
                            UNSPEC_TPREL)
824
                 (match_operand:DI 2 "register_operand" "")))]
825
  "!TARGET_TLS64"
826
  "")
827
 
828
(define_insn "*add_tprel14"
829
  [(set (match_operand:DI 0 "register_operand" "=r")
830
        (plus:DI (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
831
                            UNSPEC_TPREL)
832
                 (match_operand:DI 2 "register_operand" "r")))]
833
  "TARGET_TLS14"
834
  "adds %0 = @tprel(%1), %2"
835
  [(set_attr "itanium_class" "ialu")])
836
 
837
(define_insn "*add_tprel22"
838
  [(set (match_operand:DI 0 "register_operand" "=r")
839
        (plus:DI (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
840
                            UNSPEC_TPREL)
841
                 (match_operand:DI 2 "register_operand" "a")))]
842
  "TARGET_TLS22"
843
  "addl %0 = @tprel(%1), %2"
844
  [(set_attr "itanium_class" "ialu")])
845
 
846
;; With no offsettable memory references, we've got to have a scratch
847
;; around to play with the second word.  However, in order to avoid a
848
;; reload nightmare we lie, claim we don't need one, and fix it up
849
;; in ia64_split_tmode_move.
850
(define_expand "movti"
851
  [(set (match_operand:TI 0 "general_operand" "")
852
        (match_operand:TI 1 "general_operand" ""))]
853
  ""
854
{
855
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
856
  if (!op1)
857
    DONE;
858
  operands[1] = op1;
859
})
860
 
861
(define_insn_and_split "*movti_internal"
862
  [(set (match_operand:TI 0 "destination_operand" "=r,   *fm,*x,*f,  Q")
863
        (match_operand:TI 1 "general_operand"     "r*fim,r,  Q, *fOQ,*f"))]
864
  "ia64_move_ok (operands[0], operands[1])"
865
  "@
866
   #
867
   #
868
   ldfp8 %X0 = %1%P1
869
   #
870
   #"
871
  "reload_completed && !ia64_load_pair_ok(operands[0], operands[1])"
872
  [(const_int 0)]
873
{
874
  ia64_split_tmode_move (operands);
875
  DONE;
876
}
877
  [(set_attr "itanium_class" "unknown,unknown,fldp,unknown,unknown")])
878
 
879
;; Floating Point Moves
880
;;
881
;; Note - Patterns for SF mode moves are compulsory, but
882
;; patterns for DF are optional, as GCC can synthesize them.
883
 
884
(define_expand "movsf"
885
  [(set (match_operand:SF 0 "general_operand" "")
886
        (match_operand:SF 1 "general_operand" ""))]
887
  ""
888
{
889
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
890
  if (!op1)
891
    DONE;
892
  operands[1] = op1;
893
})
894
 
895
(define_insn "*movsf_internal"
896
  [(set (match_operand:SF 0 "destination_operand" "=f,f, Q,*r, f,*r,*r, m")
897
        (match_operand:SF 1 "general_operand"     "fG,Q,fG,fG,*r,*r, m,*r"))]
898
  "ia64_move_ok (operands[0], operands[1])"
899
  "@
900
   mov %0 = %F1
901
   ldfs %0 = %1%P1
902
   stfs %0 = %F1%P0
903
   getf.s %0 = %F1
904
   setf.s %0 = %1
905
   mov %0 = %1
906
   ld4%O1 %0 = %1%P1
907
   st4%Q0 %0 = %1%P0"
908
  [(set_attr "itanium_class" "fmisc,fld,stf,frfr,tofr,ialu,ld,st")])
909
 
910
(define_expand "movdf"
911
  [(set (match_operand:DF 0 "general_operand" "")
912
        (match_operand:DF 1 "general_operand" ""))]
913
  ""
914
{
915
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
916
  if (!op1)
917
    DONE;
918
  operands[1] = op1;
919
})
920
 
921
(define_insn "*movdf_internal"
922
  [(set (match_operand:DF 0 "destination_operand" "=f,f, Q,*r, f,*r,*r, m")
923
        (match_operand:DF 1 "general_operand"     "fG,Q,fG,fG,*r,*r, m,*r"))]
924
  "ia64_move_ok (operands[0], operands[1])"
925
  "@
926
   mov %0 = %F1
927
   ldfd %0 = %1%P1
928
   stfd %0 = %F1%P0
929
   getf.d %0 = %F1
930
   setf.d %0 = %1
931
   mov %0 = %1
932
   ld8%O1 %0 = %1%P1
933
   st8%Q0 %0 = %1%P0"
934
  [(set_attr "itanium_class" "fmisc,fld,stf,frfr,tofr,ialu,ld,st")])
935
 
936
;; With no offsettable memory references, we've got to have a scratch
937
;; around to play with the second word if the variable winds up in GRs.
938
(define_expand "movxf"
939
  [(set (match_operand:XF 0 "general_operand" "")
940
        (match_operand:XF 1 "general_operand" ""))]
941
  ""
942
{
943
  if (ia64_expand_movxf_movrf (XFmode, operands))
944
    DONE;
945
})
946
 
947
;; ??? There's no easy way to mind volatile acquire/release semantics.
948
 
949
(define_insn "*movxf_internal"
950
  [(set (match_operand:XF 0 "destination_operand" "=f,f, m")
951
        (match_operand:XF 1 "general_operand"     "fG,m,fG"))]
952
  "ia64_move_ok (operands[0], operands[1])"
953
  "@
954
   mov %0 = %F1
955
   ldfe %0 = %1%P1
956
   stfe %0 = %F1%P0"
957
  [(set_attr "itanium_class" "fmisc,fld,stf")])
958
 
959
;; Same as for movxf, but for RFmode.
960
(define_expand "movrf"
961
  [(set (match_operand:RF 0 "general_operand" "")
962
        (match_operand:RF 1 "general_operand" ""))]
963
  ""
964
{
965
  if (ia64_expand_movxf_movrf (RFmode, operands))
966
    DONE;
967
})
968
 
969
(define_insn "*movrf_internal"
970
  [(set (match_operand:RF 0 "destination_operand" "=f,f, m")
971
        (match_operand:RF 1 "general_operand"     "fG,m,fG"))]
972
  "ia64_move_ok (operands[0], operands[1])"
973
  "@
974
   mov %0 = %F1
975
   ldf.fill %0 = %1%P1
976
   stf.spill %0 = %F1%P0"
977
  [(set_attr "itanium_class" "fmisc,fld,stf")])
978
 
979
;; Better code generation via insns that deal with TFmode register pairs
980
;; directly.  Same concerns apply as for TImode.
981
(define_expand "movtf"
982
  [(set (match_operand:TF 0 "general_operand" "")
983
        (match_operand:TF 1 "general_operand" ""))]
984
  ""
985
{
986
  rtx op1 = ia64_expand_move (operands[0], operands[1]);
987
  if (!op1)
988
    DONE;
989
  operands[1] = op1;
990
})
991
 
992
(define_insn_and_split "*movtf_internal"
993
  [(set (match_operand:TF 0 "destination_operand"  "=r,r,m")
994
        (match_operand:TF 1 "general_operand"      "ri,m,r"))]
995
  "ia64_move_ok (operands[0], operands[1])"
996
  "#"
997
  "reload_completed"
998
  [(const_int 0)]
999
{
1000
  ia64_split_tmode_move (operands);
1001
  DONE;
1002
}
1003
  [(set_attr "itanium_class" "unknown")
1004
   (set_attr "predicable" "no")])
1005
 
1006
 
1007
;; ::::::::::::::::::::
1008
;; ::
1009
;; :: Conversions
1010
;; ::
1011
;; ::::::::::::::::::::
1012
 
1013
;; Signed conversions from a smaller integer to a larger integer
1014
 
1015
(define_insn "extendqidi2"
1016
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
1017
        (sign_extend:DI (match_operand:QI 1 "gr_register_operand" "r")))]
1018
  ""
1019
  "sxt1 %0 = %1"
1020
  [(set_attr "itanium_class" "xtd")])
1021
 
1022
(define_insn "extendhidi2"
1023
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
1024
        (sign_extend:DI (match_operand:HI 1 "gr_register_operand" "r")))]
1025
  ""
1026
  "sxt2 %0 = %1"
1027
  [(set_attr "itanium_class" "xtd")])
1028
 
1029
(define_insn "extendsidi2"
1030
  [(set (match_operand:DI 0 "grfr_register_operand" "=r,?f")
1031
        (sign_extend:DI (match_operand:SI 1 "grfr_register_operand" "r,f")))]
1032
  ""
1033
  "@
1034
   sxt4 %0 = %1
1035
   fsxt.r %0 = %1, %1"
1036
  [(set_attr "itanium_class" "xtd,fmisc")])
1037
 
1038
;; Unsigned conversions from a smaller integer to a larger integer
1039
 
1040
(define_insn "zero_extendqidi2"
1041
  [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
1042
        (zero_extend:DI (match_operand:QI 1 "gr_nonimmediate_operand" "r,m")))]
1043
  ""
1044
  "@
1045
   zxt1 %0 = %1
1046
   ld1%O1 %0 = %1%P1"
1047
  [(set_attr "itanium_class" "xtd,ld")])
1048
 
1049
(define_insn "zero_extendhidi2"
1050
  [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
1051
        (zero_extend:DI (match_operand:HI 1 "gr_nonimmediate_operand" "r,m")))]
1052
  ""
1053
  "@
1054
   zxt2 %0 = %1
1055
   ld2%O1 %0 = %1%P1"
1056
  [(set_attr "itanium_class" "xtd,ld")])
1057
 
1058
(define_insn "zero_extendsidi2"
1059
  [(set (match_operand:DI 0 "grfr_register_operand" "=r,r,?f")
1060
        (zero_extend:DI
1061
          (match_operand:SI 1 "grfr_nonimmediate_operand" "r,m,f")))]
1062
  ""
1063
  "@
1064
   addp4 %0 = %1, r0
1065
   ld4%O1 %0 = %1%P1
1066
   fmix.r %0 = f0, %1"
1067
  [(set_attr "itanium_class" "ialu,ld,fmisc")])
1068
 
1069
;; Convert between floating point types of different sizes.
1070
 
1071
;; At first glance, it would appear that emitting fnorm for an extending
1072
;; conversion is unnecessary.  However, the stf and getf instructions work
1073
;; correctly only if the input is properly rounded for its type.  In
1074
;; particular, we get the wrong result for getf.d/stfd if the input is a
1075
;; denorm single.  Since we don't know what the next instruction will be, we
1076
;; have to emit an fnorm.
1077
 
1078
;; ??? Optimization opportunity here.  Get rid of the insn altogether
1079
;; when we can.  Should probably use a scheme like has been proposed
1080
;; for ia32 in dealing with operands that match unary operators.  This
1081
;; would let combine merge the thing into adjacent insns.  See also how the
1082
;; mips port handles SIGN_EXTEND as operands to integer arithmetic insns via
1083
;; se_register_operand.
1084
 
1085
(define_insn "extendsfdf2"
1086
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
1087
        (float_extend:DF (match_operand:SF 1 "fr_register_operand" "f")))]
1088
  ""
1089
  "fnorm.d %0 = %1"
1090
  [(set_attr "itanium_class" "fmac")])
1091
 
1092
(define_insn "extendsfxf2"
1093
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
1094
        (float_extend:XF (match_operand:SF 1 "fr_register_operand" "f")))]
1095
  ""
1096
  "fnorm %0 = %1"
1097
  [(set_attr "itanium_class" "fmac")])
1098
 
1099
(define_insn "extenddfxf2"
1100
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
1101
        (float_extend:XF (match_operand:DF 1 "fr_register_operand" "f")))]
1102
  ""
1103
  "fnorm %0 = %1"
1104
  [(set_attr "itanium_class" "fmac")])
1105
 
1106
(define_insn "truncdfsf2"
1107
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
1108
        (float_truncate:SF (match_operand:DF 1 "fr_register_operand" "f")))]
1109
  ""
1110
  "fnorm.s %0 = %1"
1111
  [(set_attr "itanium_class" "fmac")])
1112
 
1113
(define_insn "truncxfsf2"
1114
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
1115
        (float_truncate:SF (match_operand:XF 1 "fr_register_operand" "f")))]
1116
  ""
1117
  "fnorm.s %0 = %1"
1118
  [(set_attr "itanium_class" "fmac")])
1119
 
1120
(define_insn "truncxfdf2"
1121
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
1122
        (float_truncate:DF (match_operand:XF 1 "fr_register_operand" "f")))]
1123
  ""
1124
  "fnorm.d %0 = %1"
1125
  [(set_attr "itanium_class" "fmac")])
1126
 
1127
;; Convert between signed integer types and floating point.
1128
 
1129
(define_insn "floatdixf2"
1130
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
1131
        (float:XF (match_operand:DI 1 "fr_register_operand" "f")))]
1132
  ""
1133
  "fcvt.xf %0 = %1"
1134
  [(set_attr "itanium_class" "fcvtfx")])
1135
 
1136
(define_insn "fix_truncsfdi2"
1137
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1138
        (fix:DI (match_operand:SF 1 "fr_register_operand" "f")))]
1139
  ""
1140
  "fcvt.fx.trunc %0 = %1"
1141
  [(set_attr "itanium_class" "fcvtfx")])
1142
 
1143
(define_insn "fix_truncdfdi2"
1144
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1145
        (fix:DI (match_operand:DF 1 "fr_register_operand" "f")))]
1146
  ""
1147
  "fcvt.fx.trunc %0 = %1"
1148
  [(set_attr "itanium_class" "fcvtfx")])
1149
 
1150
(define_insn "fix_truncxfdi2"
1151
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1152
        (fix:DI (match_operand:XF 1 "fr_register_operand" "f")))]
1153
  ""
1154
  "fcvt.fx.trunc %0 = %1"
1155
  [(set_attr "itanium_class" "fcvtfx")])
1156
 
1157
(define_insn "fix_truncxfdi2_alts"
1158
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1159
        (fix:DI (match_operand:XF 1 "fr_register_operand" "f")))
1160
   (use (match_operand:SI 2 "const_int_operand" ""))]
1161
  ""
1162
  "fcvt.fx.trunc.s%2 %0 = %1"
1163
  [(set_attr "itanium_class" "fcvtfx")])
1164
 
1165
;; Convert between unsigned integer types and floating point.
1166
 
1167
(define_insn "floatunsdisf2"
1168
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
1169
        (unsigned_float:SF (match_operand:DI 1 "fr_register_operand" "f")))]
1170
  ""
1171
  "fcvt.xuf.s %0 = %1"
1172
  [(set_attr "itanium_class" "fcvtfx")])
1173
 
1174
(define_insn "floatunsdidf2"
1175
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
1176
        (unsigned_float:DF (match_operand:DI 1 "fr_register_operand" "f")))]
1177
  ""
1178
  "fcvt.xuf.d %0 = %1"
1179
  [(set_attr "itanium_class" "fcvtfx")])
1180
 
1181
(define_insn "floatunsdixf2"
1182
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
1183
        (unsigned_float:XF (match_operand:DI 1 "fr_register_operand" "f")))]
1184
  ""
1185
  "fcvt.xuf %0 = %1"
1186
  [(set_attr "itanium_class" "fcvtfx")])
1187
 
1188
(define_insn "fixuns_truncsfdi2"
1189
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1190
        (unsigned_fix:DI (match_operand:SF 1 "fr_register_operand" "f")))]
1191
  ""
1192
  "fcvt.fxu.trunc %0 = %1"
1193
  [(set_attr "itanium_class" "fcvtfx")])
1194
 
1195
(define_insn "fixuns_truncdfdi2"
1196
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1197
        (unsigned_fix:DI (match_operand:DF 1 "fr_register_operand" "f")))]
1198
  ""
1199
  "fcvt.fxu.trunc %0 = %1"
1200
  [(set_attr "itanium_class" "fcvtfx")])
1201
 
1202
(define_insn "fixuns_truncxfdi2"
1203
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1204
        (unsigned_fix:DI (match_operand:XF 1 "fr_register_operand" "f")))]
1205
  ""
1206
  "fcvt.fxu.trunc %0 = %1"
1207
  [(set_attr "itanium_class" "fcvtfx")])
1208
 
1209
(define_insn "fixuns_truncxfdi2_alts"
1210
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
1211
        (unsigned_fix:DI (match_operand:XF 1 "fr_register_operand" "f")))
1212
   (use (match_operand:SI 2 "const_int_operand" ""))]
1213
  ""
1214
  "fcvt.fxu.trunc.s%2 %0 = %1"
1215
  [(set_attr "itanium_class" "fcvtfx")])
1216
 
1217
;; ::::::::::::::::::::
1218
;; ::
1219
;; :: Bit field extraction
1220
;; ::
1221
;; ::::::::::::::::::::
1222
 
1223
(define_insn "extv"
1224
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
1225
        (sign_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
1226
                         (match_operand:DI 2 "extr_len_operand" "n")
1227
                         (match_operand:DI 3 "shift_count_operand" "M")))]
1228
  ""
1229
  "extr %0 = %1, %3, %2"
1230
  [(set_attr "itanium_class" "ishf")])
1231
 
1232
(define_insn "extzv"
1233
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
1234
        (zero_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
1235
                         (match_operand:DI 2 "extr_len_operand" "n")
1236
                         (match_operand:DI 3 "shift_count_operand" "M")))]
1237
  ""
1238
  "extr.u %0 = %1, %3, %2"
1239
  [(set_attr "itanium_class" "ishf")])
1240
 
1241
;; Insert a bit field.
1242
;; Can have 3 operands, source1 (inserter), source2 (insertee), dest.
1243
;; Source1 can be 0 or -1.
1244
;; Source2 can be 0.
1245
 
1246
;; ??? Actual dep instruction is more powerful than what these insv
1247
;; patterns support.  Unfortunately, combine is unable to create patterns
1248
;; where source2 != dest.
1249
 
1250
(define_expand "insv"
1251
  [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "")
1252
                         (match_operand:DI 1 "const_int_operand" "")
1253
                         (match_operand:DI 2 "const_int_operand" ""))
1254
        (match_operand:DI 3 "nonmemory_operand" ""))]
1255
  ""
1256
{
1257
  int width = INTVAL (operands[1]);
1258
  int shift = INTVAL (operands[2]);
1259
 
1260
  /* If operand[3] is a constant, and isn't 0 or -1, then load it into a
1261
     pseudo.  */
1262
  if (! register_operand (operands[3], DImode)
1263
      && operands[3] != const0_rtx && operands[3] != constm1_rtx)
1264
    operands[3] = force_reg (DImode, operands[3]);
1265
 
1266
  /* If this is a single dep instruction, we have nothing to do.  */
1267
  if (! ((register_operand (operands[3], DImode) && width <= 16)
1268
         || operands[3] == const0_rtx || operands[3] == constm1_rtx))
1269
    {
1270
      /* Check for cases that can be implemented with a mix instruction.  */
1271
      if (width == 32 && shift == 0)
1272
        {
1273
          /* Directly generating the mix4left instruction confuses
1274
             optimize_bit_field in function.c.  Since this is performing
1275
             a useful optimization, we defer generation of the complicated
1276
             mix4left RTL to the first splitting phase.  */
1277
          rtx tmp = gen_reg_rtx (DImode);
1278
          emit_insn (gen_shift_mix4left (operands[0], operands[3], tmp));
1279
          DONE;
1280
        }
1281
      else if (width == 32 && shift == 32)
1282
        {
1283
          emit_insn (gen_mix4right (operands[0], operands[3]));
1284
          DONE;
1285
        }
1286
 
1287
      /* We could handle remaining cases by emitting multiple dep
1288
         instructions.
1289
 
1290
         If we need more than two dep instructions then we lose.  A 6
1291
         insn sequence mov mask1,mov mask2,shl;;and,and;;or is better than
1292
         mov;;dep,shr;;dep,shr;;dep.  The former can be executed in 3 cycles,
1293
         the latter is 6 cycles on an Itanium (TM) processor, because there is
1294
         only one function unit that can execute dep and shr immed.
1295
 
1296
         If we only need two dep instruction, then we still lose.
1297
         mov;;dep,shr;;dep is still 4 cycles.  Even if we optimize away
1298
         the unnecessary mov, this is still undesirable because it will be
1299
         hard to optimize, and it creates unnecessary pressure on the I0
1300
         function unit.  */
1301
 
1302
      FAIL;
1303
 
1304
#if 0
1305
      /* This code may be useful for other IA-64 processors, so we leave it in
1306
         for now.  */
1307
      while (width > 16)
1308
        {
1309
          rtx tmp;
1310
 
1311
          emit_insn (gen_insv (operands[0], GEN_INT (16), GEN_INT (shift),
1312
                               operands[3]));
1313
          shift += 16;
1314
          width -= 16;
1315
          tmp = gen_reg_rtx (DImode);
1316
          emit_insn (gen_lshrdi3 (tmp, operands[3], GEN_INT (16)));
1317
          operands[3] = tmp;
1318
        }
1319
      operands[1] = GEN_INT (width);
1320
      operands[2] = GEN_INT (shift);
1321
#endif
1322
    }
1323
})
1324
 
1325
(define_insn "*insv_internal"
1326
  [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
1327
                         (match_operand:DI 1 "const_int_operand" "n")
1328
                         (match_operand:DI 2 "const_int_operand" "n"))
1329
        (match_operand:DI 3 "nonmemory_operand" "rP"))]
1330
  "(gr_register_operand (operands[3], DImode) && INTVAL (operands[1]) <= 16)
1331
   || operands[3] == const0_rtx || operands[3] == constm1_rtx"
1332
  "dep %0 = %3, %0, %2, %1"
1333
  [(set_attr "itanium_class" "ishf")])
1334
 
1335
;; Combine doesn't like to create bit-field insertions into zero.
1336
(define_insn "*shladdp4_internal"
1337
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
1338
        (and:DI (ashift:DI (match_operand:DI 1 "gr_register_operand" "r")
1339
                           (match_operand:DI 2 "shladd_log2_operand" "n"))
1340
                (match_operand:DI 3 "const_int_operand" "n")))]
1341
  "ia64_depz_field_mask (operands[3], operands[2]) + INTVAL (operands[2]) == 32"
1342
  "shladdp4 %0 = %1, %2, r0"
1343
  [(set_attr "itanium_class" "ialu")])
1344
 
1345
(define_insn "*depz_internal"
1346
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
1347
        (and:DI (ashift:DI (match_operand:DI 1 "gr_register_operand" "r")
1348
                           (match_operand:DI 2 "const_int_operand" "n"))
1349
                (match_operand:DI 3 "const_int_operand" "n")))]
1350
  "CONST_OK_FOR_M (INTVAL (operands[2]))
1351
   && ia64_depz_field_mask (operands[3], operands[2]) > 0"
1352
{
1353
  operands[3] = GEN_INT (ia64_depz_field_mask (operands[3], operands[2]));
1354
  return "%,dep.z %0 = %1, %2, %3";
1355
}
1356
  [(set_attr "itanium_class" "ishf")])
1357
 
1358
(define_insn "shift_mix4left"
1359
  [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
1360
                         (const_int 32) (const_int 0))
1361
        (match_operand:DI 1 "gr_register_operand" "r"))
1362
   (clobber (match_operand:DI 2 "gr_register_operand" "=r"))]
1363
  ""
1364
  "#"
1365
  [(set_attr "itanium_class" "unknown")])
1366
 
1367
(define_split
1368
  [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "")
1369
                         (const_int 32) (const_int 0))
1370
        (match_operand:DI 1 "register_operand" ""))
1371
   (clobber (match_operand:DI 2 "register_operand" ""))]
1372
  ""
1373
  [(set (match_dup 3) (ashift:DI (match_dup 1) (const_int 32)))
1374
   (set (zero_extract:DI (match_dup 0) (const_int 32) (const_int 0))
1375
        (lshiftrt:DI (match_dup 3) (const_int 32)))]
1376
  "operands[3] = operands[2];")
1377
 
1378
(define_insn "*mix4left"
1379
  [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
1380
                         (const_int 32) (const_int 0))
1381
        (lshiftrt:DI (match_operand:DI 1 "gr_register_operand" "r")
1382
                     (const_int 32)))]
1383
  ""
1384
  "mix4.l %0 = %0, %r1"
1385
  [(set_attr "itanium_class" "mmshf")])
1386
 
1387
(define_insn "mix4right"
1388
  [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
1389
                         (const_int 32) (const_int 32))
1390
        (match_operand:DI 1 "gr_reg_or_0_operand" "rO"))]
1391
  ""
1392
  "mix4.r %0 = %r1, %0"
1393
  [(set_attr "itanium_class" "mmshf")])
1394
 
1395
;; This is used by the rotrsi3 pattern.
1396
 
1397
(define_insn "*mix4right_3op"
1398
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
1399
        (ior:DI (zero_extend:DI (match_operand:SI 1 "gr_register_operand" "r"))
1400
                (ashift:DI (zero_extend:DI
1401
                             (match_operand:SI 2 "gr_register_operand" "r"))
1402
                           (const_int 32))))]
1403
  ""
1404
  "mix4.r %0 = %2, %1"
1405
  [(set_attr "itanium_class" "mmshf")])
1406
 
1407
 
1408
;; ::::::::::::::::::::
1409
;; ::
1410
;; :: 1 bit Integer arithmetic
1411
;; ::
1412
;; ::::::::::::::::::::
1413
 
1414
(define_insn_and_split "andbi3"
1415
  [(set (match_operand:BI 0 "register_operand" "=c,c,r")
1416
        (and:BI (match_operand:BI 1 "register_operand" "%0,0,r")
1417
                (match_operand:BI 2 "register_operand" "c,r,r")))]
1418
  ""
1419
  "@
1420
   #
1421
   tbit.nz.and.orcm %0, %I0 = %2, 0
1422
   and %0 = %2, %1"
1423
  "reload_completed
1424
   && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1425
   && GET_CODE (operands[2]) == REG && PR_REGNO_P (REGNO (operands[2]))"
1426
  [(cond_exec (eq (match_dup 2) (const_int 0))
1427
     (set (match_dup 0) (and:BI (ne:BI (const_int 0) (const_int 0))
1428
                                (match_dup 0))))]
1429
  ""
1430
  [(set_attr "itanium_class" "unknown,tbit,ilog")])
1431
 
1432
(define_insn_and_split "*andcmbi3"
1433
  [(set (match_operand:BI 0 "register_operand" "=c,c,r")
1434
        (and:BI (not:BI (match_operand:BI 1 "register_operand" "c,r,r"))
1435
                (match_operand:BI 2 "register_operand" "0,0,r")))]
1436
  ""
1437
  "@
1438
   #
1439
   tbit.z.and.orcm %0, %I0 = %1, 0
1440
   andcm %0 = %2, %1"
1441
  "reload_completed
1442
   && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1443
   && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
1444
  [(cond_exec (ne (match_dup 1) (const_int 0))
1445
     (set (match_dup 0) (and:BI (ne:BI (const_int 0) (const_int 0))
1446
                                (match_dup 0))))]
1447
  ""
1448
  [(set_attr "itanium_class" "unknown,tbit,ilog")])
1449
 
1450
(define_insn_and_split "iorbi3"
1451
  [(set (match_operand:BI 0 "register_operand" "=c,c,r")
1452
        (ior:BI (match_operand:BI 1 "register_operand" "%0,0,r")
1453
                (match_operand:BI 2 "register_operand" "c,r,r")))]
1454
  ""
1455
  "@
1456
   #
1457
   tbit.nz.or.andcm %0, %I0 = %2, 0
1458
   or %0 = %2, %1"
1459
  "reload_completed
1460
   && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1461
   && GET_CODE (operands[2]) == REG && PR_REGNO_P (REGNO (operands[2]))"
1462
  [(cond_exec (ne (match_dup 2) (const_int 0))
1463
     (set (match_dup 0) (ior:BI (eq:BI (const_int 0) (const_int 0))
1464
                                (match_dup 0))))]
1465
  ""
1466
  [(set_attr "itanium_class" "unknown,tbit,ilog")])
1467
 
1468
(define_insn_and_split "*iorcmbi3"
1469
  [(set (match_operand:BI 0 "register_operand" "=c,c")
1470
        (ior:BI (not:BI (match_operand:BI 1 "register_operand" "c,r"))
1471
                (match_operand:BI 2 "register_operand" "0,0")))]
1472
  ""
1473
  "@
1474
   #
1475
   tbit.z.or.andcm %0, %I0 = %1, 0"
1476
  "reload_completed
1477
   && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1478
   && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
1479
  [(cond_exec (eq (match_dup 1) (const_int 0))
1480
     (set (match_dup 0) (ior:BI (eq:BI (const_int 0) (const_int 0))
1481
                                (match_dup 0))))]
1482
  ""
1483
  [(set_attr "itanium_class" "unknown,tbit")])
1484
 
1485
(define_insn "one_cmplbi2"
1486
  [(set (match_operand:BI 0 "register_operand" "=c,r,c,&c")
1487
        (not:BI (match_operand:BI 1 "register_operand" "r,r,0,c")))
1488
   (clobber (match_scratch:BI 2 "=X,X,c,X"))]
1489
  ""
1490
  "@
1491
   tbit.z %0, %I0 = %1, 0
1492
   xor %0 = 1, %1
1493
   #
1494
   #"
1495
  [(set_attr "itanium_class" "tbit,ilog,unknown,unknown")])
1496
 
1497
(define_split
1498
  [(set (match_operand:BI 0 "register_operand" "")
1499
        (not:BI (match_operand:BI 1 "register_operand" "")))
1500
   (clobber (match_scratch:BI 2 ""))]
1501
  "reload_completed
1502
   && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1503
   && rtx_equal_p (operands[0], operands[1])"
1504
  [(set (match_dup 4) (match_dup 3))
1505
   (set (match_dup 0) (const_int 1))
1506
   (cond_exec (ne (match_dup 2) (const_int 0))
1507
     (set (match_dup 0) (const_int 0)))
1508
   (set (match_dup 0) (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
1509
  "operands[3] = gen_rtx_REG (CCImode, REGNO (operands[1]));
1510
   operands[4] = gen_rtx_REG (CCImode, REGNO (operands[2]));")
1511
 
1512
(define_split
1513
  [(set (match_operand:BI 0 "register_operand" "")
1514
        (not:BI (match_operand:BI 1 "register_operand" "")))
1515
   (clobber (match_scratch:BI 2 ""))]
1516
  "reload_completed
1517
   && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1518
   && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))
1519
   && ! rtx_equal_p (operands[0], operands[1])"
1520
  [(cond_exec (ne (match_dup 1) (const_int 0))
1521
     (set (match_dup 0) (const_int 0)))
1522
   (cond_exec (eq (match_dup 1) (const_int 0))
1523
     (set (match_dup 0) (const_int 1)))
1524
   (set (match_dup 0) (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
1525
  "")
1526
 
1527
(define_insn "*cmpsi_and_0"
1528
  [(set (match_operand:BI 0 "register_operand" "=c")
1529
        (and:BI (match_operator:BI 4 "predicate_operator"
1530
                  [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1531
                   (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")])
1532
                (match_operand:BI 1 "register_operand" "0")))]
1533
  ""
1534
  "cmp4.%C4.and.orcm %0, %I0 = %3, %r2"
1535
  [(set_attr "itanium_class" "icmp")])
1536
 
1537
(define_insn "*cmpsi_and_1"
1538
  [(set (match_operand:BI 0 "register_operand" "=c")
1539
        (and:BI (match_operator:BI 3 "signed_inequality_operator"
1540
                  [(match_operand:SI 2 "gr_register_operand" "r")
1541
                   (const_int 0)])
1542
                (match_operand:BI 1 "register_operand" "0")))]
1543
  ""
1544
  "cmp4.%C3.and.orcm %0, %I0 = r0, %2"
1545
  [(set_attr "itanium_class" "icmp")])
1546
 
1547
(define_insn "*cmpsi_andnot_0"
1548
  [(set (match_operand:BI 0 "register_operand" "=c")
1549
        (and:BI (not:BI (match_operator:BI 4 "predicate_operator"
1550
                         [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1551
                          (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")]))
1552
                (match_operand:BI 1 "register_operand" "0")))]
1553
  ""
1554
  "cmp4.%C4.or.andcm %I0, %0 = %3, %r2"
1555
  [(set_attr "itanium_class" "icmp")])
1556
 
1557
(define_insn "*cmpsi_andnot_1"
1558
  [(set (match_operand:BI 0 "register_operand" "=c")
1559
        (and:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1560
                          [(match_operand:SI 2 "gr_register_operand" "r")
1561
                           (const_int 0)]))
1562
                (match_operand:BI 1 "register_operand" "0")))]
1563
  ""
1564
  "cmp4.%C3.or.andcm %I0, %0 = r0, %2"
1565
  [(set_attr "itanium_class" "icmp")])
1566
 
1567
(define_insn "*cmpdi_and_0"
1568
  [(set (match_operand:BI 0 "register_operand" "=c")
1569
        (and:BI (match_operator:BI 4 "predicate_operator"
1570
                  [(match_operand:DI 2 "gr_register_operand" "r")
1571
                   (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")])
1572
                (match_operand:BI 1 "register_operand" "0")))]
1573
  ""
1574
  "cmp.%C4.and.orcm %0, %I0 = %3, %2"
1575
  [(set_attr "itanium_class" "icmp")])
1576
 
1577
(define_insn "*cmpdi_and_1"
1578
  [(set (match_operand:BI 0 "register_operand" "=c")
1579
        (and:BI (match_operator:BI 3 "signed_inequality_operator"
1580
                  [(match_operand:DI 2 "gr_register_operand" "r")
1581
                   (const_int 0)])
1582
                (match_operand:BI 1 "register_operand" "0")))]
1583
  ""
1584
  "cmp.%C3.and.orcm %0, %I0 = r0, %2"
1585
  [(set_attr "itanium_class" "icmp")])
1586
 
1587
(define_insn "*cmpdi_andnot_0"
1588
  [(set (match_operand:BI 0 "register_operand" "=c")
1589
        (and:BI (not:BI (match_operator:BI 4 "predicate_operator"
1590
                         [(match_operand:DI 2 "gr_register_operand" "r")
1591
                          (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")]))
1592
                (match_operand:BI 1 "register_operand" "0")))]
1593
  ""
1594
  "cmp.%C4.or.andcm %I0, %0 = %3, %2"
1595
  [(set_attr "itanium_class" "icmp")])
1596
 
1597
(define_insn "*cmpdi_andnot_1"
1598
  [(set (match_operand:BI 0 "register_operand" "=c")
1599
        (and:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1600
                          [(match_operand:DI 2 "gr_register_operand" "r")
1601
                           (const_int 0)]))
1602
                (match_operand:BI 1 "register_operand" "0")))]
1603
  ""
1604
  "cmp.%C3.or.andcm %I0, %0 = r0, %2"
1605
  [(set_attr "itanium_class" "icmp")])
1606
 
1607
(define_insn "*tbit_and_0"
1608
  [(set (match_operand:BI 0 "register_operand" "=c")
1609
        (and:BI (ne:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1610
                               (const_int 1))
1611
                       (const_int 0))
1612
                (match_operand:BI 2 "register_operand" "0")))]
1613
  ""
1614
  "tbit.nz.and.orcm %0, %I0 = %1, 0"
1615
  [(set_attr "itanium_class" "tbit")])
1616
 
1617
(define_insn "*tbit_and_1"
1618
  [(set (match_operand:BI 0 "register_operand" "=c")
1619
        (and:BI (eq:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1620
                               (const_int 1))
1621
                       (const_int 0))
1622
                (match_operand:BI 2 "register_operand" "0")))]
1623
  ""
1624
  "tbit.z.and.orcm %0, %I0 = %1, 0"
1625
  [(set_attr "itanium_class" "tbit")])
1626
 
1627
(define_insn "*tbit_and_2"
1628
  [(set (match_operand:BI 0 "register_operand" "=c")
1629
        (and:BI (ne:BI (zero_extract:DI
1630
                         (match_operand:DI 1 "gr_register_operand" "r")
1631
                         (const_int 1)
1632
                         (match_operand:DI 2 "shift_count_operand" "M"))
1633
                       (const_int 0))
1634
                (match_operand:BI 3 "register_operand" "0")))]
1635
  ""
1636
  "tbit.nz.and.orcm %0, %I0 = %1, %2"
1637
  [(set_attr "itanium_class" "tbit")])
1638
 
1639
(define_insn "*tbit_and_3"
1640
  [(set (match_operand:BI 0 "register_operand" "=c")
1641
        (and:BI (eq:BI (zero_extract:DI
1642
                         (match_operand:DI 1 "gr_register_operand" "r")
1643
                         (const_int 1)
1644
                         (match_operand:DI 2 "shift_count_operand" "M"))
1645
                       (const_int 0))
1646
                (match_operand:BI 3 "register_operand" "0")))]
1647
  ""
1648
  "tbit.z.and.orcm %0, %I0 = %1, %2"
1649
  [(set_attr "itanium_class" "tbit")])
1650
 
1651
(define_insn "*cmpsi_or_0"
1652
  [(set (match_operand:BI 0 "register_operand" "=c")
1653
        (ior:BI (match_operator:BI 4 "predicate_operator"
1654
                  [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1655
                   (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")])
1656
                (match_operand:BI 1 "register_operand" "0")))]
1657
  ""
1658
  "cmp4.%C4.or.andcm %0, %I0 = %3, %r2"
1659
  [(set_attr "itanium_class" "icmp")])
1660
 
1661
(define_insn "*cmpsi_or_1"
1662
  [(set (match_operand:BI 0 "register_operand" "=c")
1663
        (ior:BI (match_operator:BI 3 "signed_inequality_operator"
1664
                  [(match_operand:SI 2 "gr_register_operand" "r")
1665
                   (const_int 0)])
1666
                (match_operand:BI 1 "register_operand" "0")))]
1667
  ""
1668
  "cmp4.%C3.or.andcm %0, %I0 = r0, %2"
1669
  [(set_attr "itanium_class" "icmp")])
1670
 
1671
(define_insn "*cmpsi_orcm_0"
1672
  [(set (match_operand:BI 0 "register_operand" "=c")
1673
        (ior:BI (not:BI (match_operator:BI 4 "predicate_operator"
1674
                         [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1675
                          (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")]))
1676
                (match_operand:BI 1 "register_operand" "0")))]
1677
  ""
1678
  "cmp4.%C4.and.orcm %I0, %0 = %3, %r2"
1679
  [(set_attr "itanium_class" "icmp")])
1680
 
1681
(define_insn "*cmpsi_orcm_1"
1682
  [(set (match_operand:BI 0 "register_operand" "=c")
1683
        (ior:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1684
                          [(match_operand:SI 2 "gr_register_operand" "r")
1685
                           (const_int 0)]))
1686
                (match_operand:BI 1 "register_operand" "0")))]
1687
  ""
1688
  "cmp4.%C3.and.orcm %I0, %0 = r0, %2"
1689
  [(set_attr "itanium_class" "icmp")])
1690
 
1691
(define_insn "*cmpdi_or_0"
1692
  [(set (match_operand:BI 0 "register_operand" "=c")
1693
        (ior:BI (match_operator:BI 4 "predicate_operator"
1694
                  [(match_operand:DI 2 "gr_register_operand" "r")
1695
                   (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")])
1696
                (match_operand:BI 1 "register_operand" "0")))]
1697
  ""
1698
  "cmp.%C4.or.andcm %0, %I0 = %3, %2"
1699
  [(set_attr "itanium_class" "icmp")])
1700
 
1701
(define_insn "*cmpdi_or_1"
1702
  [(set (match_operand:BI 0 "register_operand" "=c")
1703
        (ior:BI (match_operator:BI 3 "signed_inequality_operator"
1704
                  [(match_operand:DI 2 "gr_register_operand" "r")
1705
                   (const_int 0)])
1706
                (match_operand:BI 1 "register_operand" "0")))]
1707
  ""
1708
  "cmp.%C3.or.andcm %0, %I0 = r0, %2"
1709
  [(set_attr "itanium_class" "icmp")])
1710
 
1711
(define_insn "*cmpdi_orcm_0"
1712
  [(set (match_operand:BI 0 "register_operand" "=c")
1713
        (ior:BI (not:BI (match_operator:BI 4 "predicate_operator"
1714
                         [(match_operand:DI 2 "gr_register_operand" "r")
1715
                          (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")]))
1716
                (match_operand:BI 1 "register_operand" "0")))]
1717
  ""
1718
  "cmp.%C4.and.orcm %I0, %0 = %3, %2"
1719
  [(set_attr "itanium_class" "icmp")])
1720
 
1721
(define_insn "*cmpdi_orcm_1"
1722
  [(set (match_operand:BI 0 "register_operand" "=c")
1723
        (ior:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1724
                          [(match_operand:DI 2 "gr_register_operand" "r")
1725
                           (const_int 0)]))
1726
                (match_operand:BI 1 "register_operand" "0")))]
1727
  ""
1728
  "cmp.%C3.and.orcm %I0, %0 = r0, %2"
1729
  [(set_attr "itanium_class" "icmp")])
1730
 
1731
(define_insn "*tbit_or_0"
1732
  [(set (match_operand:BI 0 "register_operand" "=c")
1733
        (ior:BI (ne:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1734
                               (const_int 1))
1735
                       (const_int 0))
1736
                (match_operand:BI 2 "register_operand" "0")))]
1737
  ""
1738
  "tbit.nz.or.andcm %0, %I0 = %1, 0"
1739
  [(set_attr "itanium_class" "tbit")])
1740
 
1741
(define_insn "*tbit_or_1"
1742
  [(set (match_operand:BI 0 "register_operand" "=c")
1743
        (ior:BI (eq:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1744
                               (const_int 1))
1745
                       (const_int 0))
1746
                (match_operand:BI 2 "register_operand" "0")))]
1747
  ""
1748
  "tbit.z.or.andcm %0, %I0 = %1, 0"
1749
  [(set_attr "itanium_class" "tbit")])
1750
 
1751
(define_insn "*tbit_or_2"
1752
  [(set (match_operand:BI 0 "register_operand" "=c")
1753
        (ior:BI (ne:BI (zero_extract:DI
1754
                         (match_operand:DI 1 "gr_register_operand" "r")
1755
                         (const_int 1)
1756
                         (match_operand:DI 2 "shift_count_operand" "M"))
1757
                       (const_int 0))
1758
                (match_operand:BI 3 "register_operand" "0")))]
1759
  ""
1760
  "tbit.nz.or.andcm %0, %I0 = %1, %2"
1761
  [(set_attr "itanium_class" "tbit")])
1762
 
1763
(define_insn "*tbit_or_3"
1764
  [(set (match_operand:BI 0 "register_operand" "=c")
1765
        (ior:BI (eq:BI (zero_extract:DI
1766
                         (match_operand:DI 1 "gr_register_operand" "r")
1767
                         (const_int 1)
1768
                         (match_operand:DI 2 "shift_count_operand" "M"))
1769
                       (const_int 0))
1770
                (match_operand:BI 3 "register_operand" "0")))]
1771
  ""
1772
  "tbit.z.or.andcm %0, %I0 = %1, %2"
1773
  [(set_attr "itanium_class" "tbit")])
1774
 
1775
;; Transform test of and/or of setcc into parallel comparisons.
1776
 
1777
(define_split
1778
  [(set (match_operand:BI 0 "register_operand" "")
1779
        (ne:BI (and:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1780
                              (const_int 0))
1781
                       (match_operand:DI 3 "register_operand" ""))
1782
               (const_int 0)))]
1783
  ""
1784
  [(set (match_dup 0)
1785
        (and:BI (ne:BI (and:DI (match_dup 3) (const_int 1)) (const_int 0))
1786
                (match_dup 2)))]
1787
  "")
1788
 
1789
(define_split
1790
  [(set (match_operand:BI 0 "register_operand" "")
1791
        (eq:BI (and:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1792
                              (const_int 0))
1793
                       (match_operand:DI 3 "register_operand" ""))
1794
               (const_int 0)))]
1795
  ""
1796
  [(set (match_dup 0)
1797
        (and:BI (ne:BI (and:DI (match_dup 3) (const_int 1)) (const_int 0))
1798
                (match_dup 2)))
1799
   (parallel [(set (match_dup 0) (not:BI (match_dup 0)))
1800
              (clobber (scratch))])]
1801
  "")
1802
 
1803
(define_split
1804
  [(set (match_operand:BI 0 "register_operand" "")
1805
        (ne:BI (ior:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1806
                              (const_int 0))
1807
                       (match_operand:DI 3 "register_operand" ""))
1808
               (const_int 0)))]
1809
  ""
1810
  [(set (match_dup 0)
1811
        (ior:BI (ne:BI (match_dup 3) (const_int 0))
1812
                (match_dup 2)))]
1813
  "")
1814
 
1815
(define_split
1816
  [(set (match_operand:BI 0 "register_operand" "")
1817
        (eq:BI (ior:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1818
                              (const_int 0))
1819
                       (match_operand:DI 3 "register_operand" ""))
1820
               (const_int 0)))]
1821
  ""
1822
  [(set (match_dup 0)
1823
        (ior:BI (ne:BI (match_dup 3) (const_int 0))
1824
                (match_dup 2)))
1825
   (parallel [(set (match_dup 0) (not:BI (match_dup 0)))
1826
              (clobber (scratch))])]
1827
  "")
1828
 
1829
;; ??? Incredibly hackish.  Either need four proper patterns with all
1830
;; the alternatives, or rely on sched1 to split the insn and hope that
1831
;; nothing bad happens to the comparisons in the meantime.
1832
;;
1833
;; Alternately, adjust combine to allow 2->2 and 3->3 splits, assuming
1834
;; that we're doing height reduction.
1835
;
1836
;(define_insn_and_split ""
1837
;  [(set (match_operand:BI 0 "register_operand" "=c")
1838
;       (and:BI (and:BI (match_operator:BI 1 "comparison_operator"
1839
;                         [(match_operand 2 "" "")
1840
;                          (match_operand 3 "" "")])
1841
;                       (match_operator:BI 4 "comparison_operator"
1842
;                         [(match_operand 5 "" "")
1843
;                          (match_operand 6 "" "")]))
1844
;               (match_dup 0)))]
1845
;  "flag_schedule_insns"
1846
;  "#"
1847
;  ""
1848
;  [(set (match_dup 0) (and:BI (match_dup 1) (match_dup 0)))
1849
;   (set (match_dup 0) (and:BI (match_dup 4) (match_dup 0)))]
1850
;  "")
1851
;
1852
;(define_insn_and_split ""
1853
;  [(set (match_operand:BI 0 "register_operand" "=c")
1854
;       (ior:BI (ior:BI (match_operator:BI 1 "comparison_operator"
1855
;                         [(match_operand 2 "" "")
1856
;                          (match_operand 3 "" "")])
1857
;                       (match_operator:BI 4 "comparison_operator"
1858
;                         [(match_operand 5 "" "")
1859
;                          (match_operand 6 "" "")]))
1860
;               (match_dup 0)))]
1861
;  "flag_schedule_insns"
1862
;  "#"
1863
;  ""
1864
;  [(set (match_dup 0) (ior:BI (match_dup 1) (match_dup 0)))
1865
;   (set (match_dup 0) (ior:BI (match_dup 4) (match_dup 0)))]
1866
;  "")
1867
;
1868
;(define_split
1869
;  [(set (match_operand:BI 0 "register_operand" "")
1870
;       (and:BI (and:BI (match_operator:BI 1 "comparison_operator"
1871
;                         [(match_operand 2 "" "")
1872
;                          (match_operand 3 "" "")])
1873
;                       (match_operand:BI 7 "register_operand" ""))
1874
;               (and:BI (match_operator:BI 4 "comparison_operator"
1875
;                         [(match_operand 5 "" "")
1876
;                          (match_operand 6 "" "")])
1877
;                       (match_operand:BI 8 "register_operand" ""))))]
1878
;  ""
1879
;  [(set (match_dup 0) (and:BI (match_dup 7) (match_dup 8)))
1880
;   (set (match_dup 0) (and:BI (and:BI (match_dup 1) (match_dup 4))
1881
;                             (match_dup 0)))]
1882
;  "")
1883
;
1884
;(define_split
1885
;  [(set (match_operand:BI 0 "register_operand" "")
1886
;       (ior:BI (ior:BI (match_operator:BI 1 "comparison_operator"
1887
;                         [(match_operand 2 "" "")
1888
;                          (match_operand 3 "" "")])
1889
;                       (match_operand:BI 7 "register_operand" ""))
1890
;               (ior:BI (match_operator:BI 4 "comparison_operator"
1891
;                         [(match_operand 5 "" "")
1892
;                          (match_operand 6 "" "")])
1893
;                       (match_operand:BI 8 "register_operand" ""))))]
1894
;  ""
1895
;  [(set (match_dup 0) (ior:BI (match_dup 7) (match_dup 8)))
1896
;   (set (match_dup 0) (ior:BI (ior:BI (match_dup 1) (match_dup 4))
1897
;                             (match_dup 0)))]
1898
;  "")
1899
 
1900
;; Try harder to avoid predicate copies by duplicating compares.
1901
;; Note that we'll have already split the predicate copy, which
1902
;; is kind of a pain, but oh well.
1903
 
1904
(define_peephole2
1905
  [(set (match_operand:BI 0 "register_operand" "")
1906
        (match_operand:BI 1 "comparison_operator" ""))
1907
   (set (match_operand:CCI 2 "register_operand" "")
1908
        (match_operand:CCI 3 "register_operand" ""))
1909
   (set (match_operand:CCI 4 "register_operand" "")
1910
        (match_operand:CCI 5 "register_operand" ""))
1911
   (set (match_operand:BI 6 "register_operand" "")
1912
        (unspec:BI [(match_dup 6)] UNSPEC_PRED_REL_MUTEX))]
1913
  "REGNO (operands[3]) == REGNO (operands[0])
1914
   && REGNO (operands[4]) == REGNO (operands[0]) + 1
1915
   && REGNO (operands[4]) == REGNO (operands[2]) + 1
1916
   && REGNO (operands[6]) == REGNO (operands[2])"
1917
  [(set (match_dup 0) (match_dup 1))
1918
   (set (match_dup 6) (match_dup 7))]
1919
  "operands[7] = copy_rtx (operands[1]);")
1920
 
1921
;; ::::::::::::::::::::
1922
;; ::
1923
;; :: 16 bit Integer arithmetic
1924
;; ::
1925
;; ::::::::::::::::::::
1926
 
1927
(define_insn "mulhi3"
1928
  [(set (match_operand:HI 0 "gr_register_operand" "=r")
1929
        (mult:HI (match_operand:HI 1 "gr_register_operand" "r")
1930
                 (match_operand:HI 2 "gr_register_operand" "r")))]
1931
  ""
1932
  "pmpy2.r %0 = %1, %2"
1933
  [(set_attr "itanium_class" "mmmul")])
1934
 
1935
 
1936
;; ::::::::::::::::::::
1937
;; ::
1938
;; :: 32 bit Integer arithmetic
1939
;; ::
1940
;; ::::::::::::::::::::
1941
 
1942
(define_insn "addsi3"
1943
  [(set (match_operand:SI 0 "gr_register_operand" "=r,r,r")
1944
        (plus:SI (match_operand:SI 1 "gr_register_operand" "%r,r,a")
1945
                 (match_operand:SI 2 "gr_reg_or_22bit_operand" "r,I,J")))]
1946
  ""
1947
  "@
1948
   add %0 = %1, %2
1949
   adds %0 = %2, %1
1950
   addl %0 = %2, %1"
1951
  [(set_attr "itanium_class" "ialu")])
1952
 
1953
(define_insn "*addsi3_plus1"
1954
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
1955
        (plus:SI (plus:SI (match_operand:SI 1 "gr_register_operand" "r")
1956
                          (match_operand:SI 2 "gr_register_operand" "r"))
1957
                 (const_int 1)))]
1958
  ""
1959
  "add %0 = %1, %2, 1"
1960
  [(set_attr "itanium_class" "ialu")])
1961
 
1962
(define_insn "*addsi3_plus1_alt"
1963
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
1964
        (plus:SI (mult:SI (match_operand:SI 1 "gr_register_operand" "r")
1965
                          (const_int 2))
1966
                 (const_int 1)))]
1967
  ""
1968
  "add %0 = %1, %1, 1"
1969
  [(set_attr "itanium_class" "ialu")])
1970
 
1971
(define_insn "*addsi3_shladd"
1972
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
1973
        (plus:SI (mult:SI (match_operand:SI 1 "gr_register_operand" "r")
1974
                          (match_operand:SI 2 "shladd_operand" "n"))
1975
                 (match_operand:SI 3 "gr_register_operand" "r")))]
1976
  ""
1977
  "shladd %0 = %1, %S2, %3"
1978
  [(set_attr "itanium_class" "ialu")])
1979
 
1980
(define_insn "subsi3"
1981
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
1982
        (minus:SI (match_operand:SI 1 "gr_reg_or_8bit_operand" "rK")
1983
                  (match_operand:SI 2 "gr_register_operand" "r")))]
1984
  ""
1985
  "sub %0 = %1, %2"
1986
  [(set_attr "itanium_class" "ialu")])
1987
 
1988
(define_insn "*subsi3_minus1"
1989
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
1990
        (plus:SI (not:SI (match_operand:SI 1 "gr_register_operand" "r"))
1991
                 (match_operand:SI 2 "gr_register_operand" "r")))]
1992
  ""
1993
  "sub %0 = %2, %1, 1"
1994
  [(set_attr "itanium_class" "ialu")])
1995
 
1996
;; ??? Could add maddsi3 patterns patterned after the madddi3 patterns.
1997
 
1998
(define_insn "mulsi3"
1999
  [(set (match_operand:SI 0 "fr_register_operand" "=f")
2000
        (mult:SI (match_operand:SI 1 "grfr_register_operand" "f")
2001
                 (match_operand:SI 2 "grfr_register_operand" "f")))]
2002
  ""
2003
  "xmpy.l %0 = %1, %2"
2004
  [(set_attr "itanium_class" "xmpy")])
2005
 
2006
(define_insn "maddsi4"
2007
  [(set (match_operand:SI 0 "fr_register_operand" "=f")
2008
        (plus:SI (mult:SI (match_operand:SI 1 "grfr_register_operand" "f")
2009
                          (match_operand:SI 2 "grfr_register_operand" "f"))
2010
                 (match_operand:SI 3 "grfr_register_operand" "f")))]
2011
  ""
2012
  "xma.l %0 = %1, %2, %3"
2013
  [(set_attr "itanium_class" "xmpy")])
2014
 
2015
(define_insn "negsi2"
2016
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
2017
        (neg:SI (match_operand:SI 1 "gr_register_operand" "r")))]
2018
  ""
2019
  "sub %0 = r0, %1"
2020
  [(set_attr "itanium_class" "ialu")])
2021
 
2022
(define_expand "abssi2"
2023
  [(set (match_dup 2)
2024
        (ge:BI (match_operand:SI 1 "gr_register_operand" "") (const_int 0)))
2025
   (set (match_operand:SI 0 "gr_register_operand" "")
2026
        (if_then_else:SI (eq (match_dup 2) (const_int 0))
2027
                         (neg:SI (match_dup 1))
2028
                         (match_dup 1)))]
2029
  ""
2030
  { operands[2] = gen_reg_rtx (BImode); })
2031
 
2032
(define_expand "sminsi3"
2033
  [(set (match_dup 3)
2034
        (ge:BI (match_operand:SI 1 "gr_register_operand" "")
2035
               (match_operand:SI 2 "gr_register_operand" "")))
2036
   (set (match_operand:SI 0 "gr_register_operand" "")
2037
        (if_then_else:SI (ne (match_dup 3) (const_int 0))
2038
                         (match_dup 2) (match_dup 1)))]
2039
  ""
2040
  { operands[3] = gen_reg_rtx (BImode); })
2041
 
2042
(define_expand "smaxsi3"
2043
  [(set (match_dup 3)
2044
        (ge:BI (match_operand:SI 1 "gr_register_operand" "")
2045
               (match_operand:SI 2 "gr_register_operand" "")))
2046
   (set (match_operand:SI 0 "gr_register_operand" "")
2047
        (if_then_else:SI (ne (match_dup 3) (const_int 0))
2048
                         (match_dup 1) (match_dup 2)))]
2049
  ""
2050
  { operands[3] = gen_reg_rtx (BImode); })
2051
 
2052
(define_expand "uminsi3"
2053
  [(set (match_dup 3)
2054
        (geu:BI (match_operand:SI 1 "gr_register_operand" "")
2055
                (match_operand:SI 2 "gr_register_operand" "")))
2056
   (set (match_operand:SI 0 "gr_register_operand" "")
2057
        (if_then_else:SI (ne (match_dup 3) (const_int 0))
2058
                         (match_dup 2) (match_dup 1)))]
2059
  ""
2060
  { operands[3] = gen_reg_rtx (BImode); })
2061
 
2062
(define_expand "umaxsi3"
2063
  [(set (match_dup 3)
2064
        (geu:BI (match_operand:SI 1 "gr_register_operand" "")
2065
                (match_operand:SI 2 "gr_register_operand" "")))
2066
   (set (match_operand:SI 0 "gr_register_operand" "")
2067
        (if_then_else:SI (ne (match_dup 3) (const_int 0))
2068
                         (match_dup 1) (match_dup 2)))]
2069
  ""
2070
  { operands[3] = gen_reg_rtx (BImode); })
2071
 
2072
(define_expand "divsi3"
2073
  [(set (match_operand:SI 0 "register_operand" "")
2074
        (div:SI (match_operand:SI 1 "general_operand" "")
2075
                (match_operand:SI 2 "general_operand" "")))]
2076
  "TARGET_INLINE_INT_DIV"
2077
{
2078
  rtx op1_xf, op2_xf, op0_xf, op0_di, twon34, twon34_exp;
2079
 
2080
  op0_xf = gen_reg_rtx (XFmode);
2081
  op0_di = gen_reg_rtx (DImode);
2082
 
2083
  if (CONSTANT_P (operands[1]))
2084
    operands[1] = force_reg (SImode, operands[1]);
2085
  op1_xf = gen_reg_rtx (XFmode);
2086
  expand_float (op1_xf, operands[1], 0);
2087
 
2088
  if (CONSTANT_P (operands[2]))
2089
    operands[2] = force_reg (SImode, operands[2]);
2090
  op2_xf = gen_reg_rtx (XFmode);
2091
  expand_float (op2_xf, operands[2], 0);
2092
 
2093
  /* 2^-34 */
2094
  twon34_exp = gen_reg_rtx (DImode);
2095
  emit_move_insn (twon34_exp, GEN_INT (65501));
2096
  twon34 = gen_reg_rtx (XFmode);
2097
  emit_insn (gen_setf_exp_xf (twon34, twon34_exp));
2098
 
2099
  emit_insn (gen_cond_trap (EQ, operands[2], CONST0_RTX (SImode),
2100
                            CONST1_RTX (SImode)));
2101
 
2102
  emit_insn (gen_divsi3_internal (op0_xf, op1_xf, op2_xf, twon34));
2103
 
2104
  emit_insn (gen_fix_truncxfdi2_alts (op0_di, op0_xf, const1_rtx));
2105
  emit_move_insn (operands[0], gen_lowpart (SImode, op0_di));
2106
  DONE;
2107
})
2108
 
2109
(define_expand "modsi3"
2110
  [(set (match_operand:SI 0 "register_operand" "")
2111
        (mod:SI (match_operand:SI 1 "general_operand" "")
2112
                (match_operand:SI 2 "general_operand" "")))]
2113
  "TARGET_INLINE_INT_DIV"
2114
{
2115
  rtx op2_neg, op1_di, div;
2116
 
2117
  div = gen_reg_rtx (SImode);
2118
  emit_insn (gen_divsi3 (div, operands[1], operands[2]));
2119
 
2120
  op2_neg = expand_unop (SImode, neg_optab, operands[2], NULL_RTX, 0);
2121
 
2122
  /* This is a trick to get us to reuse the value that we're sure to
2123
     have already copied to the FP regs.  */
2124
  op1_di = gen_reg_rtx (DImode);
2125
  convert_move (op1_di, operands[1], 0);
2126
 
2127
  emit_insn (gen_maddsi4 (operands[0], div, op2_neg,
2128
                          gen_lowpart (SImode, op1_di)));
2129
  DONE;
2130
})
2131
 
2132
(define_expand "udivsi3"
2133
  [(set (match_operand:SI 0 "register_operand" "")
2134
        (udiv:SI (match_operand:SI 1 "general_operand" "")
2135
                 (match_operand:SI 2 "general_operand" "")))]
2136
  "TARGET_INLINE_INT_DIV"
2137
{
2138
  rtx op1_xf, op2_xf, op0_xf, op0_di, twon34, twon34_exp;
2139
 
2140
  op0_xf = gen_reg_rtx (XFmode);
2141
  op0_di = gen_reg_rtx (DImode);
2142
 
2143
  if (CONSTANT_P (operands[1]))
2144
    operands[1] = force_reg (SImode, operands[1]);
2145
  op1_xf = gen_reg_rtx (XFmode);
2146
  expand_float (op1_xf, operands[1], 1);
2147
 
2148
  if (CONSTANT_P (operands[2]))
2149
    operands[2] = force_reg (SImode, operands[2]);
2150
  op2_xf = gen_reg_rtx (XFmode);
2151
  expand_float (op2_xf, operands[2], 1);
2152
 
2153
  /* 2^-34 */
2154
  twon34_exp = gen_reg_rtx (DImode);
2155
  emit_move_insn (twon34_exp, GEN_INT (65501));
2156
  twon34 = gen_reg_rtx (XFmode);
2157
  emit_insn (gen_setf_exp_xf (twon34, twon34_exp));
2158
 
2159
  emit_insn (gen_cond_trap (EQ, operands[2], CONST0_RTX (SImode),
2160
                            CONST1_RTX (SImode)));
2161
 
2162
  emit_insn (gen_divsi3_internal (op0_xf, op1_xf, op2_xf, twon34));
2163
 
2164
  emit_insn (gen_fixuns_truncxfdi2_alts (op0_di, op0_xf, const1_rtx));
2165
  emit_move_insn (operands[0], gen_lowpart (SImode, op0_di));
2166
  DONE;
2167
})
2168
 
2169
(define_expand "umodsi3"
2170
  [(set (match_operand:SI 0 "register_operand" "")
2171
        (umod:SI (match_operand:SI 1 "general_operand" "")
2172
                 (match_operand:SI 2 "general_operand" "")))]
2173
  "TARGET_INLINE_INT_DIV"
2174
{
2175
  rtx op2_neg, op1_di, div;
2176
 
2177
  div = gen_reg_rtx (SImode);
2178
  emit_insn (gen_udivsi3 (div, operands[1], operands[2]));
2179
 
2180
  op2_neg = expand_unop (SImode, neg_optab, operands[2], NULL_RTX, 0);
2181
 
2182
  /* This is a trick to get us to reuse the value that we're sure to
2183
     have already copied to the FP regs.  */
2184
  op1_di = gen_reg_rtx (DImode);
2185
  convert_move (op1_di, operands[1], 1);
2186
 
2187
  emit_insn (gen_maddsi4 (operands[0], div, op2_neg,
2188
                          gen_lowpart (SImode, op1_di)));
2189
  DONE;
2190
})
2191
 
2192
(define_insn_and_split "divsi3_internal"
2193
  [(set (match_operand:XF 0 "fr_register_operand" "=&f")
2194
        (float:XF (div:SI (match_operand:XF 1 "fr_register_operand" "f")
2195
                          (match_operand:XF 2 "fr_register_operand" "f"))))
2196
   (clobber (match_scratch:XF 4 "=&f"))
2197
   (clobber (match_scratch:XF 5 "=&f"))
2198
   (clobber (match_scratch:BI 6 "=c"))
2199
   (use (match_operand:XF 3 "fr_register_operand" "f"))]
2200
  "TARGET_INLINE_INT_DIV"
2201
  "#"
2202
  "&& reload_completed"
2203
  [(parallel [(set (match_dup 0) (div:XF (const_int 1) (match_dup 2)))
2204
              (set (match_dup 6) (unspec:BI [(match_dup 1) (match_dup 2)]
2205
                                            UNSPEC_FR_RECIP_APPROX))
2206
              (use (const_int 1))])
2207
   (cond_exec (ne (match_dup 6) (const_int 0))
2208
     (parallel [(set (match_dup 4) (mult:XF (match_dup 1) (match_dup 0)))
2209
                (use (const_int 1))]))
2210
   (cond_exec (ne (match_dup 6) (const_int 0))
2211
     (parallel [(set (match_dup 5)
2212
                     (minus:XF (match_dup 7)
2213
                               (mult:XF (match_dup 2) (match_dup 0))))
2214
                (use (const_int 1))]))
2215
   (cond_exec (ne (match_dup 6) (const_int 0))
2216
     (parallel [(set (match_dup 4)
2217
                     (plus:XF (mult:XF (match_dup 5) (match_dup 4))
2218
                              (match_dup 4)))
2219
                (use (const_int 1))]))
2220
   (cond_exec (ne (match_dup 6) (const_int 0))
2221
     (parallel [(set (match_dup 5)
2222
                     (plus:XF (mult:XF (match_dup 5) (match_dup 5))
2223
                              (match_dup 3)))
2224
                (use (const_int 1))]))
2225
   (cond_exec (ne (match_dup 6) (const_int 0))
2226
     (parallel [(set (match_dup 0)
2227
                     (plus:XF (mult:XF (match_dup 5) (match_dup 4))
2228
                              (match_dup 4)))
2229
                (use (const_int 1))]))
2230
  ]
2231
  "operands[7] = CONST1_RTX (XFmode);"
2232
  [(set_attr "predicable" "no")])
2233
 
2234
;; ::::::::::::::::::::
2235
;; ::
2236
;; :: 64 bit Integer arithmetic
2237
;; ::
2238
;; ::::::::::::::::::::
2239
 
2240
(define_insn "adddi3"
2241
  [(set (match_operand:DI 0 "gr_register_operand" "=r,r,r")
2242
        (plus:DI (match_operand:DI 1 "gr_register_operand" "%r,r,a")
2243
                 (match_operand:DI 2 "gr_reg_or_22bit_operand" "r,I,J")))]
2244
  ""
2245
  "@
2246
   add %0 = %1, %2
2247
   adds %0 = %2, %1
2248
   addl %0 = %2, %1"
2249
  [(set_attr "itanium_class" "ialu")])
2250
 
2251
(define_insn "*adddi3_plus1"
2252
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2253
        (plus:DI (plus:DI (match_operand:DI 1 "gr_register_operand" "r")
2254
                          (match_operand:DI 2 "gr_register_operand" "r"))
2255
                 (const_int 1)))]
2256
  ""
2257
  "add %0 = %1, %2, 1"
2258
  [(set_attr "itanium_class" "ialu")])
2259
 
2260
;; This has some of the same problems as shladd.  We let the shladd
2261
;; eliminator hack handle it, which results in the 1 being forced into
2262
;; a register, but not more ugliness here.
2263
(define_insn "*adddi3_plus1_alt"
2264
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2265
        (plus:DI (mult:DI (match_operand:DI 1 "gr_register_operand" "r")
2266
                          (const_int 2))
2267
                 (const_int 1)))]
2268
  ""
2269
  "add %0 = %1, %1, 1"
2270
  [(set_attr "itanium_class" "ialu")])
2271
 
2272
(define_insn "subdi3"
2273
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2274
        (minus:DI (match_operand:DI 1 "gr_reg_or_8bit_operand" "rK")
2275
                  (match_operand:DI 2 "gr_register_operand" "r")))]
2276
  ""
2277
  "sub %0 = %1, %2"
2278
  [(set_attr "itanium_class" "ialu")])
2279
 
2280
(define_insn "*subdi3_minus1"
2281
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2282
        (plus:DI (not:DI (match_operand:DI 1 "gr_register_operand" "r"))
2283
                 (match_operand:DI 2 "gr_register_operand" "r")))]
2284
  ""
2285
  "sub %0 = %2, %1, 1"
2286
  [(set_attr "itanium_class" "ialu")])
2287
 
2288
;; ??? Use grfr instead of fr because of virtual register elimination
2289
;; and silly test cases multiplying by the frame pointer.
2290
(define_insn "muldi3"
2291
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
2292
        (mult:DI (match_operand:DI 1 "grfr_register_operand" "f")
2293
                 (match_operand:DI 2 "grfr_register_operand" "f")))]
2294
  ""
2295
  "xmpy.l %0 = %1, %2"
2296
  [(set_attr "itanium_class" "xmpy")])
2297
 
2298
;; ??? If operand 3 is an eliminable reg, then register elimination causes the
2299
;; same problem that we have with shladd below.  Unfortunately, this case is
2300
;; much harder to fix because the multiply puts the result in an FP register,
2301
;; but the add needs inputs from a general register.  We add a spurious clobber
2302
;; here so that it will be present just in case register elimination gives us
2303
;; the funny result.
2304
 
2305
;; ??? Maybe validate_changes should try adding match_scratch clobbers?
2306
 
2307
;; ??? Maybe we should change how adds are canonicalized.
2308
 
2309
(define_insn "madddi4"
2310
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
2311
        (plus:DI (mult:DI (match_operand:DI 1 "grfr_register_operand" "f")
2312
                          (match_operand:DI 2 "grfr_register_operand" "f"))
2313
                 (match_operand:DI 3 "grfr_register_operand" "f")))
2314
   (clobber (match_scratch:DI 4 "=X"))]
2315
  ""
2316
  "xma.l %0 = %1, %2, %3"
2317
  [(set_attr "itanium_class" "xmpy")])
2318
 
2319
;; This can be created by register elimination if operand3 of shladd is an
2320
;; eliminable register or has reg_equiv_constant set.
2321
 
2322
;; We have to use nonmemory_operand for operand 4, to ensure that the
2323
;; validate_changes call inside eliminate_regs will always succeed.  If it
2324
;; doesn't succeed, then this remain a madddi4 pattern, and will be reloaded
2325
;; incorrectly.
2326
 
2327
(define_insn "*madddi4_elim"
2328
  [(set (match_operand:DI 0 "register_operand" "=&r")
2329
        (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "f")
2330
                                   (match_operand:DI 2 "register_operand" "f"))
2331
                          (match_operand:DI 3 "register_operand" "f"))
2332
                 (match_operand:DI 4 "nonmemory_operand" "rI")))
2333
   (clobber (match_scratch:DI 5 "=f"))]
2334
  "reload_in_progress"
2335
  "#"
2336
  [(set_attr "itanium_class" "unknown")])
2337
 
2338
(define_split
2339
  [(set (match_operand:DI 0 "register_operand" "")
2340
        (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
2341
                                   (match_operand:DI 2 "register_operand" ""))
2342
                          (match_operand:DI 3 "register_operand" ""))
2343
                 (match_operand:DI 4 "gr_reg_or_14bit_operand" "")))
2344
   (clobber (match_scratch:DI 5 ""))]
2345
  "reload_completed"
2346
  [(parallel [(set (match_dup 5) (plus:DI (mult:DI (match_dup 1) (match_dup 2))
2347
                                          (match_dup 3)))
2348
              (clobber (match_dup 0))])
2349
   (set (match_dup 0) (match_dup 5))
2350
   (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
2351
  "")
2352
 
2353
(define_insn "smuldi3_highpart"
2354
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
2355
        (truncate:DI
2356
         (lshiftrt:TI
2357
          (mult:TI (sign_extend:TI
2358
                     (match_operand:DI 1 "fr_register_operand" "f"))
2359
                   (sign_extend:TI
2360
                     (match_operand:DI 2 "fr_register_operand" "f")))
2361
          (const_int 64))))]
2362
  ""
2363
  "xmpy.h %0 = %1, %2"
2364
  [(set_attr "itanium_class" "xmpy")])
2365
 
2366
(define_insn "umuldi3_highpart"
2367
  [(set (match_operand:DI 0 "fr_register_operand" "=f")
2368
        (truncate:DI
2369
         (lshiftrt:TI
2370
          (mult:TI (zero_extend:TI
2371
                     (match_operand:DI 1 "fr_register_operand" "f"))
2372
                   (zero_extend:TI
2373
                     (match_operand:DI 2 "fr_register_operand" "f")))
2374
          (const_int 64))))]
2375
  ""
2376
  "xmpy.hu %0 = %1, %2"
2377
  [(set_attr "itanium_class" "xmpy")])
2378
 
2379
(define_insn "negdi2"
2380
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2381
        (neg:DI (match_operand:DI 1 "gr_register_operand" "r")))]
2382
  ""
2383
  "sub %0 = r0, %1"
2384
  [(set_attr "itanium_class" "ialu")])
2385
 
2386
(define_expand "absdi2"
2387
  [(set (match_dup 2)
2388
        (ge:BI (match_operand:DI 1 "gr_register_operand" "") (const_int 0)))
2389
   (set (match_operand:DI 0 "gr_register_operand" "")
2390
        (if_then_else:DI (eq (match_dup 2) (const_int 0))
2391
                         (neg:DI (match_dup 1))
2392
                         (match_dup 1)))]
2393
  ""
2394
  { operands[2] = gen_reg_rtx (BImode); })
2395
 
2396
(define_expand "smindi3"
2397
  [(set (match_dup 3)
2398
        (ge:BI (match_operand:DI 1 "gr_register_operand" "")
2399
               (match_operand:DI 2 "gr_register_operand" "")))
2400
   (set (match_operand:DI 0 "gr_register_operand" "")
2401
        (if_then_else:DI (ne (match_dup 3) (const_int 0))
2402
                         (match_dup 2) (match_dup 1)))]
2403
  ""
2404
  { operands[3] = gen_reg_rtx (BImode); })
2405
 
2406
(define_expand "smaxdi3"
2407
  [(set (match_dup 3)
2408
        (ge:BI (match_operand:DI 1 "gr_register_operand" "")
2409
               (match_operand:DI 2 "gr_register_operand" "")))
2410
   (set (match_operand:DI 0 "gr_register_operand" "")
2411
        (if_then_else:DI (ne (match_dup 3) (const_int 0))
2412
                         (match_dup 1) (match_dup 2)))]
2413
  ""
2414
  { operands[3] = gen_reg_rtx (BImode); })
2415
 
2416
(define_expand "umindi3"
2417
  [(set (match_dup 3)
2418
        (geu:BI (match_operand:DI 1 "gr_register_operand" "")
2419
                (match_operand:DI 2 "gr_register_operand" "")))
2420
   (set (match_operand:DI 0 "gr_register_operand" "")
2421
        (if_then_else:DI (ne (match_dup 3) (const_int 0))
2422
                         (match_dup 2) (match_dup 1)))]
2423
  ""
2424
  { operands[3] = gen_reg_rtx (BImode); })
2425
 
2426
(define_expand "umaxdi3"
2427
  [(set (match_dup 3)
2428
        (geu:BI (match_operand:DI 1 "gr_register_operand" "")
2429
                (match_operand:DI 2 "gr_register_operand" "")))
2430
   (set (match_operand:DI 0 "gr_register_operand" "")
2431
        (if_then_else:DI (ne (match_dup 3) (const_int 0))
2432
                         (match_dup 1) (match_dup 2)))]
2433
  ""
2434
  { operands[3] = gen_reg_rtx (BImode); })
2435
 
2436
(define_expand "ffsdi2"
2437
  [(set (match_dup 6)
2438
        (eq:BI (match_operand:DI 1 "gr_register_operand" "") (const_int 0)))
2439
   (set (match_dup 2) (plus:DI (match_dup 1) (const_int -1)))
2440
   (set (match_dup 5) (const_int 0))
2441
   (set (match_dup 3) (xor:DI (match_dup 1) (match_dup 2)))
2442
   (set (match_dup 4) (popcount:DI (match_dup 3)))
2443
   (set (match_operand:DI 0 "gr_register_operand" "")
2444
        (if_then_else:DI (ne (match_dup 6) (const_int 0))
2445
                         (match_dup 5) (match_dup 4)))]
2446
  ""
2447
{
2448
  operands[2] = gen_reg_rtx (DImode);
2449
  operands[3] = gen_reg_rtx (DImode);
2450
  operands[4] = gen_reg_rtx (DImode);
2451
  operands[5] = gen_reg_rtx (DImode);
2452
  operands[6] = gen_reg_rtx (BImode);
2453
})
2454
 
2455
(define_expand "ctzdi2"
2456
  [(set (match_dup 2) (plus:DI (match_operand:DI 1 "gr_register_operand" "")
2457
                               (const_int -1)))
2458
   (set (match_dup 3) (not:DI (match_dup 1)))
2459
   (set (match_dup 4) (and:DI (match_dup 2) (match_dup 3)))
2460
   (set (match_operand:DI 0 "gr_register_operand" "")
2461
        (popcount:DI (match_dup 4)))]
2462
  ""
2463
{
2464
  operands[2] = gen_reg_rtx (DImode);
2465
  operands[3] = gen_reg_rtx (DImode);
2466
  operands[4] = gen_reg_rtx (DImode);
2467
})
2468
 
2469
;; Note the computation here is op0 = 63 - (exp - 0xffff).
2470
(define_expand "clzdi2"
2471
  [(set (match_dup 2)
2472
        (unsigned_float:XF (match_operand:DI 1 "fr_register_operand" "")))
2473
   (set (match_dup 3)
2474
        (unspec:DI [(match_dup 2)] UNSPEC_GETF_EXP))
2475
   (set (match_dup 4) (const_int 65598))
2476
   (set (match_operand:DI 0 "gr_register_operand" "")
2477
        (minus:DI (match_dup 4) (match_dup 3)))]
2478
  ""
2479
{
2480
  operands[2] = gen_reg_rtx (XFmode);
2481
  operands[3] = gen_reg_rtx (DImode);
2482
  operands[4] = gen_reg_rtx (DImode);
2483
})
2484
 
2485
(define_insn "popcountdi2"
2486
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2487
        (popcount:DI (match_operand:DI 1 "gr_register_operand" "r")))]
2488
  ""
2489
  "popcnt %0 = %1"
2490
  [(set_attr "itanium_class" "mmmul")])
2491
 
2492
(define_insn "*getf_exp_xf"
2493
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
2494
        (unspec:DI [(match_operand:XF 1 "fr_register_operand" "f")]
2495
                   UNSPEC_GETF_EXP))]
2496
  ""
2497
  "getf.exp %0 = %1"
2498
  [(set_attr "itanium_class" "frfr")])
2499
 
2500
(define_expand "divdi3"
2501
  [(set (match_operand:DI 0 "register_operand" "")
2502
        (div:DI (match_operand:DI 1 "general_operand" "")
2503
                (match_operand:DI 2 "general_operand" "")))]
2504
  "TARGET_INLINE_INT_DIV"
2505
{
2506
  rtx op1_xf, op2_xf, op0_xf;
2507
 
2508
  op0_xf = gen_reg_rtx (XFmode);
2509
 
2510
  if (CONSTANT_P (operands[1]))
2511
    operands[1] = force_reg (DImode, operands[1]);
2512
  op1_xf = gen_reg_rtx (XFmode);
2513
  expand_float (op1_xf, operands[1], 0);
2514
 
2515
  if (CONSTANT_P (operands[2]))
2516
    operands[2] = force_reg (DImode, operands[2]);
2517
  op2_xf = gen_reg_rtx (XFmode);
2518
  expand_float (op2_xf, operands[2], 0);
2519
 
2520
  emit_insn (gen_cond_trap (EQ, operands[2], CONST0_RTX (DImode),
2521
                            CONST1_RTX (DImode)));
2522
 
2523
  if (TARGET_INLINE_INT_DIV == INL_MIN_LAT)
2524
    emit_insn (gen_divdi3_internal_lat (op0_xf, op1_xf, op2_xf));
2525
  else
2526
    emit_insn (gen_divdi3_internal_thr (op0_xf, op1_xf, op2_xf));
2527
 
2528
  emit_insn (gen_fix_truncxfdi2_alts (operands[0], op0_xf, const1_rtx));
2529
  DONE;
2530
})
2531
 
2532
(define_expand "moddi3"
2533
  [(set (match_operand:DI 0 "register_operand" "")
2534
        (mod:SI (match_operand:DI 1 "general_operand" "")
2535
                (match_operand:DI 2 "general_operand" "")))]
2536
  "TARGET_INLINE_INT_DIV"
2537
{
2538
  rtx op2_neg, div;
2539
 
2540
  div = gen_reg_rtx (DImode);
2541
  emit_insn (gen_divdi3 (div, operands[1], operands[2]));
2542
 
2543
  op2_neg = expand_unop (DImode, neg_optab, operands[2], NULL_RTX, 0);
2544
 
2545
  emit_insn (gen_madddi4 (operands[0], div, op2_neg, operands[1]));
2546
  DONE;
2547
})
2548
 
2549
(define_expand "udivdi3"
2550
  [(set (match_operand:DI 0 "register_operand" "")
2551
        (udiv:DI (match_operand:DI 1 "general_operand" "")
2552
                 (match_operand:DI 2 "general_operand" "")))]
2553
  "TARGET_INLINE_INT_DIV"
2554
{
2555
  rtx op1_xf, op2_xf, op0_xf;
2556
 
2557
  op0_xf = gen_reg_rtx (XFmode);
2558
 
2559
  if (CONSTANT_P (operands[1]))
2560
    operands[1] = force_reg (DImode, operands[1]);
2561
  op1_xf = gen_reg_rtx (XFmode);
2562
  expand_float (op1_xf, operands[1], 1);
2563
 
2564
  if (CONSTANT_P (operands[2]))
2565
    operands[2] = force_reg (DImode, operands[2]);
2566
  op2_xf = gen_reg_rtx (XFmode);
2567
  expand_float (op2_xf, operands[2], 1);
2568
 
2569
  emit_insn (gen_cond_trap (EQ, operands[2], CONST0_RTX (DImode),
2570
                            CONST1_RTX (DImode)));
2571
 
2572
  if (TARGET_INLINE_INT_DIV == INL_MIN_LAT)
2573
    emit_insn (gen_divdi3_internal_lat (op0_xf, op1_xf, op2_xf));
2574
  else
2575
    emit_insn (gen_divdi3_internal_thr (op0_xf, op1_xf, op2_xf));
2576
 
2577
  emit_insn (gen_fixuns_truncxfdi2_alts (operands[0], op0_xf, const1_rtx));
2578
  DONE;
2579
})
2580
 
2581
(define_expand "umoddi3"
2582
  [(set (match_operand:DI 0 "register_operand" "")
2583
        (umod:DI (match_operand:DI 1 "general_operand" "")
2584
                 (match_operand:DI 2 "general_operand" "")))]
2585
  "TARGET_INLINE_INT_DIV"
2586
{
2587
  rtx op2_neg, div;
2588
 
2589
  div = gen_reg_rtx (DImode);
2590
  emit_insn (gen_udivdi3 (div, operands[1], operands[2]));
2591
 
2592
  op2_neg = expand_unop (DImode, neg_optab, operands[2], NULL_RTX, 0);
2593
 
2594
  emit_insn (gen_madddi4 (operands[0], div, op2_neg, operands[1]));
2595
  DONE;
2596
})
2597
 
2598
(define_insn_and_split "divdi3_internal_lat"
2599
  [(set (match_operand:XF 0 "fr_register_operand" "=&f")
2600
        (float:XF (div:SI (match_operand:XF 1 "fr_register_operand" "f")
2601
                          (match_operand:XF 2 "fr_register_operand" "f"))))
2602
   (clobber (match_scratch:XF 3 "=&f"))
2603
   (clobber (match_scratch:XF 4 "=&f"))
2604
   (clobber (match_scratch:XF 5 "=&f"))
2605
   (clobber (match_scratch:BI 6 "=c"))]
2606
  "TARGET_INLINE_INT_DIV == INL_MIN_LAT"
2607
  "#"
2608
  "&& reload_completed"
2609
  [(parallel [(set (match_dup 0) (div:XF (const_int 1) (match_dup 2)))
2610
              (set (match_dup 6) (unspec:BI [(match_dup 1) (match_dup 2)]
2611
                                            UNSPEC_FR_RECIP_APPROX))
2612
              (use (const_int 1))])
2613
   (cond_exec (ne (match_dup 6) (const_int 0))
2614
     (parallel [(set (match_dup 3)
2615
                     (minus:XF (match_dup 7)
2616
                               (mult:XF (match_dup 2) (match_dup 0))))
2617
                (use (const_int 1))]))
2618
   (cond_exec (ne (match_dup 6) (const_int 0))
2619
     (parallel [(set (match_dup 4) (mult:XF (match_dup 1) (match_dup 0)))
2620
                (use (const_int 1))]))
2621
   (cond_exec (ne (match_dup 6) (const_int 0))
2622
     (parallel [(set (match_dup 5) (mult:XF (match_dup 3) (match_dup 3)))
2623
                (use (const_int 1))]))
2624
   (cond_exec (ne (match_dup 6) (const_int 0))
2625
     (parallel [(set (match_dup 4)
2626
                     (plus:XF (mult:XF (match_dup 3) (match_dup 4))
2627
                              (match_dup 4)))
2628
                (use (const_int 1))]))
2629
   (cond_exec (ne (match_dup 6) (const_int 0))
2630
     (parallel [(set (match_dup 0)
2631
                     (plus:XF (mult:XF (match_dup 3) (match_dup 0))
2632
                              (match_dup 0)))
2633
                (use (const_int 1))]))
2634
   (cond_exec (ne (match_dup 6) (const_int 0))
2635
     (parallel [(set (match_dup 3)
2636
                     (plus:XF (mult:XF (match_dup 5) (match_dup 4))
2637
                              (match_dup 4)))
2638
                (use (const_int 1))]))
2639
   (cond_exec (ne (match_dup 6) (const_int 0))
2640
     (parallel [(set (match_dup 0)
2641
                     (plus:XF (mult:XF (match_dup 5) (match_dup 0))
2642
                              (match_dup 0)))
2643
                (use (const_int 1))]))
2644
   (cond_exec (ne (match_dup 6) (const_int 0))
2645
     (parallel [(set (match_dup 4)
2646
                     (minus:XF (match_dup 1)
2647
                               (mult:XF (match_dup 2) (match_dup 3))))
2648
                (use (const_int 1))]))
2649
   (cond_exec (ne (match_dup 6) (const_int 0))
2650
     (parallel [(set (match_dup 0)
2651
                     (plus:XF (mult:XF (match_dup 4) (match_dup 0))
2652
                              (match_dup 3)))
2653
                (use (const_int 1))]))
2654
  ]
2655
  "operands[7] = CONST1_RTX (XFmode);"
2656
  [(set_attr "predicable" "no")])
2657
 
2658
(define_insn_and_split "divdi3_internal_thr"
2659
  [(set (match_operand:XF 0 "fr_register_operand" "=&f")
2660
        (float:XF (div:SI (match_operand:XF 1 "fr_register_operand" "f")
2661
                          (match_operand:XF 2 "fr_register_operand" "f"))))
2662
   (clobber (match_scratch:XF 3 "=&f"))
2663
   (clobber (match_scratch:XF 4 "=f"))
2664
   (clobber (match_scratch:BI 5 "=c"))]
2665
  "TARGET_INLINE_INT_DIV == INL_MAX_THR"
2666
  "#"
2667
  "&& reload_completed"
2668
  [(parallel [(set (match_dup 0) (div:XF (const_int 1) (match_dup 2)))
2669
              (set (match_dup 5) (unspec:BI [(match_dup 1) (match_dup 2)]
2670
                                            UNSPEC_FR_RECIP_APPROX))
2671
              (use (const_int 1))])
2672
   (cond_exec (ne (match_dup 5) (const_int 0))
2673
     (parallel [(set (match_dup 3)
2674
                     (minus:XF (match_dup 6)
2675
                               (mult:XF (match_dup 2) (match_dup 0))))
2676
                (use (const_int 1))]))
2677
   (cond_exec (ne (match_dup 5) (const_int 0))
2678
     (parallel [(set (match_dup 0)
2679
                     (plus:XF (mult:XF (match_dup 3) (match_dup 0))
2680
                              (match_dup 0)))
2681
                (use (const_int 1))]))
2682
   (cond_exec (ne (match_dup 5) (const_int 0))
2683
     (parallel [(set (match_dup 3) (mult:XF (match_dup 3) (match_dup 3)))
2684
                (use (const_int 1))]))
2685
   (cond_exec (ne (match_dup 5) (const_int 0))
2686
     (parallel [(set (match_dup 0)
2687
                     (plus:XF (mult:XF (match_dup 3) (match_dup 0))
2688
                              (match_dup 0)))
2689
                (use (const_int 1))]))
2690
   (cond_exec (ne (match_dup 5) (const_int 0))
2691
     (parallel [(set (match_dup 3) (mult:XF (match_dup 0) (match_dup 1)))
2692
                (use (const_int 1))]))
2693
   (cond_exec (ne (match_dup 5) (const_int 0))
2694
     (parallel [(set (match_dup 4)
2695
                     (minus:XF (match_dup 1)
2696
                               (mult:XF (match_dup 2) (match_dup 3))))
2697
                (use (const_int 1))]))
2698
   (cond_exec (ne (match_dup 5) (const_int 0))
2699
     (parallel [(set (match_dup 0)
2700
                     (plus:XF (mult:XF (match_dup 4) (match_dup 0))
2701
                              (match_dup 3)))
2702
                (use (const_int 1))]))
2703
  ]
2704
  "operands[6] = CONST1_RTX (XFmode);"
2705
  [(set_attr "predicable" "no")])
2706
 
2707
;; ::::::::::::::::::::
2708
;; ::
2709
;; :: 128 bit Integer arithmetic
2710
;; ::
2711
;; ::::::::::::::::::::
2712
 
2713
(define_insn "addti3"
2714
  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
2715
        (plus:TI (match_operand:TI 1 "gr_register_operand" "%r")
2716
                 (match_operand:TI 2 "gr_reg_or_14bit_operand" "rI")))
2717
   (clobber (match_scratch:BI 3 "=&c"))]
2718
  ""
2719
  "#"
2720
  [(set_attr "itanium_class" "unknown")])
2721
 
2722
(define_split
2723
  [(set (match_operand:TI 0 "register_operand" "")
2724
        (plus:TI (match_operand:TI 1 "register_operand" "")
2725
                 (match_operand:TI 2 "register_operand" "")))
2726
   (clobber (match_scratch:BI 3 ""))]
2727
  "reload_completed"
2728
  [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
2729
   (set (match_dup 3) (ltu:BI (match_dup 0) (match_dup 1)))
2730
   (cond_exec (eq (match_dup 3) (const_int 0))
2731
              (set (match_dup 4) (plus:DI (match_dup 5) (match_dup 6))))
2732
   (cond_exec (ne (match_dup 3) (const_int 0))
2733
              (set (match_dup 4)
2734
                   (plus:DI (plus:DI (match_dup 5) (match_dup 6))
2735
                            (const_int 1))))]
2736
{
2737
  operands[4] = gen_highpart (DImode, operands[0]);
2738
  operands[0] = gen_lowpart (DImode, operands[0]);
2739
  operands[5] = gen_highpart (DImode, operands[1]);
2740
  operands[1] = gen_lowpart (DImode, operands[1]);
2741
  operands[6] = gen_highpart (DImode, operands[2]);
2742
  operands[2] = gen_lowpart (DImode, operands[2]);
2743
})
2744
 
2745
(define_split
2746
  [(set (match_operand:TI 0 "register_operand" "")
2747
        (plus:TI (match_operand:TI 1 "register_operand" "")
2748
                 (match_operand:TI 2 "immediate_operand" "")))
2749
   (clobber (match_scratch:BI 3 ""))]
2750
  "reload_completed"
2751
  [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
2752
   (set (match_dup 3) (ltu:BI (match_dup 0) (match_dup 1)))
2753
   (cond_exec (eq (match_dup 3) (const_int 0))
2754
              (set (match_dup 4)
2755
                   (plus:DI (match_dup 5) (match_dup 6))))
2756
   (cond_exec (ne (match_dup 3) (const_int 0))
2757
              (set (match_dup 4)
2758
                   (plus:DI (match_dup 5) (match_dup 7))))]
2759
{
2760
  operands[4] = gen_highpart (DImode, operands[0]);
2761
  operands[0] = gen_lowpart (DImode, operands[0]);
2762
  operands[5] = gen_highpart (DImode, operands[1]);
2763
  operands[1] = gen_lowpart (DImode, operands[1]);
2764
  operands[6] = INTVAL (operands[2]) < 0 ? constm1_rtx : const0_rtx;
2765
  operands[7] = INTVAL (operands[2]) < 0 ? const0_rtx : const1_rtx;
2766
})
2767
 
2768
(define_insn "subti3"
2769
  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
2770
        (minus:TI (match_operand:TI 1 "gr_reg_or_8bit_operand" "rK")
2771
                  (match_operand:TI 2 "gr_register_operand" "r")))
2772
   (clobber (match_scratch:BI 3 "=&c"))]
2773
  ""
2774
  "#"
2775
  [(set_attr "itanium_class" "unknown")])
2776
 
2777
(define_split
2778
  [(set (match_operand:TI 0 "register_operand" "")
2779
        (minus:TI (match_operand:TI 1 "register_operand" "")
2780
                  (match_operand:TI 2 "register_operand" "")))
2781
   (clobber (match_scratch:BI 3 "=&c"))]
2782
  "reload_completed"
2783
  [(set (match_dup 0) (minus:DI (match_dup 1) (match_dup 2)))
2784
   (set (match_dup 3) (ltu:BI (match_dup 1) (match_dup 0)))
2785
   (cond_exec (eq (match_dup 3) (const_int 0))
2786
              (set (match_dup 4) (minus:DI (match_dup 5) (match_dup 6))))
2787
   (cond_exec (ne (match_dup 3) (const_int 0))
2788
              (set (match_dup 4)
2789
                   (plus:DI (not:DI (match_dup 6)) (match_dup 5))))]
2790
{
2791
  operands[4] = gen_highpart (DImode, operands[0]);
2792
  operands[0] = gen_lowpart (DImode, operands[0]);
2793
  operands[5] = gen_highpart (DImode, operands[1]);
2794
  operands[1] = gen_lowpart (DImode, operands[1]);
2795
  operands[6] = gen_highpart (DImode, operands[2]);
2796
  operands[2] = gen_lowpart (DImode, operands[2]);
2797
})
2798
 
2799
(define_split
2800
  [(set (match_operand:TI 0 "register_operand" "")
2801
        (minus:TI (match_operand:TI 1 "immediate_operand" "")
2802
                  (match_operand:TI 2 "register_operand" "")))
2803
   (clobber (match_scratch:BI 3 "=&c"))]
2804
  "reload_completed && CONST_OK_FOR_K (INTVAL (operands[1]))"
2805
  [(set (match_dup 0) (minus:DI (match_dup 1) (match_dup 2)))
2806
   (set (match_dup 3) (gtu:BI (match_dup 0) (match_dup 1)))
2807
   (cond_exec (ne (match_dup 3) (const_int 0))
2808
              (set (match_dup 4) (minus:DI (match_dup 6) (match_dup 5))))
2809
   (cond_exec (eq (match_dup 3) (const_int 0))
2810
              (set (match_dup 4) (minus:DI (match_dup 7) (match_dup 5))))]
2811
{
2812
  operands[4] = gen_highpart (DImode, operands[0]);
2813
  operands[0] = gen_lowpart (DImode, operands[0]);
2814
  operands[5] = gen_highpart (DImode, operands[2]);
2815
  operands[2] = gen_lowpart (DImode, operands[2]);
2816
  operands[6] = INTVAL (operands[1]) < 0 ? GEN_INT (-2) : constm1_rtx;
2817
  operands[7] = INTVAL (operands[1]) < 0 ? constm1_rtx : const0_rtx;
2818
})
2819
 
2820
(define_expand "mulditi3"
2821
  [(set (match_operand:TI 0 "fr_register_operand" "")
2822
        (mult:TI (sign_extend:TI
2823
                   (match_operand:DI 1 "fr_register_operand" ""))
2824
                 (sign_extend:TI
2825
                   (match_operand:DI 2 "fr_register_operand" ""))))]
2826
  ""
2827
  "")
2828
 
2829
(define_insn_and_split "*mulditi3_internal"
2830
  [(set (match_operand:TI 0 "fr_register_operand" "=&f")
2831
        (mult:TI (sign_extend:TI
2832
                   (match_operand:DI 1 "fr_register_operand" "%f"))
2833
                 (sign_extend:TI
2834
                   (match_operand:DI 2 "fr_register_operand" "f"))))]
2835
  ""
2836
  "#"
2837
  "reload_completed"
2838
  [(set (match_dup 0) (mult:DI (match_dup 1) (match_dup 2)))
2839
   (set (match_dup 3) (truncate:DI
2840
                        (lshiftrt:TI
2841
                          (mult:TI (sign_extend:TI (match_dup 1))
2842
                                   (sign_extend:TI (match_dup 2)))
2843
                          (const_int 64))))]
2844
{
2845
  operands[3] = gen_highpart (DImode, operands[0]);
2846
  operands[0] = gen_lowpart (DImode, operands[0]);
2847
}
2848
  [(set_attr "itanium_class" "unknown")])
2849
 
2850
(define_expand "umulditi3"
2851
  [(set (match_operand:TI 0 "fr_register_operand" "")
2852
        (mult:TI (zero_extend:TI
2853
                   (match_operand:DI 1 "fr_register_operand" ""))
2854
                 (zero_extend:TI
2855
                   (match_operand:DI 2 "fr_register_operand" ""))))]
2856
  ""
2857
  "")
2858
 
2859
(define_insn_and_split "*umulditi3_internal"
2860
  [(set (match_operand:TI 0 "fr_register_operand" "=&f")
2861
        (mult:TI (zero_extend:TI
2862
                   (match_operand:DI 1 "fr_register_operand" "%f"))
2863
                 (zero_extend:TI
2864
                   (match_operand:DI 2 "fr_register_operand" "f"))))]
2865
  ""
2866
  "#"
2867
  "reload_completed"
2868
  [(set (match_dup 0) (mult:DI (match_dup 1) (match_dup 2)))
2869
   (set (match_dup 3) (truncate:DI
2870
                        (lshiftrt:TI
2871
                          (mult:TI (zero_extend:TI (match_dup 1))
2872
                                   (zero_extend:TI (match_dup 2)))
2873
                          (const_int 64))))]
2874
{
2875
  operands[3] = gen_highpart (DImode, operands[0]);
2876
  operands[0] = gen_lowpart (DImode, operands[0]);
2877
}
2878
  [(set_attr "itanium_class" "unknown")])
2879
 
2880
(define_insn_and_split "negti2"
2881
  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
2882
        (neg:TI (match_operand:TI 1 "gr_register_operand" "r")))
2883
   (clobber (match_scratch:BI 2 "=&c"))]
2884
  ""
2885
  "#"
2886
  "reload_completed"
2887
  [(set (match_dup 2) (eq:BI (match_dup 1) (const_int 0)))
2888
   (set (match_dup 0) (minus:DI (const_int 0) (match_dup 1)))
2889
   (cond_exec (eq (match_dup 2) (const_int 0))
2890
              (set (match_dup 3) (minus:DI (const_int -1) (match_dup 4))))
2891
   (cond_exec (ne (match_dup 2) (const_int 0))
2892
              (set (match_dup 3) (minus:DI (const_int 0) (match_dup 4))))]
2893
{
2894
  operands[3] = gen_highpart (DImode, operands[0]);
2895
  operands[0] = gen_lowpart (DImode, operands[0]);
2896
  operands[4] = gen_highpart (DImode, operands[1]);
2897
  operands[1] = gen_lowpart (DImode, operands[1]);
2898
}
2899
  [(set_attr "itanium_class" "unknown")])
2900
 
2901
;; ::::::::::::::::::::
2902
;; ::
2903
;; :: 32 bit floating point arithmetic
2904
;; ::
2905
;; ::::::::::::::::::::
2906
 
2907
(define_insn "addsf3"
2908
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2909
        (plus:SF (match_operand:SF 1 "fr_register_operand" "%f")
2910
                 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
2911
  ""
2912
  "fadd.s %0 = %1, %F2"
2913
  [(set_attr "itanium_class" "fmac")])
2914
 
2915
(define_insn "subsf3"
2916
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2917
        (minus:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2918
                  (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
2919
  ""
2920
  "fsub.s %0 = %F1, %F2"
2921
  [(set_attr "itanium_class" "fmac")])
2922
 
2923
(define_insn "mulsf3"
2924
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2925
        (mult:SF (match_operand:SF 1 "fr_register_operand" "%f")
2926
                 (match_operand:SF 2 "fr_register_operand" "f")))]
2927
  ""
2928
  "fmpy.s %0 = %1, %2"
2929
  [(set_attr "itanium_class" "fmac")])
2930
 
2931
(define_insn "abssf2"
2932
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2933
        (abs:SF (match_operand:SF 1 "fr_register_operand" "f")))]
2934
  ""
2935
  "fabs %0 = %1"
2936
  [(set_attr "itanium_class" "fmisc")])
2937
 
2938
(define_insn "negsf2"
2939
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2940
        (neg:SF (match_operand:SF 1 "fr_register_operand" "f")))]
2941
  ""
2942
  "fneg %0 = %1"
2943
  [(set_attr "itanium_class" "fmisc")])
2944
 
2945
(define_insn "*nabssf2"
2946
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2947
        (neg:SF (abs:SF (match_operand:SF 1 "fr_register_operand" "f"))))]
2948
  ""
2949
  "fnegabs %0 = %1"
2950
  [(set_attr "itanium_class" "fmisc")])
2951
 
2952
(define_insn "copysignsf3"
2953
  [(set (match_operand:SF 0 "register_operand" "=f")
2954
        (unspec:SF [(match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2955
                    (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")]
2956
                   UNSPEC_COPYSIGN))]
2957
  ""
2958
  "fmerge.s %0 = %F2, %F1"
2959
  [(set_attr "itanium_class" "fmisc")])
2960
 
2961
(define_insn "*ncopysignsf3"
2962
  [(set (match_operand:SF 0 "register_operand" "=f")
2963
        (neg:SF (unspec:SF [(match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2964
                            (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")]
2965
                           UNSPEC_COPYSIGN)))]
2966
  ""
2967
  "fmerge.ns %0 = %F2, %F1"
2968
  [(set_attr "itanium_class" "fmisc")])
2969
 
2970
(define_insn "sminsf3"
2971
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2972
        (smin:SF (match_operand:SF 1 "fr_register_operand" "f")
2973
                 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
2974
  ""
2975
  "fmin %0 = %1, %F2"
2976
  [(set_attr "itanium_class" "fmisc")])
2977
 
2978
(define_insn "smaxsf3"
2979
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2980
        (smax:SF (match_operand:SF 1 "fr_register_operand" "f")
2981
                 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
2982
  ""
2983
  "fmax %0 = %1, %F2"
2984
  [(set_attr "itanium_class" "fmisc")])
2985
 
2986
(define_insn "*maddsf4"
2987
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2988
        (plus:SF (mult:SF (match_operand:SF 1 "fr_register_operand" "f")
2989
                          (match_operand:SF 2 "fr_register_operand" "f"))
2990
                 (match_operand:SF 3 "fr_reg_or_fp01_operand" "fG")))]
2991
  ""
2992
  "fma.s %0 = %1, %2, %F3"
2993
  [(set_attr "itanium_class" "fmac")])
2994
 
2995
(define_insn "*msubsf4"
2996
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
2997
        (minus:SF (mult:SF (match_operand:SF 1 "fr_register_operand" "f")
2998
                           (match_operand:SF 2 "fr_register_operand" "f"))
2999
                  (match_operand:SF 3 "fr_reg_or_fp01_operand" "fG")))]
3000
  ""
3001
  "fms.s %0 = %1, %2, %F3"
3002
  [(set_attr "itanium_class" "fmac")])
3003
 
3004
(define_insn "*nmulsf3"
3005
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3006
        (neg:SF (mult:SF (match_operand:SF 1 "fr_register_operand" "f")
3007
                         (match_operand:SF 2 "fr_register_operand" "f"))))]
3008
  ""
3009
  "fnmpy.s %0 = %1, %2"
3010
  [(set_attr "itanium_class" "fmac")])
3011
 
3012
(define_insn "*nmaddsf4"
3013
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3014
        (minus:SF (match_operand:SF 3 "fr_reg_or_fp01_operand" "fG")
3015
                  (mult:SF (match_operand:SF 1 "fr_register_operand" "f")
3016
                           (match_operand:SF 2 "fr_register_operand" "f"))))]
3017
  ""
3018
  "fnma.s %0 = %1, %2, %F3"
3019
  [(set_attr "itanium_class" "fmac")])
3020
 
3021
(define_insn "*nmaddsf4_alts"
3022
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3023
        (minus:SF (match_operand:SF 3 "fr_reg_or_fp01_operand" "fG")
3024
                  (mult:SF (match_operand:SF 1 "fr_register_operand" "f")
3025
                           (match_operand:SF 2 "fr_register_operand" "f"))))
3026
   (use (match_operand:SI 4 "const_int_operand" ""))]
3027
  ""
3028
  "fnma.s.s%4 %0 = %1, %2, %F3"
3029
  [(set_attr "itanium_class" "fmac")])
3030
 
3031
(define_expand "divsf3"
3032
  [(set (match_operand:SF 0 "fr_register_operand" "")
3033
        (div:SF (match_operand:SF 1 "fr_register_operand" "")
3034
                (match_operand:SF 2 "fr_register_operand" "")))]
3035
  "TARGET_INLINE_FLOAT_DIV"
3036
{
3037
  rtx insn;
3038
  if (TARGET_INLINE_FLOAT_DIV == INL_MIN_LAT)
3039
    insn = gen_divsf3_internal_lat (operands[0], operands[1], operands[2]);
3040
  else
3041
    insn = gen_divsf3_internal_thr (operands[0], operands[1], operands[2]);
3042
  emit_insn (insn);
3043
  DONE;
3044
})
3045
 
3046
(define_insn_and_split "divsf3_internal_lat"
3047
  [(set (match_operand:SF 0 "fr_register_operand" "=&f")
3048
        (div:SF (match_operand:SF 1 "fr_register_operand" "f")
3049
                (match_operand:SF 2 "fr_register_operand" "f")))
3050
   (clobber (match_scratch:XF 3 "=&f"))
3051
   (clobber (match_scratch:XF 4 "=f"))
3052
   (clobber (match_scratch:BI 5 "=c"))]
3053
  "TARGET_INLINE_FLOAT_DIV == INL_MIN_LAT"
3054
  "#"
3055
  "&& reload_completed"
3056
  [(parallel [(set (match_dup 6) (div:XF (const_int 1) (match_dup 8)))
3057
              (set (match_dup 5) (unspec:BI [(match_dup 7) (match_dup 8)]
3058
                                            UNSPEC_FR_RECIP_APPROX))
3059
              (use (const_int 0))])
3060
   (cond_exec (ne (match_dup 5) (const_int 0))
3061
     (parallel [(set (match_dup 3) (mult:XF (match_dup 7) (match_dup 6)))
3062
                (use (const_int 1))]))
3063
   (cond_exec (ne (match_dup 5) (const_int 0))
3064
     (parallel [(set (match_dup 4)
3065
                     (minus:XF (match_dup 10)
3066
                               (mult:XF (match_dup 8) (match_dup 6))))
3067
                (use (const_int 1))]))
3068
   (cond_exec (ne (match_dup 5) (const_int 0))
3069
     (parallel [(set (match_dup 3)
3070
                     (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3071
                              (match_dup 3)))
3072
                (use (const_int 1))]))
3073
   (cond_exec (ne (match_dup 5) (const_int 0))
3074
     (parallel [(set (match_dup 4) (mult:XF (match_dup 4) (match_dup 4)))
3075
                (use (const_int 1))]))
3076
   (cond_exec (ne (match_dup 5) (const_int 0))
3077
     (parallel [(set (match_dup 3)
3078
                     (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3079
                              (match_dup 3)))
3080
                (use (const_int 1))]))
3081
   (cond_exec (ne (match_dup 5) (const_int 0))
3082
     (parallel [(set (match_dup 4) (mult:XF (match_dup 4) (match_dup 4)))
3083
                (use (const_int 1))]))
3084
   (cond_exec (ne (match_dup 5) (const_int 0))
3085
     (parallel [(set (match_dup 9)
3086
                     (float_truncate:DF
3087
                       (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3088
                              (match_dup 3))))
3089
                (use (const_int 1))]))
3090
   (cond_exec (ne (match_dup 5) (const_int 0))
3091
     (set (match_dup 0)
3092
          (float_truncate:SF (match_dup 6))))
3093
  ]
3094
{
3095
  operands[6] = gen_rtx_REG (XFmode, REGNO (operands[0]));
3096
  operands[7] = gen_rtx_REG (XFmode, REGNO (operands[1]));
3097
  operands[8] = gen_rtx_REG (XFmode, REGNO (operands[2]));
3098
  operands[9] = gen_rtx_REG (DFmode, REGNO (operands[0]));
3099
  operands[10] = CONST1_RTX (XFmode);
3100
}
3101
  [(set_attr "predicable" "no")])
3102
 
3103
(define_insn_and_split "divsf3_internal_thr"
3104
  [(set (match_operand:SF 0 "fr_register_operand" "=&f")
3105
        (div:SF (match_operand:SF 1 "fr_register_operand" "f")
3106
                (match_operand:SF 2 "fr_register_operand" "f")))
3107
   (clobber (match_scratch:XF 3 "=&f"))
3108
   (clobber (match_scratch:XF 4 "=f"))
3109
   (clobber (match_scratch:BI 5 "=c"))]
3110
  "TARGET_INLINE_FLOAT_DIV == INL_MAX_THR"
3111
  "#"
3112
  "&& reload_completed"
3113
  [(parallel [(set (match_dup 6) (div:XF (const_int 1) (match_dup 8)))
3114
              (set (match_dup 5) (unspec:BI [(match_dup 7) (match_dup 8)]
3115
                                            UNSPEC_FR_RECIP_APPROX))
3116
              (use (const_int 0))])
3117
   (cond_exec (ne (match_dup 5) (const_int 0))
3118
     (parallel [(set (match_dup 3)
3119
                     (minus:XF (match_dup 10)
3120
                               (mult:XF (match_dup 8) (match_dup 6))))
3121
                (use (const_int 1))]))
3122
   (cond_exec (ne (match_dup 5) (const_int 0))
3123
     (parallel [(set (match_dup 3)
3124
                     (plus:XF (mult:XF (match_dup 3) (match_dup 3))
3125
                              (match_dup 3)))
3126
                (use (const_int 1))]))
3127
   (cond_exec (ne (match_dup 5) (const_int 0))
3128
     (parallel [(set (match_dup 6)
3129
                     (plus:XF (mult:XF (match_dup 3) (match_dup 6))
3130
                              (match_dup 6)))
3131
                (use (const_int 1))]))
3132
   (cond_exec (ne (match_dup 5) (const_int 0))
3133
     (parallel [(set (match_dup 9)
3134
                     (float_truncate:SF
3135
                       (mult:XF (match_dup 7) (match_dup 6))))
3136
                (use (const_int 1))]))
3137
   (cond_exec (ne (match_dup 5) (const_int 0))
3138
     (parallel [(set (match_dup 4)
3139
                     (minus:XF (match_dup 7)
3140
                               (mult:XF (match_dup 8) (match_dup 3))))
3141
                (use (const_int 1))]))
3142
   (cond_exec (ne (match_dup 5) (const_int 0))
3143
     (set (match_dup 0)
3144
          (float_truncate:SF
3145
            (plus:XF (mult:XF (match_dup 4) (match_dup 6))
3146
                              (match_dup 3)))))
3147
  ]
3148
{
3149
  operands[6] = gen_rtx_REG (XFmode, REGNO (operands[0]));
3150
  operands[7] = gen_rtx_REG (XFmode, REGNO (operands[1]));
3151
  operands[8] = gen_rtx_REG (XFmode, REGNO (operands[2]));
3152
  operands[9] = gen_rtx_REG (SFmode, REGNO (operands[3]));
3153
  operands[10] = CONST1_RTX (XFmode);
3154
}
3155
  [(set_attr "predicable" "no")])
3156
 
3157
;; Inline square root.
3158
 
3159
(define_insn "*sqrt_approx"
3160
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3161
        (div:XF (const_int 1)
3162
                (sqrt:XF (match_operand:XF 2 "fr_register_operand" "f"))))
3163
   (set (match_operand:BI 1 "register_operand" "=c")
3164
        (unspec:BI [(match_dup 2)] UNSPEC_FR_SQRT_RECIP_APPROX))
3165
   (use (match_operand:SI 3 "const_int_operand" "")) ]
3166
  ""
3167
  "frsqrta.s%3 %0, %1 = %2"
3168
  [(set_attr "itanium_class" "fmisc")
3169
   (set_attr "predicable" "no")])
3170
 
3171
(define_insn "setf_exp_xf"
3172
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3173
        (unspec:XF [(match_operand:DI 1 "register_operand" "r")]
3174
                  UNSPEC_SETF_EXP))]
3175
  ""
3176
  "setf.exp %0 = %1"
3177
  [(set_attr "itanium_class" "frfr")])
3178
 
3179
(define_expand "sqrtsf2"
3180
  [(set (match_operand:SF 0 "fr_register_operand" "=&f")
3181
        (sqrt:SF (match_operand:SF 1 "fr_register_operand" "f")))]
3182
  "TARGET_INLINE_SQRT"
3183
{
3184
  rtx insn;
3185
#if 0
3186
  if (TARGET_INLINE_SQRT == INL_MIN_LAT)
3187
    insn = gen_sqrtsf2_internal_lat (operands[0], operands[1]);
3188
  else
3189
#else
3190
  gcc_assert (TARGET_INLINE_SQRT != INL_MIN_LAT);
3191
#endif
3192
  insn = gen_sqrtsf2_internal_thr (operands[0], operands[1]);
3193
  emit_insn (insn);
3194
  DONE;
3195
})
3196
 
3197
;; Latency-optimized square root.
3198
;; FIXME: Implement.
3199
 
3200
;; Throughput-optimized square root.
3201
 
3202
(define_insn_and_split "sqrtsf2_internal_thr"
3203
  [(set (match_operand:SF 0 "fr_register_operand" "=&f")
3204
        (sqrt:SF (match_operand:SF 1 "fr_register_operand" "f")))
3205
   ;; Register r2 in optimization guide.
3206
   (clobber (match_scratch:DI 2 "=r"))
3207
   ;; Register f8 in optimization guide
3208
   (clobber (match_scratch:XF 3 "=&f"))
3209
   ;; Register f9 in optimization guide
3210
   (clobber (match_scratch:XF 4 "=&f"))
3211
   ;; Register f10 in optimization guide
3212
   (clobber (match_scratch:XF 5 "=&f"))
3213
   ;; Register p6 in optimization guide.
3214
   (clobber (match_scratch:BI 6 "=c"))]
3215
  "TARGET_INLINE_SQRT == INL_MAX_THR"
3216
  "#"
3217
  "&& reload_completed"
3218
  [ ;; exponent of +1/2 in r2
3219
    (set (match_dup 2) (const_int 65534))
3220
    ;; +1/2 in f8
3221
    (set (match_dup 3)
3222
         (unspec:XF [(match_dup 2)] UNSPEC_SETF_EXP))
3223
    ;; Step 1
3224
    ;; y0 = 1/sqrt(a) in f7
3225
    (parallel [(set (match_dup 7)
3226
                    (div:XF (const_int 1)
3227
                            (sqrt:XF (match_dup 8))))
3228
               (set (match_dup 6)
3229
                    (unspec:BI [(match_dup 8)]
3230
                                 UNSPEC_FR_SQRT_RECIP_APPROX))
3231
               (use (const_int 0))])
3232
    ;; Step 2
3233
    ;; H0 = 1/2 * y0 in f9
3234
    (cond_exec (ne (match_dup 6) (const_int 0))
3235
      (parallel [(set (match_dup 4)
3236
                      (plus:XF (mult:XF (match_dup 3) (match_dup 7))
3237
                               (match_dup 9)))
3238
                 (use (const_int 1))]))
3239
    ;; Step 3
3240
    ;; S0 = a * y0 in f7
3241
    (cond_exec (ne (match_dup 6) (const_int 0))
3242
      (parallel [(set (match_dup 7)
3243
                      (plus:XF (mult:XF (match_dup 8) (match_dup 7))
3244
                               (match_dup 9)))
3245
                 (use (const_int 1))]))
3246
    ;; Step 4
3247
    ;; d = 1/2 - S0 * H0 in f10
3248
    (cond_exec (ne (match_dup 6) (const_int 0))
3249
      (parallel [(set (match_dup 5)
3250
                      (minus:XF (match_dup 3)
3251
                                (mult:XF (match_dup 7) (match_dup 4))))
3252
                 (use (const_int 1))]))
3253
    ;; Step 5
3254
    ;; d' = d + 1/2 * d in f8
3255
    (cond_exec (ne (match_dup 6) (const_int 0))
3256
       (parallel [(set (match_dup 3)
3257
                       (plus:XF (mult:XF (match_dup 3) (match_dup 5))
3258
                                (match_dup 5)))
3259
                  (use (const_int 1))]))
3260
    ;; Step 6
3261
    ;; e = d + d * d' in f8
3262
    (cond_exec (ne (match_dup 6) (const_int 0))
3263
       (parallel [(set (match_dup 3)
3264
                       (plus:XF (mult:XF (match_dup 5) (match_dup 3))
3265
                                (match_dup 5)))
3266
                  (use (const_int 1))]))
3267
    ;; Step 7
3268
    ;; S1 = S0 + e * S0 in f7
3269
    (cond_exec (ne (match_dup 6) (const_int 0))
3270
      (parallel [(set (match_dup 0)
3271
                      (float_truncate:SF
3272
                        (plus:XF (mult:XF (match_dup 3) (match_dup 7))
3273
                                 (match_dup 7))))
3274
                 (use (const_int 1))]))
3275
    ;; Step 8
3276
    ;; H1 = H0 + e * H0 in f8
3277
    (cond_exec (ne (match_dup 6) (const_int 0))
3278
       (parallel [(set (match_dup 3)
3279
                       (plus:XF (mult:XF (match_dup 3) (match_dup 4))
3280
                                (match_dup 4)))
3281
                  (use (const_int 1))]))
3282
    ;; Step 9
3283
    ;; d1 = a - S1 * S1 in f9
3284
    (cond_exec (ne (match_dup 6) (const_int 0))
3285
       (parallel [(set (match_dup 4)
3286
                       (minus:XF (match_dup 8)
3287
                                 (mult:XF (match_dup 7) (match_dup 7))))
3288
                  (use (const_int 1))]))
3289
    ;; Step 10
3290
    ;; S = S1 + d1 * H1 in f7
3291
    (cond_exec (ne (match_dup 6) (const_int 0))
3292
       (parallel [(set (match_dup 0)
3293
                       (float_truncate:SF
3294
                         (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3295
                                  (match_dup 7))))
3296
                  (use (const_int 0))]))]
3297
{
3298
  /* Generate 82-bit versions of the input and output operands.  */
3299
  operands[7] = gen_rtx_REG (XFmode, REGNO (operands[0]));
3300
  operands[8] = gen_rtx_REG (XFmode, REGNO (operands[1]));
3301
  /* Generate required floating-point constants.  */
3302
  operands[9] = CONST0_RTX (XFmode);
3303
}
3304
  [(set_attr "predicable" "no")])
3305
 
3306
;; ::::::::::::::::::::
3307
;; ::
3308
;; :: 64 bit floating point arithmetic
3309
;; ::
3310
;; ::::::::::::::::::::
3311
 
3312
(define_insn "adddf3"
3313
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3314
        (plus:DF (match_operand:DF 1 "fr_register_operand" "%f")
3315
                 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
3316
  ""
3317
  "fadd.d %0 = %1, %F2"
3318
  [(set_attr "itanium_class" "fmac")])
3319
 
3320
(define_insn "*adddf3_trunc"
3321
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3322
        (float_truncate:SF
3323
          (plus:DF (match_operand:DF 1 "fr_register_operand" "%f")
3324
                   (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG"))))]
3325
  ""
3326
  "fadd.s %0 = %1, %F2"
3327
  [(set_attr "itanium_class" "fmac")])
3328
 
3329
(define_insn "subdf3"
3330
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3331
        (minus:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
3332
                  (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
3333
  ""
3334
  "fsub.d %0 = %F1, %F2"
3335
  [(set_attr "itanium_class" "fmac")])
3336
 
3337
(define_insn "*subdf3_trunc"
3338
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3339
        (float_truncate:SF
3340
          (minus:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
3341
                    (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG"))))]
3342
  ""
3343
  "fsub.s %0 = %F1, %F2"
3344
  [(set_attr "itanium_class" "fmac")])
3345
 
3346
(define_insn "muldf3"
3347
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3348
        (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3349
                 (match_operand:DF 2 "fr_register_operand" "f")))]
3350
  ""
3351
  "fmpy.d %0 = %1, %2"
3352
  [(set_attr "itanium_class" "fmac")])
3353
 
3354
(define_insn "*muldf3_trunc"
3355
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3356
        (float_truncate:SF
3357
          (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3358
                   (match_operand:DF 2 "fr_register_operand" "f"))))]
3359
  ""
3360
  "fmpy.s %0 = %1, %2"
3361
  [(set_attr "itanium_class" "fmac")])
3362
 
3363
(define_insn "absdf2"
3364
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3365
        (abs:DF (match_operand:DF 1 "fr_register_operand" "f")))]
3366
  ""
3367
  "fabs %0 = %1"
3368
  [(set_attr "itanium_class" "fmisc")])
3369
 
3370
(define_insn "negdf2"
3371
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3372
        (neg:DF (match_operand:DF 1 "fr_register_operand" "f")))]
3373
  ""
3374
  "fneg %0 = %1"
3375
  [(set_attr "itanium_class" "fmisc")])
3376
 
3377
(define_insn "*nabsdf2"
3378
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3379
        (neg:DF (abs:DF (match_operand:DF 1 "fr_register_operand" "f"))))]
3380
  ""
3381
  "fnegabs %0 = %1"
3382
  [(set_attr "itanium_class" "fmisc")])
3383
 
3384
(define_insn "copysigndf3"
3385
  [(set (match_operand:DF 0 "register_operand" "=f")
3386
        (unspec:DF [(match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
3387
                    (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")]
3388
                   UNSPEC_COPYSIGN))]
3389
  ""
3390
  "fmerge.s %0 = %F2, %F1"
3391
  [(set_attr "itanium_class" "fmisc")])
3392
 
3393
(define_insn "*ncopysigndf3"
3394
  [(set (match_operand:DF 0 "register_operand" "=f")
3395
        (neg:DF (unspec:DF [(match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
3396
                            (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")]
3397
                           UNSPEC_COPYSIGN)))]
3398
  ""
3399
  "fmerge.ns %0 = %F2, %F1"
3400
  [(set_attr "itanium_class" "fmisc")])
3401
 
3402
(define_insn "smindf3"
3403
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3404
        (smin:DF (match_operand:DF 1 "fr_register_operand" "f")
3405
                 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
3406
  ""
3407
  "fmin %0 = %1, %F2"
3408
  [(set_attr "itanium_class" "fmisc")])
3409
 
3410
(define_insn "smaxdf3"
3411
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3412
        (smax:DF (match_operand:DF 1 "fr_register_operand" "f")
3413
                 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
3414
  ""
3415
  "fmax %0 = %1, %F2"
3416
  [(set_attr "itanium_class" "fmisc")])
3417
 
3418
(define_insn "*madddf4"
3419
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3420
        (plus:DF (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3421
                          (match_operand:DF 2 "fr_register_operand" "f"))
3422
                 (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")))]
3423
  ""
3424
  "fma.d %0 = %1, %2, %F3"
3425
  [(set_attr "itanium_class" "fmac")])
3426
 
3427
(define_insn "*madddf4_trunc"
3428
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3429
        (float_truncate:SF
3430
          (plus:DF (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3431
                            (match_operand:DF 2 "fr_register_operand" "f"))
3432
                   (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG"))))]
3433
  ""
3434
  "fma.s %0 = %1, %2, %F3"
3435
  [(set_attr "itanium_class" "fmac")])
3436
 
3437
(define_insn "*msubdf4"
3438
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3439
        (minus:DF (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3440
                           (match_operand:DF 2 "fr_register_operand" "f"))
3441
                  (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")))]
3442
  ""
3443
  "fms.d %0 = %1, %2, %F3"
3444
  [(set_attr "itanium_class" "fmac")])
3445
 
3446
(define_insn "*msubdf4_trunc"
3447
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3448
        (float_truncate:SF
3449
          (minus:DF (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3450
                             (match_operand:DF 2 "fr_register_operand" "f"))
3451
                    (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG"))))]
3452
  ""
3453
  "fms.s %0 = %1, %2, %F3"
3454
  [(set_attr "itanium_class" "fmac")])
3455
 
3456
(define_insn "*nmuldf3"
3457
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3458
        (neg:DF (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3459
                         (match_operand:DF 2 "fr_register_operand" "f"))))]
3460
  ""
3461
  "fnmpy.d %0 = %1, %2"
3462
  [(set_attr "itanium_class" "fmac")])
3463
 
3464
(define_insn "*nmuldf3_trunc"
3465
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3466
        (float_truncate:SF
3467
          (neg:DF (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3468
                           (match_operand:DF 2 "fr_register_operand" "f")))))]
3469
  ""
3470
  "fnmpy.s %0 = %1, %2"
3471
  [(set_attr "itanium_class" "fmac")])
3472
 
3473
(define_insn "*nmadddf4"
3474
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3475
        (minus:DF (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")
3476
                  (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3477
                           (match_operand:DF 2 "fr_register_operand" "f"))))]
3478
  ""
3479
  "fnma.d %0 = %1, %2, %F3"
3480
  [(set_attr "itanium_class" "fmac")])
3481
 
3482
(define_insn "*nmadddf4_alts"
3483
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3484
        (minus:DF (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")
3485
                  (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3486
                           (match_operand:DF 2 "fr_register_operand" "f"))))
3487
   (use (match_operand:SI 4 "const_int_operand" ""))]
3488
  ""
3489
  "fnma.d.s%4 %0 = %1, %2, %F3"
3490
  [(set_attr "itanium_class" "fmac")])
3491
 
3492
(define_insn "*nmadddf4_truncsf"
3493
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3494
        (float_truncate:SF
3495
        (minus:DF (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")
3496
                  (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3497
                           (match_operand:DF 2 "fr_register_operand" "f")))))]
3498
  ""
3499
  "fnma.s %0 = %1, %2, %F3"
3500
  [(set_attr "itanium_class" "fmac")])
3501
 
3502
(define_insn "*nmadddf4_truncsf_alts"
3503
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3504
        (float_truncate:SF
3505
        (minus:DF (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")
3506
                  (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3507
                           (match_operand:DF 2 "fr_register_operand" "f")))))
3508
   (use (match_operand:SI 4 "const_int_operand" ""))]
3509
  ""
3510
  "fnma.s.s%4 %0 = %1, %2, %F3"
3511
  [(set_attr "itanium_class" "fmac")])
3512
 
3513
(define_expand "divdf3"
3514
  [(set (match_operand:DF 0 "fr_register_operand" "")
3515
        (div:DF (match_operand:DF 1 "fr_register_operand" "")
3516
                (match_operand:DF 2 "fr_register_operand" "")))]
3517
  "TARGET_INLINE_FLOAT_DIV"
3518
{
3519
  rtx insn;
3520
  if (TARGET_INLINE_FLOAT_DIV == INL_MIN_LAT)
3521
    insn = gen_divdf3_internal_lat (operands[0], operands[1], operands[2]);
3522
  else
3523
    insn = gen_divdf3_internal_thr (operands[0], operands[1], operands[2]);
3524
  emit_insn (insn);
3525
  DONE;
3526
})
3527
 
3528
(define_insn_and_split "divdf3_internal_lat"
3529
  [(set (match_operand:DF 0 "fr_register_operand" "=&f")
3530
        (div:DF (match_operand:DF 1 "fr_register_operand" "f")
3531
                (match_operand:DF 2 "fr_register_operand" "f")))
3532
   (clobber (match_scratch:XF 3 "=&f"))
3533
   (clobber (match_scratch:XF 4 "=&f"))
3534
   (clobber (match_scratch:XF 5 "=&f"))
3535
   (clobber (match_scratch:BI 6 "=c"))]
3536
  "TARGET_INLINE_FLOAT_DIV == INL_MIN_LAT"
3537
  "#"
3538
  "&& reload_completed"
3539
  [(parallel [(set (match_dup 7) (div:XF (const_int 1) (match_dup 9)))
3540
              (set (match_dup 6) (unspec:BI [(match_dup 8) (match_dup 9)]
3541
                                            UNSPEC_FR_RECIP_APPROX))
3542
              (use (const_int 0))])
3543
   (cond_exec (ne (match_dup 6) (const_int 0))
3544
     (parallel [(set (match_dup 3) (mult:XF (match_dup 8) (match_dup 7)))
3545
                (use (const_int 1))]))
3546
   (cond_exec (ne (match_dup 6) (const_int 0))
3547
     (parallel [(set (match_dup 4)
3548
                     (minus:XF (match_dup 12)
3549
                               (mult:XF (match_dup 9) (match_dup 7))))
3550
                (use (const_int 1))]))
3551
   (cond_exec (ne (match_dup 6) (const_int 0))
3552
     (parallel [(set (match_dup 3)
3553
                     (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3554
                              (match_dup 3)))
3555
                (use (const_int 1))]))
3556
   (cond_exec (ne (match_dup 6) (const_int 0))
3557
     (parallel [(set (match_dup 5) (mult:XF (match_dup 4) (match_dup 4)))
3558
                (use (const_int 1))]))
3559
   (cond_exec (ne (match_dup 6) (const_int 0))
3560
     (parallel [(set (match_dup 7)
3561
                     (plus:XF (mult:XF (match_dup 4) (match_dup 7))
3562
                              (match_dup 7)))
3563
                (use (const_int 1))]))
3564
   (cond_exec (ne (match_dup 6) (const_int 0))
3565
     (parallel [(set (match_dup 3)
3566
                     (plus:XF (mult:XF (match_dup 5) (match_dup 3))
3567
                              (match_dup 3)))
3568
                (use (const_int 1))]))
3569
   (cond_exec (ne (match_dup 6) (const_int 0))
3570
     (parallel [(set (match_dup 4) (mult:XF (match_dup 5) (match_dup 5)))
3571
                (use (const_int 1))]))
3572
   (cond_exec (ne (match_dup 6) (const_int 0))
3573
     (parallel [(set (match_dup 7)
3574
                     (plus:XF (mult:XF (match_dup 5) (match_dup 7))
3575
                              (match_dup 7)))
3576
                (use (const_int 1))]))
3577
   (cond_exec (ne (match_dup 6) (const_int 0))
3578
     (parallel [(set (match_dup 10)
3579
                     (float_truncate:DF
3580
                       (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3581
                              (match_dup 3))))
3582
                (use (const_int 1))]))
3583
   (cond_exec (ne (match_dup 6) (const_int 0))
3584
     (parallel [(set (match_dup 7)
3585
                     (plus:XF (mult:XF (match_dup 4) (match_dup 7))
3586
                              (match_dup 7)))
3587
                (use (const_int 1))]))
3588
   (cond_exec (ne (match_dup 6) (const_int 0))
3589
     (parallel [(set (match_dup 11)
3590
                     (float_truncate:DF
3591
                       (minus:XF (match_dup 8)
3592
                                 (mult:XF (match_dup 9) (match_dup 3)))))
3593
                (use (const_int 1))]))
3594
   (cond_exec (ne (match_dup 6) (const_int 0))
3595
     (set (match_dup 0)
3596
          (float_truncate:DF (plus:XF (mult:XF (match_dup 5) (match_dup 7))
3597
                              (match_dup 3)))))
3598
  ]
3599
{
3600
  operands[7] = gen_rtx_REG (XFmode, REGNO (operands[0]));
3601
  operands[8] = gen_rtx_REG (XFmode, REGNO (operands[1]));
3602
  operands[9] = gen_rtx_REG (XFmode, REGNO (operands[2]));
3603
  operands[10] = gen_rtx_REG (DFmode, REGNO (operands[3]));
3604
  operands[11] = gen_rtx_REG (DFmode, REGNO (operands[5]));
3605
  operands[12] = CONST1_RTX (XFmode);
3606
}
3607
  [(set_attr "predicable" "no")])
3608
 
3609
(define_insn_and_split "divdf3_internal_thr"
3610
  [(set (match_operand:DF 0 "fr_register_operand" "=&f")
3611
        (div:DF (match_operand:DF 1 "fr_register_operand" "f")
3612
                (match_operand:DF 2 "fr_register_operand" "f")))
3613
   (clobber (match_scratch:XF 3 "=&f"))
3614
   (clobber (match_scratch:DF 4 "=f"))
3615
   (clobber (match_scratch:BI 5 "=c"))]
3616
  "TARGET_INLINE_FLOAT_DIV == INL_MAX_THR"
3617
  "#"
3618
  "&& reload_completed"
3619
  [(parallel [(set (match_dup 6) (div:XF (const_int 1) (match_dup 8)))
3620
              (set (match_dup 5) (unspec:BI [(match_dup 7) (match_dup 8)]
3621
                                            UNSPEC_FR_RECIP_APPROX))
3622
              (use (const_int 0))])
3623
   (cond_exec (ne (match_dup 5) (const_int 0))
3624
     (parallel [(set (match_dup 3)
3625
                     (minus:XF (match_dup 10)
3626
                               (mult:XF (match_dup 8) (match_dup 6))))
3627
                (use (const_int 1))]))
3628
   (cond_exec (ne (match_dup 5) (const_int 0))
3629
     (parallel [(set (match_dup 6)
3630
                     (plus:XF (mult:XF (match_dup 3) (match_dup 6))
3631
                              (match_dup 6)))
3632
                (use (const_int 1))]))
3633
   (cond_exec (ne (match_dup 5) (const_int 0))
3634
     (parallel [(set (match_dup 3)
3635
                     (mult:XF (match_dup 3) (match_dup 3)))
3636
                (use (const_int 1))]))
3637
   (cond_exec (ne (match_dup 5) (const_int 0))
3638
     (parallel [(set (match_dup 6)
3639
                     (plus:XF (mult:XF (match_dup 3) (match_dup 6))
3640
                              (match_dup 6)))
3641
                (use (const_int 1))]))
3642
   (cond_exec (ne (match_dup 5) (const_int 0))
3643
     (parallel [(set (match_dup 3)
3644
                     (mult:XF (match_dup 3) (match_dup 3)))
3645
                (use (const_int 1))]))
3646
   (cond_exec (ne (match_dup 5) (const_int 0))
3647
     (parallel [(set (match_dup 6)
3648
                     (plus:XF (mult:XF (match_dup 3) (match_dup 6))
3649
                              (match_dup 6)))
3650
                (use (const_int 1))]))
3651
   (cond_exec (ne (match_dup 5) (const_int 0))
3652
     (parallel [(set (match_dup 9)
3653
                     (float_truncate:DF
3654
                       (mult:XF (match_dup 7) (match_dup 6))))
3655
                (use (const_int 1))]))
3656
   (cond_exec (ne (match_dup 5) (const_int 0))
3657
     (parallel [(set (match_dup 4)
3658
                     (minus:DF (match_dup 1)
3659
                               (mult:DF (match_dup 2) (match_dup 9))))
3660
                (use (const_int 1))]))
3661
   (cond_exec (ne (match_dup 5) (const_int 0))
3662
     (set (match_dup 0)
3663
          (plus:DF (mult:DF (match_dup 4) (match_dup 0))
3664
                            (match_dup 9))))
3665
  ]
3666
{
3667
  operands[6] = gen_rtx_REG (XFmode, REGNO (operands[0]));
3668
  operands[7] = gen_rtx_REG (XFmode, REGNO (operands[1]));
3669
  operands[8] = gen_rtx_REG (XFmode, REGNO (operands[2]));
3670
  operands[9] = gen_rtx_REG (DFmode, REGNO (operands[3]));
3671
  operands[10] = CONST1_RTX (XFmode);
3672
}
3673
  [(set_attr "predicable" "no")])
3674
 
3675
;; Inline square root.
3676
 
3677
(define_expand "sqrtdf2"
3678
  [(set (match_operand:DF 0 "fr_register_operand" "=&f")
3679
        (sqrt:DF (match_operand:DF 1 "fr_register_operand" "f")))]
3680
  "TARGET_INLINE_SQRT"
3681
{
3682
  rtx insn;
3683
#if 0
3684
  if (TARGET_INLINE_SQRT == INL_MIN_LAT)
3685
    insn = gen_sqrtdf2_internal_lat (operands[0], operands[1]);
3686
  else
3687
#else
3688
  gcc_assert (TARGET_INLINE_SQRT != INL_MIN_LAT);
3689
#endif
3690
  insn = gen_sqrtdf2_internal_thr (operands[0], operands[1]);
3691
  emit_insn (insn);
3692
  DONE;
3693
})
3694
 
3695
;; Latency-optimized square root.
3696
;; FIXME: Implement.
3697
 
3698
;; Throughput-optimized square root.
3699
 
3700
(define_insn_and_split "sqrtdf2_internal_thr"
3701
  [(set (match_operand:DF 0 "fr_register_operand" "=&f")
3702
        (sqrt:DF (match_operand:DF 1 "fr_register_operand" "f")))
3703
   ;; Register r2 in optimization guide.
3704
   (clobber (match_scratch:DI 2 "=r"))
3705
   ;; Register f8 in optimization guide
3706
   (clobber (match_scratch:XF 3 "=&f"))
3707
   ;; Register f9 in optimization guide
3708
   (clobber (match_scratch:XF 4 "=&f"))
3709
   ;; Register f10 in optimization guide
3710
   (clobber (match_scratch:XF 5 "=&f"))
3711
   ;; Register p6 in optimization guide.
3712
   (clobber (match_scratch:BI 6 "=c"))]
3713
  "TARGET_INLINE_SQRT == INL_MAX_THR"
3714
  "#"
3715
  "&& reload_completed"
3716
  [ ;; exponent of +1/2 in r2
3717
    (set (match_dup 2) (const_int 65534))
3718
    ;; +1/2 in f10
3719
    (set (match_dup 5)
3720
         (unspec:XF [(match_dup 2)] UNSPEC_SETF_EXP))
3721
    ;; Step 1
3722
    ;; y0 = 1/sqrt(a) in f7
3723
    (parallel [(set (match_dup 7)
3724
                    (div:XF (const_int 1)
3725
                            (sqrt:XF (match_dup 8))))
3726
               (set (match_dup 6)
3727
                    (unspec:BI [(match_dup 8)]
3728
                                 UNSPEC_FR_SQRT_RECIP_APPROX))
3729
               (use (const_int 0))])
3730
    ;; Step 2
3731
    ;; H0 = 1/2 * y0 in f8
3732
    (cond_exec (ne (match_dup 6) (const_int 0))
3733
      (parallel [(set (match_dup 3)
3734
                      (plus:XF (mult:XF (match_dup 5) (match_dup 7))
3735
                               (match_dup 9)))
3736
                 (use (const_int 1))]))
3737
    ;; Step 3
3738
    ;; G0 = a * y0 in f7
3739
    (cond_exec (ne (match_dup 6) (const_int 0))
3740
      (parallel [(set (match_dup 7)
3741
                      (plus:XF (mult:XF (match_dup 8) (match_dup 7))
3742
                               (match_dup 9)))
3743
                 (use (const_int 1))]))
3744
    ;; Step 4
3745
    ;; r0 = 1/2 - G0 * H0 in f9
3746
    (cond_exec (ne (match_dup 6) (const_int 0))
3747
      (parallel [(set (match_dup 4)
3748
                      (minus:XF (match_dup 5)
3749
                                (mult:XF (match_dup 7) (match_dup 3))))
3750
                 (use (const_int 1))]))
3751
    ;; Step 5
3752
    ;; H1 = H0 + r0 * H0 in f8
3753
    (cond_exec (ne (match_dup 6) (const_int 0))
3754
       (parallel [(set (match_dup 3)
3755
                       (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3756
                                (match_dup 3)))
3757
                  (use (const_int 1))]))
3758
    ;; Step 6
3759
    ;; G1 = G0 + r0 * G0 in f7
3760
    (cond_exec (ne (match_dup 6) (const_int 0))
3761
       (parallel [(set (match_dup 7)
3762
                       (plus:XF (mult:XF (match_dup 4) (match_dup 7))
3763
                                (match_dup 7)))
3764
                  (use (const_int 1))]))
3765
    ;; Step 7
3766
    ;; r1 = 1/2 - G1 * H1 in f9
3767
    (cond_exec (ne (match_dup 6) (const_int 0))
3768
      (parallel [(set (match_dup 4)
3769
                      (minus:XF (match_dup 5)
3770
                                (mult:XF (match_dup 7) (match_dup 3))))
3771
                 (use (const_int 1))]))
3772
    ;; Step 8
3773
    ;; H2 = H1 + r1 * H1 in f8
3774
    (cond_exec (ne (match_dup 6) (const_int 0))
3775
       (parallel [(set (match_dup 3)
3776
                       (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3777
                                (match_dup 3)))
3778
                  (use (const_int 1))]))
3779
    ;; Step 9
3780
    ;; G2 = G1 + r1 * G1 in f7
3781
    (cond_exec (ne (match_dup 6) (const_int 0))
3782
       (parallel [(set (match_dup 7)
3783
                       (plus:XF (mult:XF (match_dup 4) (match_dup 7))
3784
                                (match_dup 7)))
3785
                  (use (const_int 1))]))
3786
    ;; Step 10
3787
    ;; d2 = a - G2 * G2 in f9
3788
    (cond_exec (ne (match_dup 6) (const_int 0))
3789
       (parallel [(set (match_dup 4)
3790
                       (minus:XF (match_dup 8)
3791
                                 (mult:XF (match_dup 7) (match_dup 7))))
3792
                  (use (const_int 1))]))
3793
    ;; Step 11
3794
    ;; G3 = G2 + d2 * H2 in f7
3795
    (cond_exec (ne (match_dup 6) (const_int 0))
3796
       (parallel [(set (match_dup 7)
3797
                       (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3798
                                (match_dup 7)))
3799
                  (use (const_int 1))]))
3800
    ;; Step 12
3801
    ;; d3 = a - G3 * G3 in f9
3802
    (cond_exec (ne (match_dup 6) (const_int 0))
3803
       (parallel [(set (match_dup 4)
3804
                       (minus:XF (match_dup 8)
3805
                                 (mult:XF (match_dup 7) (match_dup 7))))
3806
                  (use (const_int 1))]))
3807
    ;; Step 13
3808
    ;; S = G3 + d3 * H2 in f7
3809
    (cond_exec (ne (match_dup 6) (const_int 0))
3810
       (parallel [(set (match_dup 0)
3811
                       (float_truncate:DF
3812
                         (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3813
                                  (match_dup 7))))
3814
                  (use (const_int 0))]))]
3815
{
3816
  /* Generate 82-bit versions of the input and output operands.  */
3817
  operands[7] = gen_rtx_REG (XFmode, REGNO (operands[0]));
3818
  operands[8] = gen_rtx_REG (XFmode, REGNO (operands[1]));
3819
  /* Generate required floating-point constants.  */
3820
  operands[9] = CONST0_RTX (XFmode);
3821
}
3822
  [(set_attr "predicable" "no")])
3823
 
3824
;; ::::::::::::::::::::
3825
;; ::
3826
;; :: 80 bit floating point arithmetic
3827
;; ::
3828
;; ::::::::::::::::::::
3829
 
3830
(define_insn "addxf3"
3831
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3832
        (plus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3833
                 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3834
  ""
3835
  "fadd %0 = %F1, %F2"
3836
  [(set_attr "itanium_class" "fmac")])
3837
 
3838
(define_insn "*addxf3_truncsf"
3839
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3840
        (float_truncate:SF
3841
          (plus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3842
                   (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3843
  ""
3844
  "fadd.s %0 = %F1, %F2"
3845
  [(set_attr "itanium_class" "fmac")])
3846
 
3847
(define_insn "*addxf3_truncdf"
3848
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3849
        (float_truncate:DF
3850
          (plus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3851
                   (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3852
  ""
3853
  "fadd.d %0 = %F1, %F2"
3854
  [(set_attr "itanium_class" "fmac")])
3855
 
3856
(define_insn "subxf3"
3857
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3858
        (minus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3859
                  (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3860
  ""
3861
  "fsub %0 = %F1, %F2"
3862
  [(set_attr "itanium_class" "fmac")])
3863
 
3864
(define_insn "*subxf3_truncsf"
3865
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3866
        (float_truncate:SF
3867
          (minus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3868
                    (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3869
  ""
3870
  "fsub.s %0 = %F1, %F2"
3871
  [(set_attr "itanium_class" "fmac")])
3872
 
3873
(define_insn "*subxf3_truncdf"
3874
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3875
        (float_truncate:DF
3876
          (minus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3877
                    (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3878
  ""
3879
  "fsub.d %0 = %F1, %F2"
3880
  [(set_attr "itanium_class" "fmac")])
3881
 
3882
(define_insn "mulxf3"
3883
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3884
        (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3885
                 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3886
  ""
3887
  "fmpy %0 = %F1, %F2"
3888
  [(set_attr "itanium_class" "fmac")])
3889
 
3890
(define_insn "*mulxf3_truncsf"
3891
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3892
        (float_truncate:SF
3893
          (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3894
                   (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3895
  ""
3896
  "fmpy.s %0 = %F1, %F2"
3897
  [(set_attr "itanium_class" "fmac")])
3898
 
3899
(define_insn "*mulxf3_truncdf"
3900
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3901
        (float_truncate:DF
3902
          (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3903
                   (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3904
  ""
3905
  "fmpy.d %0 = %F1, %F2"
3906
  [(set_attr "itanium_class" "fmac")])
3907
 
3908
(define_insn "*mulxf3_alts"
3909
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3910
        (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3911
                 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))
3912
   (use (match_operand:SI 3 "const_int_operand" ""))]
3913
  ""
3914
  "fmpy.s%3 %0 = %F1, %F2"
3915
  [(set_attr "itanium_class" "fmac")])
3916
 
3917
(define_insn "*mulxf3_truncsf_alts"
3918
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
3919
        (float_truncate:SF
3920
          (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3921
                   (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))
3922
   (use (match_operand:SI 3 "const_int_operand" ""))]
3923
  ""
3924
  "fmpy.s.s%3 %0 = %F1, %F2"
3925
  [(set_attr "itanium_class" "fmac")])
3926
 
3927
(define_insn "*mulxf3_truncdf_alts"
3928
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
3929
        (float_truncate:DF
3930
          (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3931
                   (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))
3932
   (use (match_operand:SI 3 "const_int_operand" ""))]
3933
  ""
3934
  "fmpy.d.s%3 %0 = %F1, %F2"
3935
  [(set_attr "itanium_class" "fmac")])
3936
 
3937
(define_insn "absxf2"
3938
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3939
        (abs:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")))]
3940
  ""
3941
  "fabs %0 = %F1"
3942
  [(set_attr "itanium_class" "fmisc")])
3943
 
3944
(define_insn "negxf2"
3945
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3946
        (neg:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")))]
3947
  ""
3948
  "fneg %0 = %F1"
3949
  [(set_attr "itanium_class" "fmisc")])
3950
 
3951
(define_insn "*nabsxf2"
3952
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3953
        (neg:XF (abs:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG"))))]
3954
  ""
3955
  "fnegabs %0 = %F1"
3956
  [(set_attr "itanium_class" "fmisc")])
3957
 
3958
(define_insn "copysignxf3"
3959
  [(set (match_operand:XF 0 "register_operand" "=f")
3960
        (unspec:XF [(match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
3961
                    (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")]
3962
                   UNSPEC_COPYSIGN))]
3963
  ""
3964
  "fmerge.s %0 = %F2, %F1"
3965
  [(set_attr "itanium_class" "fmisc")])
3966
 
3967
(define_insn "*ncopysignxf3"
3968
  [(set (match_operand:XF 0 "register_operand" "=f")
3969
        (neg:XF (unspec:XF [(match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
3970
                            (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")]
3971
                           UNSPEC_COPYSIGN)))]
3972
  ""
3973
  "fmerge.ns %0 = %F2, %F1"
3974
  [(set_attr "itanium_class" "fmisc")])
3975
 
3976
(define_insn "sminxf3"
3977
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3978
        (smin:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3979
                 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3980
  ""
3981
  "fmin %0 = %F1, %F2"
3982
  [(set_attr "itanium_class" "fmisc")])
3983
 
3984
(define_insn "smaxxf3"
3985
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3986
        (smax:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3987
                 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3988
  ""
3989
  "fmax %0 = %F1, %F2"
3990
  [(set_attr "itanium_class" "fmisc")])
3991
 
3992
(define_insn "*maddxf4"
3993
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
3994
        (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3995
                          (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
3996
                 (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")))]
3997
  ""
3998
  "fma %0 = %F1, %F2, %F3"
3999
  [(set_attr "itanium_class" "fmac")])
4000
 
4001
(define_insn "*maddxf4_truncsf"
4002
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
4003
        (float_truncate:SF
4004
          (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4005
                            (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
4006
                   (match_operand:XF 3 "xfreg_or_fp01_operand" "fG"))))]
4007
  ""
4008
  "fma.s %0 = %F1, %F2, %F3"
4009
  [(set_attr "itanium_class" "fmac")])
4010
 
4011
(define_insn "*maddxf4_truncdf"
4012
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
4013
        (float_truncate:DF
4014
          (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4015
                            (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
4016
                   (match_operand:XF 3 "xfreg_or_fp01_operand" "fG"))))]
4017
  ""
4018
  "fma.d %0 = %F1, %F2, %F3"
4019
  [(set_attr "itanium_class" "fmac")])
4020
 
4021
(define_insn "*maddxf4_alts"
4022
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
4023
        (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4024
                          (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
4025
                 (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")))
4026
   (use (match_operand:SI 4 "const_int_operand" ""))]
4027
  ""
4028
  "fma.s%4 %0 = %F1, %F2, %F3"
4029
  [(set_attr "itanium_class" "fmac")])
4030
 
4031
(define_insn "*maddxf4_alts_truncsf"
4032
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
4033
        (float_truncate:SF
4034
          (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4035
                            (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
4036
                   (match_operand:XF 3 "xfreg_or_fp01_operand" "fG"))))
4037
   (use (match_operand:SI 4 "const_int_operand" ""))]
4038
  ""
4039
  "fma.s.s%4 %0 = %F1, %F2, %F3"
4040
  [(set_attr "itanium_class" "fmac")])
4041
 
4042
(define_insn "*maddxf4_alts_truncdf"
4043
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
4044
        (float_truncate:DF
4045
          (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4046
                            (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
4047
                   (match_operand:XF 3 "xfreg_or_fp01_operand" "fG"))))
4048
   (use (match_operand:SI 4 "const_int_operand" ""))]
4049
  ""
4050
  "fma.d.s%4 %0 = %F1, %F2, %F3"
4051
  [(set_attr "itanium_class" "fmac")])
4052
 
4053
(define_insn "*msubxf4"
4054
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
4055
        (minus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4056
                           (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
4057
                  (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")))]
4058
  ""
4059
  "fms %0 = %F1, %F2, %F3"
4060
  [(set_attr "itanium_class" "fmac")])
4061
 
4062
(define_insn "*msubxf4_truncsf"
4063
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
4064
        (float_truncate:SF
4065
          (minus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4066
                             (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
4067
                    (match_operand:XF 3 "xfreg_or_fp01_operand" "fG"))))]
4068
  ""
4069
  "fms.s %0 = %F1, %F2, %F3"
4070
  [(set_attr "itanium_class" "fmac")])
4071
 
4072
(define_insn "*msubxf4_truncdf"
4073
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
4074
        (float_truncate:DF
4075
          (minus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4076
                             (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
4077
                    (match_operand:XF 3 "xfreg_or_fp01_operand" "fG"))))]
4078
  ""
4079
  "fms.d %0 = %F1, %F2, %F3"
4080
  [(set_attr "itanium_class" "fmac")])
4081
 
4082
(define_insn "*nmulxf3"
4083
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
4084
        (neg:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4085
                         (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
4086
  ""
4087
  "fnmpy %0 = %F1, %F2"
4088
  [(set_attr "itanium_class" "fmac")])
4089
 
4090
(define_insn "*nmulxf3_truncsf"
4091
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
4092
        (float_truncate:SF
4093
          (neg:XF (mult:XF
4094
                    (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4095
                    (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))))]
4096
  ""
4097
  "fnmpy.s %0 = %F1, %F2"
4098
  [(set_attr "itanium_class" "fmac")])
4099
 
4100
(define_insn "*nmulxf3_truncdf"
4101
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
4102
        (float_truncate:DF
4103
          (neg:XF (mult:XF
4104
                    (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4105
                    (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))))]
4106
  ""
4107
  "fnmpy.d %0 = %F1, %F2"
4108
  [(set_attr "itanium_class" "fmac")])
4109
 
4110
(define_insn "*nmaddxf4"
4111
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
4112
        (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")
4113
                  (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4114
                           (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
4115
   )))]
4116
  ""
4117
  "fnma %0 = %F1, %F2, %F3"
4118
  [(set_attr "itanium_class" "fmac")])
4119
 
4120
(define_insn "*nmaddxf4_truncsf"
4121
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
4122
        (float_truncate:SF
4123
          (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")
4124
                    (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4125
                             (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
4126
   ))))]
4127
  ""
4128
  "fnma.s %0 = %F1, %F2, %F3"
4129
  [(set_attr "itanium_class" "fmac")])
4130
 
4131
(define_insn "*nmaddxf4_truncdf"
4132
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
4133
        (float_truncate:DF
4134
          (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")
4135
                    (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4136
                             (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
4137
   ))))]
4138
  ""
4139
  "fnma.d %0 = %F1, %F2, %F3"
4140
  [(set_attr "itanium_class" "fmac")])
4141
 
4142
(define_insn "*nmaddxf4_alts"
4143
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
4144
        (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")
4145
                  (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4146
                           (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
4147
   )))
4148
   (use (match_operand:SI 4 "const_int_operand" ""))]
4149
  ""
4150
  "fnma.s%4 %0 = %F1, %F2, %F3"
4151
  [(set_attr "itanium_class" "fmac")])
4152
 
4153
(define_insn "*nmaddxf4_truncsf_alts"
4154
  [(set (match_operand:SF 0 "fr_register_operand" "=f")
4155
        (float_truncate:SF
4156
          (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")
4157
                    (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4158
                             (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
4159
   ))))
4160
   (use (match_operand:SI 4 "const_int_operand" ""))]
4161
  ""
4162
  "fnma.s.s%4 %0 = %F1, %F2, %F3"
4163
  [(set_attr "itanium_class" "fmac")])
4164
 
4165
(define_insn "*nmaddxf4_truncdf_alts"
4166
  [(set (match_operand:DF 0 "fr_register_operand" "=f")
4167
        (float_truncate:DF
4168
          (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")
4169
                    (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4170
                             (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
4171
   ))))
4172
   (use (match_operand:SI 4 "const_int_operand" ""))]
4173
  ""
4174
  "fnma.d.s%4 %0 = %F1, %F2, %F3"
4175
  [(set_attr "itanium_class" "fmac")])
4176
 
4177
(define_expand "divxf3"
4178
  [(set (match_operand:XF 0 "fr_register_operand" "")
4179
        (div:XF (match_operand:XF 1 "fr_register_operand" "")
4180
                (match_operand:XF 2 "fr_register_operand" "")))]
4181
  "TARGET_INLINE_FLOAT_DIV"
4182
{
4183
  rtx insn;
4184
  if (TARGET_INLINE_FLOAT_DIV == INL_MIN_LAT)
4185
    insn = gen_divxf3_internal_lat (operands[0], operands[1], operands[2]);
4186
  else
4187
    insn = gen_divxf3_internal_thr (operands[0], operands[1], operands[2]);
4188
  emit_insn (insn);
4189
  DONE;
4190
})
4191
 
4192
(define_insn_and_split "divxf3_internal_lat"
4193
  [(set (match_operand:XF 0 "fr_register_operand" "=&f")
4194
        (div:XF (match_operand:XF 1 "fr_register_operand" "f")
4195
                (match_operand:XF 2 "fr_register_operand" "f")))
4196
   (clobber (match_scratch:XF 3 "=&f"))
4197
   (clobber (match_scratch:XF 4 "=&f"))
4198
   (clobber (match_scratch:XF 5 "=&f"))
4199
   (clobber (match_scratch:XF 6 "=&f"))
4200
   (clobber (match_scratch:BI 7 "=c"))]
4201
  "TARGET_INLINE_FLOAT_DIV == INL_MIN_LAT"
4202
  "#"
4203
  "&& reload_completed"
4204
  [(parallel [(set (match_dup 0) (div:XF (const_int 1) (match_dup 2)))
4205
              (set (match_dup 7) (unspec:BI [(match_dup 1) (match_dup 2)]
4206
                                            UNSPEC_FR_RECIP_APPROX))
4207
              (use (const_int 0))])
4208
   (cond_exec (ne (match_dup 7) (const_int 0))
4209
     (parallel [(set (match_dup 3)
4210
                     (minus:XF (match_dup 8)
4211
                               (mult:XF (match_dup 2) (match_dup 0))))
4212
                (use (const_int 1))]))
4213
   (cond_exec (ne (match_dup 7) (const_int 0))
4214
     (parallel [(set (match_dup 4) (mult:XF (match_dup 1) (match_dup 0)))
4215
                (use (const_int 1))]))
4216
   (cond_exec (ne (match_dup 7) (const_int 0))
4217
     (parallel [(set (match_dup 5) (mult:XF (match_dup 3) (match_dup 3)))
4218
                (use (const_int 1))]))
4219
   (cond_exec (ne (match_dup 7) (const_int 0))
4220
     (parallel [(set (match_dup 6)
4221
                     (plus:XF (mult:XF (match_dup 3) (match_dup 3))
4222
                              (match_dup 3)))
4223
                (use (const_int 1))]))
4224
   (cond_exec (ne (match_dup 7) (const_int 0))
4225
     (parallel [(set (match_dup 3)
4226
                     (plus:XF (mult:XF (match_dup 5) (match_dup 5))
4227
                              (match_dup 3)))
4228
                (use (const_int 1))]))
4229
   (cond_exec (ne (match_dup 7) (const_int 0))
4230
     (parallel [(set (match_dup 5)
4231
                     (plus:XF (mult:XF (match_dup 6) (match_dup 0))
4232
                              (match_dup 0)))
4233
                (use (const_int 1))]))
4234
   (cond_exec (ne (match_dup 7) (const_int 0))
4235
     (parallel [(set (match_dup 0)
4236
                     (plus:XF (mult:XF (match_dup 5) (match_dup 3))
4237
                              (match_dup 0)))
4238
                (use (const_int 1))]))
4239
   (cond_exec (ne (match_dup 7) (const_int 0))
4240
     (parallel [(set (match_dup 4)
4241
                     (minus:XF (match_dup 1)
4242
                               (mult:XF (match_dup 2) (match_dup 4))))
4243
                (use (const_int 1))]))
4244
   (cond_exec (ne (match_dup 7) (const_int 0))
4245
     (parallel [(set (match_dup 3)
4246
                     (plus:XF (mult:XF (match_dup 3) (match_dup 0))
4247
                              (match_dup 4)))
4248
                (use (const_int 1))]))
4249
   (cond_exec (ne (match_dup 7) (const_int 0))
4250
     (parallel [(set (match_dup 5)
4251
                     (minus:XF (match_dup 8)
4252
                               (mult:XF (match_dup 2) (match_dup 0))))
4253
                (use (const_int 1))]))
4254
   (cond_exec (ne (match_dup 7) (const_int 0))
4255
     (parallel [(set (match_dup 0)
4256
                     (plus:XF (mult:XF (match_dup 4) (match_dup 0))
4257
                              (match_dup 0)))
4258
                (use (const_int 1))]))
4259
   (cond_exec (ne (match_dup 7) (const_int 0))
4260
     (parallel [(set (match_dup 4)
4261
                     (minus:XF (match_dup 1)
4262
                               (mult:XF (match_dup 2) (match_dup 3))))
4263
                (use (const_int 1))]))
4264
   (cond_exec (ne (match_dup 7) (const_int 0))
4265
     (set (match_dup 0)
4266
          (plus:XF (mult:XF (match_dup 4) (match_dup 0))
4267
                   (match_dup 3))))
4268
  ]
4269
  "operands[8] = CONST1_RTX (XFmode);"
4270
  [(set_attr "predicable" "no")])
4271
 
4272
(define_insn_and_split "divxf3_internal_thr"
4273
  [(set (match_operand:XF 0 "fr_register_operand" "=&f")
4274
        (div:XF (match_operand:XF 1 "fr_register_operand" "f")
4275
                (match_operand:XF 2 "fr_register_operand" "f")))
4276
   (clobber (match_scratch:XF 3 "=&f"))
4277
   (clobber (match_scratch:XF 4 "=&f"))
4278
   (clobber (match_scratch:BI 5 "=c"))]
4279
  "TARGET_INLINE_FLOAT_DIV == INL_MAX_THR"
4280
  "#"
4281
  "&& reload_completed"
4282
  [(parallel [(set (match_dup 0) (div:XF (const_int 1) (match_dup 2)))
4283
              (set (match_dup 5) (unspec:BI [(match_dup 1) (match_dup 2)]
4284
                                            UNSPEC_FR_RECIP_APPROX))
4285
              (use (const_int 0))])
4286
   (cond_exec (ne (match_dup 5) (const_int 0))
4287
     (parallel [(set (match_dup 3)
4288
                     (minus:XF (match_dup 6)
4289
                               (mult:XF (match_dup 2) (match_dup 0))))
4290
                (use (const_int 1))]))
4291
   (cond_exec (ne (match_dup 5) (const_int 0))
4292
     (parallel [(set (match_dup 4)
4293
                     (plus:XF (mult:XF (match_dup 3) (match_dup 0))
4294
                              (match_dup 0)))
4295
                (use (const_int 1))]))
4296
   (cond_exec (ne (match_dup 5) (const_int 0))
4297
     (parallel [(set (match_dup 3) (mult:XF (match_dup 3) (match_dup 3)))
4298
                (use (const_int 1))]))
4299
   (cond_exec (ne (match_dup 5) (const_int 0))
4300
     (parallel [(set (match_dup 3)
4301
                     (plus:XF (mult:XF (match_dup 3) (match_dup 4))
4302
                              (match_dup 4)))
4303
                (use (const_int 1))]))
4304
   (cond_exec (ne (match_dup 5) (const_int 0))
4305
     (parallel [(set (match_dup 4) (mult:XF (match_dup 1) (match_dup 0)))
4306
                (use (const_int 1))]))
4307
   (cond_exec (ne (match_dup 5) (const_int 0))
4308
     (parallel [(set (match_dup 0)
4309
                     (minus:XF (match_dup 6)
4310
                               (mult:XF (match_dup 2) (match_dup 3))))
4311
                (use (const_int 1))]))
4312
   (cond_exec (ne (match_dup 5) (const_int 0))
4313
     (parallel [(set (match_dup 0)
4314
                     (plus:XF (mult:XF (match_dup 0) (match_dup 3))
4315
                              (match_dup 3)))
4316
                (use (const_int 1))]))
4317
   (cond_exec (ne (match_dup 5) (const_int 0))
4318
     (parallel [(set (match_dup 3)
4319
                     (minus:XF (match_dup 1)
4320
                               (mult:XF (match_dup 2) (match_dup 4))))
4321
                (use (const_int 1))]))
4322
   (cond_exec (ne (match_dup 5) (const_int 0))
4323
     (parallel [(set (match_dup 3)
4324
                     (plus:XF (mult:XF (match_dup 3) (match_dup 0))
4325
                              (match_dup 4)))
4326
                (use (const_int 1))]))
4327
   (cond_exec (ne (match_dup 5) (const_int 0))
4328
     (parallel [(set (match_dup 4)
4329
                     (minus:XF (match_dup 6)
4330
                               (mult:XF (match_dup 2) (match_dup 0))))
4331
                (use (const_int 1))]))
4332
   (cond_exec (ne (match_dup 5) (const_int 0))
4333
     (parallel [(set (match_dup 0)
4334
                     (plus:XF (mult:XF (match_dup 4) (match_dup 0))
4335
                              (match_dup 0)))
4336
                (use (const_int 1))]))
4337
   (cond_exec (ne (match_dup 5) (const_int 0))
4338
     (parallel [(set (match_dup 4)
4339
                     (minus:XF (match_dup 1)
4340
                               (mult:XF (match_dup 2) (match_dup 3))))
4341
                (use (const_int 1))]))
4342
   (cond_exec (ne (match_dup 5) (const_int 0))
4343
     (set (match_dup 0)
4344
          (plus:XF (mult:XF (match_dup 4) (match_dup 0))
4345
                   (match_dup 3))))
4346
  ]
4347
  "operands[6] = CONST1_RTX (XFmode);"
4348
  [(set_attr "predicable" "no")])
4349
 
4350
;; Inline square root.
4351
 
4352
(define_expand "sqrtxf2"
4353
  [(set (match_operand:XF 0 "fr_register_operand" "=&f")
4354
        (sqrt:XF (match_operand:XF 1 "fr_register_operand" "f")))]
4355
  "TARGET_INLINE_SQRT"
4356
{
4357
  rtx insn;
4358
#if 0
4359
  if (TARGET_INLINE_SQRT == INL_MIN_LAT)
4360
    insn = gen_sqrtxf2_internal_lat (operands[0], operands[1]);
4361
  else
4362
#else
4363
  gcc_assert (TARGET_INLINE_SQRT != INL_MIN_LAT);
4364
#endif
4365
  insn = gen_sqrtxf2_internal_thr (operands[0], operands[1]);
4366
  emit_insn (insn);
4367
  DONE;
4368
})
4369
 
4370
;; Latency-optimized square root.
4371
;; FIXME: Implement.
4372
 
4373
;; Throughput-optimized square root.
4374
 
4375
(define_insn_and_split "sqrtxf2_internal_thr"
4376
  [(set (match_operand:XF 0 "fr_register_operand" "=&f")
4377
        (sqrt:XF (match_operand:XF 1 "fr_register_operand" "f")))
4378
   ;; Register r2 in optimization guide.
4379
   (clobber (match_scratch:DI 2 "=r"))
4380
   ;; Register f8 in optimization guide
4381
   (clobber (match_scratch:XF 3 "=&f"))
4382
   ;; Register f9 in optimization guide
4383
   (clobber (match_scratch:XF 4 "=&f"))
4384
   ;; Register f10 in optimization guide
4385
   (clobber (match_scratch:XF 5 "=&f"))
4386
   ;; Register f11 in optimization guide
4387
   (clobber (match_scratch:XF 6 "=&f"))
4388
   ;; Register p6 in optimization guide.
4389
   (clobber (match_scratch:BI 7 "=c"))]
4390
  "TARGET_INLINE_SQRT == INL_MAX_THR"
4391
  "#"
4392
  "&& reload_completed"
4393
  [ ;; exponent of +1/2 in r2
4394
    (set (match_dup 2) (const_int 65534))
4395
    ;; +1/2 in f8.  The Intel manual mistakenly specifies f10.
4396
    (set (match_dup 3)
4397
         (unspec:XF [(match_dup 2)] UNSPEC_SETF_EXP))
4398
    ;; Step 1
4399
    ;; y0 = 1/sqrt(a) in f7
4400
    (parallel [(set (match_dup 8)
4401
                    (div:XF (const_int 1)
4402
                            (sqrt:XF (match_dup 9))))
4403
               (set (match_dup 7)
4404
                    (unspec:BI [(match_dup 9)]
4405
                                 UNSPEC_FR_SQRT_RECIP_APPROX))
4406
               (use (const_int 0))])
4407
    ;; Step 2
4408
    ;; H0 = 1/2 * y0 in f9
4409
    (cond_exec (ne (match_dup 7) (const_int 0))
4410
      (parallel [(set (match_dup 4)
4411
                      (plus:XF (mult:XF (match_dup 3) (match_dup 8))
4412
                               (match_dup 10)))
4413
                 (use (const_int 1))]))
4414
    ;; Step 3
4415
    ;; S0 = a * y0 in f7
4416
    (cond_exec (ne (match_dup 7) (const_int 0))
4417
      (parallel [(set (match_dup 8)
4418
                      (plus:XF (mult:XF (match_dup 9) (match_dup 8))
4419
                               (match_dup 10)))
4420
                 (use (const_int 1))]))
4421
    ;; Step 4
4422
    ;; d0 = 1/2 - S0 * H0 in f10
4423
    (cond_exec (ne (match_dup 7) (const_int 0))
4424
      (parallel [(set (match_dup 5)
4425
                      (minus:XF (match_dup 3)
4426
                                (mult:XF (match_dup 8) (match_dup 4))))
4427
                 (use (const_int 1))]))
4428
    ;; Step 5
4429
    ;; H1 = H0 + d0 * H0 in f9
4430
    (cond_exec (ne (match_dup 7) (const_int 0))
4431
       (parallel [(set (match_dup 4)
4432
                       (plus:XF (mult:XF (match_dup 5) (match_dup 4))
4433
                                (match_dup 4)))
4434
                  (use (const_int 1))]))
4435
    ;; Step 6
4436
    ;; S1 = S0 + d0 * S0 in f7
4437
    (cond_exec (ne (match_dup 7) (const_int 0))
4438
       (parallel [(set (match_dup 8)
4439
                       (plus:XF (mult:XF (match_dup 5) (match_dup 8))
4440
                                (match_dup 8)))
4441
                  (use (const_int 1))]))
4442
    ;; Step 7
4443
    ;; d1 = 1/2 - S1 * H1 in f10
4444
    (cond_exec (ne (match_dup 7) (const_int 0))
4445
      (parallel [(set (match_dup 5)
4446
                      (minus:XF (match_dup 3)
4447
                                (mult:XF (match_dup 8) (match_dup 4))))
4448
                 (use (const_int 1))]))
4449
    ;; Step 8
4450
    ;; H2 = H1 + d1 * H1 in f9
4451
    (cond_exec (ne (match_dup 7) (const_int 0))
4452
       (parallel [(set (match_dup 4)
4453
                       (plus:XF (mult:XF (match_dup 5) (match_dup 4))
4454
                                (match_dup 4)))
4455
                  (use (const_int 1))]))
4456
    ;; Step 9
4457
    ;; S2 = S1 + d1 * S1 in f7
4458
    (cond_exec (ne (match_dup 7) (const_int 0))
4459
       (parallel [(set (match_dup 8)
4460
                       (plus:XF (mult:XF (match_dup 5) (match_dup 8))
4461
                                (match_dup 8)))
4462
                  (use (const_int 1))]))
4463
    ;; Step 10
4464
    ;; d2 = 1/2 - S2 * H2 in f10
4465
    (cond_exec (ne (match_dup 7) (const_int 0))
4466
       (parallel [(set (match_dup 5)
4467
                       (minus:XF (match_dup 3)
4468
                                 (mult:XF (match_dup 8) (match_dup 4))))
4469
                  (use (const_int 1))]))
4470
    ;; Step 11
4471
    ;; e2 = a - S2 * S2 in f8
4472
    (cond_exec (ne (match_dup 7) (const_int 0))
4473
       (parallel [(set (match_dup 3)
4474
                       (minus:XF (match_dup 9)
4475
                                 (mult:XF (match_dup 8) (match_dup 8))))
4476
                  (use (const_int 1))]))
4477
    ;; Step 12
4478
    ;; S3 = S2 + e2 * H2 in f7
4479
    (cond_exec (ne (match_dup 7) (const_int 0))
4480
       (parallel [(set (match_dup 8)
4481
                       (plus:XF (mult:XF (match_dup 3) (match_dup 4))
4482
                                (match_dup 8)))
4483
                  (use (const_int 1))]))
4484
    ;; Step 13
4485
    ;; H3 = H2 + d2 * H2 in f9
4486
    (cond_exec (ne (match_dup 7) (const_int 0))
4487
       (parallel [(set (match_dup 4)
4488
                       (plus:XF (mult:XF (match_dup 5) (match_dup 4))
4489
                                (match_dup 4)))
4490
                  (use (const_int 1))]))
4491
    ;; Step 14
4492
    ;; e3 = a - S3 * S3 in f8
4493
    (cond_exec (ne (match_dup 7) (const_int 0))
4494
       (parallel [(set (match_dup 3)
4495
                       (minus:XF (match_dup 9)
4496
                                 (mult:XF (match_dup 8) (match_dup 8))))
4497
                  (use (const_int 1))]))
4498
    ;; Step 15
4499
    ;; S = S3 + e3 * H3 in f7
4500
    (cond_exec (ne (match_dup 7) (const_int 0))
4501
       (parallel [(set (match_dup 0)
4502
                       (plus:XF (mult:XF (match_dup 3) (match_dup 4))
4503
                                (match_dup 8)))
4504
                  (use (const_int 0))]))]
4505
{
4506
  /* Generate 82-bit versions of the input and output operands.  */
4507
  operands[8] = gen_rtx_REG (XFmode, REGNO (operands[0]));
4508
  operands[9] = gen_rtx_REG (XFmode, REGNO (operands[1]));
4509
  /* Generate required floating-point constants.  */
4510
  operands[10] = CONST0_RTX (XFmode);
4511
}
4512
  [(set_attr "predicable" "no")])
4513
 
4514
;; ??? frcpa works like cmp.foo.unc.
4515
 
4516
(define_insn "*recip_approx"
4517
  [(set (match_operand:XF 0 "fr_register_operand" "=f")
4518
        (div:XF (const_int 1)
4519
                (match_operand:XF 3 "fr_register_operand" "f")))
4520
   (set (match_operand:BI 1 "register_operand" "=c")
4521
        (unspec:BI [(match_operand:XF 2 "fr_register_operand" "f")
4522
                    (match_dup 3)] UNSPEC_FR_RECIP_APPROX))
4523
   (use (match_operand:SI 4 "const_int_operand" ""))]
4524
  ""
4525
  "frcpa.s%4 %0, %1 = %2, %3"
4526
  [(set_attr "itanium_class" "fmisc")
4527
   (set_attr "predicable" "no")])
4528
 
4529
;; ::::::::::::::::::::
4530
;; ::
4531
;; :: 32 bit Integer Shifts and Rotates
4532
;; ::
4533
;; ::::::::::::::::::::
4534
 
4535
(define_expand "ashlsi3"
4536
  [(set (match_operand:SI 0 "gr_register_operand" "")
4537
        (ashift:SI (match_operand:SI 1 "gr_register_operand" "")
4538
                   (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
4539
  ""
4540
{
4541
  if (GET_CODE (operands[2]) != CONST_INT)
4542
    {
4543
      /* Why oh why didn't Intel arrange for SHIFT_COUNT_TRUNCATED?  Now
4544
         we've got to get rid of stray bits outside the SImode register.  */
4545
      rtx subshift = gen_reg_rtx (DImode);
4546
      emit_insn (gen_zero_extendsidi2 (subshift, operands[2]));
4547
      operands[2] = subshift;
4548
    }
4549
})
4550
 
4551
(define_insn "*ashlsi3_internal"
4552
  [(set (match_operand:SI 0 "gr_register_operand" "=r,r,r")
4553
        (ashift:SI (match_operand:SI 1 "gr_register_operand" "r,r,r")
4554
                   (match_operand:DI 2 "gr_reg_or_5bit_operand" "R,n,r")))]
4555
  ""
4556
  "@
4557
   shladd %0 = %1, %2, r0
4558
   dep.z %0 = %1, %2, %E2
4559
   shl %0 = %1, %2"
4560
  [(set_attr "itanium_class" "ialu,ishf,mmshf")])
4561
 
4562
(define_expand "ashrsi3"
4563
  [(set (match_operand:SI 0 "gr_register_operand" "")
4564
        (ashiftrt:SI (match_operand:SI 1 "gr_register_operand" "")
4565
                     (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
4566
  ""
4567
{
4568
  rtx subtarget = gen_reg_rtx (DImode);
4569
  if (GET_CODE (operands[2]) == CONST_INT)
4570
    emit_insn (gen_extv (subtarget, gen_lowpart (DImode, operands[1]),
4571
                         GEN_INT (32 - INTVAL (operands[2])), operands[2]));
4572
  else
4573
    {
4574
      rtx subshift = gen_reg_rtx (DImode);
4575
      emit_insn (gen_extendsidi2 (subtarget, operands[1]));
4576
      emit_insn (gen_zero_extendsidi2 (subshift, operands[2]));
4577
      emit_insn (gen_ashrdi3 (subtarget, subtarget, subshift));
4578
    }
4579
  emit_move_insn (gen_lowpart (DImode, operands[0]), subtarget);
4580
  DONE;
4581
})
4582
 
4583
(define_expand "lshrsi3"
4584
  [(set (match_operand:SI 0 "gr_register_operand" "")
4585
        (lshiftrt:SI (match_operand:SI 1 "gr_register_operand" "")
4586
                     (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
4587
  ""
4588
{
4589
  rtx subtarget = gen_reg_rtx (DImode);
4590
  if (GET_CODE (operands[2]) == CONST_INT)
4591
    emit_insn (gen_extzv (subtarget, gen_lowpart (DImode, operands[1]),
4592
                          GEN_INT (32 - INTVAL (operands[2])), operands[2]));
4593
  else
4594
    {
4595
      rtx subshift = gen_reg_rtx (DImode);
4596
      emit_insn (gen_zero_extendsidi2 (subtarget, operands[1]));
4597
      emit_insn (gen_zero_extendsidi2 (subshift, operands[2]));
4598
      emit_insn (gen_lshrdi3 (subtarget, subtarget, subshift));
4599
    }
4600
  emit_move_insn (gen_lowpart (DImode, operands[0]), subtarget);
4601
  DONE;
4602
})
4603
 
4604
;; Use mix4.r/shr to implement rotrsi3.  We only get 32 bits of valid result
4605
;; here, instead of 64 like the patterns above.  Keep the pattern together
4606
;; until after combine; otherwise it won't get matched often.
4607
 
4608
(define_expand "rotrsi3"
4609
  [(set (match_operand:SI 0 "gr_register_operand" "")
4610
        (rotatert:SI (match_operand:SI 1 "gr_register_operand" "")
4611
                     (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
4612
  ""
4613
{
4614
  if (GET_MODE (operands[2]) != VOIDmode)
4615
    {
4616
      rtx tmp = gen_reg_rtx (DImode);
4617
      emit_insn (gen_zero_extendsidi2 (tmp, operands[2]));
4618
      operands[2] = tmp;
4619
    }
4620
})
4621
 
4622
(define_insn_and_split "*rotrsi3_internal"
4623
  [(set (match_operand:SI 0 "gr_register_operand" "=&r")
4624
        (rotatert:SI (match_operand:SI 1 "gr_register_operand" "r")
4625
                     (match_operand:DI 2 "gr_reg_or_5bit_operand" "rM")))]
4626
  ""
4627
  "#"
4628
  "reload_completed"
4629
  [(set (match_dup 3)
4630
        (ior:DI (zero_extend:DI (match_dup 1))
4631
                (ashift:DI (zero_extend:DI (match_dup 1)) (const_int 32))))
4632
   (set (match_dup 3)
4633
        (lshiftrt:DI (match_dup 3) (match_dup 2)))]
4634
  "operands[3] = gen_rtx_REG (DImode, REGNO (operands[0]));")
4635
 
4636
(define_expand "rotlsi3"
4637
  [(set (match_operand:SI 0 "gr_register_operand" "")
4638
        (rotate:SI (match_operand:SI 1 "gr_register_operand" "")
4639
                   (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
4640
  ""
4641
{
4642
  if (! shift_32bit_count_operand (operands[2], SImode))
4643
    {
4644
      rtx tmp = gen_reg_rtx (SImode);
4645
      emit_insn (gen_subsi3 (tmp, GEN_INT (32), operands[2]));
4646
      emit_insn (gen_rotrsi3 (operands[0], operands[1], tmp));
4647
      DONE;
4648
    }
4649
})
4650
 
4651
(define_insn_and_split "*rotlsi3_internal"
4652
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
4653
        (rotate:SI (match_operand:SI 1 "gr_register_operand" "r")
4654
                   (match_operand:SI 2 "shift_32bit_count_operand" "n")))]
4655
  ""
4656
  "mux2 %0 = %1, 0xe1"
4657
  "reload_completed && INTVAL (operands[2]) != 16"
4658
  [(set (match_dup 3)
4659
        (ior:DI (zero_extend:DI (match_dup 1))
4660
                (ashift:DI (zero_extend:DI (match_dup 1)) (const_int 32))))
4661
   (set (match_dup 3)
4662
        (lshiftrt:DI (match_dup 3) (match_dup 2)))]
4663
{
4664
  operands[3] = gen_rtx_REG (DImode, REGNO (operands[0]));
4665
  operands[2] = GEN_INT (32 - INTVAL (operands[2]));
4666
}
4667
  [(set_attr "itanium_class" "mmshf")])
4668
 
4669
;; ::::::::::::::::::::
4670
;; ::
4671
;; :: 64 bit Integer Shifts and Rotates
4672
;; ::
4673
;; ::::::::::::::::::::
4674
 
4675
(define_insn "ashldi3"
4676
  [(set (match_operand:DI 0 "gr_register_operand" "=r,r,r")
4677
        (ashift:DI (match_operand:DI 1 "gr_register_operand" "r,r,r")
4678
                   (match_operand:DI 2 "gr_reg_or_6bit_operand" "R,r,rM")))]
4679
  ""
4680
  "@
4681
   shladd %0 = %1, %2, r0
4682
   shl %0 = %1, %2
4683
   shl %0 = %1, %2"
4684
  [(set_attr "itanium_class" "ialu,mmshf,mmshfi")])
4685
 
4686
;; ??? Maybe combine this with the multiply and add instruction?
4687
 
4688
(define_insn "*shladd"
4689
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
4690
        (plus:DI (mult:DI (match_operand:DI 1 "gr_register_operand" "r")
4691
                          (match_operand:DI 2 "shladd_operand" "n"))
4692
                 (match_operand:DI 3 "gr_register_operand" "r")))]
4693
  ""
4694
  "shladd %0 = %1, %S2, %3"
4695
  [(set_attr "itanium_class" "ialu")])
4696
 
4697
;; This can be created by register elimination if operand3 of shladd is an
4698
;; eliminable register or has reg_equiv_constant set.
4699
 
4700
;; We have to use nonmemory_operand for operand 4, to ensure that the
4701
;; validate_changes call inside eliminate_regs will always succeed.  If it
4702
;; doesn't succeed, then this remain a shladd pattern, and will be reloaded
4703
;; incorrectly.
4704
 
4705
(define_insn_and_split "*shladd_elim"
4706
  [(set (match_operand:DI 0 "gr_register_operand" "=&r")
4707
        (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "gr_register_operand" "r")
4708
                                   (match_operand:DI 2 "shladd_operand" "n"))
4709
                          (match_operand:DI 3 "nonmemory_operand" "r"))
4710
                 (match_operand:DI 4 "nonmemory_operand" "rI")))]
4711
  "reload_in_progress"
4712
  "* gcc_unreachable ();"
4713
  "reload_completed"
4714
  [(set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (match_dup 2))
4715
                               (match_dup 3)))
4716
   (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
4717
  ""
4718
  [(set_attr "itanium_class" "unknown")])
4719
 
4720
(define_insn "ashrdi3"
4721
  [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
4722
        (ashiftrt:DI (match_operand:DI 1 "gr_register_operand" "r,r")
4723
                     (match_operand:DI 2 "gr_reg_or_6bit_operand" "r,rM")))]
4724
  ""
4725
  "@
4726
   shr %0 = %1, %2
4727
   shr %0 = %1, %2"
4728
  [(set_attr "itanium_class" "mmshf,mmshfi")])
4729
 
4730
(define_insn "lshrdi3"
4731
  [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
4732
        (lshiftrt:DI (match_operand:DI 1 "gr_register_operand" "r,r")
4733
                     (match_operand:DI 2 "gr_reg_or_6bit_operand" "r,rM")))]
4734
  ""
4735
  "@
4736
   shr.u %0 = %1, %2
4737
   shr.u %0 = %1, %2"
4738
  [(set_attr "itanium_class" "mmshf,mmshfi")])
4739
 
4740
;; Using a predicate that accepts only constants doesn't work, because optabs
4741
;; will load the operand into a register and call the pattern if the predicate
4742
;; did not accept it on the first try.  So we use nonmemory_operand and then
4743
;; verify that we have an appropriate constant in the expander.
4744
 
4745
(define_expand "rotrdi3"
4746
  [(set (match_operand:DI 0 "gr_register_operand" "")
4747
        (rotatert:DI (match_operand:DI 1 "gr_register_operand" "")
4748
                     (match_operand:DI 2 "nonmemory_operand" "")))]
4749
  ""
4750
{
4751
  if (! shift_count_operand (operands[2], DImode))
4752
    FAIL;
4753
})
4754
 
4755
(define_insn "*rotrdi3_internal"
4756
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
4757
        (rotatert:DI (match_operand:DI 1 "gr_register_operand" "r")
4758
                     (match_operand:DI 2 "shift_count_operand" "M")))]
4759
  ""
4760
  "shrp %0 = %1, %1, %2"
4761
  [(set_attr "itanium_class" "ishf")])
4762
 
4763
(define_expand "rotldi3"
4764
  [(set (match_operand:DI 0 "gr_register_operand" "")
4765
        (rotate:DI (match_operand:DI 1 "gr_register_operand" "")
4766
                   (match_operand:DI 2 "nonmemory_operand" "")))]
4767
  ""
4768
{
4769
  if (! shift_count_operand (operands[2], DImode))
4770
    FAIL;
4771
})
4772
 
4773
(define_insn "*rotldi3_internal"
4774
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
4775
        (rotate:DI (match_operand:DI 1 "gr_register_operand" "r")
4776
                   (match_operand:DI 2 "shift_count_operand" "M")))]
4777
  ""
4778
  "shrp %0 = %1, %1, %e2"
4779
  [(set_attr "itanium_class" "ishf")])
4780
 
4781
;; ::::::::::::::::::::
4782
;; ::
4783
;; :: 128 bit Integer Shifts and Rotates
4784
;; ::
4785
;; ::::::::::::::::::::
4786
 
4787
(define_expand "ashlti3"
4788
  [(set (match_operand:TI 0 "gr_register_operand" "")
4789
        (ashift:TI (match_operand:TI 1 "gr_register_operand" "")
4790
                   (match_operand:DI 2 "nonmemory_operand" "")))]
4791
  ""
4792
{
4793
  if (!dshift_count_operand (operands[2], DImode))
4794
    FAIL;
4795
})
4796
 
4797
(define_insn_and_split "*ashlti3_internal"
4798
  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
4799
        (ashift:TI (match_operand:TI 1 "gr_register_operand" "r")
4800
                   (match_operand:DI 2 "dshift_count_operand" "n")))]
4801
  ""
4802
  "#"
4803
  "reload_completed"
4804
  [(const_int 0)]
4805
{
4806
  HOST_WIDE_INT shift = INTVAL (operands[2]);
4807
  rtx rl = gen_lowpart (DImode, operands[0]);
4808
  rtx rh = gen_highpart (DImode, operands[0]);
4809
  rtx lo = gen_lowpart (DImode, operands[1]);
4810
  rtx shiftlo = GEN_INT (shift & 63);
4811
 
4812
  if (shift & 64)
4813
    {
4814
      emit_move_insn (rl, const0_rtx);
4815
      if (shift & 63)
4816
        emit_insn (gen_ashldi3 (rh, lo, shiftlo));
4817
      else
4818
        emit_move_insn (rh, lo);
4819
    }
4820
  else
4821
    {
4822
      rtx hi = gen_highpart (DImode, operands[1]);
4823
 
4824
      emit_insn (gen_shrp (rh, hi, lo, GEN_INT (-shift & 63)));
4825
      emit_insn (gen_ashldi3 (rl, lo, shiftlo));
4826
    }
4827
  DONE;
4828
})
4829
 
4830
(define_expand "ashrti3"
4831
  [(set (match_operand:TI 0 "gr_register_operand" "")
4832
        (ashiftrt:TI (match_operand:TI 1 "gr_register_operand" "")
4833
                     (match_operand:DI 2 "nonmemory_operand" "")))]
4834
  ""
4835
{
4836
  if (!dshift_count_operand (operands[2], DImode))
4837
    FAIL;
4838
})
4839
 
4840
(define_insn_and_split "*ashrti3_internal"
4841
  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
4842
        (ashiftrt:TI (match_operand:TI 1 "gr_register_operand" "r")
4843
                     (match_operand:DI 2 "dshift_count_operand" "n")))]
4844
  ""
4845
  "#"
4846
  "reload_completed"
4847
  [(const_int 0)]
4848
{
4849
  HOST_WIDE_INT shift = INTVAL (operands[2]);
4850
  rtx rl = gen_lowpart (DImode, operands[0]);
4851
  rtx rh = gen_highpart (DImode, operands[0]);
4852
  rtx hi = gen_highpart (DImode, operands[1]);
4853
  rtx shiftlo = GEN_INT (shift & 63);
4854
 
4855
  if (shift & 64)
4856
    {
4857
      if (shift & 63)
4858
        emit_insn (gen_ashrdi3 (rl, hi, shiftlo));
4859
      else
4860
        emit_move_insn (rl, hi);
4861
      emit_insn (gen_ashrdi3 (rh, hi, GEN_INT (63)));
4862
    }
4863
  else
4864
    {
4865
      rtx lo = gen_lowpart (DImode, operands[1]);
4866
 
4867
      emit_insn (gen_shrp (rl, hi, lo, shiftlo));
4868
      emit_insn (gen_ashrdi3 (rh, hi, shiftlo));
4869
    }
4870
  DONE;
4871
})
4872
 
4873
(define_expand "lshrti3"
4874
  [(set (match_operand:TI 0 "gr_register_operand" "")
4875
        (lshiftrt:TI (match_operand:TI 1 "gr_register_operand" "")
4876
                     (match_operand:DI 2 "nonmemory_operand" "")))]
4877
  ""
4878
{
4879
  if (!dshift_count_operand (operands[2], DImode))
4880
    FAIL;
4881
})
4882
 
4883
(define_insn_and_split "*lshrti3_internal"
4884
  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
4885
        (lshiftrt:TI (match_operand:TI 1 "gr_register_operand" "r")
4886
                     (match_operand:DI 2 "dshift_count_operand" "n")))]
4887
  ""
4888
  "#"
4889
  "reload_completed"
4890
  [(const_int 0)]
4891
{
4892
  HOST_WIDE_INT shift = INTVAL (operands[2]);
4893
  rtx rl = gen_lowpart (DImode, operands[0]);
4894
  rtx rh = gen_highpart (DImode, operands[0]);
4895
  rtx hi = gen_highpart (DImode, operands[1]);
4896
  rtx shiftlo = GEN_INT (shift & 63);
4897
 
4898
  if (shift & 64)
4899
    {
4900
      if (shift & 63)
4901
        emit_insn (gen_lshrdi3 (rl, hi, shiftlo));
4902
      else
4903
        emit_move_insn (rl, hi);
4904
      emit_move_insn (rh, const0_rtx);
4905
    }
4906
  else
4907
    {
4908
      rtx lo = gen_lowpart (DImode, operands[1]);
4909
 
4910
      emit_insn (gen_shrp (rl, hi, lo, shiftlo));
4911
      emit_insn (gen_lshrdi3 (rh, hi, shiftlo));
4912
    }
4913
  DONE;
4914
})
4915
 
4916
(define_expand "rotlti3"
4917
  [(set (match_operand:TI 0 "gr_register_operand" "")
4918
        (rotate:TI (match_operand:TI 1 "gr_register_operand" "")
4919
                   (match_operand:DI 2 "nonmemory_operand" "")))]
4920
  ""
4921
{
4922
  if (! dshift_count_operand (operands[2], DImode))
4923
    FAIL;
4924
})
4925
 
4926
(define_insn_and_split "*rotlti3_internal"
4927
  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
4928
        (rotate:TI (match_operand:TI 1 "gr_register_operand" "r")
4929
                   (match_operand:DI 2 "dshift_count_operand" "n")))]
4930
  ""
4931
  "#"
4932
  "reload_completed"
4933
  [(const_int 0)]
4934
{
4935
  HOST_WIDE_INT count = INTVAL (operands[2]);
4936
  rtx rl = gen_lowpart (DImode, operands[0]);
4937
  rtx rh = gen_highpart (DImode, operands[0]);
4938
  rtx lo = gen_lowpart (DImode, operands[1]);
4939
  rtx hi = gen_highpart (DImode, operands[1]);
4940
  rtx countlo = GEN_INT (-count & 63);
4941
 
4942
  if (count & 64)
4943
    {
4944
      if (count & 63)
4945
        {
4946
          emit_insn (gen_shrp (rl, hi, lo, countlo));
4947
          emit_insn (gen_shrp (rh, lo, hi, countlo));
4948
        }
4949
      else
4950
        {
4951
          emit_move_insn (rl, hi);
4952
          emit_move_insn (rh, lo);
4953
        }
4954
    }
4955
  else
4956
    {
4957
      emit_insn (gen_shrp (rl, lo, hi, countlo));
4958
      emit_insn (gen_shrp (rh, hi, lo, countlo));
4959
    }
4960
  DONE;
4961
}
4962
  [(set_attr "itanium_class" "unknown")])
4963
 
4964
(define_insn "shrp"
4965
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
4966
        (unspec:DI [(match_operand:DI 1 "gr_register_operand" "r")
4967
                    (match_operand:DI 2 "gr_register_operand" "r")
4968
                    (match_operand:DI 3 "shift_count_operand" "M")]
4969
                   UNSPEC_SHRP))]
4970
  ""
4971
  "shrp %0 = %1, %2, %3"
4972
  [(set_attr "itanium_class" "ishf")])
4973
 
4974
;; ::::::::::::::::::::
4975
;; ::
4976
;; :: 32 bit Integer Logical operations
4977
;; ::
4978
;; ::::::::::::::::::::
4979
 
4980
;; We don't seem to need any other 32-bit logical operations, because gcc
4981
;; generates zero-extend;zero-extend;DImode-op, which combine optimizes to
4982
;; DImode-op;zero-extend, and then we can optimize away the zero-extend.
4983
;; This doesn't work for unary logical operations, because we don't call
4984
;; apply_distributive_law for them.
4985
 
4986
;; ??? Likewise, this doesn't work for andnot, which isn't handled by
4987
;; apply_distributive_law.  We get inefficient code for
4988
;; int sub4 (int i, int j) { return i & ~j; }
4989
;; We could convert (and (not (sign_extend A)) (sign_extend B)) to
4990
;; (zero_extend (and (not A) B)) in combine.
4991
;; Or maybe fix this by adding andsi3/iorsi3/xorsi3 patterns like the
4992
;; one_cmplsi2 pattern.
4993
 
4994
(define_insn "one_cmplsi2"
4995
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
4996
        (not:SI (match_operand:SI 1 "gr_register_operand" "r")))]
4997
  ""
4998
  "andcm %0 = -1, %1"
4999
  [(set_attr "itanium_class" "ilog")])
5000
 
5001
;; ::::::::::::::::::::
5002
;; ::
5003
;; :: 64 bit Integer Logical operations
5004
;; ::
5005
;; ::::::::::::::::::::
5006
 
5007
(define_insn "anddi3"
5008
  [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
5009
        (and:DI (match_operand:DI 1 "grfr_register_operand" "%r,*f")
5010
                (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
5011
  ""
5012
  "@
5013
   and %0 = %2, %1
5014
   fand %0 = %2, %1"
5015
  [(set_attr "itanium_class" "ilog,fmisc")])
5016
 
5017
(define_insn "*andnot"
5018
  [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
5019
        (and:DI (not:DI (match_operand:DI 1 "grfr_register_operand" "r,*f"))
5020
                (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
5021
  ""
5022
  "@
5023
   andcm %0 = %2, %1
5024
   fandcm %0 = %2, %1"
5025
  [(set_attr "itanium_class" "ilog,fmisc")])
5026
 
5027
(define_insn "iordi3"
5028
  [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
5029
        (ior:DI (match_operand:DI 1 "grfr_register_operand" "%r,*f")
5030
                (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
5031
  ""
5032
  "@
5033
   or %0 = %2, %1
5034
   for %0 = %2, %1"
5035
  [(set_attr "itanium_class" "ilog,fmisc")])
5036
 
5037
(define_insn "xordi3"
5038
  [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
5039
        (xor:DI (match_operand:DI 1 "grfr_register_operand" "%r,*f")
5040
                (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
5041
  ""
5042
  "@
5043
   xor %0 = %2, %1
5044
   fxor %0 = %2, %1"
5045
  [(set_attr "itanium_class" "ilog,fmisc")])
5046
 
5047
(define_insn "one_cmpldi2"
5048
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
5049
        (not:DI (match_operand:DI 1 "gr_register_operand" "r")))]
5050
  ""
5051
  "andcm %0 = -1, %1"
5052
  [(set_attr "itanium_class" "ilog")])
5053
 
5054
;; ::::::::::::::::::::
5055
;; ::
5056
;; :: Comparisons
5057
;; ::
5058
;; ::::::::::::::::::::
5059
 
5060
(define_expand "cmpbi"
5061
  [(set (cc0)
5062
        (compare (match_operand:BI 0 "register_operand" "")
5063
                 (match_operand:BI 1 "const_int_operand" "")))]
5064
  ""
5065
{
5066
  ia64_compare_op0 = operands[0];
5067
  ia64_compare_op1 = operands[1];
5068
  DONE;
5069
})
5070
 
5071
(define_expand "cmpsi"
5072
  [(set (cc0)
5073
        (compare (match_operand:SI 0 "gr_register_operand" "")
5074
                 (match_operand:SI 1 "gr_reg_or_8bit_and_adjusted_operand" "")))]
5075
  ""
5076
{
5077
  ia64_compare_op0 = operands[0];
5078
  ia64_compare_op1 = operands[1];
5079
  DONE;
5080
})
5081
 
5082
(define_expand "cmpdi"
5083
  [(set (cc0)
5084
        (compare (match_operand:DI 0 "gr_register_operand" "")
5085
                 (match_operand:DI 1 "gr_reg_or_8bit_and_adjusted_operand" "")))]
5086
  ""
5087
{
5088
  ia64_compare_op0 = operands[0];
5089
  ia64_compare_op1 = operands[1];
5090
  DONE;
5091
})
5092
 
5093
(define_expand "cmpsf"
5094
  [(set (cc0)
5095
        (compare (match_operand:SF 0 "fr_reg_or_fp01_operand" "")
5096
                 (match_operand:SF 1 "fr_reg_or_fp01_operand" "")))]
5097
  ""
5098
{
5099
  ia64_compare_op0 = operands[0];
5100
  ia64_compare_op1 = operands[1];
5101
  DONE;
5102
})
5103
 
5104
(define_expand "cmpdf"
5105
  [(set (cc0)
5106
        (compare (match_operand:DF 0 "fr_reg_or_fp01_operand" "")
5107
                 (match_operand:DF 1 "fr_reg_or_fp01_operand" "")))]
5108
  ""
5109
{
5110
  ia64_compare_op0 = operands[0];
5111
  ia64_compare_op1 = operands[1];
5112
  DONE;
5113
})
5114
 
5115
(define_expand "cmpxf"
5116
  [(set (cc0)
5117
        (compare (match_operand:XF 0 "xfreg_or_fp01_operand" "")
5118
                 (match_operand:XF 1 "xfreg_or_fp01_operand" "")))]
5119
  ""
5120
{
5121
  ia64_compare_op0 = operands[0];
5122
  ia64_compare_op1 = operands[1];
5123
  DONE;
5124
})
5125
 
5126
(define_expand "cmptf"
5127
  [(set (cc0)
5128
        (compare (match_operand:TF 0 "gr_register_operand" "")
5129
                 (match_operand:TF 1 "gr_register_operand" "")))]
5130
  "TARGET_HPUX"
5131
{
5132
  ia64_compare_op0 = operands[0];
5133
  ia64_compare_op1 = operands[1];
5134
  DONE;
5135
})
5136
 
5137
(define_insn "*cmpsi_normal"
5138
  [(set (match_operand:BI 0 "register_operand" "=c")
5139
        (match_operator:BI 1 "normal_comparison_operator"
5140
           [(match_operand:SI 2 "gr_register_operand" "r")
5141
            (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")]))]
5142
  ""
5143
  "cmp4.%C1 %0, %I0 = %3, %2"
5144
  [(set_attr "itanium_class" "icmp")])
5145
 
5146
;; We use %r3 because it is possible for us to match a 0, and two of the
5147
;; unsigned comparisons don't accept immediate operands of zero.
5148
 
5149
(define_insn "*cmpsi_adjusted"
5150
  [(set (match_operand:BI 0 "register_operand" "=c")
5151
        (match_operator:BI 1 "adjusted_comparison_operator"
5152
           [(match_operand:SI 2 "gr_register_operand" "r")
5153
            (match_operand:SI 3 "gr_reg_or_8bit_adjusted_operand" "rL")]))]
5154
  ""
5155
  "cmp4.%C1 %0, %I0 = %r3, %2"
5156
  [(set_attr "itanium_class" "icmp")])
5157
 
5158
(define_insn "*cmpdi_normal"
5159
  [(set (match_operand:BI 0 "register_operand" "=c")
5160
        (match_operator:BI 1 "normal_comparison_operator"
5161
           [(match_operand:DI 2 "gr_reg_or_0_operand" "rO")
5162
            (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")]))]
5163
  ""
5164
  "cmp.%C1 %0, %I0 = %3, %r2"
5165
  [(set_attr "itanium_class" "icmp")])
5166
 
5167
;; We use %r3 because it is possible for us to match a 0, and two of the
5168
;; unsigned comparisons don't accept immediate operands of zero.
5169
 
5170
(define_insn "*cmpdi_adjusted"
5171
  [(set (match_operand:BI 0 "register_operand" "=c")
5172
        (match_operator:BI 1 "adjusted_comparison_operator"
5173
           [(match_operand:DI 2 "gr_register_operand" "r")
5174
            (match_operand:DI 3 "gr_reg_or_8bit_adjusted_operand" "rL")]))]
5175
  ""
5176
  "cmp.%C1 %0, %I0 = %r3, %2"
5177
  [(set_attr "itanium_class" "icmp")])
5178
 
5179
(define_insn "*cmpsf_internal"
5180
  [(set (match_operand:BI 0 "register_operand" "=c")
5181
        (match_operator:BI 1 "comparison_operator"
5182
           [(match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")
5183
            (match_operand:SF 3 "fr_reg_or_fp01_operand" "fG")]))]
5184
  ""
5185
  "fcmp.%D1 %0, %I0 = %F2, %F3"
5186
  [(set_attr "itanium_class" "fcmp")])
5187
 
5188
(define_insn "*cmpdf_internal"
5189
  [(set (match_operand:BI 0 "register_operand" "=c")
5190
        (match_operator:BI 1 "comparison_operator"
5191
           [(match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")
5192
            (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")]))]
5193
  ""
5194
  "fcmp.%D1 %0, %I0 = %F2, %F3"
5195
  [(set_attr "itanium_class" "fcmp")])
5196
 
5197
(define_insn "*cmpxf_internal"
5198
  [(set (match_operand:BI 0 "register_operand" "=c")
5199
        (match_operator:BI 1 "comparison_operator"
5200
                   [(match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
5201
                    (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")]))]
5202
  ""
5203
  "fcmp.%D1 %0, %I0 = %F2, %F3"
5204
  [(set_attr "itanium_class" "fcmp")])
5205
 
5206
;; ??? Can this pattern be generated?
5207
 
5208
(define_insn "*bit_zero"
5209
  [(set (match_operand:BI 0 "register_operand" "=c")
5210
        (eq:BI (zero_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
5211
                                (const_int 1)
5212
                                (match_operand:DI 2 "shift_count_operand" "M"))
5213
               (const_int 0)))]
5214
  ""
5215
  "tbit.z %0, %I0 = %1, %2"
5216
  [(set_attr "itanium_class" "tbit")])
5217
 
5218
(define_insn "*bit_one"
5219
  [(set (match_operand:BI 0 "register_operand" "=c")
5220
        (ne:BI (zero_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
5221
                                (const_int 1)
5222
                                (match_operand:DI 2 "shift_count_operand" "M"))
5223
               (const_int 0)))]
5224
  ""
5225
  "tbit.nz %0, %I0 = %1, %2"
5226
  [(set_attr "itanium_class" "tbit")])
5227
 
5228
;; ::::::::::::::::::::
5229
;; ::
5230
;; :: Branches
5231
;; ::
5232
;; ::::::::::::::::::::
5233
 
5234
(define_expand "beq"
5235
  [(set (pc)
5236
        (if_then_else (match_dup 1)
5237
                      (label_ref (match_operand 0 "" ""))
5238
                      (pc)))]
5239
  ""
5240
  "operands[1] = ia64_expand_compare (EQ, VOIDmode);")
5241
 
5242
(define_expand "bne"
5243
  [(set (pc)
5244
        (if_then_else (match_dup 1)
5245
                      (label_ref (match_operand 0 "" ""))
5246
                      (pc)))]
5247
  ""
5248
  "operands[1] = ia64_expand_compare (NE, VOIDmode);")
5249
 
5250
(define_expand "blt"
5251
  [(set (pc)
5252
        (if_then_else (match_dup 1)
5253
                      (label_ref (match_operand 0 "" ""))
5254
                      (pc)))]
5255
  ""
5256
  "operands[1] = ia64_expand_compare (LT, VOIDmode);")
5257
 
5258
(define_expand "ble"
5259
  [(set (pc)
5260
        (if_then_else (match_dup 1)
5261
                      (label_ref (match_operand 0 "" ""))
5262
                      (pc)))]
5263
  ""
5264
  "operands[1] = ia64_expand_compare (LE, VOIDmode);")
5265
 
5266
(define_expand "bgt"
5267
  [(set (pc)
5268
        (if_then_else (match_dup 1)
5269
                      (label_ref (match_operand 0 "" ""))
5270
                      (pc)))]
5271
  ""
5272
  "operands[1] = ia64_expand_compare (GT, VOIDmode);")
5273
 
5274
(define_expand "bge"
5275
  [(set (pc)
5276
        (if_then_else (match_dup 1)
5277
                      (label_ref (match_operand 0 "" ""))
5278
                      (pc)))]
5279
  ""
5280
  "operands[1] = ia64_expand_compare (GE, VOIDmode);")
5281
 
5282
(define_expand "bltu"
5283
  [(set (pc)
5284
        (if_then_else (match_dup 1)
5285
                      (label_ref (match_operand 0 "" ""))
5286
                      (pc)))]
5287
  ""
5288
  "operands[1] = ia64_expand_compare (LTU, VOIDmode);")
5289
 
5290
(define_expand "bleu"
5291
  [(set (pc)
5292
        (if_then_else (match_dup 1)
5293
                      (label_ref (match_operand 0 "" ""))
5294
                      (pc)))]
5295
  ""
5296
  "operands[1] = ia64_expand_compare (LEU, VOIDmode);")
5297
 
5298
(define_expand "bgtu"
5299
  [(set (pc)
5300
        (if_then_else (match_dup 1)
5301
                      (label_ref (match_operand 0 "" ""))
5302
                      (pc)))]
5303
  ""
5304
  "operands[1] = ia64_expand_compare (GTU, VOIDmode);")
5305
 
5306
(define_expand "bgeu"
5307
  [(set (pc)
5308
        (if_then_else (match_dup 1)
5309
                      (label_ref (match_operand 0 "" ""))
5310
                      (pc)))]
5311
  ""
5312
  "operands[1] = ia64_expand_compare (GEU, VOIDmode);")
5313
 
5314
(define_expand "bunordered"
5315
  [(set (pc)
5316
        (if_then_else (match_dup 1)
5317
                      (label_ref (match_operand 0 "" ""))
5318
                      (pc)))]
5319
  ""
5320
  "operands[1] = ia64_expand_compare (UNORDERED, VOIDmode);")
5321
 
5322
(define_expand "bordered"
5323
  [(set (pc)
5324
        (if_then_else (match_dup 1)
5325
                      (label_ref (match_operand 0 "" ""))
5326
                      (pc)))]
5327
  ""
5328
  "operands[1] = ia64_expand_compare (ORDERED, VOIDmode);")
5329
 
5330
(define_insn "*br_true"
5331
  [(set (pc)
5332
        (if_then_else (match_operator 0 "predicate_operator"
5333
                        [(match_operand:BI 1 "register_operand" "c")
5334
                         (const_int 0)])
5335
                      (label_ref (match_operand 2 "" ""))
5336
                      (pc)))]
5337
  ""
5338
  "(%J0) br.cond%+ %l2"
5339
  [(set_attr "itanium_class" "br")
5340
   (set_attr "predicable" "no")])
5341
 
5342
(define_insn "*br_false"
5343
  [(set (pc)
5344
        (if_then_else (match_operator 0 "predicate_operator"
5345
                        [(match_operand:BI 1 "register_operand" "c")
5346
                         (const_int 0)])
5347
                      (pc)
5348
                      (label_ref (match_operand 2 "" ""))))]
5349
  ""
5350
  "(%j0) br.cond%+ %l2"
5351
  [(set_attr "itanium_class" "br")
5352
   (set_attr "predicable" "no")])
5353
 
5354
;; ::::::::::::::::::::
5355
;; ::
5356
;; :: Counted loop operations
5357
;; ::
5358
;; ::::::::::::::::::::
5359
 
5360
(define_expand "doloop_end"
5361
  [(use (match_operand 0 "" ""))        ; loop pseudo
5362
   (use (match_operand 1 "" ""))        ; iterations; zero if unknown
5363
   (use (match_operand 2 "" ""))        ; max iterations
5364
   (use (match_operand 3 "" ""))        ; loop level
5365
   (use (match_operand 4 "" ""))]       ; label
5366
  ""
5367
{
5368
  /* Only use cloop on innermost loops.  */
5369
  if (INTVAL (operands[3]) > 1)
5370
    FAIL;
5371
  emit_jump_insn (gen_doloop_end_internal (gen_rtx_REG (DImode, AR_LC_REGNUM),
5372
                                           operands[4]));
5373
  DONE;
5374
})
5375
 
5376
(define_insn "doloop_end_internal"
5377
  [(set (pc) (if_then_else (ne (match_operand:DI 0 "ar_lc_reg_operand" "")
5378
                               (const_int 0))
5379
                (label_ref (match_operand 1 "" ""))
5380
                (pc)))
5381
   (set (match_dup 0) (if_then_else:DI (ne (match_dup 0) (const_int 0))
5382
                         (plus:DI (match_dup 0) (const_int -1))
5383
                         (match_dup 0)))]
5384
  ""
5385
  "br.cloop.sptk.few %l1"
5386
  [(set_attr "itanium_class" "br")
5387
   (set_attr "predicable" "no")])
5388
 
5389
;; ::::::::::::::::::::
5390
;; ::
5391
;; :: Set flag operations
5392
;; ::
5393
;; ::::::::::::::::::::
5394
 
5395
(define_expand "seq"
5396
  [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5397
  ""
5398
  "operands[1] = ia64_expand_compare (EQ, DImode);")
5399
 
5400
(define_expand "sne"
5401
  [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5402
  ""
5403
  "operands[1] = ia64_expand_compare (NE, DImode);")
5404
 
5405
(define_expand "slt"
5406
  [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5407
  ""
5408
  "operands[1] = ia64_expand_compare (LT, DImode);")
5409
 
5410
(define_expand "sle"
5411
  [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5412
  ""
5413
  "operands[1] = ia64_expand_compare (LE, DImode);")
5414
 
5415
(define_expand "sgt"
5416
  [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5417
  ""
5418
  "operands[1] = ia64_expand_compare (GT, DImode);")
5419
 
5420
(define_expand "sge"
5421
  [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5422
  ""
5423
  "operands[1] = ia64_expand_compare (GE, DImode);")
5424
 
5425
(define_expand "sltu"
5426
  [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5427
  ""
5428
  "operands[1] = ia64_expand_compare (LTU, DImode);")
5429
 
5430
(define_expand "sleu"
5431
  [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5432
  ""
5433
  "operands[1] = ia64_expand_compare (LEU, DImode);")
5434
 
5435
(define_expand "sgtu"
5436
  [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5437
  ""
5438
  "operands[1] = ia64_expand_compare (GTU, DImode);")
5439
 
5440
(define_expand "sgeu"
5441
  [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5442
  ""
5443
  "operands[1] = ia64_expand_compare (GEU, DImode);")
5444
 
5445
(define_expand "sunordered"
5446
  [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5447
  ""
5448
  "operands[1] = ia64_expand_compare (UNORDERED, DImode);")
5449
 
5450
(define_expand "sordered"
5451
  [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5452
  ""
5453
  "operands[1] = ia64_expand_compare (ORDERED, DImode);")
5454
 
5455
;; Don't allow memory as destination here, because cmov/cmov/st is more
5456
;; efficient than mov/mov/cst/cst.
5457
 
5458
(define_insn_and_split "*sne_internal"
5459
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
5460
        (ne:DI (match_operand:BI 1 "register_operand" "c")
5461
               (const_int 0)))]
5462
  ""
5463
  "#"
5464
  "reload_completed"
5465
  [(cond_exec (ne (match_dup 1) (const_int 0))
5466
     (set (match_dup 0) (const_int 1)))
5467
   (cond_exec (eq (match_dup 1) (const_int 0))
5468
     (set (match_dup 0) (const_int 0)))]
5469
  ""
5470
  [(set_attr "itanium_class" "unknown")])
5471
 
5472
(define_insn_and_split "*seq_internal"
5473
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
5474
        (eq:DI (match_operand:BI 1 "register_operand" "c")
5475
               (const_int 0)))]
5476
  ""
5477
  "#"
5478
  "reload_completed"
5479
  [(cond_exec (ne (match_dup 1) (const_int 0))
5480
     (set (match_dup 0) (const_int 0)))
5481
   (cond_exec (eq (match_dup 1) (const_int 0))
5482
     (set (match_dup 0) (const_int 1)))]
5483
  ""
5484
  [(set_attr "itanium_class" "unknown")])
5485
 
5486
;; ::::::::::::::::::::
5487
;; ::
5488
;; :: Conditional move instructions.
5489
;; ::
5490
;; ::::::::::::::::::::
5491
 
5492
;; ??? Add movXXcc patterns?
5493
 
5494
;;
5495
;; DImode if_then_else patterns.
5496
;;
5497
 
5498
(define_insn "*cmovdi_internal"
5499
  [(set (match_operand:DI 0 "destination_operand"
5500
           "= r,  r,  r,   r,  r,  r,   r, r, r,   r, m, Q, *f,*b,*d*e")
5501
        (if_then_else:DI
5502
          (match_operator 4 "predicate_operator"
5503
            [(match_operand:BI 1 "register_operand"
5504
                "c,c,c,c,c,c,c,c,c,c,c,c,c,c,c")
5505
             (const_int 0)])
5506
          (match_operand:DI 2 "move_operand"
5507
           "rim, *f, *b,*d*e,rim,rim, rim,*f,*b,*d*e,rO,*f,rOQ,rO,  rK")
5508
          (match_operand:DI 3 "move_operand"
5509
           "rim,rim,rim, rim, *f, *b,*d*e,*f,*b,*d*e,rO,*f,rOQ,rO,  rK")))]
5510
  "ia64_move_ok (operands[0], operands[2])
5511
   && ia64_move_ok (operands[0], operands[3])"
5512
  { gcc_unreachable (); }
5513
  [(set_attr "predicable" "no")])
5514
 
5515
(define_split
5516
  [(set (match_operand 0 "destination_operand" "")
5517
        (if_then_else
5518
          (match_operator 4 "predicate_operator"
5519
            [(match_operand:BI 1 "register_operand" "")
5520
             (const_int 0)])
5521
          (match_operand 2 "move_operand" "")
5522
          (match_operand 3 "move_operand" "")))]
5523
  "reload_completed"
5524
  [(const_int 0)]
5525
{
5526
  bool emitted_something = false;
5527
  rtx dest = operands[0];
5528
  rtx srct = operands[2];
5529
  rtx srcf = operands[3];
5530
  rtx cond = operands[4];
5531
 
5532
  if (! rtx_equal_p (dest, srct))
5533
    {
5534
      ia64_emit_cond_move (dest, srct, cond);
5535
      emitted_something = true;
5536
    }
5537
  if (! rtx_equal_p (dest, srcf))
5538
    {
5539
      cond = gen_rtx_fmt_ee (GET_CODE (cond) == NE ? EQ : NE,
5540
                             VOIDmode, operands[1], const0_rtx);
5541
      ia64_emit_cond_move (dest, srcf, cond);
5542
      emitted_something = true;
5543
    }
5544
  if (! emitted_something)
5545
    emit_note (NOTE_INSN_DELETED);
5546
  DONE;
5547
})
5548
 
5549
;; Absolute value pattern.
5550
 
5551
(define_insn "*absdi2_internal"
5552
  [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
5553
        (if_then_else:DI
5554
          (match_operator 4 "predicate_operator"
5555
            [(match_operand:BI 1 "register_operand" "c,c")
5556
             (const_int 0)])
5557
          (neg:DI (match_operand:DI 2 "gr_reg_or_22bit_operand" "rI,rI"))
5558
          (match_operand:DI 3 "gr_reg_or_22bit_operand" "0,rI")))]
5559
  ""
5560
  "#"
5561
  [(set_attr "itanium_class" "ialu,unknown")
5562
   (set_attr "predicable" "no")])
5563
 
5564
(define_split
5565
  [(set (match_operand:DI 0 "register_operand" "")
5566
        (if_then_else:DI
5567
          (match_operator 4 "predicate_operator"
5568
            [(match_operand:BI 1 "register_operand" "c,c")
5569
             (const_int 0)])
5570
          (neg:DI (match_operand:DI 2 "gr_reg_or_22bit_operand" ""))
5571
          (match_operand:DI 3 "gr_reg_or_22bit_operand" "")))]
5572
  "reload_completed && rtx_equal_p (operands[0], operands[3])"
5573
  [(cond_exec
5574
     (match_dup 4)
5575
     (set (match_dup 0)
5576
          (neg:DI (match_dup 2))))]
5577
  "")
5578
 
5579
(define_split
5580
  [(set (match_operand:DI 0 "register_operand" "")
5581
        (if_then_else:DI
5582
          (match_operator 4 "predicate_operator"
5583
            [(match_operand:BI 1 "register_operand" "c,c")
5584
             (const_int 0)])
5585
          (neg:DI (match_operand:DI 2 "gr_reg_or_22bit_operand" ""))
5586
          (match_operand:DI 3 "gr_reg_or_22bit_operand" "")))]
5587
  "reload_completed"
5588
  [(cond_exec
5589
     (match_dup 4)
5590
     (set (match_dup 0) (neg:DI (match_dup 2))))
5591
   (cond_exec
5592
     (match_dup 5)
5593
     (set (match_dup 0) (match_dup 3)))]
5594
{
5595
  operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[4]) == NE ? EQ : NE,
5596
                                VOIDmode, operands[1], const0_rtx);
5597
})
5598
 
5599
;;
5600
;; SImode if_then_else patterns.
5601
;;
5602
 
5603
(define_insn "*cmovsi_internal"
5604
  [(set (match_operand:SI 0 "destination_operand" "=r,m,*f,r,m,*f,r,m,*f")
5605
        (if_then_else:SI
5606
          (match_operator 4 "predicate_operator"
5607
            [(match_operand:BI 1 "register_operand" "c,c,c,c,c,c,c,c,c")
5608
             (const_int 0)])
5609
          (match_operand:SI 2 "move_operand"
5610
                    "0,0,0,rim*f,rO,rO,rim*f,rO,rO")
5611
          (match_operand:SI 3 "move_operand"
5612
                    "rim*f,rO,rO,0,0,0,rim*f,rO,rO")))]
5613
  "ia64_move_ok (operands[0], operands[2])
5614
   && ia64_move_ok (operands[0], operands[3])"
5615
  { gcc_unreachable (); }
5616
  [(set_attr "predicable" "no")])
5617
 
5618
(define_insn "*abssi2_internal"
5619
  [(set (match_operand:SI 0 "gr_register_operand" "=r,r")
5620
        (if_then_else:SI
5621
          (match_operator 4 "predicate_operator"
5622
            [(match_operand:BI 1 "register_operand" "c,c")
5623
             (const_int 0)])
5624
          (neg:SI (match_operand:SI 3 "gr_reg_or_22bit_operand" "rI,rI"))
5625
          (match_operand:SI 2 "gr_reg_or_22bit_operand" "0,rI")))]
5626
  ""
5627
  "#"
5628
  [(set_attr "itanium_class" "ialu,unknown")
5629
   (set_attr "predicable" "no")])
5630
 
5631
(define_split
5632
  [(set (match_operand:SI 0 "register_operand" "")
5633
        (if_then_else:SI
5634
          (match_operator 4 "predicate_operator"
5635
            [(match_operand:BI 1 "register_operand" "c,c")
5636
             (const_int 0)])
5637
          (neg:SI (match_operand:SI 2 "gr_reg_or_22bit_operand" ""))
5638
          (match_operand:SI 3 "gr_reg_or_22bit_operand" "")))]
5639
  "reload_completed && rtx_equal_p (operands[0], operands[3])"
5640
  [(cond_exec
5641
     (match_dup 4)
5642
     (set (match_dup 0)
5643
          (neg:SI (match_dup 2))))]
5644
  "")
5645
 
5646
(define_split
5647
  [(set (match_operand:SI 0 "register_operand" "")
5648
        (if_then_else:SI
5649
          (match_operator 4 "predicate_operator"
5650
            [(match_operand:BI 1 "register_operand" "c,c")
5651
             (const_int 0)])
5652
          (neg:SI (match_operand:SI 2 "gr_reg_or_22bit_operand" ""))
5653
          (match_operand:SI 3 "gr_reg_or_22bit_operand" "")))]
5654
  "reload_completed"
5655
  [(cond_exec
5656
     (match_dup 4)
5657
     (set (match_dup 0) (neg:SI (match_dup 2))))
5658
   (cond_exec
5659
     (match_dup 5)
5660
     (set (match_dup 0) (match_dup 3)))]
5661
{
5662
  operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[4]) == NE ? EQ : NE,
5663
                                VOIDmode, operands[1], const0_rtx);
5664
})
5665
 
5666
(define_insn_and_split "*cond_opsi2_internal"
5667
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
5668
        (match_operator:SI 5 "condop_operator"
5669
          [(if_then_else:SI
5670
             (match_operator 6 "predicate_operator"
5671
               [(match_operand:BI 1 "register_operand" "c")
5672
                (const_int 0)])
5673
             (match_operand:SI 2 "gr_register_operand" "r")
5674
             (match_operand:SI 3 "gr_register_operand" "r"))
5675
           (match_operand:SI 4 "gr_register_operand" "r")]))]
5676
  ""
5677
  "#"
5678
  "reload_completed"
5679
  [(cond_exec
5680
     (match_dup 6)
5681
     (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 2) (match_dup 4)])))
5682
   (cond_exec
5683
     (match_dup 7)
5684
     (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 3) (match_dup 4)])))]
5685
{
5686
  operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[6]) == NE ? EQ : NE,
5687
                                VOIDmode, operands[1], const0_rtx);
5688
}
5689
  [(set_attr "itanium_class" "ialu")
5690
   (set_attr "predicable" "no")])
5691
 
5692
 
5693
(define_insn_and_split "*cond_opsi2_internal_b"
5694
  [(set (match_operand:SI 0 "gr_register_operand" "=r")
5695
        (match_operator:SI 5 "condop_operator"
5696
          [(match_operand:SI 4 "gr_register_operand" "r")
5697
           (if_then_else:SI
5698
             (match_operator 6 "predicate_operator"
5699
               [(match_operand:BI 1 "register_operand" "c")
5700
                (const_int 0)])
5701
             (match_operand:SI 2 "gr_register_operand" "r")
5702
             (match_operand:SI 3 "gr_register_operand" "r"))]))]
5703
  ""
5704
  "#"
5705
  "reload_completed"
5706
  [(cond_exec
5707
     (match_dup 6)
5708
     (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 4) (match_dup 2)])))
5709
   (cond_exec
5710
     (match_dup 7)
5711
     (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 4) (match_dup 3)])))]
5712
{
5713
  operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[6]) == NE ? EQ : NE,
5714
                                VOIDmode, operands[1], const0_rtx);
5715
}
5716
  [(set_attr "itanium_class" "ialu")
5717
   (set_attr "predicable" "no")])
5718
 
5719
 
5720
;; ::::::::::::::::::::
5721
;; ::
5722
;; :: Call and branch instructions
5723
;; ::
5724
;; ::::::::::::::::::::
5725
 
5726
;; Subroutine call instruction returning no value.  Operand 0 is the function
5727
;; to call; operand 1 is the number of bytes of arguments pushed (in mode
5728
;; `SImode', except it is normally a `const_int'); operand 2 is the number of
5729
;; registers used as operands.
5730
 
5731
;; On most machines, operand 2 is not actually stored into the RTL pattern.  It
5732
;; is supplied for the sake of some RISC machines which need to put this
5733
;; information into the assembler code; they can put it in the RTL instead of
5734
;; operand 1.
5735
 
5736
(define_expand "call"
5737
  [(use (match_operand:DI 0 "" ""))
5738
   (use (match_operand 1 "" ""))
5739
   (use (match_operand 2 "" ""))
5740
   (use (match_operand 3 "" ""))]
5741
  ""
5742
{
5743
  ia64_expand_call (NULL_RTX, operands[0], operands[2], false);
5744
  DONE;
5745
})
5746
 
5747
(define_expand "sibcall"
5748
  [(use (match_operand:DI 0 "" ""))
5749
   (use (match_operand 1 "" ""))
5750
   (use (match_operand 2 "" ""))
5751
   (use (match_operand 3 "" ""))]
5752
  ""
5753
{
5754
  ia64_expand_call (NULL_RTX, operands[0], operands[2], true);
5755
  DONE;
5756
})
5757
 
5758
;; Subroutine call instruction returning a value.  Operand 0 is the hard
5759
;; register in which the value is returned.  There are three more operands,
5760
;; the same as the three operands of the `call' instruction (but with numbers
5761
;; increased by one).
5762
;;
5763
;; Subroutines that return `BLKmode' objects use the `call' insn.
5764
 
5765
(define_expand "call_value"
5766
  [(use (match_operand 0 "" ""))
5767
   (use (match_operand:DI 1 "" ""))
5768
   (use (match_operand 2 "" ""))
5769
   (use (match_operand 3 "" ""))
5770
   (use (match_operand 4 "" ""))]
5771
  ""
5772
{
5773
  ia64_expand_call (operands[0], operands[1], operands[3], false);
5774
  DONE;
5775
})
5776
 
5777
(define_expand "sibcall_value"
5778
  [(use (match_operand 0 "" ""))
5779
   (use (match_operand:DI 1 "" ""))
5780
   (use (match_operand 2 "" ""))
5781
   (use (match_operand 3 "" ""))
5782
   (use (match_operand 4 "" ""))]
5783
  ""
5784
{
5785
  ia64_expand_call (operands[0], operands[1], operands[3], true);
5786
  DONE;
5787
})
5788
 
5789
;; Call subroutine returning any type.
5790
 
5791
(define_expand "untyped_call"
5792
  [(parallel [(call (match_operand 0 "" "")
5793
                    (const_int 0))
5794
              (match_operand 1 "" "")
5795
              (match_operand 2 "" "")])]
5796
  ""
5797
{
5798
  int i;
5799
 
5800
  emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx));
5801
 
5802
  for (i = 0; i < XVECLEN (operands[2], 0); i++)
5803
    {
5804
      rtx set = XVECEXP (operands[2], 0, i);
5805
      emit_move_insn (SET_DEST (set), SET_SRC (set));
5806
    }
5807
 
5808
  /* The optimizer does not know that the call sets the function value
5809
     registers we stored in the result block.  We avoid problems by
5810
     claiming that all hard registers are used and clobbered at this
5811
     point.  */
5812
  emit_insn (gen_blockage ());
5813
 
5814
  DONE;
5815
})
5816
 
5817
(define_insn "call_nogp"
5818
  [(call (mem:DI (match_operand:DI 0 "call_operand" "?b,i"))
5819
         (const_int 0))
5820
   (clobber (match_operand:DI 1 "register_operand" "=b,b"))]
5821
  ""
5822
  "br.call%+.many %1 = %0"
5823
  [(set_attr "itanium_class" "br,scall")])
5824
 
5825
(define_insn "call_value_nogp"
5826
  [(set (match_operand 0 "" "=X,X")
5827
        (call (mem:DI (match_operand:DI 1 "call_operand" "?b,i"))
5828
              (const_int 0)))
5829
   (clobber (match_operand:DI 2 "register_operand" "=b,b"))]
5830
  ""
5831
  "br.call%+.many %2 = %1"
5832
  [(set_attr "itanium_class" "br,scall")])
5833
 
5834
(define_insn "sibcall_nogp"
5835
  [(call (mem:DI (match_operand:DI 0 "call_operand" "?b,i"))
5836
         (const_int 0))]
5837
  ""
5838
  "br%+.many %0"
5839
  [(set_attr "itanium_class" "br,scall")])
5840
 
5841
(define_insn "call_gp"
5842
  [(call (mem:DI (match_operand:DI 0 "call_operand" "?r,i"))
5843
         (const_int 1))
5844
   (clobber (match_operand:DI 1 "register_operand" "=b,b"))
5845
   (clobber (match_scratch:DI 2 "=&r,X"))
5846
   (clobber (match_scratch:DI 3 "=b,X"))]
5847
  ""
5848
  "#"
5849
  [(set_attr "itanium_class" "br,scall")])
5850
 
5851
;; Irritatingly, we don't have access to INSN within the split body.
5852
;; See commentary in ia64_split_call as to why these aren't peep2.
5853
(define_split
5854
  [(call (mem (match_operand 0 "call_operand" ""))
5855
         (const_int 1))
5856
   (clobber (match_operand:DI 1 "register_operand" ""))
5857
   (clobber (match_scratch:DI 2 ""))
5858
   (clobber (match_scratch:DI 3 ""))]
5859
  "reload_completed && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
5860
  [(const_int 0)]
5861
{
5862
  ia64_split_call (NULL_RTX, operands[0], operands[1], operands[2],
5863
                   operands[3], true, false);
5864
  DONE;
5865
})
5866
 
5867
(define_split
5868
  [(call (mem (match_operand 0 "call_operand" ""))
5869
         (const_int 1))
5870
   (clobber (match_operand:DI 1 "register_operand" ""))
5871
   (clobber (match_scratch:DI 2 ""))
5872
   (clobber (match_scratch:DI 3 ""))]
5873
  "reload_completed"
5874
  [(const_int 0)]
5875
{
5876
  ia64_split_call (NULL_RTX, operands[0], operands[1], operands[2],
5877
                   operands[3], false, false);
5878
  DONE;
5879
})
5880
 
5881
(define_insn "call_value_gp"
5882
  [(set (match_operand 0 "" "=X,X")
5883
        (call (mem:DI (match_operand:DI 1 "call_operand" "?r,i"))
5884
              (const_int 1)))
5885
   (clobber (match_operand:DI 2 "register_operand" "=b,b"))
5886
   (clobber (match_scratch:DI 3 "=&r,X"))
5887
   (clobber (match_scratch:DI 4 "=b,X"))]
5888
  ""
5889
  "#"
5890
  [(set_attr "itanium_class" "br,scall")])
5891
 
5892
(define_split
5893
  [(set (match_operand 0 "" "")
5894
        (call (mem:DI (match_operand:DI 1 "call_operand" ""))
5895
              (const_int 1)))
5896
   (clobber (match_operand:DI 2 "register_operand" ""))
5897
   (clobber (match_scratch:DI 3 ""))
5898
   (clobber (match_scratch:DI 4 ""))]
5899
  "reload_completed && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
5900
  [(const_int 0)]
5901
{
5902
  ia64_split_call (operands[0], operands[1], operands[2], operands[3],
5903
                   operands[4], true, false);
5904
  DONE;
5905
})
5906
 
5907
(define_split
5908
  [(set (match_operand 0 "" "")
5909
        (call (mem:DI (match_operand:DI 1 "call_operand" ""))
5910
              (const_int 1)))
5911
   (clobber (match_operand:DI 2 "register_operand" ""))
5912
   (clobber (match_scratch:DI 3 ""))
5913
   (clobber (match_scratch:DI 4 ""))]
5914
  "reload_completed"
5915
  [(const_int 0)]
5916
{
5917
  ia64_split_call (operands[0], operands[1], operands[2], operands[3],
5918
                   operands[4], false, false);
5919
  DONE;
5920
})
5921
 
5922
(define_insn_and_split "sibcall_gp"
5923
  [(call (mem:DI (match_operand:DI 0 "call_operand" "?r,i"))
5924
         (const_int 1))
5925
   (clobber (match_scratch:DI 1 "=&r,X"))
5926
   (clobber (match_scratch:DI 2 "=b,X"))]
5927
  ""
5928
  "#"
5929
  "reload_completed"
5930
  [(const_int 0)]
5931
{
5932
  ia64_split_call (NULL_RTX, operands[0], NULL_RTX, operands[1],
5933
                   operands[2], true, true);
5934
  DONE;
5935
}
5936
  [(set_attr "itanium_class" "br")])
5937
 
5938
(define_insn "return_internal"
5939
  [(return)
5940
   (use (match_operand:DI 0 "register_operand" "b"))]
5941
  ""
5942
  "br.ret.sptk.many %0"
5943
  [(set_attr "itanium_class" "br")])
5944
 
5945
(define_insn "return"
5946
  [(return)]
5947
  "ia64_direct_return ()"
5948
  "br.ret.sptk.many rp"
5949
  [(set_attr "itanium_class" "br")])
5950
 
5951
(define_insn "*return_true"
5952
  [(set (pc)
5953
        (if_then_else (match_operator 0 "predicate_operator"
5954
                        [(match_operand:BI 1 "register_operand" "c")
5955
                         (const_int 0)])
5956
                      (return)
5957
                      (pc)))]
5958
  "ia64_direct_return ()"
5959
  "(%J0) br.ret%+.many rp"
5960
  [(set_attr "itanium_class" "br")
5961
   (set_attr "predicable" "no")])
5962
 
5963
(define_insn "*return_false"
5964
  [(set (pc)
5965
        (if_then_else (match_operator 0 "predicate_operator"
5966
                        [(match_operand:BI 1 "register_operand" "c")
5967
                         (const_int 0)])
5968
                      (pc)
5969
                      (return)))]
5970
  "ia64_direct_return ()"
5971
  "(%j0) br.ret%+.many rp"
5972
  [(set_attr "itanium_class" "br")
5973
   (set_attr "predicable" "no")])
5974
 
5975
(define_insn "jump"
5976
  [(set (pc) (label_ref (match_operand 0 "" "")))]
5977
  ""
5978
  "br %l0"
5979
  [(set_attr "itanium_class" "br")])
5980
 
5981
(define_insn "indirect_jump"
5982
  [(set (pc) (match_operand:DI 0 "register_operand" "b"))]
5983
  ""
5984
  "br %0"
5985
  [(set_attr "itanium_class" "br")])
5986
 
5987
(define_expand "tablejump"
5988
  [(parallel [(set (pc) (match_operand:DI 0 "memory_operand" ""))
5989
              (use (label_ref (match_operand 1 "" "")))])]
5990
  ""
5991
{
5992
  rtx op0 = operands[0];
5993
  rtx addr;
5994
 
5995
  /* ??? Bother -- do_tablejump is "helpful" and pulls the table
5996
     element into a register without bothering to see whether that
5997
     is necessary given the operand predicate.  Check for MEM just
5998
     in case someone fixes this.  */
5999
  if (GET_CODE (op0) == MEM)
6000
    addr = XEXP (op0, 0);
6001
  else
6002
    {
6003
      /* Otherwise, cheat and guess that the previous insn in the
6004
         stream was the memory load.  Grab the address from that.
6005
         Note we have to momentarily pop out of the sequence started
6006
         by the insn-emit wrapper in order to grab the last insn.  */
6007
      rtx last, set;
6008
 
6009
      end_sequence ();
6010
      last = get_last_insn ();
6011
      start_sequence ();
6012
      set = single_set (last);
6013
 
6014
      gcc_assert (rtx_equal_p (SET_DEST (set), op0)
6015
                  && GET_CODE (SET_SRC (set)) == MEM);
6016
      addr = XEXP (SET_SRC (set), 0);
6017
      gcc_assert (!rtx_equal_p (addr, op0));
6018
    }
6019
 
6020
  /* Jump table elements are stored pc-relative.  That is, a displacement
6021
     from the entry to the label.  Thus to convert to an absolute address
6022
     we add the address of the memory from which the value is loaded.  */
6023
  operands[0] = expand_simple_binop (DImode, PLUS, op0, addr,
6024
                                     NULL_RTX, 1, OPTAB_DIRECT);
6025
})
6026
 
6027
(define_insn "*tablejump_internal"
6028
  [(set (pc) (match_operand:DI 0 "register_operand" "b"))
6029
   (use (label_ref (match_operand 1 "" "")))]
6030
  ""
6031
  "br %0"
6032
  [(set_attr "itanium_class" "br")])
6033
 
6034
 
6035
;; ::::::::::::::::::::
6036
;; ::
6037
;; :: Prologue and Epilogue instructions
6038
;; ::
6039
;; ::::::::::::::::::::
6040
 
6041
(define_expand "prologue"
6042
  [(const_int 1)]
6043
  ""
6044
{
6045
  ia64_expand_prologue ();
6046
  DONE;
6047
})
6048
 
6049
(define_expand "epilogue"
6050
  [(return)]
6051
  ""
6052
{
6053
  ia64_expand_epilogue (0);
6054
  DONE;
6055
})
6056
 
6057
(define_expand "sibcall_epilogue"
6058
  [(return)]
6059
  ""
6060
{
6061
  ia64_expand_epilogue (1);
6062
  DONE;
6063
})
6064
 
6065
;; This prevents the scheduler from moving the SP decrement past FP-relative
6066
;; stack accesses.  This is the same as adddi3 plus the extra set.
6067
 
6068
(define_insn "prologue_allocate_stack"
6069
  [(set (match_operand:DI 0 "register_operand" "=r,r,r")
6070
        (plus:DI (match_operand:DI 1 "register_operand" "%r,r,a")
6071
                 (match_operand:DI 2 "gr_reg_or_22bit_operand" "r,I,J")))
6072
   (set (match_operand:DI 3 "register_operand" "+r,r,r")
6073
        (match_dup 3))]
6074
  ""
6075
  "@
6076
   add %0 = %1, %2
6077
   adds %0 = %2, %1
6078
   addl %0 = %2, %1"
6079
  [(set_attr "itanium_class" "ialu")])
6080
 
6081
;; This prevents the scheduler from moving the SP restore past FP-relative
6082
;; stack accesses.  This is similar to movdi plus the extra set.
6083
 
6084
(define_insn "epilogue_deallocate_stack"
6085
  [(set (match_operand:DI 0 "register_operand" "=r")
6086
        (match_operand:DI 1 "register_operand" "+r"))
6087
   (set (match_dup 1) (match_dup 1))]
6088
  ""
6089
  "mov %0 = %1"
6090
  [(set_attr "itanium_class" "ialu")])
6091
 
6092
;; As USE insns aren't meaningful after reload, this is used instead
6093
;; to prevent deleting instructions setting registers for EH handling
6094
(define_insn "prologue_use"
6095
  [(unspec:DI [(match_operand:DI 0 "register_operand" "")]
6096
              UNSPEC_PROLOGUE_USE)]
6097
  ""
6098
  ""
6099
  [(set_attr "itanium_class" "ignore")
6100
   (set_attr "predicable" "no")
6101
   (set_attr "empty" "yes")])
6102
 
6103
;; Allocate a new register frame.
6104
 
6105
(define_insn "alloc"
6106
  [(set (match_operand:DI 0 "register_operand" "=r")
6107
        (unspec_volatile:DI [(const_int 0)] UNSPECV_ALLOC))
6108
   (use (match_operand:DI 1 "const_int_operand" "i"))
6109
   (use (match_operand:DI 2 "const_int_operand" "i"))
6110
   (use (match_operand:DI 3 "const_int_operand" "i"))
6111
   (use (match_operand:DI 4 "const_int_operand" "i"))]
6112
  ""
6113
  "alloc %0 = ar.pfs, %1, %2, %3, %4"
6114
  [(set_attr "itanium_class" "syst_m0")
6115
   (set_attr "predicable" "no")
6116
   (set_attr "first_insn" "yes")])
6117
 
6118
;; Modifies ar.unat
6119
(define_expand "gr_spill"
6120
  [(parallel [(set (match_operand:DI 0 "memory_operand" "=m")
6121
                   (unspec:DI [(match_operand:DI 1 "register_operand" "r")
6122
                               (match_operand:DI 2 "const_int_operand" "")]
6123
                              UNSPEC_GR_SPILL))
6124
              (clobber (match_dup 3))])]
6125
  ""
6126
  "operands[3] = gen_rtx_REG (DImode, AR_UNAT_REGNUM);")
6127
 
6128
(define_insn "gr_spill_internal"
6129
  [(set (match_operand:DI 0 "destination_operand" "=m")
6130
        (unspec:DI [(match_operand:DI 1 "register_operand" "r")
6131
                    (match_operand:DI 2 "const_int_operand" "")]
6132
                   UNSPEC_GR_SPILL))
6133
   (clobber (match_operand:DI 3 "register_operand" ""))]
6134
  ""
6135
{
6136
  /* Note that we use a C output pattern here to avoid the predicate
6137
     being automatically added before the .mem.offset directive.  */
6138
  return ".mem.offset %2, 0\;%,st8.spill %0 = %1%P0";
6139
}
6140
  [(set_attr "itanium_class" "st")])
6141
 
6142
;; Reads ar.unat
6143
(define_expand "gr_restore"
6144
  [(parallel [(set (match_operand:DI 0 "register_operand" "=r")
6145
                   (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
6146
                               (match_operand:DI 2 "const_int_operand" "")]
6147
                              UNSPEC_GR_RESTORE))
6148
              (use (match_dup 3))])]
6149
  ""
6150
  "operands[3] = gen_rtx_REG (DImode, AR_UNAT_REGNUM);")
6151
 
6152
(define_insn "gr_restore_internal"
6153
  [(set (match_operand:DI 0 "register_operand" "=r")
6154
        (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
6155
                    (match_operand:DI 2 "const_int_operand" "")]
6156
                   UNSPEC_GR_RESTORE))
6157
   (use (match_operand:DI 3 "register_operand" ""))]
6158
  ""
6159
  { return ".mem.offset %2, 0\;%,ld8.fill %0 = %1%P1"; }
6160
  [(set_attr "itanium_class" "ld")])
6161
 
6162
(define_insn "fr_spill"
6163
  [(set (match_operand:XF 0 "destination_operand" "=m")
6164
        (unspec:XF [(match_operand:XF 1 "register_operand" "f")]
6165
                   UNSPEC_FR_SPILL))]
6166
  ""
6167
  "stf.spill %0 = %1%P0"
6168
  [(set_attr "itanium_class" "stf")])
6169
 
6170
(define_insn "fr_restore"
6171
  [(set (match_operand:XF 0 "register_operand" "=f")
6172
        (unspec:XF [(match_operand:XF 1 "memory_operand" "m")]
6173
                   UNSPEC_FR_RESTORE))]
6174
  ""
6175
  "ldf.fill %0 = %1%P1"
6176
  [(set_attr "itanium_class" "fld")])
6177
 
6178
;; ??? The explicit stop is not ideal.  It would be better if
6179
;; rtx_needs_barrier took care of this, but this is something that can be
6180
;; fixed later.  This avoids an RSE DV.
6181
 
6182
(define_insn "bsp_value"
6183
  [(set (match_operand:DI 0 "register_operand" "=r")
6184
        (unspec:DI [(const_int 0)] UNSPEC_BSP_VALUE))]
6185
  ""
6186
  "*
6187
{
6188
  return \";;\;%,mov %0 = ar.bsp\";
6189
}"
6190
  [(set_attr "itanium_class" "frar_i")])
6191
 
6192
(define_insn "set_bsp"
6193
  [(unspec_volatile [(match_operand:DI 0 "register_operand" "r")]
6194
                    UNSPECV_SET_BSP)]
6195
  ""
6196
  "flushrs
6197
        mov r19=ar.rsc
6198
        ;;
6199
        and r19=0x1c,r19
6200
        ;;
6201
        mov ar.rsc=r19
6202
        ;;
6203
        mov ar.bspstore=%0
6204
        ;;
6205
        or r19=0x3,r19
6206
        ;;
6207
        loadrs
6208
        invala
6209
        ;;
6210
        mov ar.rsc=r19"
6211
  [(set_attr "itanium_class" "unknown")
6212
   (set_attr "predicable" "no")])
6213
 
6214
;; ??? The explicit stops are not ideal.  It would be better if
6215
;; rtx_needs_barrier took care of this, but this is something that can be
6216
;; fixed later.  This avoids an RSE DV.
6217
 
6218
(define_insn "flushrs"
6219
  [(unspec [(const_int 0)] UNSPEC_FLUSHRS)]
6220
  ""
6221
  ";;\;flushrs\;;;"
6222
  [(set_attr "itanium_class" "rse_m")
6223
   (set_attr "predicable" "no")])
6224
 
6225
;; ::::::::::::::::::::
6226
;; ::
6227
;; :: Miscellaneous instructions
6228
;; ::
6229
;; ::::::::::::::::::::
6230
 
6231
;; ??? Emitting a NOP instruction isn't very useful.  This should probably
6232
;; be emitting ";;" to force a break in the instruction packing.
6233
 
6234
;; No operation, needed in case the user uses -g but not -O.
6235
(define_insn "nop"
6236
  [(const_int 0)]
6237
  ""
6238
  "nop 0"
6239
  [(set_attr "itanium_class" "nop")])
6240
 
6241
(define_insn "nop_m"
6242
  [(const_int 1)]
6243
  ""
6244
  "nop.m 0"
6245
  [(set_attr "itanium_class" "nop_m")])
6246
 
6247
(define_insn "nop_i"
6248
  [(const_int 2)]
6249
  ""
6250
  "nop.i 0"
6251
  [(set_attr "itanium_class" "nop_i")])
6252
 
6253
(define_insn "nop_f"
6254
  [(const_int 3)]
6255
  ""
6256
  "nop.f 0"
6257
  [(set_attr "itanium_class" "nop_f")])
6258
 
6259
(define_insn "nop_b"
6260
  [(const_int 4)]
6261
  ""
6262
  "nop.b 0"
6263
  [(set_attr "itanium_class" "nop_b")])
6264
 
6265
(define_insn "nop_x"
6266
  [(const_int 5)]
6267
  ""
6268
  ""
6269
  [(set_attr "itanium_class" "nop_x")
6270
   (set_attr "empty" "yes")])
6271
 
6272
;; The following insn will be never generated.  It is used only by
6273
;; insn scheduler to change state before advancing cycle.
6274
(define_insn "pre_cycle"
6275
  [(const_int 6)]
6276
  ""
6277
  ""
6278
  [(set_attr "itanium_class" "pre_cycle")])
6279
 
6280
(define_insn "bundle_selector"
6281
  [(unspec [(match_operand 0 "const_int_operand" "")] UNSPEC_BUNDLE_SELECTOR)]
6282
  ""
6283
  { return get_bundle_name (INTVAL (operands[0])); }
6284
  [(set_attr "itanium_class" "ignore")
6285
   (set_attr "predicable" "no")])
6286
 
6287
;; Pseudo instruction that prevents the scheduler from moving code above this
6288
;; point.
6289
(define_insn "blockage"
6290
  [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6291
  ""
6292
  ""
6293
  [(set_attr "itanium_class" "ignore")
6294
   (set_attr "predicable" "no")])
6295
 
6296
(define_insn "insn_group_barrier"
6297
  [(unspec_volatile [(match_operand 0 "const_int_operand" "")]
6298
                    UNSPECV_INSN_GROUP_BARRIER)]
6299
  ""
6300
  ";;"
6301
  [(set_attr "itanium_class" "stop_bit")
6302
   (set_attr "predicable" "no")
6303
   (set_attr "empty" "yes")])
6304
 
6305
(define_expand "trap"
6306
  [(trap_if (const_int 1) (const_int 0))]
6307
  ""
6308
  "")
6309
 
6310
;; ??? We don't have a match-any slot type.  Setting the type to unknown
6311
;; produces worse code that setting the slot type to A.
6312
 
6313
(define_insn "*trap"
6314
  [(trap_if (const_int 1) (match_operand 0 "const_int_operand" ""))]
6315
  ""
6316
  "break %0"
6317
  [(set_attr "itanium_class" "chk_s_i")])
6318
 
6319
(define_expand "conditional_trap"
6320
  [(trap_if (match_operand 0 "" "") (match_operand 1 "" ""))]
6321
  ""
6322
{
6323
  operands[0] = ia64_expand_compare (GET_CODE (operands[0]), VOIDmode);
6324
})
6325
 
6326
(define_insn "*conditional_trap"
6327
  [(trap_if (match_operator 0 "predicate_operator"
6328
              [(match_operand:BI 1 "register_operand" "c")
6329
               (const_int 0)])
6330
            (match_operand 2 "const_int_operand" ""))]
6331
  ""
6332
  "(%J0) break %2"
6333
  [(set_attr "itanium_class" "chk_s_i")
6334
   (set_attr "predicable" "no")])
6335
 
6336
(define_insn "break_f"
6337
  [(unspec_volatile [(const_int 0)] UNSPECV_BREAK)]
6338
  ""
6339
  "break.f 0"
6340
  [(set_attr "itanium_class" "nop_f")])
6341
 
6342
(define_insn "prefetch"
6343
  [(prefetch (match_operand:DI 0 "address_operand" "p")
6344
             (match_operand:DI 1 "const_int_operand" "n")
6345
             (match_operand:DI 2 "const_int_operand" "n"))]
6346
  ""
6347
{
6348
  static const char * const alt[2][4] = {
6349
    {
6350
      "%,lfetch.nta [%0]",
6351
      "%,lfetch.nt1 [%0]",
6352
      "%,lfetch.nt2 [%0]",
6353
      "%,lfetch [%0]"
6354
    },
6355
    {
6356
      "%,lfetch.excl.nta [%0]",
6357
      "%,lfetch.excl.nt1 [%0]",
6358
      "%,lfetch.excl.nt2 [%0]",
6359
      "%,lfetch.excl [%0]"
6360
    }
6361
  };
6362
  int i = (INTVAL (operands[1]));
6363
  int j = (INTVAL (operands[2]));
6364
 
6365
  gcc_assert (i == 0 || i == 1);
6366
  gcc_assert (j >= 0 && j <= 3);
6367
  return alt[i][j];
6368
}
6369
  [(set_attr "itanium_class" "lfetch")])
6370
 
6371
;; Non-local goto support.
6372
 
6373
(define_expand "save_stack_nonlocal"
6374
  [(use (match_operand:OI 0 "memory_operand" ""))
6375
   (use (match_operand:DI 1 "register_operand" ""))]
6376
  ""
6377
{
6378
  emit_library_call (gen_rtx_SYMBOL_REF (Pmode,
6379
                                         \"__ia64_save_stack_nonlocal\"),
6380
                     0, VOIDmode, 2, XEXP (operands[0], 0), Pmode,
6381
                     operands[1], Pmode);
6382
  DONE;
6383
})
6384
 
6385
(define_expand "nonlocal_goto"
6386
  [(use (match_operand 0 "general_operand" ""))
6387
   (use (match_operand 1 "general_operand" ""))
6388
   (use (match_operand 2 "general_operand" ""))
6389
   (use (match_operand 3 "general_operand" ""))]
6390
  ""
6391
{
6392
  emit_library_call (gen_rtx_SYMBOL_REF (Pmode, \"__ia64_nonlocal_goto\"),
6393
                     LCT_NORETURN, VOIDmode, 3,
6394
                     operands[1], Pmode,
6395
                     copy_to_reg (XEXP (operands[2], 0)), Pmode,
6396
                     operands[3], Pmode);
6397
  emit_barrier ();
6398
  DONE;
6399
})
6400
 
6401
(define_insn_and_split "builtin_setjmp_receiver"
6402
  [(unspec_volatile [(match_operand:DI 0 "" "")] UNSPECV_SETJMP_RECEIVER)]
6403
  ""
6404
  "#"
6405
  "reload_completed"
6406
  [(const_int 0)]
6407
{
6408
  ia64_reload_gp ();
6409
  DONE;
6410
})
6411
 
6412
(define_expand "eh_epilogue"
6413
  [(use (match_operand:DI 0 "register_operand" "r"))
6414
   (use (match_operand:DI 1 "register_operand" "r"))
6415
   (use (match_operand:DI 2 "register_operand" "r"))]
6416
  ""
6417
{
6418
  rtx bsp = gen_rtx_REG (Pmode, 10);
6419
  rtx sp = gen_rtx_REG (Pmode, 9);
6420
 
6421
  if (GET_CODE (operands[0]) != REG || REGNO (operands[0]) != 10)
6422
    {
6423
      emit_move_insn (bsp, operands[0]);
6424
      operands[0] = bsp;
6425
    }
6426
  if (GET_CODE (operands[2]) != REG || REGNO (operands[2]) != 9)
6427
    {
6428
      emit_move_insn (sp, operands[2]);
6429
      operands[2] = sp;
6430
    }
6431
  emit_insn (gen_rtx_USE (VOIDmode, sp));
6432
  emit_insn (gen_rtx_USE (VOIDmode, bsp));
6433
 
6434
  cfun->machine->ia64_eh_epilogue_sp = sp;
6435
  cfun->machine->ia64_eh_epilogue_bsp = bsp;
6436
})
6437
 
6438
;; Builtin apply support.
6439
 
6440
(define_expand "restore_stack_nonlocal"
6441
  [(use (match_operand:DI 0 "register_operand" ""))
6442
   (use (match_operand:OI 1 "memory_operand" ""))]
6443
  ""
6444
{
6445
  emit_library_call (gen_rtx_SYMBOL_REF (Pmode,
6446
                                         "__ia64_restore_stack_nonlocal"),
6447
                     0, VOIDmode, 1,
6448
                     copy_to_reg (XEXP (operands[1], 0)), Pmode);
6449
  DONE;
6450
})
6451
 
6452
 
6453
;; Predication.
6454
 
6455
(define_cond_exec
6456
  [(match_operator 0 "predicate_operator"
6457
     [(match_operand:BI 1 "register_operand" "c")
6458
      (const_int 0)])]
6459
  ""
6460
  "(%J0)")
6461
 
6462
(define_insn "pred_rel_mutex"
6463
  [(set (match_operand:BI 0 "register_operand" "+c")
6464
       (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
6465
  ""
6466
  ".pred.rel.mutex %0, %I0"
6467
  [(set_attr "itanium_class" "ignore")
6468
   (set_attr "predicable" "no")])
6469
 
6470
(define_insn "safe_across_calls_all"
6471
  [(unspec_volatile [(const_int 0)] UNSPECV_PSAC_ALL)]
6472
  ""
6473
  ".pred.safe_across_calls p1-p63"
6474
  [(set_attr "itanium_class" "ignore")
6475
   (set_attr "predicable" "no")])
6476
 
6477
(define_insn "safe_across_calls_normal"
6478
  [(unspec_volatile [(const_int 0)] UNSPECV_PSAC_NORMAL)]
6479
  ""
6480
{
6481
  emit_safe_across_calls ();
6482
  return "";
6483
}
6484
  [(set_attr "itanium_class" "ignore")
6485
   (set_attr "predicable" "no")])
6486
 
6487
;; UNSPEC instruction definition to "swizzle" 32 bit pointer into 64 bit
6488
;; pointer.  This is used by the HP-UX 32 bit mode.
6489
 
6490
(define_insn "ptr_extend"
6491
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
6492
        (unspec:DI [(match_operand:SI 1 "gr_register_operand" "r")]
6493
                   UNSPEC_ADDP4))]
6494
  ""
6495
  "addp4 %0 = 0,%1"
6496
  [(set_attr "itanium_class" "ialu")])
6497
 
6498
;;
6499
;; Optimizations for ptr_extend
6500
 
6501
(define_insn "ptr_extend_plus_imm"
6502
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
6503
        (unspec:DI
6504
         [(plus:SI (match_operand:SI 1 "basereg_operand" "r")
6505
                   (match_operand:SI 2 "gr_reg_or_14bit_operand" "rI"))]
6506
         UNSPEC_ADDP4))]
6507
  "addp4_optimize_ok (operands[1], operands[2])"
6508
  "addp4 %0 = %2, %1"
6509
  [(set_attr "itanium_class" "ialu")])
6510
 
6511
(define_insn "*ptr_extend_plus_2"
6512
  [(set (match_operand:DI 0 "gr_register_operand" "=r")
6513
        (unspec:DI
6514
         [(plus:SI (match_operand:SI 1 "gr_register_operand" "r")
6515
                   (match_operand:SI 2 "basereg_operand" "r"))]
6516
         UNSPEC_ADDP4))]
6517
  "addp4_optimize_ok (operands[1], operands[2])"
6518
  "addp4 %0 = %1, %2"
6519
  [(set_attr "itanium_class" "ialu")])
6520
 
6521
;;
6522
;; Get instruction pointer
6523
 
6524
(define_insn "ip_value"
6525
  [(set (match_operand:DI 0 "register_operand" "=r")
6526
        (pc))]
6527
 ""
6528
 "mov %0 = ip"
6529
  [(set_attr "itanium_class" "ialu")])
6530
 
6531
;; Vector operations
6532
(include "vect.md")
6533
;; Atomic operations
6534
(include "sync.md")

powered by: WebSVN 2.1.0

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