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