OSDN Git Service

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