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