OSDN Git Service

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