OSDN Git Service

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