OSDN Git Service

* explow.c (force_reg): Call mark_reg_pointer as appropriate.
[pf3gnuchains/gcc-fork.git] / gcc / config / alpha / alpha.md
1 ;; Machine description for DEC Alpha for GNU C compiler
2 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 ;; 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
4 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
5 ;;
6 ;; This file is part of GCC.
7 ;;
8 ;; GCC 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 ;; GCC 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 GCC; 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 ;; Uses of UNSPEC in this file:
26
27 (define_constants
28   [(UNSPEC_ARG_HOME     0)
29    (UNSPEC_CTTZ         1)
30    (UNSPEC_INSXH        2)
31    (UNSPEC_MSKXH        3)
32    (UNSPEC_CVTQL        4)
33    (UNSPEC_CVTLQ        5)
34    (UNSPEC_UMK_LAUM     6)
35    (UNSPEC_UMK_LALM     7)
36    (UNSPEC_UMK_LAL      8)
37    (UNSPEC_UMK_LOAD_CIW 9)
38    (UNSPEC_LDGP2        10)
39    (UNSPEC_LITERAL      11)
40    (UNSPEC_LITUSE       12)
41    (UNSPEC_SIBCALL      13)
42    (UNSPEC_SYMBOL       14)
43
44    ;; TLS Support
45    (UNSPEC_TLSGD_CALL   15)
46    (UNSPEC_TLSLDM_CALL  16)
47    (UNSPEC_TLSGD        17)
48    (UNSPEC_TLSLDM       18)
49    (UNSPEC_DTPREL       19)
50    (UNSPEC_TPREL        20)
51    (UNSPEC_TP           21)
52
53    ;; Builtins
54    (UNSPEC_CMPBGE       22)
55    (UNSPEC_ZAP          23)
56    (UNSPEC_AMASK        24)
57    (UNSPEC_IMPLVER      25)
58    (UNSPEC_PERR         26)
59    (UNSPEC_CTLZ         27)
60    (UNSPEC_CTPOP        28)
61   ])
62
63 ;; UNSPEC_VOLATILE:
64
65 (define_constants
66   [(UNSPECV_IMB         0)
67    (UNSPECV_BLOCKAGE    1)
68    (UNSPECV_SETJMPR     2)      ; builtin_setjmp_receiver
69    (UNSPECV_LONGJMP     3)      ; builtin_longjmp
70    (UNSPECV_TRAPB       4)
71    (UNSPECV_PSPL        5)      ; prologue_stack_probe_loop
72    (UNSPECV_REALIGN     6)
73    (UNSPECV_EHR         7)      ; exception_receiver
74    (UNSPECV_MCOUNT      8)
75    (UNSPECV_FORCE_MOV   9)
76    (UNSPECV_LDGP1       10)
77    (UNSPECV_PLDGP2      11)     ; prologue ldgp
78    (UNSPECV_SET_TP      12)
79    (UNSPECV_RPCC        13)
80   ])
81
82 ;; Where necessary, the suffixes _le and _be are used to distinguish between
83 ;; little-endian and big-endian patterns.
84 ;;
85 ;; Note that the Unicos/Mk assembler does not support the following
86 ;; opcodes: mov, fmov, nop, fnop, unop.
87 \f
88 ;; Processor type -- this attribute must exactly match the processor_type
89 ;; enumeration in alpha.h.
90
91 (define_attr "cpu" "ev4,ev5,ev6"
92   (const (symbol_ref "alpha_cpu")))
93
94 ;; Define an insn type attribute.  This is used in function unit delay
95 ;; computations, among other purposes.  For the most part, we use the names
96 ;; defined in the EV4 documentation, but add a few that we have to know about
97 ;; separately.
98
99 (define_attr "type"
100   "ild,fld,ldsym,ist,fst,ibr,callpal,fbr,jsr,iadd,ilog,shift,icmov,fcmov,
101    icmp,imul,fadd,fmul,fcpys,fdiv,fsqrt,misc,mvi,ftoi,itof,multi,none"
102   (const_string "iadd"))
103
104 ;; Describe a user's asm statement.
105 (define_asm_attributes
106   [(set_attr "type" "multi")])
107
108 ;; Define the operand size an insn operates on.  Used primarily by mul
109 ;; and div operations that have size dependent timings.
110
111 (define_attr "opsize" "si,di,udi"
112   (const_string "di"))
113
114 ;; The TRAP attribute marks instructions that may generate traps
115 ;; (which are imprecise and may need a trapb if software completion
116 ;; is desired).
117
118 (define_attr "trap" "no,yes"
119   (const_string "no"))
120
121 ;; The ROUND_SUFFIX attribute marks which instructions require a
122 ;; rounding-mode suffix.  The value NONE indicates no suffix,
123 ;; the value NORMAL indicates a suffix controlled by alpha_fprm.
124
125 (define_attr "round_suffix" "none,normal,c"
126   (const_string "none"))
127
128 ;; The TRAP_SUFFIX attribute marks instructions requiring a trap-mode suffix:
129 ;;   NONE       no suffix
130 ;;   SU         accepts only /su (cmpt et al)
131 ;;   SUI        accepts only /sui (cvtqt and cvtqs)
132 ;;   V_SV       accepts /v and /sv (cvtql only)
133 ;;   V_SV_SVI   accepts /v, /sv and /svi (cvttq only)
134 ;;   U_SU_SUI   accepts /u, /su and /sui (most fp instructions)
135 ;;
136 ;; The actual suffix emitted is controlled by alpha_fptm.
137
138 (define_attr "trap_suffix" "none,su,sui,v_sv,v_sv_svi,u_su_sui"
139   (const_string "none"))
140
141 ;; The length of an instruction sequence in bytes.
142
143 (define_attr "length" ""
144   (const_int 4))
145
146 ;; The USEGP attribute marks instructions that have relocations that use
147 ;; the GP.
148
149 (define_attr "usegp" "no,yes"
150   (cond [(eq_attr "type" "ldsym,jsr")
151            (const_string "yes")
152          (eq_attr "type" "ild,fld,ist,fst")
153            (symbol_ref "alpha_find_lo_sum_using_gp(insn)")
154         ]
155         (const_string "no")))
156
157 ;; The CANNOT_COPY attribute marks instructions with relocations that
158 ;; cannot easily be duplicated.  This includes insns with gpdisp relocs
159 ;; since they have to stay in 1-1 correspondence with one another.  This
160 ;; also includes jsr insns, since they must stay in correspondence with
161 ;; the immediately following gpdisp instructions.
162
163 (define_attr "cannot_copy" "false,true"
164   (const_string "false"))
165 \f
166 ;; Include scheduling descriptions.
167   
168 (include "ev4.md")
169 (include "ev5.md")
170 (include "ev6.md")
171 \f
172 ;; First define the arithmetic insns.  Note that the 32-bit forms also
173 ;; sign-extend.
174
175 ;; Handle 32-64 bit extension from memory to a floating point register
176 ;; specially, since this occurs frequently in int->double conversions.
177 ;;
178 ;; Note that while we must retain the =f case in the insn for reload's
179 ;; benefit, it should be eliminated after reload, so we should never emit
180 ;; code for that case.  But we don't reject the possibility.
181
182 (define_expand "extendsidi2"
183   [(set (match_operand:DI 0 "register_operand" "")
184         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
185   ""
186   "")
187
188 (define_insn "*cvtlq"
189   [(set (match_operand:DI 0 "register_operand" "=f")
190         (unspec:DI [(match_operand:SF 1 "reg_or_0_operand" "fG")]
191                    UNSPEC_CVTLQ))]
192   ""
193   "cvtlq %1,%0"
194   [(set_attr "type" "fadd")])
195
196 (define_insn "*extendsidi2_1"
197   [(set (match_operand:DI 0 "register_operand" "=r,r,!*f")
198         (sign_extend:DI
199           (match_operand:SI 1 "nonimmediate_operand" "r,m,m")))]
200   ""
201   "@
202    addl $31,%1,%0
203    ldl %0,%1
204    lds %0,%1\;cvtlq %0,%0"
205   [(set_attr "type" "iadd,ild,fld")
206    (set_attr "length" "*,*,8")])
207
208 (define_split
209   [(set (match_operand:DI 0 "hard_fp_register_operand" "")
210         (sign_extend:DI (match_operand:SI 1 "memory_operand" "")))]
211   "reload_completed"
212   [(set (match_dup 2) (match_dup 1))
213    (set (match_dup 0) (unspec:DI [(match_dup 2)] UNSPEC_CVTLQ))]
214 {
215   operands[1] = adjust_address (operands[1], SFmode, 0);
216   operands[2] = gen_rtx_REG (SFmode, REGNO (operands[0]));
217 })
218
219 ;; Optimize sign-extension of SImode loads.  This shows up in the wake of
220 ;; reload when converting fp->int.
221
222 (define_peephole2
223   [(set (match_operand:SI 0 "hard_int_register_operand" "")
224         (match_operand:SI 1 "memory_operand" ""))
225    (set (match_operand:DI 2 "hard_int_register_operand" "")
226         (sign_extend:DI (match_dup 0)))]
227   "true_regnum (operands[0]) == true_regnum (operands[2])
228    || peep2_reg_dead_p (2, operands[0])"
229   [(set (match_dup 2)
230         (sign_extend:DI (match_dup 1)))]
231   "")
232
233 ;; Don't say we have addsi3 if optimizing.  This generates better code.  We
234 ;; have the anonymous addsi3 pattern below in case combine wants to make it.
235 (define_expand "addsi3"
236   [(set (match_operand:SI 0 "register_operand" "")
237         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "")
238                  (match_operand:SI 2 "add_operand" "")))]
239   "! optimize"
240   "")
241
242 (define_insn "*addsi_internal"
243   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
244         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ,rJ,rJ,rJ")
245                  (match_operand:SI 2 "add_operand" "rI,O,K,L")))]
246   ""
247   "@
248    addl %r1,%2,%0
249    subl %r1,%n2,%0
250    lda %0,%2(%r1)
251    ldah %0,%h2(%r1)")
252
253 (define_split
254   [(set (match_operand:SI 0 "register_operand" "")
255         (plus:SI (match_operand:SI 1 "register_operand" "")
256                  (match_operand:SI 2 "const_int_operand" "")))]
257   "! add_operand (operands[2], SImode)"
258   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
259    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
260 {
261   HOST_WIDE_INT val = INTVAL (operands[2]);
262   HOST_WIDE_INT low = (val & 0xffff) - 2 * (val & 0x8000);
263   HOST_WIDE_INT rest = val - low;
264
265   operands[3] = GEN_INT (rest);
266   operands[4] = GEN_INT (low);
267 })
268
269 (define_insn "*addsi_se"
270   [(set (match_operand:DI 0 "register_operand" "=r,r")
271         (sign_extend:DI
272          (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ,rJ")
273                   (match_operand:SI 2 "sext_add_operand" "rI,O"))))]
274   ""
275   "@
276    addl %r1,%2,%0
277    subl %r1,%n2,%0")
278
279 (define_insn "*addsi_se2"
280   [(set (match_operand:DI 0 "register_operand" "=r,r")
281         (sign_extend:DI
282          (subreg:SI (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ")
283                              (match_operand:DI 2 "sext_add_operand" "rI,O"))
284                     0)))]
285   ""
286   "@
287    addl %r1,%2,%0
288    subl %r1,%n2,%0")
289
290 (define_split
291   [(set (match_operand:DI 0 "register_operand" "")
292         (sign_extend:DI
293          (plus:SI (match_operand:SI 1 "reg_not_elim_operand" "")
294                   (match_operand:SI 2 "const_int_operand" ""))))
295    (clobber (match_operand:SI 3 "reg_not_elim_operand" ""))]
296   "! sext_add_operand (operands[2], SImode) && INTVAL (operands[2]) > 0
297    && INTVAL (operands[2]) % 4 == 0"
298   [(set (match_dup 3) (match_dup 4))
299    (set (match_dup 0) (sign_extend:DI (plus:SI (mult:SI (match_dup 3)
300                                                         (match_dup 5))
301                                                (match_dup 1))))]
302 {
303   HOST_WIDE_INT val = INTVAL (operands[2]) / 4;
304   int mult = 4;
305
306   if (val % 2 == 0)
307     val /= 2, mult = 8;
308
309   operands[4] = GEN_INT (val);
310   operands[5] = GEN_INT (mult);
311 })
312
313 (define_split
314   [(set (match_operand:DI 0 "register_operand" "")
315         (sign_extend:DI
316          (plus:SI (match_operator:SI 1 "comparison_operator"
317                                      [(match_operand 2 "" "")
318                                       (match_operand 3 "" "")])
319                   (match_operand:SI 4 "add_operand" ""))))
320    (clobber (match_operand:DI 5 "register_operand" ""))]
321   ""
322   [(set (match_dup 5) (match_dup 6))
323    (set (match_dup 0) (sign_extend:DI (plus:SI (match_dup 7) (match_dup 4))))]
324 {
325   operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[1]), DImode,
326                                 operands[2], operands[3]);
327   operands[7] = gen_lowpart (SImode, operands[5]);
328 })
329
330 (define_insn "addvsi3"
331   [(set (match_operand:SI 0 "register_operand" "=r,r")
332         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ,rJ")
333                  (match_operand:SI 2 "sext_add_operand" "rI,O")))
334    (trap_if (ne (plus:DI (sign_extend:DI (match_dup 1))
335                          (sign_extend:DI (match_dup 2)))
336                 (sign_extend:DI (plus:SI (match_dup 1)
337                                          (match_dup 2))))
338             (const_int 0))]
339   ""
340   "@
341    addlv %r1,%2,%0
342    sublv %r1,%n2,%0")
343
344 (define_expand "adddi3"
345   [(set (match_operand:DI 0 "register_operand" "")
346         (plus:DI (match_operand:DI 1 "register_operand" "")
347                  (match_operand:DI 2 "add_operand" "")))]
348   ""
349   "")
350
351 (define_insn "*adddi_er_lo16_dtp"
352   [(set (match_operand:DI 0 "register_operand" "=r")
353         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
354                    (match_operand:DI 2 "dtp16_symbolic_operand" "")))]
355   "HAVE_AS_TLS"
356   "lda %0,%2(%1)\t\t!dtprel")
357
358 (define_insn "*adddi_er_hi32_dtp"
359   [(set (match_operand:DI 0 "register_operand" "=r")
360         (plus:DI (match_operand:DI 1 "register_operand" "r")
361                  (high:DI (match_operand:DI 2 "dtp32_symbolic_operand" ""))))]
362   "HAVE_AS_TLS"
363   "ldah %0,%2(%1)\t\t!dtprelhi")
364
365 (define_insn "*adddi_er_lo32_dtp"
366   [(set (match_operand:DI 0 "register_operand" "=r")
367         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
368                    (match_operand:DI 2 "dtp32_symbolic_operand" "")))]
369   "HAVE_AS_TLS"
370   "lda %0,%2(%1)\t\t!dtprello")
371
372 (define_insn "*adddi_er_lo16_tp"
373   [(set (match_operand:DI 0 "register_operand" "=r")
374         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
375                    (match_operand:DI 2 "tp16_symbolic_operand" "")))]
376   "HAVE_AS_TLS"
377   "lda %0,%2(%1)\t\t!tprel")
378
379 (define_insn "*adddi_er_hi32_tp"
380   [(set (match_operand:DI 0 "register_operand" "=r")
381         (plus:DI (match_operand:DI 1 "register_operand" "r")
382                  (high:DI (match_operand:DI 2 "tp32_symbolic_operand" ""))))]
383   "HAVE_AS_TLS"
384   "ldah %0,%2(%1)\t\t!tprelhi")
385
386 (define_insn "*adddi_er_lo32_tp"
387   [(set (match_operand:DI 0 "register_operand" "=r")
388         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
389                    (match_operand:DI 2 "tp32_symbolic_operand" "")))]
390   "HAVE_AS_TLS"
391   "lda %0,%2(%1)\t\t!tprello")
392
393 (define_insn "*adddi_er_high_l"
394   [(set (match_operand:DI 0 "register_operand" "=r")
395         (plus:DI (match_operand:DI 1 "register_operand" "r")
396                  (high:DI (match_operand:DI 2 "local_symbolic_operand" ""))))]
397   "TARGET_EXPLICIT_RELOCS && reload_completed"
398   "ldah %0,%2(%1)\t\t!gprelhigh"
399   [(set_attr "usegp" "yes")])
400
401 (define_split
402   [(set (match_operand:DI 0 "register_operand" "")
403         (high:DI (match_operand:DI 1 "local_symbolic_operand" "")))]
404   "TARGET_EXPLICIT_RELOCS && reload_completed"
405   [(set (match_dup 0)
406         (plus:DI (match_dup 2) (high:DI (match_dup 1))))]
407   "operands[2] = pic_offset_table_rtx;")
408
409 ;; We used to expend quite a lot of effort choosing addq/subq/lda.
410 ;; With complications like
411 ;;
412 ;;   The NT stack unwind code can't handle a subq to adjust the stack
413 ;;   (that's a bug, but not one we can do anything about).  As of NT4.0 SP3,
414 ;;   the exception handling code will loop if a subq is used and an
415 ;;   exception occurs.
416 ;;
417 ;;   The 19980616 change to emit prologues as RTL also confused some
418 ;;   versions of GDB, which also interprets prologues.  This has been
419 ;;   fixed as of GDB 4.18, but it does not harm to unconditionally
420 ;;   use lda here.
421 ;;
422 ;; and the fact that the three insns schedule exactly the same, it's
423 ;; just not worth the effort.
424
425 (define_insn "*adddi_internal"
426   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
427         (plus:DI (match_operand:DI 1 "register_operand" "%r,r,r")
428                  (match_operand:DI 2 "add_operand" "r,K,L")))]
429   ""
430   "@
431    addq %1,%2,%0
432    lda %0,%2(%1)
433    ldah %0,%h2(%1)")
434
435 ;; ??? Allow large constants when basing off the frame pointer or some
436 ;; virtual register that may eliminate to the frame pointer.  This is
437 ;; done because register elimination offsets will change the hi/lo split,
438 ;; and if we split before reload, we will require additional instructions.
439
440 (define_insn "*adddi_fp_hack"
441   [(set (match_operand:DI 0 "register_operand" "=r")
442         (plus:DI (match_operand:DI 1 "reg_no_subreg_operand" "r")
443                  (match_operand:DI 2 "const_int_operand" "n")))]
444   "NONSTRICT_REG_OK_FP_BASE_P (operands[1])
445    && INTVAL (operands[2]) >= 0
446    /* This is the largest constant an lda+ldah pair can add, minus
447       an upper bound on the displacement between SP and AP during
448       register elimination.  See INITIAL_ELIMINATION_OFFSET.  */
449    && INTVAL (operands[2])
450         < (0x7fff8000
451            - FIRST_PSEUDO_REGISTER * UNITS_PER_WORD
452            - ALPHA_ROUND(current_function_outgoing_args_size)
453            - (ALPHA_ROUND (get_frame_size ()
454                            + max_reg_num () * UNITS_PER_WORD
455                            + current_function_pretend_args_size)
456               - current_function_pretend_args_size))"
457   "#")
458
459 ;; Don't do this if we are adjusting SP since we don't want to do it
460 ;; in two steps.  Don't split FP sources for the reason listed above.
461 (define_split
462   [(set (match_operand:DI 0 "register_operand" "")
463         (plus:DI (match_operand:DI 1 "register_operand" "")
464                  (match_operand:DI 2 "const_int_operand" "")))]
465   "! add_operand (operands[2], DImode)
466    && operands[0] != stack_pointer_rtx
467    && operands[1] != frame_pointer_rtx
468    && operands[1] != arg_pointer_rtx"
469   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
470    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
471 {
472   HOST_WIDE_INT val = INTVAL (operands[2]);
473   HOST_WIDE_INT low = (val & 0xffff) - 2 * (val & 0x8000);
474   HOST_WIDE_INT rest = val - low;
475
476   operands[4] = GEN_INT (low);
477   if (CONST_OK_FOR_LETTER_P (rest, 'L'))
478     operands[3] = GEN_INT (rest);
479   else if (! no_new_pseudos)
480     {
481       operands[3] = gen_reg_rtx (DImode);
482       emit_move_insn (operands[3], operands[2]);
483       emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
484       DONE;
485     }
486   else
487     FAIL;
488 })
489
490 (define_insn "*saddl"
491   [(set (match_operand:SI 0 "register_operand" "=r,r")
492         (plus:SI (mult:SI (match_operand:SI 1 "reg_not_elim_operand" "r,r")
493                           (match_operand:SI 2 "const48_operand" "I,I"))
494                  (match_operand:SI 3 "sext_add_operand" "rI,O")))]
495   ""
496   "@
497    s%2addl %1,%3,%0
498    s%2subl %1,%n3,%0")
499
500 (define_insn "*saddl_se"
501   [(set (match_operand:DI 0 "register_operand" "=r,r")
502         (sign_extend:DI
503          (plus:SI (mult:SI (match_operand:SI 1 "reg_not_elim_operand" "r,r")
504                            (match_operand:SI 2 "const48_operand" "I,I"))
505                   (match_operand:SI 3 "sext_add_operand" "rI,O"))))]
506   ""
507   "@
508    s%2addl %1,%3,%0
509    s%2subl %1,%n3,%0")
510
511 (define_split
512   [(set (match_operand:DI 0 "register_operand" "")
513         (sign_extend:DI
514          (plus:SI (mult:SI (match_operator:SI 1 "comparison_operator"
515                                               [(match_operand 2 "" "")
516                                                (match_operand 3 "" "")])
517                            (match_operand:SI 4 "const48_operand" ""))
518                   (match_operand:SI 5 "sext_add_operand" ""))))
519    (clobber (match_operand:DI 6 "reg_not_elim_operand" ""))]
520   ""
521   [(set (match_dup 6) (match_dup 7))
522    (set (match_dup 0)
523         (sign_extend:DI (plus:SI (mult:SI (match_dup 8) (match_dup 4))
524                                  (match_dup 5))))]
525 {
526   operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[1]), DImode,
527                                 operands[2], operands[3]);
528   operands[8] = gen_lowpart (SImode, operands[6]);
529 })
530
531 (define_insn "*saddq"
532   [(set (match_operand:DI 0 "register_operand" "=r,r")
533         (plus:DI (mult:DI (match_operand:DI 1 "reg_not_elim_operand" "r,r")
534                           (match_operand:DI 2 "const48_operand" "I,I"))
535                  (match_operand:DI 3 "sext_add_operand" "rI,O")))]
536   ""
537   "@
538    s%2addq %1,%3,%0
539    s%2subq %1,%n3,%0")
540
541 (define_insn "addvdi3"
542   [(set (match_operand:DI 0 "register_operand" "=r,r")
543         (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ")
544                  (match_operand:DI 2 "sext_add_operand" "rI,O")))
545    (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
546                          (sign_extend:TI (match_dup 2)))
547                 (sign_extend:TI (plus:DI (match_dup 1)
548                                          (match_dup 2))))
549             (const_int 0))]
550   ""
551   "@
552    addqv %r1,%2,%0
553    subqv %r1,%n2,%0")
554
555 (define_insn "negsi2"
556   [(set (match_operand:SI 0 "register_operand" "=r")
557         (neg:SI (match_operand:SI 1 "reg_or_8bit_operand" "rI")))]
558   ""
559   "subl $31,%1,%0")
560
561 (define_insn "*negsi_se"
562   [(set (match_operand:DI 0 "register_operand" "=r")
563         (sign_extend:DI (neg:SI
564                          (match_operand:SI 1 "reg_or_8bit_operand" "rI"))))]
565   ""
566   "subl $31,%1,%0")
567
568 (define_insn "negvsi2"
569   [(set (match_operand:SI 0 "register_operand" "=r")
570         (neg:SI (match_operand:SI 1 "register_operand" "r")))
571    (trap_if (ne (neg:DI (sign_extend:DI (match_dup 1)))
572                 (sign_extend:DI (neg:SI (match_dup 1))))
573             (const_int 0))]
574   ""
575   "sublv $31,%1,%0")
576
577 (define_insn "negdi2"
578   [(set (match_operand:DI 0 "register_operand" "=r")
579         (neg:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI")))]
580   ""
581   "subq $31,%1,%0")
582
583 (define_insn "negvdi2"
584   [(set (match_operand:DI 0 "register_operand" "=r")
585         (neg:DI (match_operand:DI 1 "register_operand" "r")))
586    (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
587                 (sign_extend:TI (neg:DI (match_dup 1))))
588             (const_int 0))]
589   ""
590   "subqv $31,%1,%0")
591
592 (define_expand "subsi3"
593   [(set (match_operand:SI 0 "register_operand" "")
594         (minus:SI (match_operand:SI 1 "reg_or_0_operand" "")
595                   (match_operand:SI 2 "reg_or_8bit_operand" "")))]
596   "! optimize"
597   "")
598
599 (define_insn "*subsi_internal"
600   [(set (match_operand:SI 0 "register_operand" "=r")
601         (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
602                   (match_operand:SI 2 "reg_or_8bit_operand" "rI")))]
603   ""
604   "subl %r1,%2,%0")
605
606 (define_insn "*subsi_se"
607   [(set (match_operand:DI 0 "register_operand" "=r")
608         (sign_extend:DI (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
609                                   (match_operand:SI 2 "reg_or_8bit_operand" "rI"))))]
610   ""
611   "subl %r1,%2,%0")
612
613 (define_insn "*subsi_se2"
614   [(set (match_operand:DI 0 "register_operand" "=r")
615         (sign_extend:DI
616          (subreg:SI (minus:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
617                               (match_operand:DI 2 "reg_or_8bit_operand" "rI"))
618                     0)))]
619   ""
620   "subl %r1,%2,%0")
621
622 (define_insn "subvsi3"
623   [(set (match_operand:SI 0 "register_operand" "=r")
624         (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
625                   (match_operand:SI 2 "reg_or_8bit_operand" "rI")))
626    (trap_if (ne (minus:DI (sign_extend:DI (match_dup 1))
627                           (sign_extend:DI (match_dup 2)))
628                 (sign_extend:DI (minus:SI (match_dup 1)
629                                           (match_dup 2))))
630             (const_int 0))]
631   ""
632   "sublv %r1,%2,%0")
633
634 (define_insn "subdi3"
635   [(set (match_operand:DI 0 "register_operand" "=r")
636         (minus:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
637                   (match_operand:DI 2 "reg_or_8bit_operand" "rI")))]
638   ""
639   "subq %r1,%2,%0")
640
641 (define_insn "*ssubl"
642   [(set (match_operand:SI 0 "register_operand" "=r")
643         (minus:SI (mult:SI (match_operand:SI 1 "reg_not_elim_operand" "r")
644                            (match_operand:SI 2 "const48_operand" "I"))
645                   (match_operand:SI 3 "reg_or_8bit_operand" "rI")))]
646   ""
647   "s%2subl %1,%3,%0")
648
649 (define_insn "*ssubl_se"
650   [(set (match_operand:DI 0 "register_operand" "=r")
651         (sign_extend:DI
652          (minus:SI (mult:SI (match_operand:SI 1 "reg_not_elim_operand" "r")
653                             (match_operand:SI 2 "const48_operand" "I"))
654                    (match_operand:SI 3 "reg_or_8bit_operand" "rI"))))]
655   ""
656   "s%2subl %1,%3,%0")
657
658 (define_insn "*ssubq"
659   [(set (match_operand:DI 0 "register_operand" "=r")
660         (minus:DI (mult:DI (match_operand:DI 1 "reg_not_elim_operand" "r")
661                            (match_operand:DI 2 "const48_operand" "I"))
662                   (match_operand:DI 3 "reg_or_8bit_operand" "rI")))]
663   ""
664   "s%2subq %1,%3,%0")
665
666 (define_insn "subvdi3"
667   [(set (match_operand:DI 0 "register_operand" "=r")
668         (minus:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
669                   (match_operand:DI 2 "reg_or_8bit_operand" "rI")))
670    (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
671                           (sign_extend:TI (match_dup 2)))
672                 (sign_extend:TI (minus:DI (match_dup 1)
673                                           (match_dup 2))))
674             (const_int 0))]
675   ""
676   "subqv %r1,%2,%0")
677
678 ;; The Unicos/Mk assembler doesn't support mull.
679
680 (define_insn "mulsi3"
681   [(set (match_operand:SI 0 "register_operand" "=r")
682         (mult:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
683                  (match_operand:SI 2 "reg_or_8bit_operand" "rI")))]
684   "!TARGET_ABI_UNICOSMK"
685   "mull %r1,%2,%0"
686   [(set_attr "type" "imul")
687    (set_attr "opsize" "si")])
688
689 (define_insn "*mulsi_se"
690   [(set (match_operand:DI 0 "register_operand" "=r")
691         (sign_extend:DI
692           (mult:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
693                    (match_operand:SI 2 "reg_or_8bit_operand" "rI"))))]
694   "!TARGET_ABI_UNICOSMK"
695   "mull %r1,%2,%0"
696   [(set_attr "type" "imul")
697    (set_attr "opsize" "si")])
698
699 (define_insn "mulvsi3"
700   [(set (match_operand:SI 0 "register_operand" "=r")
701         (mult:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
702                  (match_operand:SI 2 "reg_or_8bit_operand" "rI")))
703    (trap_if (ne (mult:DI (sign_extend:DI (match_dup 1))
704                          (sign_extend:DI (match_dup 2)))
705                 (sign_extend:DI (mult:SI (match_dup 1)
706                                          (match_dup 2))))
707             (const_int 0))]
708   "!TARGET_ABI_UNICOSMK"
709   "mullv %r1,%2,%0"
710   [(set_attr "type" "imul")
711    (set_attr "opsize" "si")])
712
713 (define_insn "muldi3"
714   [(set (match_operand:DI 0 "register_operand" "=r")
715         (mult:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ")
716                  (match_operand:DI 2 "reg_or_8bit_operand" "rI")))]
717   ""
718   "mulq %r1,%2,%0"
719   [(set_attr "type" "imul")])
720
721 (define_insn "mulvdi3"
722   [(set (match_operand:DI 0 "register_operand" "=r")
723         (mult:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ")
724                  (match_operand:DI 2 "reg_or_8bit_operand" "rI")))
725    (trap_if (ne (mult:TI (sign_extend:TI (match_dup 1))
726                          (sign_extend:TI (match_dup 2)))
727                 (sign_extend:TI (mult:DI (match_dup 1)
728                                          (match_dup 2))))
729             (const_int 0))]
730   ""
731   "mulqv %r1,%2,%0"
732   [(set_attr "type" "imul")])
733
734 (define_expand "umuldi3_highpart"
735   [(set (match_operand:DI 0 "register_operand" "")
736         (truncate:DI
737          (lshiftrt:TI
738           (mult:TI (zero_extend:TI
739                      (match_operand:DI 1 "register_operand" ""))
740                    (match_operand:DI 2 "reg_or_8bit_operand" ""))
741           (const_int 64))))]
742   ""
743 {
744   if (REG_P (operands[2]))
745     operands[2] = gen_rtx_ZERO_EXTEND (TImode, operands[2]);
746 })
747
748 (define_insn "*umuldi3_highpart_reg"
749   [(set (match_operand:DI 0 "register_operand" "=r")
750         (truncate:DI
751          (lshiftrt:TI
752           (mult:TI (zero_extend:TI
753                      (match_operand:DI 1 "register_operand" "r"))
754                    (zero_extend:TI
755                      (match_operand:DI 2 "register_operand" "r")))
756           (const_int 64))))]
757   ""
758   "umulh %1,%2,%0"
759   [(set_attr "type" "imul")
760    (set_attr "opsize" "udi")])
761
762 (define_insn "*umuldi3_highpart_const"
763   [(set (match_operand:DI 0 "register_operand" "=r")
764         (truncate:DI
765          (lshiftrt:TI
766           (mult:TI (zero_extend:TI (match_operand:DI 1 "register_operand" "r"))
767                    (match_operand:TI 2 "cint8_operand" "I"))
768           (const_int 64))))]
769   ""
770   "umulh %1,%2,%0"
771   [(set_attr "type" "imul")
772    (set_attr "opsize" "udi")])
773 \f
774 ;; The divide and remainder operations take their inputs from r24 and
775 ;; r25, put their output in r27, and clobber r23 and r28 on all
776 ;; systems except Unicos/Mk. On Unicos, the standard library provides
777 ;; subroutines which use the standard calling convention and work on
778 ;; DImode operands.
779
780 ;; ??? Force sign-extension here because some versions of OSF/1 and
781 ;; Interix/NT don't do the right thing if the inputs are not properly
782 ;; sign-extended.  But Linux, for instance, does not have this
783 ;; problem.  Is it worth the complication here to eliminate the sign
784 ;; extension?
785
786 (define_expand "divsi3"
787   [(set (match_dup 3)
788         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))
789    (set (match_dup 4)
790         (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "")))
791    (parallel [(set (match_dup 5)
792                    (sign_extend:DI (div:SI (match_dup 3) (match_dup 4))))
793               (clobber (reg:DI 23))
794               (clobber (reg:DI 28))])
795    (set (match_operand:SI 0 "nonimmediate_operand" "")
796         (subreg:SI (match_dup 5) 0))]
797   "! TARGET_ABI_OPEN_VMS && ! TARGET_ABI_UNICOSMK"
798 {
799   operands[3] = gen_reg_rtx (DImode);
800   operands[4] = gen_reg_rtx (DImode);
801   operands[5] = gen_reg_rtx (DImode);
802 })
803
804 (define_expand "udivsi3"
805   [(set (match_dup 3)
806         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))
807    (set (match_dup 4)
808         (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "")))
809    (parallel [(set (match_dup 5)
810                    (sign_extend:DI (udiv:SI (match_dup 3) (match_dup 4))))
811               (clobber (reg:DI 23))
812               (clobber (reg:DI 28))])
813    (set (match_operand:SI 0 "nonimmediate_operand" "")
814         (subreg:SI (match_dup 5) 0))]
815   "! TARGET_ABI_OPEN_VMS && ! TARGET_ABI_UNICOSMK"
816 {
817   operands[3] = gen_reg_rtx (DImode);
818   operands[4] = gen_reg_rtx (DImode);
819   operands[5] = gen_reg_rtx (DImode);
820 })
821
822 (define_expand "modsi3"
823   [(set (match_dup 3)
824         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))
825    (set (match_dup 4)
826         (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "")))
827    (parallel [(set (match_dup 5)
828                    (sign_extend:DI (mod:SI (match_dup 3) (match_dup 4))))
829               (clobber (reg:DI 23))
830               (clobber (reg:DI 28))])
831    (set (match_operand:SI 0 "nonimmediate_operand" "")
832         (subreg:SI (match_dup 5) 0))]
833   "! TARGET_ABI_OPEN_VMS && ! TARGET_ABI_UNICOSMK"
834 {
835   operands[3] = gen_reg_rtx (DImode);
836   operands[4] = gen_reg_rtx (DImode);
837   operands[5] = gen_reg_rtx (DImode);
838 })
839
840 (define_expand "umodsi3"
841   [(set (match_dup 3)
842         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))
843    (set (match_dup 4)
844         (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "")))
845    (parallel [(set (match_dup 5)
846                    (sign_extend:DI (umod:SI (match_dup 3) (match_dup 4))))
847               (clobber (reg:DI 23))
848               (clobber (reg:DI 28))])
849    (set (match_operand:SI 0 "nonimmediate_operand" "")
850         (subreg:SI (match_dup 5) 0))]
851   "! TARGET_ABI_OPEN_VMS && ! TARGET_ABI_UNICOSMK"
852 {
853   operands[3] = gen_reg_rtx (DImode);
854   operands[4] = gen_reg_rtx (DImode);
855   operands[5] = gen_reg_rtx (DImode);
856 })
857
858 (define_expand "divdi3"
859   [(parallel [(set (match_operand:DI 0 "register_operand" "")
860                    (div:DI (match_operand:DI 1 "register_operand" "")
861                            (match_operand:DI 2 "register_operand" "")))
862               (clobber (reg:DI 23))
863               (clobber (reg:DI 28))])]
864   "! TARGET_ABI_OPEN_VMS && ! TARGET_ABI_UNICOSMK"
865   "")
866
867 (define_expand "udivdi3"
868   [(parallel [(set (match_operand:DI 0 "register_operand" "")
869                    (udiv:DI (match_operand:DI 1 "register_operand" "")
870                             (match_operand:DI 2 "register_operand" "")))
871               (clobber (reg:DI 23))
872               (clobber (reg:DI 28))])]
873   "! TARGET_ABI_OPEN_VMS && ! TARGET_ABI_UNICOSMK"
874   "")
875
876 (define_expand "moddi3"
877   [(use (match_operand:DI 0 "register_operand" ""))
878    (use (match_operand:DI 1 "register_operand" ""))
879    (use (match_operand:DI 2 "register_operand" ""))]
880   "!TARGET_ABI_OPEN_VMS"
881 {
882   if (TARGET_ABI_UNICOSMK)
883     emit_insn (gen_moddi3_umk (operands[0], operands[1], operands[2]));
884   else
885     emit_insn (gen_moddi3_dft (operands[0], operands[1], operands[2]));
886   DONE;
887 })
888
889 (define_expand "moddi3_dft"
890   [(parallel [(set (match_operand:DI 0 "register_operand" "")
891                    (mod:DI (match_operand:DI 1 "register_operand" "")
892                            (match_operand:DI 2 "register_operand" "")))
893               (clobber (reg:DI 23))
894               (clobber (reg:DI 28))])]
895   "! TARGET_ABI_OPEN_VMS && ! TARGET_ABI_UNICOSMK"
896   "")
897
898 ;; On Unicos/Mk, we do as the system's C compiler does:
899 ;; compute the quotient, multiply and subtract.
900
901 (define_expand "moddi3_umk"
902   [(use (match_operand:DI 0 "register_operand" ""))
903    (use (match_operand:DI 1 "register_operand" ""))
904    (use (match_operand:DI 2 "register_operand" ""))]
905   "TARGET_ABI_UNICOSMK"
906 {
907   rtx div, mul = gen_reg_rtx (DImode);
908
909   div = expand_binop (DImode, sdiv_optab, operands[1], operands[2],
910                       NULL_RTX, 0, OPTAB_LIB);
911   div = force_reg (DImode, div);
912   emit_insn (gen_muldi3 (mul, operands[2], div));
913   emit_insn (gen_subdi3 (operands[0], operands[1], mul));
914   DONE;
915 })
916
917 (define_expand "umoddi3"
918   [(use (match_operand:DI 0 "register_operand" ""))
919    (use (match_operand:DI 1 "register_operand" ""))
920    (use (match_operand:DI 2 "register_operand" ""))]
921   "! TARGET_ABI_OPEN_VMS"
922 {
923   if (TARGET_ABI_UNICOSMK)
924     emit_insn (gen_umoddi3_umk (operands[0], operands[1], operands[2]));
925   else
926     emit_insn (gen_umoddi3_dft (operands[0], operands[1], operands[2]));
927   DONE;
928 })
929
930 (define_expand "umoddi3_dft"
931   [(parallel [(set (match_operand:DI 0 "register_operand" "")
932                    (umod:DI (match_operand:DI 1 "register_operand" "")
933                             (match_operand:DI 2 "register_operand" "")))
934               (clobber (reg:DI 23))
935               (clobber (reg:DI 28))])]
936   "! TARGET_ABI_OPEN_VMS && ! TARGET_ABI_UNICOSMK"
937   "")
938
939 (define_expand "umoddi3_umk"
940   [(use (match_operand:DI 0 "register_operand" ""))
941    (use (match_operand:DI 1 "register_operand" ""))
942    (use (match_operand:DI 2 "register_operand" ""))]
943   "TARGET_ABI_UNICOSMK"
944 {
945   rtx div, mul = gen_reg_rtx (DImode);
946
947   div = expand_binop (DImode, udiv_optab, operands[1], operands[2],
948                       NULL_RTX, 1, OPTAB_LIB);
949   div = force_reg (DImode, div);
950   emit_insn (gen_muldi3 (mul, operands[2], div));
951   emit_insn (gen_subdi3 (operands[0], operands[1], mul));
952   DONE;
953 })
954
955 ;; Lengths of 8 for ldq $t12,__divq($gp); jsr $t9,($t12),__divq as
956 ;; expanded by the assembler.
957
958 (define_insn_and_split "*divmodsi_internal_er"
959   [(set (match_operand:DI 0 "register_operand" "=c")
960         (sign_extend:DI (match_operator:SI 3 "divmod_operator"
961                         [(match_operand:DI 1 "register_operand" "a")
962                          (match_operand:DI 2 "register_operand" "b")])))
963    (clobber (reg:DI 23))
964    (clobber (reg:DI 28))]
965   "TARGET_EXPLICIT_RELOCS && ! TARGET_ABI_OPEN_VMS"
966   "ldq $27,__%E3($29)\t\t!literal!%#\;jsr $23,($27),__%E3\t\t!lituse_jsr!%#"
967   "&& reload_completed"
968   [(parallel [(set (match_dup 0)
969                    (sign_extend:DI (match_dup 3)))
970               (use (match_dup 0))
971               (use (match_dup 4))
972               (clobber (reg:DI 23))
973               (clobber (reg:DI 28))])]
974 {
975   const char *str;
976   switch (GET_CODE (operands[3]))
977     {
978     case DIV: 
979       str = "__divl";
980       break; 
981     case UDIV:
982       str = "__divlu";
983       break;
984     case MOD:
985       str = "__reml";
986       break;
987     case UMOD:
988       str = "__remlu";
989       break;
990     default:
991       abort ();
992     }
993   operands[4] = GEN_INT (alpha_next_sequence_number++);
994   emit_insn (gen_movdi_er_high_g (operands[0], pic_offset_table_rtx,
995                                   gen_rtx_SYMBOL_REF (DImode, str),
996                                   operands[4]));
997 }
998   [(set_attr "type" "jsr")
999    (set_attr "length" "8")])
1000
1001 (define_insn "*divmodsi_internal_er_1"
1002   [(set (match_operand:DI 0 "register_operand" "=c")
1003         (sign_extend:DI (match_operator:SI 3 "divmod_operator"
1004                         [(match_operand:DI 1 "register_operand" "a")
1005                          (match_operand:DI 2 "register_operand" "b")])))
1006    (use (match_operand:DI 4 "register_operand" "c"))
1007    (use (match_operand 5 "const_int_operand" ""))
1008    (clobber (reg:DI 23))
1009    (clobber (reg:DI 28))]
1010   "TARGET_EXPLICIT_RELOCS && ! TARGET_ABI_OPEN_VMS"
1011   "jsr $23,($27),__%E3%J5"
1012   [(set_attr "type" "jsr")
1013    (set_attr "length" "4")])
1014
1015 (define_insn "*divmodsi_internal"
1016   [(set (match_operand:DI 0 "register_operand" "=c")
1017         (sign_extend:DI (match_operator:SI 3 "divmod_operator"
1018                         [(match_operand:DI 1 "register_operand" "a")
1019                          (match_operand:DI 2 "register_operand" "b")])))
1020    (clobber (reg:DI 23))
1021    (clobber (reg:DI 28))]
1022   "! TARGET_ABI_OPEN_VMS && ! TARGET_ABI_UNICOSMK"
1023   "%E3 %1,%2,%0"
1024   [(set_attr "type" "jsr")
1025    (set_attr "length" "8")])
1026
1027 (define_insn_and_split "*divmoddi_internal_er"
1028   [(set (match_operand:DI 0 "register_operand" "=c")
1029         (match_operator:DI 3 "divmod_operator"
1030                         [(match_operand:DI 1 "register_operand" "a")
1031                          (match_operand:DI 2 "register_operand" "b")]))
1032    (clobber (reg:DI 23))
1033    (clobber (reg:DI 28))]
1034   "TARGET_EXPLICIT_RELOCS && ! TARGET_ABI_OPEN_VMS"
1035   "ldq $27,__%E3($29)\t\t!literal!%#\;jsr $23,($27),__%E3\t\t!lituse_jsr!%#"
1036   "&& reload_completed"
1037   [(parallel [(set (match_dup 0) (match_dup 3))
1038               (use (match_dup 0))
1039               (use (match_dup 4))
1040               (clobber (reg:DI 23))
1041               (clobber (reg:DI 28))])]
1042 {
1043   const char *str;
1044   switch (GET_CODE (operands[3]))
1045     {
1046     case DIV: 
1047       str = "__divq";
1048       break; 
1049     case UDIV:
1050       str = "__divqu";
1051       break;
1052     case MOD:
1053       str = "__remq";
1054       break;
1055     case UMOD:
1056       str = "__remqu";
1057       break;
1058     default:
1059       abort ();
1060     }
1061   operands[4] = GEN_INT (alpha_next_sequence_number++);
1062   emit_insn (gen_movdi_er_high_g (operands[0], pic_offset_table_rtx,
1063                                   gen_rtx_SYMBOL_REF (DImode, str),
1064                                   operands[4]));
1065 }
1066   [(set_attr "type" "jsr")
1067    (set_attr "length" "8")])
1068
1069 (define_insn "*divmoddi_internal_er_1"
1070   [(set (match_operand:DI 0 "register_operand" "=c")
1071         (match_operator:DI 3 "divmod_operator"
1072                         [(match_operand:DI 1 "register_operand" "a")
1073                          (match_operand:DI 2 "register_operand" "b")]))
1074    (use (match_operand:DI 4 "register_operand" "c"))
1075    (use (match_operand 5 "const_int_operand" ""))
1076    (clobber (reg:DI 23))
1077    (clobber (reg:DI 28))]
1078   "TARGET_EXPLICIT_RELOCS && ! TARGET_ABI_OPEN_VMS"
1079   "jsr $23,($27),__%E3%J5"
1080   [(set_attr "type" "jsr")
1081    (set_attr "length" "4")])
1082
1083 (define_insn "*divmoddi_internal"
1084   [(set (match_operand:DI 0 "register_operand" "=c")
1085         (match_operator:DI 3 "divmod_operator"
1086                         [(match_operand:DI 1 "register_operand" "a")
1087                          (match_operand:DI 2 "register_operand" "b")]))
1088    (clobber (reg:DI 23))
1089    (clobber (reg:DI 28))]
1090   "! TARGET_ABI_OPEN_VMS && ! TARGET_ABI_UNICOSMK"
1091   "%E3 %1,%2,%0"
1092   [(set_attr "type" "jsr")
1093    (set_attr "length" "8")])
1094 \f
1095 ;; Next are the basic logical operations.  These only exist in DImode.
1096
1097 (define_insn "anddi3"
1098   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1099         (and:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ,rJ")
1100                 (match_operand:DI 2 "and_operand" "rI,N,MH")))]
1101   ""
1102   "@
1103    and %r1,%2,%0
1104    bic %r1,%N2,%0
1105    zapnot %r1,%m2,%0"
1106   [(set_attr "type" "ilog,ilog,shift")])
1107
1108 ;; There are times when we can split an AND into two AND insns.  This occurs
1109 ;; when we can first clear any bytes and then clear anything else.  For
1110 ;; example "I & 0xffff07" is "(I & 0xffffff) & 0xffffffffffffff07".
1111 ;; Only do this when running on 64-bit host since the computations are
1112 ;; too messy otherwise.
1113
1114 (define_split
1115   [(set (match_operand:DI 0 "register_operand" "")
1116         (and:DI (match_operand:DI 1 "register_operand" "")
1117                 (match_operand:DI 2 "const_int_operand" "")))]
1118   "HOST_BITS_PER_WIDE_INT == 64 && ! and_operand (operands[2], DImode)"
1119   [(set (match_dup 0) (and:DI (match_dup 1) (match_dup 3)))
1120    (set (match_dup 0) (and:DI (match_dup 0) (match_dup 4)))]
1121 {
1122   unsigned HOST_WIDE_INT mask1 = INTVAL (operands[2]);
1123   unsigned HOST_WIDE_INT mask2 = mask1;
1124   int i;
1125
1126   /* For each byte that isn't all zeros, make it all ones.  */
1127   for (i = 0; i < 64; i += 8)
1128     if ((mask1 & ((HOST_WIDE_INT) 0xff << i)) != 0)
1129       mask1 |= (HOST_WIDE_INT) 0xff << i;
1130
1131   /* Now turn on any bits we've just turned off.  */
1132   mask2 |= ~ mask1;
1133
1134   operands[3] = GEN_INT (mask1);
1135   operands[4] = GEN_INT (mask2);
1136 })
1137
1138 (define_expand "zero_extendqihi2"
1139   [(set (match_operand:HI 0 "register_operand" "")
1140         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
1141   ""
1142 {
1143   if (! TARGET_BWX)
1144     operands[1] = force_reg (QImode, operands[1]);
1145 })
1146
1147 (define_insn "*zero_extendqihi2_bwx"
1148   [(set (match_operand:HI 0 "register_operand" "=r,r")
1149         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
1150   "TARGET_BWX"
1151   "@
1152    and %1,0xff,%0
1153    ldbu %0,%1"
1154   [(set_attr "type" "ilog,ild")])
1155
1156 (define_insn "*zero_extendqihi2_nobwx"
1157   [(set (match_operand:HI 0 "register_operand" "=r")
1158         (zero_extend:HI (match_operand:QI 1 "register_operand" "r")))]
1159   "! TARGET_BWX"
1160   "and %1,0xff,%0"
1161   [(set_attr "type" "ilog")])
1162
1163 (define_expand "zero_extendqisi2"
1164   [(set (match_operand:SI 0 "register_operand" "")
1165         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1166   ""
1167 {
1168   if (! TARGET_BWX)
1169     operands[1] = force_reg (QImode, operands[1]);
1170 })
1171
1172 (define_insn "*zero_extendqisi2_bwx"
1173   [(set (match_operand:SI 0 "register_operand" "=r,r")
1174         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
1175   "TARGET_BWX"
1176   "@
1177    and %1,0xff,%0
1178    ldbu %0,%1"
1179   [(set_attr "type" "ilog,ild")])
1180
1181 (define_insn "*zero_extendqisi2_nobwx"
1182   [(set (match_operand:SI 0 "register_operand" "=r")
1183         (zero_extend:SI (match_operand:QI 1 "register_operand" "r")))]
1184   "! TARGET_BWX"
1185   "and %1,0xff,%0"
1186   [(set_attr "type" "ilog")])
1187
1188 (define_expand "zero_extendqidi2"
1189   [(set (match_operand:DI 0 "register_operand" "")
1190         (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "")))]
1191   ""
1192 {
1193   if (! TARGET_BWX)
1194     operands[1] = force_reg (QImode, operands[1]);
1195 })
1196
1197 (define_insn "*zero_extendqidi2_bwx"
1198   [(set (match_operand:DI 0 "register_operand" "=r,r")
1199         (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
1200   "TARGET_BWX"
1201   "@
1202    and %1,0xff,%0
1203    ldbu %0,%1"
1204   [(set_attr "type" "ilog,ild")])
1205
1206 (define_insn "*zero_extendqidi2_nobwx"
1207   [(set (match_operand:DI 0 "register_operand" "=r")
1208         (zero_extend:DI (match_operand:QI 1 "register_operand" "r")))]
1209   "! TARGET_BWX"
1210   "and %1,0xff,%0"
1211   [(set_attr "type" "ilog")])
1212
1213 (define_expand "zero_extendhisi2"
1214   [(set (match_operand:SI 0 "register_operand" "")
1215         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
1216   ""
1217 {
1218   if (! TARGET_BWX)
1219     operands[1] = force_reg (HImode, operands[1]);
1220 })
1221
1222 (define_insn "*zero_extendhisi2_bwx"
1223   [(set (match_operand:SI 0 "register_operand" "=r,r")
1224         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
1225   "TARGET_BWX"
1226   "@
1227    zapnot %1,3,%0
1228    ldwu %0,%1"
1229   [(set_attr "type" "shift,ild")])
1230
1231 (define_insn "*zero_extendhisi2_nobwx"
1232   [(set (match_operand:SI 0 "register_operand" "=r")
1233         (zero_extend:SI (match_operand:HI 1 "register_operand" "r")))]
1234   "! TARGET_BWX"
1235   "zapnot %1,3,%0"
1236   [(set_attr "type" "shift")])
1237
1238 (define_expand "zero_extendhidi2"
1239   [(set (match_operand:DI 0 "register_operand" "")
1240         (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "")))]
1241   ""
1242 {
1243   if (! TARGET_BWX)
1244     operands[1] = force_reg (HImode, operands[1]);
1245 })
1246
1247 (define_insn "*zero_extendhidi2_bwx"
1248   [(set (match_operand:DI 0 "register_operand" "=r,r")
1249         (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
1250   "TARGET_BWX"
1251   "@
1252    zapnot %1,3,%0
1253    ldwu %0,%1"
1254   [(set_attr "type" "shift,ild")])
1255
1256 (define_insn "*zero_extendhidi2_nobwx"
1257   [(set (match_operand:DI 0 "register_operand" "=r")
1258         (zero_extend:DI (match_operand:HI 1 "register_operand" "r")))]
1259   ""
1260   "zapnot %1,3,%0"
1261   [(set_attr "type" "shift")])
1262
1263 (define_insn "zero_extendsidi2"
1264   [(set (match_operand:DI 0 "register_operand" "=r")
1265         (zero_extend:DI (match_operand:SI 1 "register_operand" "r")))]
1266   ""
1267   "zapnot %1,15,%0"
1268   [(set_attr "type" "shift")])
1269
1270 (define_insn "andnotdi3"
1271   [(set (match_operand:DI 0 "register_operand" "=r")
1272         (and:DI (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI"))
1273                 (match_operand:DI 2 "reg_or_0_operand" "rJ")))]
1274   ""
1275   "bic %r2,%1,%0"
1276   [(set_attr "type" "ilog")])
1277
1278 (define_insn "iordi3"
1279   [(set (match_operand:DI 0 "register_operand" "=r,r")
1280         (ior:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ")
1281                 (match_operand:DI 2 "or_operand" "rI,N")))]
1282   ""
1283   "@
1284    bis %r1,%2,%0
1285    ornot %r1,%N2,%0"
1286   [(set_attr "type" "ilog")])
1287
1288 (define_insn "one_cmpldi2"
1289   [(set (match_operand:DI 0 "register_operand" "=r")
1290         (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI")))]
1291   ""
1292   "ornot $31,%1,%0"
1293   [(set_attr "type" "ilog")])
1294
1295 (define_insn "*iornot"
1296   [(set (match_operand:DI 0 "register_operand" "=r")
1297         (ior:DI (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI"))
1298                 (match_operand:DI 2 "reg_or_0_operand" "rJ")))]
1299   ""
1300   "ornot %r2,%1,%0"
1301   [(set_attr "type" "ilog")])
1302
1303 (define_insn "xordi3"
1304   [(set (match_operand:DI 0 "register_operand" "=r,r")
1305         (xor:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ")
1306                 (match_operand:DI 2 "or_operand" "rI,N")))]
1307   ""
1308   "@
1309    xor %r1,%2,%0
1310    eqv %r1,%N2,%0"
1311   [(set_attr "type" "ilog")])
1312
1313 (define_insn "*xornot"
1314   [(set (match_operand:DI 0 "register_operand" "=r")
1315         (not:DI (xor:DI (match_operand:DI 1 "register_operand" "%rJ")
1316                         (match_operand:DI 2 "register_operand" "rI"))))]
1317   ""
1318   "eqv %r1,%2,%0"
1319   [(set_attr "type" "ilog")])
1320 \f
1321 ;; Handle FFS and related insns iff we support CIX.
1322
1323 (define_expand "ffsdi2"
1324   [(set (match_dup 2)
1325         (unspec:DI [(match_operand:DI 1 "register_operand" "")] UNSPEC_CTTZ))
1326    (set (match_dup 3)
1327         (plus:DI (match_dup 2) (const_int 1)))
1328    (set (match_operand:DI 0 "register_operand" "")
1329         (if_then_else:DI (eq (match_dup 1) (const_int 0))
1330                          (const_int 0) (match_dup 3)))]
1331   "TARGET_CIX"
1332 {
1333   operands[2] = gen_reg_rtx (DImode);
1334   operands[3] = gen_reg_rtx (DImode);
1335 })
1336
1337 (define_insn "*cttz"
1338   [(set (match_operand:DI 0 "register_operand" "=r")
1339         (unspec:DI [(match_operand:DI 1 "register_operand" "r")] UNSPEC_CTTZ))]
1340   "TARGET_CIX"
1341   "cttz %1,%0"
1342   ; EV6 calls all mvi and cttz/ctlz/popc class imisc, so just
1343   ; reuse the existing type name.
1344   [(set_attr "type" "mvi")])
1345
1346 (define_insn "clzdi2"
1347   [(set (match_operand:DI 0 "register_operand" "=r")
1348         (clz:DI (match_operand:DI 1 "register_operand" "r")))]
1349   "TARGET_CIX"
1350   "ctlz %1,%0"
1351   [(set_attr "type" "mvi")])
1352
1353 (define_insn "ctzdi2"
1354   [(set (match_operand:DI 0 "register_operand" "=r")
1355         (ctz:DI (match_operand:DI 1 "register_operand" "r")))]
1356   "TARGET_CIX"
1357   "cttz %1,%0"
1358   [(set_attr "type" "mvi")])
1359
1360 (define_insn "popcountdi2"
1361   [(set (match_operand:DI 0 "register_operand" "=r")
1362         (popcount:DI (match_operand:DI 1 "register_operand" "r")))]
1363   "TARGET_CIX"
1364   "ctpop %1,%0"
1365   [(set_attr "type" "mvi")])
1366 \f
1367 ;; Next come the shifts and the various extract and insert operations.
1368
1369 (define_insn "ashldi3"
1370   [(set (match_operand:DI 0 "register_operand" "=r,r")
1371         (ashift:DI (match_operand:DI 1 "reg_or_0_operand" "rJ,rJ")
1372                    (match_operand:DI 2 "reg_or_6bit_operand" "P,rS")))]
1373   ""
1374 {
1375   switch (which_alternative)
1376     {
1377     case 0:
1378       if (operands[2] == const1_rtx)
1379         return "addq %r1,%r1,%0";
1380       else
1381         return "s%P2addq %r1,0,%0";
1382     case 1:
1383       return "sll %r1,%2,%0";
1384     default:
1385       abort();
1386     }
1387 }
1388   [(set_attr "type" "iadd,shift")])
1389
1390 (define_insn "*ashldi_se"
1391   [(set (match_operand:DI 0 "register_operand" "=r")
1392         (sign_extend:DI
1393          (subreg:SI (ashift:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1394                                (match_operand:DI 2 "const_int_operand" "P"))
1395                     0)))]
1396   "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3"
1397 {
1398   if (operands[2] == const1_rtx)
1399     return "addl %r1,%r1,%0";
1400   else
1401     return "s%P2addl %r1,0,%0";
1402 }
1403   [(set_attr "type" "iadd")])
1404
1405 (define_insn "lshrdi3"
1406   [(set (match_operand:DI 0 "register_operand" "=r")
1407         (lshiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1408                      (match_operand:DI 2 "reg_or_6bit_operand" "rS")))]
1409   ""
1410   "srl %r1,%2,%0"
1411   [(set_attr "type" "shift")])
1412
1413 (define_insn "ashrdi3"
1414   [(set (match_operand:DI 0 "register_operand" "=r")
1415         (ashiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1416                      (match_operand:DI 2 "reg_or_6bit_operand" "rS")))]
1417   ""
1418   "sra %r1,%2,%0"
1419   [(set_attr "type" "shift")])
1420
1421 (define_expand "extendqihi2"
1422   [(set (match_dup 2)
1423         (ashift:DI (match_operand:QI 1 "some_operand" "")
1424                    (const_int 56)))
1425    (set (match_operand:HI 0 "register_operand" "")
1426         (ashiftrt:DI (match_dup 2)
1427                      (const_int 56)))]
1428   ""
1429 {
1430   if (TARGET_BWX)
1431     {
1432       emit_insn (gen_extendqihi2x (operands[0],
1433                                    force_reg (QImode, operands[1])));
1434       DONE;
1435     }
1436
1437  /* If we have an unaligned MEM, extend to DImode (which we do
1438      specially) and then copy to the result.  */
1439   if (unaligned_memory_operand (operands[1], HImode))
1440     {
1441       rtx temp = gen_reg_rtx (DImode);
1442
1443       emit_insn (gen_extendqidi2 (temp, operands[1]));
1444       emit_move_insn (operands[0], gen_lowpart (HImode, temp));
1445       DONE;
1446     }
1447
1448   operands[0] = gen_lowpart (DImode, operands[0]);
1449   operands[1] = gen_lowpart (DImode, force_reg (QImode, operands[1]));
1450   operands[2] = gen_reg_rtx (DImode);
1451 })
1452
1453 (define_insn "extendqidi2x"
1454   [(set (match_operand:DI 0 "register_operand" "=r")
1455         (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
1456   "TARGET_BWX"
1457   "sextb %1,%0"
1458   [(set_attr "type" "shift")])
1459
1460 (define_insn "extendhidi2x"
1461   [(set (match_operand:DI 0 "register_operand" "=r")
1462         (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
1463   "TARGET_BWX"
1464   "sextw %1,%0"
1465   [(set_attr "type" "shift")])
1466
1467 (define_insn "extendqisi2x"
1468   [(set (match_operand:SI 0 "register_operand" "=r")
1469         (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
1470   "TARGET_BWX"
1471   "sextb %1,%0"
1472   [(set_attr "type" "shift")])
1473
1474 (define_insn "extendhisi2x"
1475   [(set (match_operand:SI 0 "register_operand" "=r")
1476         (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
1477   "TARGET_BWX"
1478   "sextw %1,%0"
1479   [(set_attr "type" "shift")])
1480
1481 (define_insn "extendqihi2x"
1482   [(set (match_operand:HI 0 "register_operand" "=r")
1483         (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
1484   "TARGET_BWX"
1485   "sextb %1,%0"
1486   [(set_attr "type" "shift")])
1487
1488 (define_expand "extendqisi2"
1489   [(set (match_dup 2)
1490         (ashift:DI (match_operand:QI 1 "some_operand" "")
1491                    (const_int 56)))
1492    (set (match_operand:SI 0 "register_operand" "")
1493         (ashiftrt:DI (match_dup 2)
1494                      (const_int 56)))]
1495   ""
1496 {
1497   if (TARGET_BWX)
1498     {
1499       emit_insn (gen_extendqisi2x (operands[0],
1500                                    force_reg (QImode, operands[1])));
1501       DONE;
1502     }
1503
1504   /* If we have an unaligned MEM, extend to a DImode form of
1505      the result (which we do specially).  */
1506   if (unaligned_memory_operand (operands[1], QImode))
1507     {
1508       rtx temp = gen_reg_rtx (DImode);
1509
1510       emit_insn (gen_extendqidi2 (temp, operands[1]));
1511       emit_move_insn (operands[0], gen_lowpart (SImode, temp));
1512       DONE;
1513     }
1514
1515   operands[0] = gen_lowpart (DImode, operands[0]);
1516   operands[1] = gen_lowpart (DImode, force_reg (QImode, operands[1]));
1517   operands[2] = gen_reg_rtx (DImode);
1518 })
1519
1520 (define_expand "extendqidi2"
1521   [(set (match_dup 2)
1522         (ashift:DI (match_operand:QI 1 "some_operand" "")
1523                    (const_int 56)))
1524    (set (match_operand:DI 0 "register_operand" "")
1525         (ashiftrt:DI (match_dup 2)
1526                      (const_int 56)))]
1527   ""
1528 {
1529   if (TARGET_BWX)
1530     {
1531       emit_insn (gen_extendqidi2x (operands[0],
1532                                    force_reg (QImode, operands[1])));
1533       DONE;
1534     }
1535
1536   if (unaligned_memory_operand (operands[1], QImode))
1537     {
1538       rtx seq
1539         = gen_unaligned_extendqidi (operands[0],
1540                                     get_unaligned_address (operands[1], 1));
1541
1542       alpha_set_memflags (seq, operands[1]);
1543       emit_insn (seq);
1544       DONE;
1545     }
1546
1547   operands[1] = gen_lowpart (DImode, force_reg (QImode, operands[1]));
1548   operands[2] = gen_reg_rtx (DImode);
1549 })
1550
1551 (define_expand "extendhisi2"
1552   [(set (match_dup 2)
1553         (ashift:DI (match_operand:HI 1 "some_operand" "")
1554                    (const_int 48)))
1555    (set (match_operand:SI 0 "register_operand" "")
1556         (ashiftrt:DI (match_dup 2)
1557                      (const_int 48)))]
1558   ""
1559 {
1560   if (TARGET_BWX)
1561     {
1562       emit_insn (gen_extendhisi2x (operands[0],
1563                                    force_reg (HImode, operands[1])));
1564       DONE;
1565     }
1566
1567   /* If we have an unaligned MEM, extend to a DImode form of
1568      the result (which we do specially).  */
1569   if (unaligned_memory_operand (operands[1], HImode))
1570     {
1571       rtx temp = gen_reg_rtx (DImode);
1572
1573       emit_insn (gen_extendhidi2 (temp, operands[1]));
1574       emit_move_insn (operands[0], gen_lowpart (SImode, temp));
1575       DONE;
1576     }
1577
1578   operands[0] = gen_lowpart (DImode, operands[0]);
1579   operands[1] = gen_lowpart (DImode, force_reg (HImode, operands[1]));
1580   operands[2] = gen_reg_rtx (DImode);
1581 })
1582
1583 (define_expand "extendhidi2"
1584   [(set (match_dup 2)
1585         (ashift:DI (match_operand:HI 1 "some_operand" "")
1586                    (const_int 48)))
1587    (set (match_operand:DI 0 "register_operand" "")
1588         (ashiftrt:DI (match_dup 2)
1589                      (const_int 48)))]
1590   ""
1591 {
1592   if (TARGET_BWX)
1593     {
1594       emit_insn (gen_extendhidi2x (operands[0],
1595                                    force_reg (HImode, operands[1])));
1596       DONE;
1597     }
1598
1599   if (unaligned_memory_operand (operands[1], HImode))
1600     {
1601       rtx seq
1602         = gen_unaligned_extendhidi (operands[0],
1603                                     get_unaligned_address (operands[1], 2));
1604
1605       alpha_set_memflags (seq, operands[1]);
1606       emit_insn (seq);
1607       DONE;
1608     }
1609
1610   operands[1] = gen_lowpart (DImode, force_reg (HImode, operands[1]));
1611   operands[2] = gen_reg_rtx (DImode);
1612 })
1613
1614 ;; Here's how we sign extend an unaligned byte and halfword.  Doing this
1615 ;; as a pattern saves one instruction.  The code is similar to that for
1616 ;; the unaligned loads (see below).
1617 ;;
1618 ;; Operand 1 is the address + 1 (+2 for HI), operand 0 is the result.
1619 (define_expand "unaligned_extendqidi"
1620   [(use (match_operand:QI 0 "register_operand" ""))
1621    (use (match_operand:DI 1 "address_operand" ""))]
1622   ""
1623 {
1624   if (WORDS_BIG_ENDIAN)
1625     emit_insn (gen_unaligned_extendqidi_be (operands[0], operands[1]));
1626   else
1627     emit_insn (gen_unaligned_extendqidi_le (operands[0], operands[1]));
1628   DONE;
1629 })
1630
1631 (define_expand "unaligned_extendqidi_le"
1632   [(set (match_dup 2) (match_operand:DI 1 "address_operand" ""))
1633    (set (match_dup 3)
1634         (mem:DI (and:DI (plus:DI (match_dup 2) (const_int -1))
1635                         (const_int -8))))
1636    (set (match_dup 4)
1637         (ashift:DI (match_dup 3)
1638                    (minus:DI (const_int 64)
1639                              (ashift:DI
1640                               (and:DI (match_dup 2) (const_int 7))
1641                               (const_int 3)))))
1642    (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
1643         (ashiftrt:DI (match_dup 4) (const_int 56)))]
1644   "! WORDS_BIG_ENDIAN"
1645 {
1646   operands[2] = gen_reg_rtx (DImode);
1647   operands[3] = gen_reg_rtx (DImode);
1648   operands[4] = gen_reg_rtx (DImode);
1649 })
1650
1651 (define_expand "unaligned_extendqidi_be"
1652   [(set (match_dup 2) (match_operand:DI 1 "address_operand" ""))
1653    (set (match_dup 3) (plus:DI (match_dup 2) (const_int -1)))
1654    (set (match_dup 4)
1655         (mem:DI (and:DI (match_dup 3)
1656                         (const_int -8))))
1657    (set (match_dup 5) (plus:DI (match_dup 2) (const_int -2)))
1658    (set (match_dup 6)
1659         (ashift:DI (match_dup 4)
1660                    (ashift:DI
1661                      (and:DI
1662                        (plus:DI (match_dup 5) (const_int 1))
1663                        (const_int 7))
1664                      (const_int 3))))
1665    (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
1666         (ashiftrt:DI (match_dup 6) (const_int 56)))]
1667   "WORDS_BIG_ENDIAN"
1668 {
1669   operands[2] = gen_reg_rtx (DImode);
1670   operands[3] = gen_reg_rtx (DImode);
1671   operands[4] = gen_reg_rtx (DImode);
1672   operands[5] = gen_reg_rtx (DImode);
1673   operands[6] = gen_reg_rtx (DImode);
1674 })
1675
1676 (define_expand "unaligned_extendhidi"
1677   [(use (match_operand:QI 0 "register_operand" ""))
1678    (use (match_operand:DI 1 "address_operand" ""))]
1679   ""
1680 {
1681   operands[0] = gen_lowpart (DImode, operands[0]);
1682   emit_insn ((WORDS_BIG_ENDIAN
1683               ? gen_unaligned_extendhidi_be
1684               : gen_unaligned_extendhidi_le) (operands[0], operands[1]));
1685   DONE;
1686 })
1687
1688 (define_expand "unaligned_extendhidi_le"
1689   [(set (match_dup 2) (match_operand:DI 1 "address_operand" ""))
1690    (set (match_dup 3)
1691         (mem:DI (and:DI (plus:DI (match_dup 2) (const_int -2))
1692                         (const_int -8))))
1693    (set (match_dup 4)
1694         (ashift:DI (match_dup 3)
1695                    (minus:DI (const_int 64)
1696                              (ashift:DI
1697                               (and:DI (match_dup 2) (const_int 7))
1698                               (const_int 3)))))
1699    (set (match_operand:DI 0 "register_operand" "")
1700         (ashiftrt:DI (match_dup 4) (const_int 48)))]
1701   "! WORDS_BIG_ENDIAN"
1702 {
1703   operands[2] = gen_reg_rtx (DImode);
1704   operands[3] = gen_reg_rtx (DImode);
1705   operands[4] = gen_reg_rtx (DImode);
1706 })
1707
1708 (define_expand "unaligned_extendhidi_be"
1709   [(set (match_dup 2) (match_operand:DI 1 "address_operand" ""))
1710    (set (match_dup 3) (plus:DI (match_dup 2) (const_int -2)))
1711    (set (match_dup 4)
1712         (mem:DI (and:DI (match_dup 3)
1713                         (const_int -8))))
1714    (set (match_dup 5) (plus:DI (match_dup 2) (const_int -3)))
1715    (set (match_dup 6)
1716         (ashift:DI (match_dup 4)
1717                    (ashift:DI
1718                      (and:DI
1719                        (plus:DI (match_dup 5) (const_int 1))
1720                        (const_int 7))
1721                      (const_int 3))))
1722    (set (match_operand:DI 0 "register_operand" "")
1723         (ashiftrt:DI (match_dup 6) (const_int 48)))]
1724   "WORDS_BIG_ENDIAN"
1725 {
1726   operands[2] = gen_reg_rtx (DImode);
1727   operands[3] = gen_reg_rtx (DImode);
1728   operands[4] = gen_reg_rtx (DImode);
1729   operands[5] = gen_reg_rtx (DImode);
1730   operands[6] = gen_reg_rtx (DImode);
1731 })
1732
1733 (define_insn "*extxl_const"
1734   [(set (match_operand:DI 0 "register_operand" "=r")
1735         (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1736                          (match_operand:DI 2 "mode_width_operand" "n")
1737                          (match_operand:DI 3 "mul8_operand" "I")))]
1738   ""
1739   "ext%M2l %r1,%s3,%0"
1740   [(set_attr "type" "shift")])
1741
1742 (define_insn "extxl_le"
1743   [(set (match_operand:DI 0 "register_operand" "=r")
1744         (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1745                          (match_operand:DI 2 "mode_width_operand" "n")
1746                          (ashift:DI (match_operand:DI 3 "reg_or_8bit_operand" "rI")
1747                                     (const_int 3))))]
1748   "! WORDS_BIG_ENDIAN"
1749   "ext%M2l %r1,%3,%0"
1750   [(set_attr "type" "shift")])
1751
1752 (define_insn "extxl_be"
1753   [(set (match_operand:DI 0 "register_operand" "=r")
1754         (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1755                          (match_operand:DI 2 "mode_width_operand" "n")
1756                          (minus:DI
1757                            (const_int 56)
1758                            (ashift:DI
1759                              (match_operand:DI 3 "reg_or_8bit_operand" "rI")
1760                              (const_int 3)))))]
1761   "WORDS_BIG_ENDIAN"
1762   "ext%M2l %r1,%3,%0"
1763   [(set_attr "type" "shift")])
1764
1765 ;; Combine has some strange notion of preserving existing undefined behavior
1766 ;; in shifts larger than a word size.  So capture these patterns that it
1767 ;; should have turned into zero_extracts.
1768
1769 (define_insn "*extxl_1_le"
1770   [(set (match_operand:DI 0 "register_operand" "=r")
1771         (and:DI (lshiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1772                   (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1773                              (const_int 3)))
1774              (match_operand:DI 3 "mode_mask_operand" "n")))]
1775   "! WORDS_BIG_ENDIAN"
1776   "ext%U3l %1,%2,%0"
1777   [(set_attr "type" "shift")])
1778
1779 (define_insn "*extxl_1_be"
1780   [(set (match_operand:DI 0 "register_operand" "=r")
1781         (and:DI (lshiftrt:DI
1782                   (match_operand:DI 1 "reg_or_0_operand" "rJ")
1783                   (minus:DI (const_int 56)
1784                     (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1785                                (const_int 3))))
1786                 (match_operand:DI 3 "mode_mask_operand" "n")))]
1787   "WORDS_BIG_ENDIAN"
1788   "ext%U3l %1,%2,%0"
1789   [(set_attr "type" "shift")])
1790
1791 (define_insn "*extql_2_le"
1792   [(set (match_operand:DI 0 "register_operand" "=r")
1793         (lshiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1794           (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1795                      (const_int 3))))]
1796   "! WORDS_BIG_ENDIAN"
1797   "extql %1,%2,%0"
1798   [(set_attr "type" "shift")])
1799
1800 (define_insn "*extql_2_be"
1801   [(set (match_operand:DI 0 "register_operand" "=r")
1802         (lshiftrt:DI
1803           (match_operand:DI 1 "reg_or_0_operand" "rJ")
1804           (minus:DI (const_int 56)
1805                     (ashift:DI
1806                       (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1807                       (const_int 3)))))]
1808   "WORDS_BIG_ENDIAN"
1809   "extql %1,%2,%0"
1810   [(set_attr "type" "shift")])
1811
1812 (define_insn "extqh_le"
1813   [(set (match_operand:DI 0 "register_operand" "=r")
1814         (ashift:DI
1815          (match_operand:DI 1 "reg_or_0_operand" "rJ")
1816           (minus:DI (const_int 64)
1817                     (ashift:DI
1818                      (and:DI
1819                       (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1820                       (const_int 7))
1821                      (const_int 3)))))]
1822   "! WORDS_BIG_ENDIAN"
1823   "extqh %r1,%2,%0"
1824   [(set_attr "type" "shift")])
1825
1826 (define_insn "extqh_be"
1827   [(set (match_operand:DI 0 "register_operand" "=r")
1828         (ashift:DI
1829           (match_operand:DI 1 "reg_or_0_operand" "rJ")
1830           (ashift:DI
1831             (and:DI
1832               (plus:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1833                        (const_int 1))
1834               (const_int 7))
1835             (const_int 3))))]
1836   "WORDS_BIG_ENDIAN"
1837   "extqh %r1,%2,%0"
1838   [(set_attr "type" "shift")])
1839
1840 (define_insn "extlh_le"
1841   [(set (match_operand:DI 0 "register_operand" "=r")
1842         (ashift:DI
1843          (and:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1844                  (const_int 2147483647))
1845          (minus:DI (const_int 64)
1846                     (ashift:DI
1847                      (and:DI
1848                       (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1849                       (const_int 7))
1850                      (const_int 3)))))]
1851   "! WORDS_BIG_ENDIAN"
1852   "extlh %r1,%2,%0"
1853   [(set_attr "type" "shift")])
1854
1855 (define_insn "extlh_be"
1856   [(set (match_operand:DI 0 "register_operand" "=r")
1857         (and:DI
1858           (ashift:DI
1859             (match_operand:DI 1 "reg_or_0_operand" "rJ")
1860             (ashift:DI
1861               (and:DI
1862                 (plus:DI
1863                   (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1864                   (const_int 1))
1865                 (const_int 7))
1866               (const_int 3)))
1867           (const_int 2147483647)))]
1868   "WORDS_BIG_ENDIAN"
1869   "extlh %r1,%2,%0"
1870   [(set_attr "type" "shift")])
1871
1872 (define_insn "extwh_le"
1873   [(set (match_operand:DI 0 "register_operand" "=r")
1874         (ashift:DI
1875          (and:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1876                  (const_int 65535))
1877          (minus:DI (const_int 64)
1878                     (ashift:DI
1879                      (and:DI
1880                       (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1881                       (const_int 7))
1882                      (const_int 3)))))]
1883   "! WORDS_BIG_ENDIAN"
1884   "extwh %r1,%2,%0"
1885   [(set_attr "type" "shift")])
1886
1887 (define_insn "extwh_be"
1888   [(set (match_operand:DI 0 "register_operand" "=r")
1889         (and:DI
1890           (ashift:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1891                      (ashift:DI
1892                        (and:DI
1893                          (plus:DI
1894                            (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1895                            (const_int 1))
1896                          (const_int 7))
1897                        (const_int 3)))
1898           (const_int 65535)))]
1899   "WORDS_BIG_ENDIAN"
1900   "extwh %r1,%2,%0"
1901   [(set_attr "type" "shift")])
1902
1903 ;; This converts an extXl into an extXh with an appropriate adjustment
1904 ;; to the address calculation.
1905
1906 ;;(define_split
1907 ;;  [(set (match_operand:DI 0 "register_operand" "")
1908 ;;      (ashift:DI (zero_extract:DI (match_operand:DI 1 "register_operand" "")
1909 ;;                                  (match_operand:DI 2 "mode_width_operand" "")
1910 ;;                                  (ashift:DI (match_operand:DI 3 "" "")
1911 ;;                                             (const_int 3)))
1912 ;;                 (match_operand:DI 4 "const_int_operand" "")))
1913 ;;   (clobber (match_operand:DI 5 "register_operand" ""))]
1914 ;;  "INTVAL (operands[4]) == 64 - INTVAL (operands[2])"
1915 ;;  [(set (match_dup 5) (match_dup 6))
1916 ;;   (set (match_dup 0)
1917 ;;      (ashift:DI (zero_extract:DI (match_dup 1) (match_dup 2)
1918 ;;                                  (ashift:DI (plus:DI (match_dup 5)
1919 ;;                                                      (match_dup 7))
1920 ;;                                             (const_int 3)))
1921 ;;                 (match_dup 4)))]
1922 ;;  "
1923 ;;{
1924 ;;  operands[6] = plus_constant (operands[3],
1925 ;;                             INTVAL (operands[2]) / BITS_PER_UNIT);
1926 ;;  operands[7] = GEN_INT (- INTVAL (operands[2]) / BITS_PER_UNIT);
1927 ;;}")
1928
1929 (define_insn "*insbl_const"
1930   [(set (match_operand:DI 0 "register_operand" "=r")
1931         (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" "r"))
1932                    (match_operand:DI 2 "mul8_operand" "I")))]
1933   ""
1934   "insbl %1,%s2,%0"
1935   [(set_attr "type" "shift")])
1936
1937 (define_insn "*inswl_const"
1938   [(set (match_operand:DI 0 "register_operand" "=r")
1939         (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" "r"))
1940                    (match_operand:DI 2 "mul8_operand" "I")))]
1941   ""
1942   "inswl %1,%s2,%0"
1943   [(set_attr "type" "shift")])
1944
1945 (define_insn "*insll_const"
1946   [(set (match_operand:DI 0 "register_operand" "=r")
1947         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
1948                    (match_operand:DI 2 "mul8_operand" "I")))]
1949   ""
1950   "insll %1,%s2,%0"
1951   [(set_attr "type" "shift")])
1952
1953 (define_insn "insbl_le"
1954   [(set (match_operand:DI 0 "register_operand" "=r")
1955         (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" "r"))
1956                    (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1957                               (const_int 3))))]
1958   "! WORDS_BIG_ENDIAN"
1959   "insbl %1,%2,%0"
1960   [(set_attr "type" "shift")])
1961
1962 (define_insn "insbl_be"
1963  [(set (match_operand:DI 0 "register_operand" "=r")
1964        (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" "r"))
1965          (minus:DI (const_int 56)
1966            (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1967                       (const_int 3)))))]
1968   "WORDS_BIG_ENDIAN"
1969   "insbl %1,%2,%0"
1970   [(set_attr "type" "shift")])
1971
1972 (define_insn "inswl_le"
1973   [(set (match_operand:DI 0 "register_operand" "=r")
1974         (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" "r"))
1975                    (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1976                               (const_int 3))))]
1977   "! WORDS_BIG_ENDIAN"
1978   "inswl %1,%2,%0"
1979   [(set_attr "type" "shift")])
1980
1981 (define_insn "inswl_be"
1982   [(set (match_operand:DI 0 "register_operand" "=r")
1983         (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" "r"))
1984           (minus:DI (const_int 56)
1985             (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1986                        (const_int 3)))))]
1987   "WORDS_BIG_ENDIAN"
1988   "inswl %1,%2,%0"
1989   [(set_attr "type" "shift")])
1990
1991 (define_insn "insll_le"
1992   [(set (match_operand:DI 0 "register_operand" "=r")
1993         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
1994                    (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1995                               (const_int 3))))]
1996   "! WORDS_BIG_ENDIAN"
1997   "insll %1,%2,%0"
1998   [(set_attr "type" "shift")])
1999
2000 (define_insn "insll_be"
2001   [(set (match_operand:DI 0 "register_operand" "=r")
2002         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
2003           (minus:DI (const_int 56)
2004             (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
2005                        (const_int 3)))))]
2006   "WORDS_BIG_ENDIAN"
2007   "insll %1,%2,%0"
2008   [(set_attr "type" "shift")])
2009
2010 (define_insn "insql_le"
2011   [(set (match_operand:DI 0 "register_operand" "=r")
2012         (ashift:DI (match_operand:DI 1 "register_operand" "r")
2013                    (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
2014                               (const_int 3))))]
2015   "! WORDS_BIG_ENDIAN"
2016   "insql %1,%2,%0"
2017   [(set_attr "type" "shift")])
2018
2019 (define_insn "insql_be"
2020   [(set (match_operand:DI 0 "register_operand" "=r")
2021         (ashift:DI (match_operand:DI 1 "register_operand" "r")
2022           (minus:DI (const_int 56)
2023             (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
2024                        (const_int 3)))))]
2025   "WORDS_BIG_ENDIAN"
2026   "insql %1,%2,%0"
2027   [(set_attr "type" "shift")])
2028
2029 ;; Combine has this sometimes habit of moving the and outside of the
2030 ;; shift, making life more interesting.
2031
2032 (define_insn "*insxl"
2033   [(set (match_operand:DI 0 "register_operand" "=r")
2034         (and:DI (ashift:DI (match_operand:DI 1 "register_operand" "r")
2035                            (match_operand:DI 2 "mul8_operand" "I"))
2036                 (match_operand:DI 3 "immediate_operand" "i")))]
2037   "HOST_BITS_PER_WIDE_INT == 64
2038    && GET_CODE (operands[3]) == CONST_INT
2039    && (((unsigned HOST_WIDE_INT) 0xff << INTVAL (operands[2])
2040         == (unsigned HOST_WIDE_INT) INTVAL (operands[3]))
2041        || ((unsigned HOST_WIDE_INT) 0xffff << INTVAL (operands[2])
2042         == (unsigned HOST_WIDE_INT) INTVAL (operands[3]))
2043        || ((unsigned HOST_WIDE_INT) 0xffffffff << INTVAL (operands[2])
2044         == (unsigned HOST_WIDE_INT) INTVAL (operands[3])))"
2045 {
2046 #if HOST_BITS_PER_WIDE_INT == 64
2047   if ((unsigned HOST_WIDE_INT) 0xff << INTVAL (operands[2])
2048       == (unsigned HOST_WIDE_INT) INTVAL (operands[3]))
2049     return "insbl %1,%s2,%0";
2050   if ((unsigned HOST_WIDE_INT) 0xffff << INTVAL (operands[2])
2051       == (unsigned HOST_WIDE_INT) INTVAL (operands[3]))
2052     return "inswl %1,%s2,%0";
2053   if ((unsigned HOST_WIDE_INT) 0xffffffff << INTVAL (operands[2])
2054       == (unsigned HOST_WIDE_INT) INTVAL (operands[3]))
2055     return "insll %1,%s2,%0";
2056 #endif
2057   abort();
2058 }
2059   [(set_attr "type" "shift")])
2060
2061 ;; We do not include the insXh insns because they are complex to express
2062 ;; and it does not appear that we would ever want to generate them.
2063 ;;
2064 ;; Since we need them for block moves, though, cop out and use unspec.
2065
2066 (define_insn "insxh"
2067   [(set (match_operand:DI 0 "register_operand" "=r")
2068         (unspec:DI [(match_operand:DI 1 "register_operand" "r")
2069                     (match_operand:DI 2 "mode_width_operand" "n")
2070                     (match_operand:DI 3 "reg_or_8bit_operand" "rI")]
2071                    UNSPEC_INSXH))]
2072   ""
2073   "ins%M2h %1,%3,%0"
2074   [(set_attr "type" "shift")])
2075
2076 (define_insn "mskxl_le"
2077   [(set (match_operand:DI 0 "register_operand" "=r")
2078         (and:DI (not:DI (ashift:DI
2079                          (match_operand:DI 2 "mode_mask_operand" "n")
2080                          (ashift:DI
2081                           (match_operand:DI 3 "reg_or_8bit_operand" "rI")
2082                           (const_int 3))))
2083                 (match_operand:DI 1 "reg_or_0_operand" "rJ")))]
2084   "! WORDS_BIG_ENDIAN"
2085   "msk%U2l %r1,%3,%0"
2086   [(set_attr "type" "shift")])
2087
2088 (define_insn "mskxl_be"
2089   [(set (match_operand:DI 0 "register_operand" "=r")
2090         (and:DI (not:DI (ashift:DI
2091                           (match_operand:DI 2 "mode_mask_operand" "n")
2092                           (minus:DI (const_int 56)
2093                             (ashift:DI
2094                               (match_operand:DI 3 "reg_or_8bit_operand" "rI")
2095                               (const_int 3)))))
2096                 (match_operand:DI 1 "reg_or_0_operand" "rJ")))]
2097   "WORDS_BIG_ENDIAN"
2098   "msk%U2l %r1,%3,%0"
2099   [(set_attr "type" "shift")])
2100
2101 ;; We do not include the mskXh insns because it does not appear we would
2102 ;; ever generate one.
2103 ;;
2104 ;; Again, we do for block moves and we use unspec again.
2105
2106 (define_insn "mskxh"
2107   [(set (match_operand:DI 0 "register_operand" "=r")
2108         (unspec:DI [(match_operand:DI 1 "register_operand" "r")
2109                     (match_operand:DI 2 "mode_width_operand" "n")
2110                     (match_operand:DI 3 "reg_or_8bit_operand" "rI")]
2111                    UNSPEC_MSKXH))]
2112   ""
2113   "msk%M2h %1,%3,%0"
2114   [(set_attr "type" "shift")])
2115
2116 ;; Prefer AND + NE over LSHIFTRT + AND.
2117
2118 (define_insn_and_split "*ze_and_ne"
2119   [(set (match_operand:DI 0 "register_operand" "=r")
2120         (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
2121                          (const_int 1)
2122                          (match_operand 2 "const_int_operand" "I")))]
2123   "(unsigned HOST_WIDE_INT) INTVAL (operands[2]) < 8"
2124   "#"
2125   "(unsigned HOST_WIDE_INT) INTVAL (operands[2]) < 8"
2126   [(set (match_dup 0)
2127         (and:DI (match_dup 1) (match_dup 3)))
2128    (set (match_dup 0)
2129         (ne:DI (match_dup 0) (const_int 0)))]
2130   "operands[3] = GEN_INT (1 << INTVAL (operands[2]));")
2131 \f
2132 ;; Floating-point operations.  All the double-precision insns can extend
2133 ;; from single, so indicate that.  The exception are the ones that simply
2134 ;; play with the sign bits; it's not clear what to do there.
2135
2136 (define_insn "abssf2"
2137   [(set (match_operand:SF 0 "register_operand" "=f")
2138         (abs:SF (match_operand:SF 1 "reg_or_0_operand" "fG")))]
2139   "TARGET_FP"
2140   "cpys $f31,%R1,%0"
2141   [(set_attr "type" "fcpys")])
2142
2143 (define_insn "*nabssf2"
2144   [(set (match_operand:SF 0 "register_operand" "=f")
2145         (neg:SF (abs:SF (match_operand:SF 1 "reg_or_0_operand" "fG"))))]
2146   "TARGET_FP"
2147   "cpysn $f31,%R1,%0"
2148   [(set_attr "type" "fadd")])
2149
2150 (define_insn "absdf2"
2151   [(set (match_operand:DF 0 "register_operand" "=f")
2152         (abs:DF (match_operand:DF 1 "reg_or_0_operand" "fG")))]
2153   "TARGET_FP"
2154   "cpys $f31,%R1,%0"
2155   [(set_attr "type" "fcpys")])
2156
2157 (define_insn "*nabsdf2"
2158   [(set (match_operand:DF 0 "register_operand" "=f")
2159         (neg:DF (abs:DF (match_operand:DF 1 "reg_or_0_operand" "fG"))))]
2160   "TARGET_FP"
2161   "cpysn $f31,%R1,%0"
2162   [(set_attr "type" "fadd")])
2163
2164 (define_expand "abstf2"
2165   [(parallel [(set (match_operand:TF 0 "register_operand" "")
2166                    (abs:TF (match_operand:TF 1 "reg_or_0_operand" "")))
2167               (use (match_dup 2))])]
2168   "TARGET_HAS_XFLOATING_LIBS"
2169 {
2170 #if HOST_BITS_PER_WIDE_INT >= 64
2171   operands[2] = force_reg (DImode, GEN_INT ((HOST_WIDE_INT) 1 << 63));
2172 #else
2173   operands[2] = force_reg (DImode, immed_double_const (0, 0x80000000, DImode));
2174 #endif
2175 })
2176
2177 (define_insn_and_split "*abstf_internal"
2178   [(set (match_operand:TF 0 "register_operand" "=r")
2179         (abs:TF (match_operand:TF 1 "reg_or_0_operand" "rG")))
2180    (use (match_operand:DI 2 "register_operand" "r"))]
2181   "TARGET_HAS_XFLOATING_LIBS"
2182   "#"
2183   "&& reload_completed"
2184   [(const_int 0)]
2185   "alpha_split_tfmode_frobsign (operands, gen_andnotdi3); DONE;")
2186
2187 (define_insn "negsf2"
2188   [(set (match_operand:SF 0 "register_operand" "=f")
2189         (neg:SF (match_operand:SF 1 "reg_or_0_operand" "fG")))]
2190   "TARGET_FP"
2191   "cpysn %R1,%R1,%0"
2192   [(set_attr "type" "fadd")])
2193
2194 (define_insn "negdf2"
2195   [(set (match_operand:DF 0 "register_operand" "=f")
2196         (neg:DF (match_operand:DF 1 "reg_or_0_operand" "fG")))]
2197   "TARGET_FP"
2198   "cpysn %R1,%R1,%0"
2199   [(set_attr "type" "fadd")])
2200
2201 (define_expand "negtf2"
2202   [(parallel [(set (match_operand:TF 0 "register_operand" "")
2203                    (neg:TF (match_operand:TF 1 "reg_or_0_operand" "")))
2204               (use (match_dup 2))])]
2205   "TARGET_HAS_XFLOATING_LIBS"
2206 {
2207 #if HOST_BITS_PER_WIDE_INT >= 64
2208   operands[2] = force_reg (DImode, GEN_INT ((HOST_WIDE_INT) 1 << 63));
2209 #else
2210   operands[2] = force_reg (DImode, immed_double_const (0, 0x80000000, DImode));
2211 #endif
2212 })
2213
2214 (define_insn_and_split "*negtf_internal"
2215   [(set (match_operand:TF 0 "register_operand" "=r")
2216         (neg:TF (match_operand:TF 1 "reg_or_0_operand" "rG")))
2217    (use (match_operand:DI 2 "register_operand" "r"))]
2218   "TARGET_HAS_XFLOATING_LIBS"
2219   "#"
2220   "&& reload_completed"
2221   [(const_int 0)]
2222   "alpha_split_tfmode_frobsign (operands, gen_xordi3); DONE;")
2223
2224 (define_insn "*addsf_ieee"
2225   [(set (match_operand:SF 0 "register_operand" "=&f")
2226         (plus:SF (match_operand:SF 1 "reg_or_0_operand" "%fG")
2227                  (match_operand:SF 2 "reg_or_0_operand" "fG")))]
2228   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2229   "add%,%/ %R1,%R2,%0"
2230   [(set_attr "type" "fadd")
2231    (set_attr "trap" "yes")
2232    (set_attr "round_suffix" "normal")
2233    (set_attr "trap_suffix" "u_su_sui")])
2234
2235 (define_insn "addsf3"
2236   [(set (match_operand:SF 0 "register_operand" "=f")
2237         (plus:SF (match_operand:SF 1 "reg_or_0_operand" "%fG")
2238                  (match_operand:SF 2 "reg_or_0_operand" "fG")))]
2239   "TARGET_FP"
2240   "add%,%/ %R1,%R2,%0"
2241   [(set_attr "type" "fadd")
2242    (set_attr "trap" "yes")
2243    (set_attr "round_suffix" "normal")
2244    (set_attr "trap_suffix" "u_su_sui")])
2245
2246 (define_insn "*adddf_ieee"
2247   [(set (match_operand:DF 0 "register_operand" "=&f")
2248         (plus:DF (match_operand:DF 1 "reg_or_0_operand" "%fG")
2249                  (match_operand:DF 2 "reg_or_0_operand" "fG")))]
2250   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2251   "add%-%/ %R1,%R2,%0"
2252   [(set_attr "type" "fadd")
2253    (set_attr "trap" "yes")
2254    (set_attr "round_suffix" "normal")
2255    (set_attr "trap_suffix" "u_su_sui")])
2256
2257 (define_insn "adddf3"
2258   [(set (match_operand:DF 0 "register_operand" "=f")
2259         (plus:DF (match_operand:DF 1 "reg_or_0_operand" "%fG")
2260                  (match_operand:DF 2 "reg_or_0_operand" "fG")))]
2261   "TARGET_FP"
2262   "add%-%/ %R1,%R2,%0"
2263   [(set_attr "type" "fadd")
2264    (set_attr "trap" "yes")
2265    (set_attr "round_suffix" "normal")
2266    (set_attr "trap_suffix" "u_su_sui")])
2267
2268 (define_insn "*adddf_ext1"
2269   [(set (match_operand:DF 0 "register_operand" "=f")
2270         (plus:DF (float_extend:DF
2271                   (match_operand:SF 1 "reg_or_0_operand" "fG"))
2272                  (match_operand:DF 2 "reg_or_0_operand" "fG")))]
2273   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
2274   "add%-%/ %R1,%R2,%0"
2275   [(set_attr "type" "fadd")
2276    (set_attr "trap" "yes")
2277    (set_attr "round_suffix" "normal")
2278    (set_attr "trap_suffix" "u_su_sui")])
2279
2280 (define_insn "*adddf_ext2"
2281   [(set (match_operand:DF 0 "register_operand" "=f")
2282         (plus:DF (float_extend:DF
2283                   (match_operand:SF 1 "reg_or_0_operand" "%fG"))
2284                  (float_extend:DF
2285                   (match_operand:SF 2 "reg_or_0_operand" "fG"))))]
2286   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
2287   "add%-%/ %R1,%R2,%0"
2288   [(set_attr "type" "fadd")
2289    (set_attr "trap" "yes")
2290    (set_attr "round_suffix" "normal")
2291    (set_attr "trap_suffix" "u_su_sui")])
2292
2293 (define_expand "addtf3"
2294   [(use (match_operand 0 "register_operand" ""))
2295    (use (match_operand 1 "general_operand" ""))
2296    (use (match_operand 2 "general_operand" ""))]
2297   "TARGET_HAS_XFLOATING_LIBS"
2298   "alpha_emit_xfloating_arith (PLUS, operands); DONE;")
2299
2300 ;; Define conversion operators between DFmode and SImode, using the cvtql
2301 ;; instruction.  To allow combine et al to do useful things, we keep the
2302 ;; operation as a unit until after reload, at which point we split the
2303 ;; instructions.
2304 ;;
2305 ;; Note that we (attempt to) only consider this optimization when the
2306 ;; ultimate destination is memory.  If we will be doing further integer
2307 ;; processing, it is cheaper to do the truncation in the int regs.
2308
2309 (define_insn "*cvtql"
2310   [(set (match_operand:SF 0 "register_operand" "=f")
2311         (unspec:SF [(match_operand:DI 1 "reg_or_0_operand" "fG")]
2312                    UNSPEC_CVTQL))]
2313   "TARGET_FP"
2314   "cvtql%/ %R1,%0"
2315   [(set_attr "type" "fadd")
2316    (set_attr "trap" "yes")
2317    (set_attr "trap_suffix" "v_sv")])
2318
2319 (define_insn_and_split "*fix_truncdfsi_ieee"
2320   [(set (match_operand:SI 0 "memory_operand" "=m")
2321         (subreg:SI
2322           (match_operator:DI 4 "fix_operator" 
2323             [(match_operand:DF 1 "reg_or_0_operand" "fG")]) 0))
2324    (clobber (match_scratch:DI 2 "=&f"))
2325    (clobber (match_scratch:SF 3 "=&f"))]
2326   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2327   "#"
2328   "&& reload_completed"
2329   [(set (match_dup 2) (match_op_dup 4 [(match_dup 1)]))
2330    (set (match_dup 3) (unspec:SF [(match_dup 2)] UNSPEC_CVTQL))
2331    (set (match_dup 5) (match_dup 3))]
2332 {
2333   operands[5] = adjust_address (operands[0], SFmode, 0);
2334 }
2335   [(set_attr "type" "fadd")
2336    (set_attr "trap" "yes")])
2337
2338 (define_insn_and_split "*fix_truncdfsi_internal"
2339   [(set (match_operand:SI 0 "memory_operand" "=m")
2340         (subreg:SI
2341           (match_operator:DI 3 "fix_operator" 
2342             [(match_operand:DF 1 "reg_or_0_operand" "fG")]) 0))
2343    (clobber (match_scratch:DI 2 "=f"))]
2344   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
2345   "#"
2346   "&& reload_completed"
2347   [(set (match_dup 2) (match_op_dup 3 [(match_dup 1)]))
2348    (set (match_dup 4) (unspec:SF [(match_dup 2)] UNSPEC_CVTQL))
2349    (set (match_dup 5) (match_dup 4))]
2350 {
2351   operands[4] = gen_rtx_REG (SFmode, REGNO (operands[2]));
2352   operands[5] = adjust_address (operands[0], SFmode, 0);
2353 }
2354   [(set_attr "type" "fadd")
2355    (set_attr "trap" "yes")])
2356
2357 (define_insn "*fix_truncdfdi_ieee"
2358   [(set (match_operand:DI 0 "reg_no_subreg_operand" "=&f")
2359         (match_operator:DI 2 "fix_operator" 
2360           [(match_operand:DF 1 "reg_or_0_operand" "fG")]))]
2361   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2362   "cvt%-q%/ %R1,%0"
2363   [(set_attr "type" "fadd")
2364    (set_attr "trap" "yes")
2365    (set_attr "round_suffix" "c")
2366    (set_attr "trap_suffix" "v_sv_svi")])
2367
2368 (define_insn "*fix_truncdfdi2"
2369   [(set (match_operand:DI 0 "reg_no_subreg_operand" "=f")
2370         (match_operator:DI 2 "fix_operator" 
2371           [(match_operand:DF 1 "reg_or_0_operand" "fG")]))]
2372   "TARGET_FP"
2373   "cvt%-q%/ %R1,%0"
2374   [(set_attr "type" "fadd")
2375    (set_attr "trap" "yes")
2376    (set_attr "round_suffix" "c")
2377    (set_attr "trap_suffix" "v_sv_svi")])
2378
2379 (define_expand "fix_truncdfdi2"
2380   [(set (match_operand:DI 0 "reg_no_subreg_operand" "")
2381         (fix:DI (match_operand:DF 1 "reg_or_0_operand" "")))]
2382   "TARGET_FP"
2383   "")
2384
2385 (define_expand "fixuns_truncdfdi2"
2386   [(set (match_operand:DI 0 "reg_no_subreg_operand" "")
2387         (unsigned_fix:DI (match_operand:DF 1 "reg_or_0_operand" "")))]
2388   "TARGET_FP"
2389   "")
2390
2391 ;; Likewise between SFmode and SImode.
2392
2393 (define_insn_and_split "*fix_truncsfsi_ieee"
2394   [(set (match_operand:SI 0 "memory_operand" "=m")
2395         (subreg:SI
2396           (match_operator:DI 4 "fix_operator" 
2397             [(float_extend:DF
2398                (match_operand:SF 1 "reg_or_0_operand" "fG"))]) 0))
2399    (clobber (match_scratch:DI 2 "=&f"))
2400    (clobber (match_scratch:SF 3 "=&f"))]
2401   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2402   "#"
2403   "&& reload_completed"
2404   [(set (match_dup 2) (match_op_dup 4 [(float_extend:DF (match_dup 1))]))
2405    (set (match_dup 3) (unspec:SF [(match_dup 2)] UNSPEC_CVTQL))
2406    (set (match_dup 5) (match_dup 3))]
2407 {
2408   operands[5] = adjust_address (operands[0], SFmode, 0);
2409 }
2410   [(set_attr "type" "fadd")
2411    (set_attr "trap" "yes")])
2412
2413 (define_insn_and_split "*fix_truncsfsi_internal"
2414   [(set (match_operand:SI 0 "memory_operand" "=m")
2415         (subreg:SI
2416           (match_operator:DI 3 "fix_operator" 
2417             [(float_extend:DF
2418                (match_operand:SF 1 "reg_or_0_operand" "fG"))]) 0))
2419    (clobber (match_scratch:DI 2 "=f"))]
2420   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
2421   "#"
2422   "&& reload_completed"
2423   [(set (match_dup 2) (match_op_dup 3 [(float_extend:DF (match_dup 1))]))
2424    (set (match_dup 4) (unspec:SF [(match_dup 2)] UNSPEC_CVTQL))
2425    (set (match_dup 5) (match_dup 4))]
2426 {
2427   operands[4] = gen_rtx_REG (SFmode, REGNO (operands[2]));
2428   operands[5] = adjust_address (operands[0], SFmode, 0);
2429 }
2430   [(set_attr "type" "fadd")
2431    (set_attr "trap" "yes")])
2432
2433 (define_insn "*fix_truncsfdi_ieee"
2434   [(set (match_operand:DI 0 "reg_no_subreg_operand" "=&f")
2435         (match_operator:DI 2 "fix_operator" 
2436           [(float_extend:DF (match_operand:SF 1 "reg_or_0_operand" "fG"))]))]
2437   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2438   "cvt%-q%/ %R1,%0"
2439   [(set_attr "type" "fadd")
2440    (set_attr "trap" "yes")
2441    (set_attr "round_suffix" "c")
2442    (set_attr "trap_suffix" "v_sv_svi")])
2443
2444 (define_insn "*fix_truncsfdi2"
2445   [(set (match_operand:DI 0 "reg_no_subreg_operand" "=f")
2446         (match_operator:DI 2 "fix_operator" 
2447           [(float_extend:DF (match_operand:SF 1 "reg_or_0_operand" "fG"))]))]
2448   "TARGET_FP"
2449   "cvt%-q%/ %R1,%0"
2450   [(set_attr "type" "fadd")
2451    (set_attr "trap" "yes")
2452    (set_attr "round_suffix" "c")
2453    (set_attr "trap_suffix" "v_sv_svi")])
2454
2455 (define_expand "fix_truncsfdi2"
2456   [(set (match_operand:DI 0 "reg_no_subreg_operand" "")
2457         (fix:DI (float_extend:DF (match_operand:SF 1 "reg_or_0_operand" ""))))]
2458   "TARGET_FP"
2459   "")
2460
2461 (define_expand "fixuns_truncsfdi2"
2462   [(set (match_operand:DI 0 "reg_no_subreg_operand" "")
2463         (unsigned_fix:DI
2464           (float_extend:DF (match_operand:SF 1 "reg_or_0_operand" ""))))]
2465   "TARGET_FP"
2466   "")
2467
2468 (define_expand "fix_trunctfdi2"
2469   [(use (match_operand:DI 0 "register_operand" ""))
2470    (use (match_operand:TF 1 "general_operand" ""))]
2471   "TARGET_HAS_XFLOATING_LIBS"
2472   "alpha_emit_xfloating_cvt (FIX, operands); DONE;")
2473
2474 (define_expand "fixuns_trunctfdi2"
2475   [(use (match_operand:DI 0 "register_operand" ""))
2476    (use (match_operand:TF 1 "general_operand" ""))]
2477   "TARGET_HAS_XFLOATING_LIBS"
2478   "alpha_emit_xfloating_cvt (UNSIGNED_FIX, operands); DONE;")
2479
2480 (define_insn "*floatdisf_ieee"
2481   [(set (match_operand:SF 0 "register_operand" "=&f")
2482         (float:SF (match_operand:DI 1 "reg_no_subreg_operand" "f")))]
2483   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2484   "cvtq%,%/ %1,%0"
2485   [(set_attr "type" "fadd")
2486    (set_attr "trap" "yes")
2487    (set_attr "round_suffix" "normal")
2488    (set_attr "trap_suffix" "sui")])
2489
2490 (define_insn "floatdisf2"
2491   [(set (match_operand:SF 0 "register_operand" "=f")
2492         (float:SF (match_operand:DI 1 "reg_no_subreg_operand" "f")))]
2493   "TARGET_FP"
2494   "cvtq%,%/ %1,%0"
2495   [(set_attr "type" "fadd")
2496    (set_attr "trap" "yes")
2497    (set_attr "round_suffix" "normal")
2498    (set_attr "trap_suffix" "sui")])
2499
2500 (define_insn_and_split "*floatsisf2_ieee"
2501   [(set (match_operand:SF 0 "register_operand" "=&f")
2502         (float:SF (match_operand:SI 1 "memory_operand" "m")))
2503    (clobber (match_scratch:DI 2 "=&f"))
2504    (clobber (match_scratch:SF 3 "=&f"))]
2505   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2506   "#"
2507   "&& reload_completed"
2508   [(set (match_dup 3) (match_dup 1))
2509    (set (match_dup 2) (unspec:DI [(match_dup 3)] UNSPEC_CVTLQ))
2510    (set (match_dup 0) (float:SF (match_dup 2)))]
2511 {
2512   operands[1] = adjust_address (operands[1], SFmode, 0);
2513 })
2514
2515 (define_insn_and_split "*floatsisf2"
2516   [(set (match_operand:SF 0 "register_operand" "=f")
2517         (float:SF (match_operand:SI 1 "memory_operand" "m")))]
2518   "TARGET_FP"
2519   "#"
2520   "&& reload_completed"
2521   [(set (match_dup 0) (match_dup 1))
2522    (set (match_dup 2) (unspec:DI [(match_dup 0)] UNSPEC_CVTLQ))
2523    (set (match_dup 0) (float:SF (match_dup 2)))]
2524 {
2525   operands[1] = adjust_address (operands[1], SFmode, 0);
2526   operands[2] = gen_rtx_REG (DImode, REGNO (operands[0]));
2527 })
2528
2529 (define_insn "*floatdidf_ieee"
2530   [(set (match_operand:DF 0 "register_operand" "=&f")
2531         (float:DF (match_operand:DI 1 "reg_no_subreg_operand" "f")))]
2532   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2533   "cvtq%-%/ %1,%0"
2534   [(set_attr "type" "fadd")
2535    (set_attr "trap" "yes")
2536    (set_attr "round_suffix" "normal")
2537    (set_attr "trap_suffix" "sui")])
2538
2539 (define_insn "floatdidf2"
2540   [(set (match_operand:DF 0 "register_operand" "=f")
2541         (float:DF (match_operand:DI 1 "reg_no_subreg_operand" "f")))]
2542   "TARGET_FP"
2543   "cvtq%-%/ %1,%0"
2544   [(set_attr "type" "fadd")
2545    (set_attr "trap" "yes")
2546    (set_attr "round_suffix" "normal")
2547    (set_attr "trap_suffix" "sui")])
2548
2549 (define_insn_and_split "*floatsidf2_ieee"
2550   [(set (match_operand:DF 0 "register_operand" "=&f")
2551         (float:DF (match_operand:SI 1 "memory_operand" "m")))
2552    (clobber (match_scratch:DI 2 "=&f"))
2553    (clobber (match_scratch:SF 3 "=&f"))]
2554   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2555   "#"
2556   "&& reload_completed"
2557   [(set (match_dup 3) (match_dup 1))
2558    (set (match_dup 2) (unspec:DI [(match_dup 3)] UNSPEC_CVTLQ))
2559    (set (match_dup 0) (float:DF (match_dup 2)))]
2560 {
2561   operands[1] = adjust_address (operands[1], SFmode, 0);
2562 })
2563
2564 (define_insn_and_split "*floatsidf2"
2565   [(set (match_operand:DF 0 "register_operand" "=f")
2566         (float:DF (match_operand:SI 1 "memory_operand" "m")))]
2567   "TARGET_FP"
2568   "#"
2569   "&& reload_completed"
2570   [(set (match_dup 3) (match_dup 1))
2571    (set (match_dup 2) (unspec:DI [(match_dup 3)] UNSPEC_CVTLQ))
2572    (set (match_dup 0) (float:DF (match_dup 2)))]
2573 {
2574   operands[1] = adjust_address (operands[1], SFmode, 0);
2575   operands[2] = gen_rtx_REG (DImode, REGNO (operands[0]));
2576   operands[3] = gen_rtx_REG (SFmode, REGNO (operands[0]));
2577 })
2578
2579 (define_expand "floatditf2"
2580   [(use (match_operand:TF 0 "register_operand" ""))
2581    (use (match_operand:DI 1 "general_operand" ""))]
2582   "TARGET_HAS_XFLOATING_LIBS"
2583   "alpha_emit_xfloating_cvt (FLOAT, operands); DONE;")
2584
2585 (define_expand "floatunsdisf2"
2586   [(use (match_operand:SF 0 "register_operand" ""))
2587    (use (match_operand:DI 1 "register_operand" ""))]
2588   "TARGET_FP"
2589   "alpha_emit_floatuns (operands); DONE;")
2590
2591 (define_expand "floatunsdidf2"
2592   [(use (match_operand:DF 0 "register_operand" ""))
2593    (use (match_operand:DI 1 "register_operand" ""))]
2594   "TARGET_FP"
2595   "alpha_emit_floatuns (operands); DONE;")
2596
2597 (define_expand "floatunsditf2"
2598   [(use (match_operand:TF 0 "register_operand" ""))
2599    (use (match_operand:DI 1 "general_operand" ""))]
2600   "TARGET_HAS_XFLOATING_LIBS"
2601   "alpha_emit_xfloating_cvt (UNSIGNED_FLOAT, operands); DONE;")
2602
2603 (define_expand "extendsfdf2"
2604   [(set (match_operand:DF 0 "register_operand" "")
2605         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "")))]
2606   "TARGET_FP"
2607 {
2608   if (alpha_fptm >= ALPHA_FPTM_SU)
2609     operands[1] = force_reg (SFmode, operands[1]);
2610 })
2611
2612 ;; The Unicos/Mk assembler doesn't support cvtst, but we've already
2613 ;; asserted that alpha_fptm == ALPHA_FPTM_N.
2614
2615 (define_insn "*extendsfdf2_ieee"
2616   [(set (match_operand:DF 0 "register_operand" "=&f")
2617         (float_extend:DF (match_operand:SF 1 "register_operand" "f")))]
2618   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2619   "cvtsts %1,%0"
2620   [(set_attr "type" "fadd")
2621    (set_attr "trap" "yes")])
2622
2623 (define_insn "*extendsfdf2_internal"
2624   [(set (match_operand:DF 0 "register_operand" "=f,f,m")
2625         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,m,f")))]
2626   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
2627   "@
2628    cpys %1,%1,%0
2629    ld%, %0,%1
2630    st%- %1,%0"
2631   [(set_attr "type" "fcpys,fld,fst")])
2632
2633 (define_expand "extendsftf2"
2634   [(use (match_operand:TF 0 "register_operand" ""))
2635    (use (match_operand:SF 1 "general_operand" ""))]
2636   "TARGET_HAS_XFLOATING_LIBS"
2637 {
2638   rtx tmp = gen_reg_rtx (DFmode);
2639   emit_insn (gen_extendsfdf2 (tmp, operands[1]));
2640   emit_insn (gen_extenddftf2 (operands[0], tmp));
2641   DONE;
2642 })
2643
2644 (define_expand "extenddftf2"
2645   [(use (match_operand:TF 0 "register_operand" ""))
2646    (use (match_operand:DF 1 "general_operand" ""))]
2647   "TARGET_HAS_XFLOATING_LIBS"
2648   "alpha_emit_xfloating_cvt (FLOAT_EXTEND, operands); DONE;")
2649
2650 (define_insn "*truncdfsf2_ieee"
2651   [(set (match_operand:SF 0 "register_operand" "=&f")
2652         (float_truncate:SF (match_operand:DF 1 "reg_or_0_operand" "fG")))]
2653   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2654   "cvt%-%,%/ %R1,%0"
2655   [(set_attr "type" "fadd")
2656    (set_attr "trap" "yes")
2657    (set_attr "round_suffix" "normal")
2658    (set_attr "trap_suffix" "u_su_sui")])
2659
2660 (define_insn "truncdfsf2"
2661   [(set (match_operand:SF 0 "register_operand" "=f")
2662         (float_truncate:SF (match_operand:DF 1 "reg_or_0_operand" "fG")))]
2663   "TARGET_FP"
2664   "cvt%-%,%/ %R1,%0"
2665   [(set_attr "type" "fadd")
2666    (set_attr "trap" "yes")
2667    (set_attr "round_suffix" "normal")
2668    (set_attr "trap_suffix" "u_su_sui")])
2669
2670 (define_expand "trunctfdf2"
2671   [(use (match_operand:DF 0 "register_operand" ""))
2672    (use (match_operand:TF 1 "general_operand" ""))]
2673   "TARGET_HAS_XFLOATING_LIBS"
2674   "alpha_emit_xfloating_cvt (FLOAT_TRUNCATE, operands); DONE;")
2675
2676 (define_expand "trunctfsf2"
2677   [(use (match_operand:SF 0 "register_operand" ""))
2678    (use (match_operand:TF 1 "general_operand" ""))]
2679   "TARGET_FP && TARGET_HAS_XFLOATING_LIBS"
2680 {
2681   rtx tmpf, sticky, arg, lo, hi;
2682
2683   tmpf = gen_reg_rtx (DFmode);
2684   sticky = gen_reg_rtx (DImode);
2685   arg = copy_to_mode_reg (TFmode, operands[1]);
2686   lo = gen_lowpart (DImode, arg);
2687   hi = gen_highpart (DImode, arg);
2688
2689   /* Convert the low word of the TFmode value into a sticky rounding bit,
2690      then or it into the low bit of the high word.  This leaves the sticky
2691      bit at bit 48 of the fraction, which is representable in DFmode,
2692      which prevents rounding error in the final conversion to SFmode.  */
2693
2694   emit_insn (gen_rtx_SET (VOIDmode, sticky,
2695                           gen_rtx_NE (DImode, lo, const0_rtx)));
2696   emit_insn (gen_iordi3 (hi, hi, sticky));
2697   emit_insn (gen_trunctfdf2 (tmpf, arg));
2698   emit_insn (gen_truncdfsf2 (operands[0], tmpf));
2699   DONE;
2700 })
2701
2702 (define_insn "*divsf3_ieee"
2703   [(set (match_operand:SF 0 "register_operand" "=&f")
2704         (div:SF (match_operand:SF 1 "reg_or_0_operand" "fG")
2705                 (match_operand:SF 2 "reg_or_0_operand" "fG")))]
2706   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2707   "div%,%/ %R1,%R2,%0"
2708   [(set_attr "type" "fdiv")
2709    (set_attr "opsize" "si")
2710    (set_attr "trap" "yes")
2711    (set_attr "round_suffix" "normal")
2712    (set_attr "trap_suffix" "u_su_sui")])
2713
2714 (define_insn "divsf3"
2715   [(set (match_operand:SF 0 "register_operand" "=f")
2716         (div:SF (match_operand:SF 1 "reg_or_0_operand" "fG")
2717                 (match_operand:SF 2 "reg_or_0_operand" "fG")))]
2718   "TARGET_FP"
2719   "div%,%/ %R1,%R2,%0"
2720   [(set_attr "type" "fdiv")
2721    (set_attr "opsize" "si")
2722    (set_attr "trap" "yes")
2723    (set_attr "round_suffix" "normal")
2724    (set_attr "trap_suffix" "u_su_sui")])
2725
2726 (define_insn "*divdf3_ieee"
2727   [(set (match_operand:DF 0 "register_operand" "=&f")
2728         (div:DF (match_operand:DF 1 "reg_or_0_operand" "fG")
2729                 (match_operand:DF 2 "reg_or_0_operand" "fG")))]
2730   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2731   "div%-%/ %R1,%R2,%0"
2732   [(set_attr "type" "fdiv")
2733    (set_attr "trap" "yes")
2734    (set_attr "round_suffix" "normal")
2735    (set_attr "trap_suffix" "u_su_sui")])
2736
2737 (define_insn "divdf3"
2738   [(set (match_operand:DF 0 "register_operand" "=f")
2739         (div:DF (match_operand:DF 1 "reg_or_0_operand" "fG")
2740                 (match_operand:DF 2 "reg_or_0_operand" "fG")))]
2741   "TARGET_FP"
2742   "div%-%/ %R1,%R2,%0"
2743   [(set_attr "type" "fdiv")
2744    (set_attr "trap" "yes")
2745    (set_attr "round_suffix" "normal")
2746    (set_attr "trap_suffix" "u_su_sui")])
2747
2748 (define_insn "*divdf_ext1"
2749   [(set (match_operand:DF 0 "register_operand" "=f")
2750         (div:DF (float_extend:DF (match_operand:SF 1 "reg_or_0_operand" "fG"))
2751                 (match_operand:DF 2 "reg_or_0_operand" "fG")))]
2752   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
2753   "div%-%/ %R1,%R2,%0"
2754   [(set_attr "type" "fdiv")
2755    (set_attr "trap" "yes")
2756    (set_attr "round_suffix" "normal")
2757    (set_attr "trap_suffix" "u_su_sui")])
2758
2759 (define_insn "*divdf_ext2"
2760   [(set (match_operand:DF 0 "register_operand" "=f")
2761         (div:DF (match_operand:DF 1 "reg_or_0_operand" "fG")
2762                 (float_extend:DF
2763                  (match_operand:SF 2 "reg_or_0_operand" "fG"))))]
2764   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
2765   "div%-%/ %R1,%R2,%0"
2766   [(set_attr "type" "fdiv")
2767    (set_attr "trap" "yes")
2768    (set_attr "round_suffix" "normal")
2769    (set_attr "trap_suffix" "u_su_sui")])
2770
2771 (define_insn "*divdf_ext3"
2772   [(set (match_operand:DF 0 "register_operand" "=f")
2773         (div:DF (float_extend:DF (match_operand:SF 1 "reg_or_0_operand" "fG"))
2774                 (float_extend:DF (match_operand:SF 2 "reg_or_0_operand" "fG"))))]
2775   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
2776   "div%-%/ %R1,%R2,%0"
2777   [(set_attr "type" "fdiv")
2778    (set_attr "trap" "yes")
2779    (set_attr "round_suffix" "normal")
2780    (set_attr "trap_suffix" "u_su_sui")])
2781
2782 (define_expand "divtf3"
2783   [(use (match_operand 0 "register_operand" ""))
2784    (use (match_operand 1 "general_operand" ""))
2785    (use (match_operand 2 "general_operand" ""))]
2786   "TARGET_HAS_XFLOATING_LIBS"
2787   "alpha_emit_xfloating_arith (DIV, operands); DONE;")
2788
2789 (define_insn "*mulsf3_ieee"
2790   [(set (match_operand:SF 0 "register_operand" "=&f")
2791         (mult:SF (match_operand:SF 1 "reg_or_0_operand" "%fG")
2792                  (match_operand:SF 2 "reg_or_0_operand" "fG")))]
2793   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2794   "mul%,%/ %R1,%R2,%0"
2795   [(set_attr "type" "fmul")
2796    (set_attr "trap" "yes")
2797    (set_attr "round_suffix" "normal")
2798    (set_attr "trap_suffix" "u_su_sui")])
2799
2800 (define_insn "mulsf3"
2801   [(set (match_operand:SF 0 "register_operand" "=f")
2802         (mult:SF (match_operand:SF 1 "reg_or_0_operand" "%fG")
2803                  (match_operand:SF 2 "reg_or_0_operand" "fG")))]
2804   "TARGET_FP"
2805   "mul%,%/ %R1,%R2,%0"
2806   [(set_attr "type" "fmul")
2807    (set_attr "trap" "yes")
2808    (set_attr "round_suffix" "normal")
2809    (set_attr "trap_suffix" "u_su_sui")])
2810
2811 (define_insn "*muldf3_ieee"
2812   [(set (match_operand:DF 0 "register_operand" "=&f")
2813         (mult:DF (match_operand:DF 1 "reg_or_0_operand" "%fG")
2814                  (match_operand:DF 2 "reg_or_0_operand" "fG")))]
2815   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2816   "mul%-%/ %R1,%R2,%0"
2817   [(set_attr "type" "fmul")
2818    (set_attr "trap" "yes")
2819    (set_attr "round_suffix" "normal")
2820    (set_attr "trap_suffix" "u_su_sui")])
2821
2822 (define_insn "muldf3"
2823   [(set (match_operand:DF 0 "register_operand" "=f")
2824         (mult:DF (match_operand:DF 1 "reg_or_0_operand" "%fG")
2825                  (match_operand:DF 2 "reg_or_0_operand" "fG")))]
2826   "TARGET_FP"
2827   "mul%-%/ %R1,%R2,%0"
2828   [(set_attr "type" "fmul")
2829    (set_attr "trap" "yes")
2830    (set_attr "round_suffix" "normal")
2831    (set_attr "trap_suffix" "u_su_sui")])
2832
2833 (define_insn "*muldf_ext1"
2834   [(set (match_operand:DF 0 "register_operand" "=f")
2835         (mult:DF (float_extend:DF
2836                   (match_operand:SF 1 "reg_or_0_operand" "fG"))
2837                  (match_operand:DF 2 "reg_or_0_operand" "fG")))]
2838   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
2839   "mul%-%/ %R1,%R2,%0"
2840   [(set_attr "type" "fmul")
2841    (set_attr "trap" "yes")
2842    (set_attr "round_suffix" "normal")
2843    (set_attr "trap_suffix" "u_su_sui")])
2844
2845 (define_insn "*muldf_ext2"
2846   [(set (match_operand:DF 0 "register_operand" "=f")
2847         (mult:DF (float_extend:DF
2848                   (match_operand:SF 1 "reg_or_0_operand" "%fG"))
2849                  (float_extend:DF
2850                   (match_operand:SF 2 "reg_or_0_operand" "fG"))))]
2851   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
2852   "mul%-%/ %R1,%R2,%0"
2853   [(set_attr "type" "fmul")
2854    (set_attr "trap" "yes")
2855    (set_attr "round_suffix" "normal")
2856    (set_attr "trap_suffix" "u_su_sui")])
2857
2858 (define_expand "multf3"
2859   [(use (match_operand 0 "register_operand" ""))
2860    (use (match_operand 1 "general_operand" ""))
2861    (use (match_operand 2 "general_operand" ""))]
2862   "TARGET_HAS_XFLOATING_LIBS"
2863   "alpha_emit_xfloating_arith (MULT, operands); DONE;")
2864
2865 (define_insn "*subsf3_ieee"
2866   [(set (match_operand:SF 0 "register_operand" "=&f")
2867         (minus:SF (match_operand:SF 1 "reg_or_0_operand" "fG")
2868                   (match_operand:SF 2 "reg_or_0_operand" "fG")))]
2869   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2870   "sub%,%/ %R1,%R2,%0"
2871   [(set_attr "type" "fadd")
2872    (set_attr "trap" "yes")
2873    (set_attr "round_suffix" "normal")
2874    (set_attr "trap_suffix" "u_su_sui")])
2875
2876 (define_insn "subsf3"
2877   [(set (match_operand:SF 0 "register_operand" "=f")
2878         (minus:SF (match_operand:SF 1 "reg_or_0_operand" "fG")
2879                   (match_operand:SF 2 "reg_or_0_operand" "fG")))]
2880   "TARGET_FP"
2881   "sub%,%/ %R1,%R2,%0"
2882   [(set_attr "type" "fadd")
2883    (set_attr "trap" "yes")
2884    (set_attr "round_suffix" "normal")
2885    (set_attr "trap_suffix" "u_su_sui")])
2886
2887 (define_insn "*subdf3_ieee"
2888   [(set (match_operand:DF 0 "register_operand" "=&f")
2889         (minus:DF (match_operand:DF 1 "reg_or_0_operand" "fG")
2890                   (match_operand:DF 2 "reg_or_0_operand" "fG")))]
2891   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
2892   "sub%-%/ %R1,%R2,%0"
2893   [(set_attr "type" "fadd")
2894    (set_attr "trap" "yes")
2895    (set_attr "round_suffix" "normal")
2896    (set_attr "trap_suffix" "u_su_sui")])
2897
2898 (define_insn "subdf3"
2899   [(set (match_operand:DF 0 "register_operand" "=f")
2900         (minus:DF (match_operand:DF 1 "reg_or_0_operand" "fG")
2901                   (match_operand:DF 2 "reg_or_0_operand" "fG")))]
2902   "TARGET_FP"
2903   "sub%-%/ %R1,%R2,%0"
2904   [(set_attr "type" "fadd")
2905    (set_attr "trap" "yes")
2906    (set_attr "round_suffix" "normal")
2907    (set_attr "trap_suffix" "u_su_sui")])
2908
2909 (define_insn "*subdf_ext1"
2910   [(set (match_operand:DF 0 "register_operand" "=f")
2911         (minus:DF (float_extend:DF
2912                    (match_operand:SF 1 "reg_or_0_operand" "fG"))
2913                   (match_operand:DF 2 "reg_or_0_operand" "fG")))]
2914   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
2915   "sub%-%/ %R1,%R2,%0"
2916   [(set_attr "type" "fadd")
2917    (set_attr "trap" "yes")
2918    (set_attr "round_suffix" "normal")
2919    (set_attr "trap_suffix" "u_su_sui")])
2920
2921 (define_insn "*subdf_ext2"
2922   [(set (match_operand:DF 0 "register_operand" "=f")
2923         (minus:DF (match_operand:DF 1 "reg_or_0_operand" "fG")
2924                   (float_extend:DF
2925                    (match_operand:SF 2 "reg_or_0_operand" "fG"))))]
2926   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
2927   "sub%-%/ %R1,%R2,%0"
2928   [(set_attr "type" "fadd")
2929    (set_attr "trap" "yes")
2930    (set_attr "round_suffix" "normal")
2931    (set_attr "trap_suffix" "u_su_sui")])
2932
2933 (define_insn "*subdf_ext3"
2934   [(set (match_operand:DF 0 "register_operand" "=f")
2935         (minus:DF (float_extend:DF
2936                    (match_operand:SF 1 "reg_or_0_operand" "fG"))
2937                   (float_extend:DF
2938                    (match_operand:SF 2 "reg_or_0_operand" "fG"))))]
2939   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
2940   "sub%-%/ %R1,%R2,%0"
2941   [(set_attr "type" "fadd")
2942    (set_attr "trap" "yes")
2943    (set_attr "round_suffix" "normal")
2944    (set_attr "trap_suffix" "u_su_sui")])
2945
2946 (define_expand "subtf3"
2947   [(use (match_operand 0 "register_operand" ""))
2948    (use (match_operand 1 "general_operand" ""))
2949    (use (match_operand 2 "general_operand" ""))]
2950   "TARGET_HAS_XFLOATING_LIBS"
2951   "alpha_emit_xfloating_arith (MINUS, operands); DONE;")
2952
2953 (define_insn "*sqrtsf2_ieee"
2954   [(set (match_operand:SF 0 "register_operand" "=&f")
2955         (sqrt:SF (match_operand:SF 1 "reg_or_0_operand" "fG")))]
2956   "TARGET_FP && TARGET_FIX && alpha_fptm >= ALPHA_FPTM_SU"
2957   "sqrt%,%/ %R1,%0"
2958   [(set_attr "type" "fsqrt")
2959    (set_attr "opsize" "si")
2960    (set_attr "trap" "yes")
2961    (set_attr "round_suffix" "normal")
2962    (set_attr "trap_suffix" "u_su_sui")])
2963
2964 (define_insn "sqrtsf2"
2965   [(set (match_operand:SF 0 "register_operand" "=f")
2966         (sqrt:SF (match_operand:SF 1 "reg_or_0_operand" "fG")))]
2967   "TARGET_FP && TARGET_FIX"
2968   "sqrt%,%/ %R1,%0"
2969   [(set_attr "type" "fsqrt")
2970    (set_attr "opsize" "si")
2971    (set_attr "trap" "yes")
2972    (set_attr "round_suffix" "normal")
2973    (set_attr "trap_suffix" "u_su_sui")])
2974
2975 (define_insn "*sqrtdf2_ieee"
2976   [(set (match_operand:DF 0 "register_operand" "=&f")
2977         (sqrt:DF (match_operand:DF 1 "reg_or_0_operand" "fG")))]
2978   "TARGET_FP && TARGET_FIX && alpha_fptm >= ALPHA_FPTM_SU"
2979   "sqrt%-%/ %R1,%0"
2980   [(set_attr "type" "fsqrt")
2981    (set_attr "trap" "yes")
2982    (set_attr "round_suffix" "normal")
2983    (set_attr "trap_suffix" "u_su_sui")])
2984
2985 (define_insn "sqrtdf2"
2986   [(set (match_operand:DF 0 "register_operand" "=f")
2987         (sqrt:DF (match_operand:DF 1 "reg_or_0_operand" "fG")))]
2988   "TARGET_FP && TARGET_FIX"
2989   "sqrt%-%/ %R1,%0"
2990   [(set_attr "type" "fsqrt")
2991    (set_attr "trap" "yes")
2992    (set_attr "round_suffix" "normal")
2993    (set_attr "trap_suffix" "u_su_sui")])
2994 \f
2995 ;; Next are all the integer comparisons, and conditional moves and branches
2996 ;; and some of the related define_expand's and define_split's.
2997
2998 (define_insn "*setcc_internal"
2999   [(set (match_operand 0 "register_operand" "=r")
3000         (match_operator 1 "alpha_comparison_operator"
3001                            [(match_operand:DI 2 "register_operand" "r")
3002                             (match_operand:DI 3 "reg_or_8bit_operand" "rI")]))]
3003   "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT
3004    && GET_MODE_SIZE (GET_MODE (operands[0])) <= 8
3005    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
3006   "cmp%C1 %2,%3,%0"
3007   [(set_attr "type" "icmp")])
3008
3009 ;; Yes, we can technically support reg_or_8bit_operand in operand 2,
3010 ;; but that's non-canonical rtl and allowing that causes inefficiencies
3011 ;; from cse on.
3012 (define_insn "*setcc_swapped_internal"
3013   [(set (match_operand 0 "register_operand" "=r")
3014         (match_operator 1 "alpha_swapped_comparison_operator"
3015                            [(match_operand:DI 2 "register_operand" "r")
3016                             (match_operand:DI 3 "reg_or_0_operand" "rJ")]))]
3017   "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT
3018    && GET_MODE_SIZE (GET_MODE (operands[0])) <= 8
3019    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
3020   "cmp%c1 %r3,%2,%0"
3021   [(set_attr "type" "icmp")])
3022
3023 ;; Use match_operator rather than ne directly so that we can match
3024 ;; multiple integer modes.
3025 (define_insn "*setne_internal"
3026   [(set (match_operand 0 "register_operand" "=r")
3027         (match_operator 1 "signed_comparison_operator"
3028                           [(match_operand:DI 2 "register_operand" "r")
3029                            (const_int 0)]))]
3030   "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT
3031    && GET_MODE_SIZE (GET_MODE (operands[0])) <= 8
3032    && GET_CODE (operands[1]) == NE
3033    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
3034   "cmpult $31,%2,%0"
3035   [(set_attr "type" "icmp")])
3036
3037 ;; The mode folding trick can't be used with const_int operands, since
3038 ;; reload needs to know the proper mode.
3039 ;;
3040 ;; Use add_operand instead of the more seemingly natural reg_or_8bit_operand
3041 ;; in order to create more pairs of constants.  As long as we're allowing
3042 ;; two constants at the same time, and will have to reload one of them...
3043
3044 (define_insn "*movqicc_internal"
3045   [(set (match_operand:QI 0 "register_operand" "=r,r,r,r")
3046         (if_then_else:QI
3047          (match_operator 2 "signed_comparison_operator"
3048                          [(match_operand:DI 3 "reg_or_0_operand" "rJ,rJ,J,J")
3049                           (match_operand:DI 4 "reg_or_0_operand" "J,J,rJ,rJ")])
3050          (match_operand:QI 1 "add_operand" "rI,0,rI,0")
3051          (match_operand:QI 5 "add_operand" "0,rI,0,rI")))]
3052   "(operands[3] == const0_rtx || operands[4] == const0_rtx)"
3053   "@
3054    cmov%C2 %r3,%1,%0
3055    cmov%D2 %r3,%5,%0
3056    cmov%c2 %r4,%1,%0
3057    cmov%d2 %r4,%5,%0"
3058   [(set_attr "type" "icmov")])
3059
3060 (define_insn "*movhicc_internal"
3061   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
3062         (if_then_else:HI
3063          (match_operator 2 "signed_comparison_operator"
3064                          [(match_operand:DI 3 "reg_or_0_operand" "rJ,rJ,J,J")
3065                           (match_operand:DI 4 "reg_or_0_operand" "J,J,rJ,rJ")])
3066          (match_operand:HI 1 "add_operand" "rI,0,rI,0")
3067          (match_operand:HI 5 "add_operand" "0,rI,0,rI")))]
3068   "(operands[3] == const0_rtx || operands[4] == const0_rtx)"
3069   "@
3070    cmov%C2 %r3,%1,%0
3071    cmov%D2 %r3,%5,%0
3072    cmov%c2 %r4,%1,%0
3073    cmov%d2 %r4,%5,%0"
3074   [(set_attr "type" "icmov")])
3075
3076 (define_insn "*movsicc_internal"
3077   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
3078         (if_then_else:SI
3079          (match_operator 2 "signed_comparison_operator"
3080                          [(match_operand:DI 3 "reg_or_0_operand" "rJ,rJ,J,J")
3081                           (match_operand:DI 4 "reg_or_0_operand" "J,J,rJ,rJ")])
3082          (match_operand:SI 1 "add_operand" "rI,0,rI,0")
3083          (match_operand:SI 5 "add_operand" "0,rI,0,rI")))]
3084   "(operands[3] == const0_rtx || operands[4] == const0_rtx)"
3085   "@
3086    cmov%C2 %r3,%1,%0
3087    cmov%D2 %r3,%5,%0
3088    cmov%c2 %r4,%1,%0
3089    cmov%d2 %r4,%5,%0"
3090   [(set_attr "type" "icmov")])
3091
3092 (define_insn "*movdicc_internal"
3093   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r")
3094         (if_then_else:DI
3095          (match_operator 2 "signed_comparison_operator"
3096                          [(match_operand:DI 3 "reg_or_0_operand" "rJ,rJ,J,J")
3097                           (match_operand:DI 4 "reg_or_0_operand" "J,J,rJ,rJ")])
3098          (match_operand:DI 1 "add_operand" "rI,0,rI,0")
3099          (match_operand:DI 5 "add_operand" "0,rI,0,rI")))]
3100   "(operands[3] == const0_rtx || operands[4] == const0_rtx)"
3101   "@
3102    cmov%C2 %r3,%1,%0
3103    cmov%D2 %r3,%5,%0
3104    cmov%c2 %r4,%1,%0
3105    cmov%d2 %r4,%5,%0"
3106   [(set_attr "type" "icmov")])
3107
3108 (define_insn "*movqicc_lbc"
3109   [(set (match_operand:QI 0 "register_operand" "=r,r")
3110         (if_then_else:QI
3111          (eq (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
3112                               (const_int 1)
3113                               (const_int 0))
3114              (const_int 0))
3115          (match_operand:QI 1 "reg_or_8bit_operand" "rI,0")
3116          (match_operand:QI 3 "reg_or_8bit_operand" "0,rI")))]
3117   ""
3118   "@
3119    cmovlbc %r2,%1,%0
3120    cmovlbs %r2,%3,%0"
3121   [(set_attr "type" "icmov")])
3122
3123 (define_insn "*movhicc_lbc"
3124   [(set (match_operand:HI 0 "register_operand" "=r,r")
3125         (if_then_else:HI
3126          (eq (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
3127                               (const_int 1)
3128                               (const_int 0))
3129              (const_int 0))
3130          (match_operand:HI 1 "reg_or_8bit_operand" "rI,0")
3131          (match_operand:HI 3 "reg_or_8bit_operand" "0,rI")))]
3132   ""
3133   "@
3134    cmovlbc %r2,%1,%0
3135    cmovlbs %r2,%3,%0"
3136   [(set_attr "type" "icmov")])
3137
3138 (define_insn "*movsicc_lbc"
3139   [(set (match_operand:SI 0 "register_operand" "=r,r")
3140         (if_then_else:SI
3141          (eq (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
3142                               (const_int 1)
3143                               (const_int 0))
3144              (const_int 0))
3145          (match_operand:SI 1 "reg_or_8bit_operand" "rI,0")
3146          (match_operand:SI 3 "reg_or_8bit_operand" "0,rI")))]
3147   ""
3148   "@
3149    cmovlbc %r2,%1,%0
3150    cmovlbs %r2,%3,%0"
3151   [(set_attr "type" "icmov")])
3152
3153 (define_insn "*movdicc_lbc"
3154   [(set (match_operand:DI 0 "register_operand" "=r,r")
3155         (if_then_else:DI
3156          (eq (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
3157                               (const_int 1)
3158                               (const_int 0))
3159              (const_int 0))
3160          (match_operand:DI 1 "reg_or_8bit_operand" "rI,0")
3161          (match_operand:DI 3 "reg_or_8bit_operand" "0,rI")))]
3162   ""
3163   "@
3164    cmovlbc %r2,%1,%0
3165    cmovlbs %r2,%3,%0"
3166   [(set_attr "type" "icmov")])
3167
3168 (define_insn "*movqicc_lbs"
3169   [(set (match_operand:QI 0 "register_operand" "=r,r")
3170         (if_then_else:QI
3171          (ne (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
3172                               (const_int 1)
3173                               (const_int 0))
3174              (const_int 0))
3175          (match_operand:QI 1 "reg_or_8bit_operand" "rI,0")
3176          (match_operand:QI 3 "reg_or_8bit_operand" "0,rI")))]
3177   ""
3178   "@
3179    cmovlbs %r2,%1,%0
3180    cmovlbc %r2,%3,%0"
3181   [(set_attr "type" "icmov")])
3182
3183 (define_insn "*movhicc_lbs"
3184   [(set (match_operand:HI 0 "register_operand" "=r,r")
3185         (if_then_else:HI
3186          (ne (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
3187                               (const_int 1)
3188                               (const_int 0))
3189              (const_int 0))
3190          (match_operand:HI 1 "reg_or_8bit_operand" "rI,0")
3191          (match_operand:HI 3 "reg_or_8bit_operand" "0,rI")))]
3192   ""
3193   "@
3194    cmovlbs %r2,%1,%0
3195    cmovlbc %r2,%3,%0"
3196   [(set_attr "type" "icmov")])
3197
3198 (define_insn "*movsicc_lbs"
3199   [(set (match_operand:SI 0 "register_operand" "=r,r")
3200         (if_then_else:SI
3201          (ne (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
3202                               (const_int 1)
3203                               (const_int 0))
3204              (const_int 0))
3205          (match_operand:SI 1 "reg_or_8bit_operand" "rI,0")
3206          (match_operand:SI 3 "reg_or_8bit_operand" "0,rI")))]
3207   ""
3208   "@
3209    cmovlbs %r2,%1,%0
3210    cmovlbc %r2,%3,%0"
3211   [(set_attr "type" "icmov")])
3212
3213 (define_insn "*movdicc_lbs"
3214   [(set (match_operand:DI 0 "register_operand" "=r,r")
3215         (if_then_else:DI
3216          (ne (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
3217                               (const_int 1)
3218                               (const_int 0))
3219              (const_int 0))
3220          (match_operand:DI 1 "reg_or_8bit_operand" "rI,0")
3221          (match_operand:DI 3 "reg_or_8bit_operand" "0,rI")))]
3222   ""
3223   "@
3224    cmovlbs %r2,%1,%0
3225    cmovlbc %r2,%3,%0"
3226   [(set_attr "type" "icmov")])
3227
3228 ;; For ABS, we have two choices, depending on whether the input and output
3229 ;; registers are the same or not.
3230 (define_expand "absdi2"
3231   [(set (match_operand:DI 0 "register_operand" "")
3232         (abs:DI (match_operand:DI 1 "register_operand" "")))]
3233   ""
3234 {
3235   if (rtx_equal_p (operands[0], operands[1]))
3236     emit_insn (gen_absdi2_same (operands[0], gen_reg_rtx (DImode)));
3237   else
3238     emit_insn (gen_absdi2_diff (operands[0], operands[1]));
3239   DONE;
3240 })
3241
3242 (define_expand "absdi2_same"
3243   [(set (match_operand:DI 1 "register_operand" "")
3244         (neg:DI (match_operand:DI 0 "register_operand" "")))
3245    (set (match_dup 0)
3246         (if_then_else:DI (ge (match_dup 0) (const_int 0))
3247                          (match_dup 0)
3248                          (match_dup 1)))]
3249   ""
3250   "")
3251
3252 (define_expand "absdi2_diff"
3253   [(set (match_operand:DI 0 "register_operand" "")
3254         (neg:DI (match_operand:DI 1 "register_operand" "")))
3255    (set (match_dup 0)
3256         (if_then_else:DI (lt (match_dup 1) (const_int 0))
3257                          (match_dup 0)
3258                          (match_dup 1)))]
3259   ""
3260   "")
3261
3262 (define_split
3263   [(set (match_operand:DI 0 "register_operand" "")
3264         (abs:DI (match_dup 0)))
3265    (clobber (match_operand:DI 1 "register_operand" ""))]
3266   ""
3267   [(set (match_dup 1) (neg:DI (match_dup 0)))
3268    (set (match_dup 0) (if_then_else:DI (ge (match_dup 0) (const_int 0))
3269                                        (match_dup 0) (match_dup 1)))]
3270   "")
3271
3272 (define_split
3273   [(set (match_operand:DI 0 "register_operand" "")
3274         (abs:DI (match_operand:DI 1 "register_operand" "")))]
3275   "! rtx_equal_p (operands[0], operands[1])"
3276   [(set (match_dup 0) (neg:DI (match_dup 1)))
3277    (set (match_dup 0) (if_then_else:DI (lt (match_dup 1) (const_int 0))
3278                                        (match_dup 0) (match_dup 1)))]
3279   "")
3280
3281 (define_split
3282   [(set (match_operand:DI 0 "register_operand" "")
3283         (neg:DI (abs:DI (match_dup 0))))
3284    (clobber (match_operand:DI 1 "register_operand" ""))]
3285   ""
3286   [(set (match_dup 1) (neg:DI (match_dup 0)))
3287    (set (match_dup 0) (if_then_else:DI (le (match_dup 0) (const_int 0))
3288                                        (match_dup 0) (match_dup 1)))]
3289   "")
3290
3291 (define_split
3292   [(set (match_operand:DI 0 "register_operand" "")
3293         (neg:DI (abs:DI (match_operand:DI 1 "register_operand" ""))))]
3294   "! rtx_equal_p (operands[0], operands[1])"
3295   [(set (match_dup 0) (neg:DI (match_dup 1)))
3296    (set (match_dup 0) (if_then_else:DI (gt (match_dup 1) (const_int 0))
3297                                        (match_dup 0) (match_dup 1)))]
3298   "")
3299
3300 (define_insn "sminqi3"
3301   [(set (match_operand:QI 0 "register_operand" "=r")
3302         (smin:QI (match_operand:QI 1 "reg_or_0_operand" "%rJ")
3303                  (match_operand:QI 2 "reg_or_8bit_operand" "rI")))]
3304   "TARGET_MAX"
3305   "minsb8 %r1,%2,%0"
3306   [(set_attr "type" "mvi")])
3307
3308 (define_insn "uminqi3"
3309   [(set (match_operand:QI 0 "register_operand" "=r")
3310         (umin:QI (match_operand:QI 1 "reg_or_0_operand" "%rJ")
3311                  (match_operand:QI 2 "reg_or_8bit_operand" "rI")))]
3312   "TARGET_MAX"
3313   "minub8 %r1,%2,%0"
3314   [(set_attr "type" "mvi")])
3315
3316 (define_insn "smaxqi3"
3317   [(set (match_operand:QI 0 "register_operand" "=r")
3318         (smax:QI (match_operand:QI 1 "reg_or_0_operand" "%rJ")
3319                  (match_operand:QI 2 "reg_or_8bit_operand" "rI")))]
3320   "TARGET_MAX"
3321   "maxsb8 %r1,%2,%0"
3322   [(set_attr "type" "mvi")])
3323
3324 (define_insn "umaxqi3"
3325   [(set (match_operand:QI 0 "register_operand" "=r")
3326         (umax:QI (match_operand:QI 1 "reg_or_0_operand" "%rJ")
3327                  (match_operand:QI 2 "reg_or_8bit_operand" "rI")))]
3328   "TARGET_MAX"
3329   "maxub8 %r1,%2,%0"
3330   [(set_attr "type" "mvi")])
3331
3332 (define_insn "sminhi3"
3333   [(set (match_operand:HI 0 "register_operand" "=r")
3334         (smin:HI (match_operand:HI 1 "reg_or_0_operand" "%rJ")
3335                  (match_operand:HI 2 "reg_or_8bit_operand" "rI")))]
3336   "TARGET_MAX"
3337   "minsw4 %r1,%2,%0"
3338   [(set_attr "type" "mvi")])
3339
3340 (define_insn "uminhi3"
3341   [(set (match_operand:HI 0 "register_operand" "=r")
3342         (umin:HI (match_operand:HI 1 "reg_or_0_operand" "%rJ")
3343                  (match_operand:HI 2 "reg_or_8bit_operand" "rI")))]
3344   "TARGET_MAX"
3345   "minuw4 %r1,%2,%0"
3346   [(set_attr "type" "mvi")])
3347
3348 (define_insn "smaxhi3"
3349   [(set (match_operand:HI 0 "register_operand" "=r")
3350         (smax:HI (match_operand:HI 1 "reg_or_0_operand" "%rJ")
3351                  (match_operand:HI 2 "reg_or_8bit_operand" "rI")))]
3352   "TARGET_MAX"
3353   "maxsw4 %r1,%2,%0"
3354   [(set_attr "type" "mvi")])
3355
3356 (define_insn "umaxhi3"
3357   [(set (match_operand:HI 0 "register_operand" "=r")
3358         (umax:HI (match_operand:HI 1 "reg_or_0_operand" "%rJ")
3359                  (match_operand:HI 2 "reg_or_8bit_operand" "rI")))]
3360   "TARGET_MAX"
3361   "maxuw4 %r1,%2,%0"
3362   [(set_attr "type" "mvi")])
3363
3364 (define_expand "smaxdi3"
3365   [(set (match_dup 3)
3366         (le:DI (match_operand:DI 1 "reg_or_0_operand" "")
3367                (match_operand:DI 2 "reg_or_8bit_operand" "")))
3368    (set (match_operand:DI 0 "register_operand" "")
3369         (if_then_else:DI (eq (match_dup 3) (const_int 0))
3370                          (match_dup 1) (match_dup 2)))]
3371   ""
3372   { operands[3] = gen_reg_rtx (DImode); })
3373
3374 (define_split
3375   [(set (match_operand:DI 0 "register_operand" "")
3376         (smax:DI (match_operand:DI 1 "reg_or_0_operand" "")
3377                  (match_operand:DI 2 "reg_or_8bit_operand" "")))
3378    (clobber (match_operand:DI 3 "register_operand" ""))]
3379   "operands[2] != const0_rtx"
3380   [(set (match_dup 3) (le:DI (match_dup 1) (match_dup 2)))
3381    (set (match_dup 0) (if_then_else:DI (eq (match_dup 3) (const_int 0))
3382                                        (match_dup 1) (match_dup 2)))]
3383   "")
3384
3385 (define_insn "*smax_const0"
3386   [(set (match_operand:DI 0 "register_operand" "=r")
3387         (smax:DI (match_operand:DI 1 "register_operand" "0")
3388                  (const_int 0)))]
3389   ""
3390   "cmovlt %0,0,%0"
3391   [(set_attr "type" "icmov")])
3392
3393 (define_expand "smindi3"
3394   [(set (match_dup 3)
3395         (lt:DI (match_operand:DI 1 "reg_or_0_operand" "")
3396                (match_operand:DI 2 "reg_or_8bit_operand" "")))
3397    (set (match_operand:DI 0 "register_operand" "")
3398         (if_then_else:DI (ne (match_dup 3) (const_int 0))
3399                          (match_dup 1) (match_dup 2)))]
3400   ""
3401   { operands[3] = gen_reg_rtx (DImode); })
3402
3403 (define_split
3404   [(set (match_operand:DI 0 "register_operand" "")
3405         (smin:DI (match_operand:DI 1 "reg_or_0_operand" "")
3406                  (match_operand:DI 2 "reg_or_8bit_operand" "")))
3407    (clobber (match_operand:DI 3 "register_operand" ""))]
3408   "operands[2] != const0_rtx"
3409   [(set (match_dup 3) (lt:DI (match_dup 1) (match_dup 2)))
3410    (set (match_dup 0) (if_then_else:DI (ne (match_dup 3) (const_int 0))
3411                                        (match_dup 1) (match_dup 2)))]
3412   "")
3413
3414 (define_insn "*smin_const0"
3415   [(set (match_operand:DI 0 "register_operand" "=r")
3416         (smin:DI (match_operand:DI 1 "register_operand" "0")
3417                  (const_int 0)))]
3418   ""
3419   "cmovgt %0,0,%0"
3420   [(set_attr "type" "icmov")])
3421
3422 (define_expand "umaxdi3"
3423   [(set (match_dup 3)
3424         (leu:DI (match_operand:DI 1 "reg_or_0_operand" "")
3425                 (match_operand:DI 2 "reg_or_8bit_operand" "")))
3426    (set (match_operand:DI 0 "register_operand" "")
3427         (if_then_else:DI (eq (match_dup 3) (const_int 0))
3428                          (match_dup 1) (match_dup 2)))]
3429   ""
3430   "operands[3] = gen_reg_rtx (DImode);")
3431
3432 (define_split
3433   [(set (match_operand:DI 0 "register_operand" "")
3434         (umax:DI (match_operand:DI 1 "reg_or_0_operand" "")
3435                  (match_operand:DI 2 "reg_or_8bit_operand" "")))
3436    (clobber (match_operand:DI 3 "register_operand" ""))]
3437   "operands[2] != const0_rtx"
3438   [(set (match_dup 3) (leu:DI (match_dup 1) (match_dup 2)))
3439    (set (match_dup 0) (if_then_else:DI (eq (match_dup 3) (const_int 0))
3440                                        (match_dup 1) (match_dup 2)))]
3441   "")
3442
3443 (define_expand "umindi3"
3444   [(set (match_dup 3)
3445         (ltu:DI (match_operand:DI 1 "reg_or_0_operand" "")
3446                 (match_operand:DI 2 "reg_or_8bit_operand" "")))
3447    (set (match_operand:DI 0 "register_operand" "")
3448         (if_then_else:DI (ne (match_dup 3) (const_int 0))
3449                          (match_dup 1) (match_dup 2)))]
3450   ""
3451   "operands[3] = gen_reg_rtx (DImode);")
3452
3453 (define_split
3454   [(set (match_operand:DI 0 "register_operand" "")
3455         (umin:DI (match_operand:DI 1 "reg_or_0_operand" "")
3456                  (match_operand:DI 2 "reg_or_8bit_operand" "")))
3457    (clobber (match_operand:DI 3 "register_operand" ""))]
3458   "operands[2] != const0_rtx"
3459   [(set (match_dup 3) (ltu:DI (match_dup 1) (match_dup 2)))
3460    (set (match_dup 0) (if_then_else:DI (ne (match_dup 3) (const_int 0))
3461                                        (match_dup 1) (match_dup 2)))]
3462   "")
3463
3464 (define_insn "*bcc_normal"
3465   [(set (pc)
3466         (if_then_else
3467          (match_operator 1 "signed_comparison_operator"
3468                          [(match_operand:DI 2 "reg_or_0_operand" "rJ")
3469                           (const_int 0)])
3470          (label_ref (match_operand 0 "" ""))
3471          (pc)))]
3472   ""
3473   "b%C1 %r2,%0"
3474   [(set_attr "type" "ibr")])
3475
3476 (define_insn "*bcc_reverse"
3477   [(set (pc)
3478         (if_then_else
3479          (match_operator 1 "signed_comparison_operator"
3480                          [(match_operand:DI 2 "register_operand" "r")
3481                           (const_int 0)])
3482
3483          (pc)
3484          (label_ref (match_operand 0 "" ""))))]
3485   ""
3486   "b%c1 %2,%0"
3487   [(set_attr "type" "ibr")])
3488
3489 (define_insn "*blbs_normal"
3490   [(set (pc)
3491         (if_then_else
3492          (ne (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
3493                               (const_int 1)
3494                               (const_int 0))
3495              (const_int 0))
3496          (label_ref (match_operand 0 "" ""))
3497          (pc)))]
3498   ""
3499   "blbs %r1,%0"
3500   [(set_attr "type" "ibr")])
3501
3502 (define_insn "*blbc_normal"
3503   [(set (pc)
3504         (if_then_else
3505          (eq (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
3506                               (const_int 1)
3507                               (const_int 0))
3508              (const_int 0))
3509          (label_ref (match_operand 0 "" ""))
3510          (pc)))]
3511   ""
3512   "blbc %r1,%0"
3513   [(set_attr "type" "ibr")])
3514
3515 (define_split
3516   [(parallel
3517     [(set (pc)
3518           (if_then_else
3519            (match_operator 1 "comparison_operator"
3520                            [(zero_extract:DI (match_operand:DI 2 "register_operand" "")
3521                                              (const_int 1)
3522                                              (match_operand:DI 3 "const_int_operand" ""))
3523                             (const_int 0)])
3524            (label_ref (match_operand 0 "" ""))
3525            (pc)))
3526      (clobber (match_operand:DI 4 "register_operand" ""))])]
3527   "INTVAL (operands[3]) != 0"
3528   [(set (match_dup 4)
3529         (lshiftrt:DI (match_dup 2) (match_dup 3)))
3530    (set (pc)
3531         (if_then_else (match_op_dup 1
3532                                     [(zero_extract:DI (match_dup 4)
3533                                                       (const_int 1)
3534                                                       (const_int 0))
3535                                      (const_int 0)])
3536                       (label_ref (match_dup 0))
3537                       (pc)))]
3538   "")
3539 \f
3540 ;; The following are the corresponding floating-point insns.  Recall
3541 ;; we need to have variants that expand the arguments from SFmode
3542 ;; to DFmode.
3543
3544 (define_insn "*cmpdf_ieee"
3545   [(set (match_operand:DF 0 "register_operand" "=&f")
3546         (match_operator:DF 1 "alpha_fp_comparison_operator"
3547                            [(match_operand:DF 2 "reg_or_0_operand" "fG")
3548                             (match_operand:DF 3 "reg_or_0_operand" "fG")]))]
3549   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
3550   "cmp%-%C1%/ %R2,%R3,%0"
3551   [(set_attr "type" "fadd")
3552    (set_attr "trap" "yes")
3553    (set_attr "trap_suffix" "su")])
3554
3555 (define_insn "*cmpdf_internal"
3556   [(set (match_operand:DF 0 "register_operand" "=f")
3557         (match_operator:DF 1 "alpha_fp_comparison_operator"
3558                            [(match_operand:DF 2 "reg_or_0_operand" "fG")
3559                             (match_operand:DF 3 "reg_or_0_operand" "fG")]))]
3560   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
3561   "cmp%-%C1%/ %R2,%R3,%0"
3562   [(set_attr "type" "fadd")
3563    (set_attr "trap" "yes")
3564    (set_attr "trap_suffix" "su")])
3565
3566 (define_insn "*cmpdf_ieee_ext1"
3567   [(set (match_operand:DF 0 "register_operand" "=&f")
3568         (match_operator:DF 1 "alpha_fp_comparison_operator"
3569                            [(float_extend:DF
3570                              (match_operand:SF 2 "reg_or_0_operand" "fG"))
3571                             (match_operand:DF 3 "reg_or_0_operand" "fG")]))]
3572   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
3573   "cmp%-%C1%/ %R2,%R3,%0"
3574   [(set_attr "type" "fadd")
3575    (set_attr "trap" "yes")
3576    (set_attr "trap_suffix" "su")])
3577
3578 (define_insn "*cmpdf_ext1"
3579   [(set (match_operand:DF 0 "register_operand" "=f")
3580         (match_operator:DF 1 "alpha_fp_comparison_operator"
3581                            [(float_extend:DF
3582                              (match_operand:SF 2 "reg_or_0_operand" "fG"))
3583                             (match_operand:DF 3 "reg_or_0_operand" "fG")]))]
3584   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
3585   "cmp%-%C1%/ %R2,%R3,%0"
3586   [(set_attr "type" "fadd")
3587    (set_attr "trap" "yes")
3588    (set_attr "trap_suffix" "su")])
3589
3590 (define_insn "*cmpdf_ieee_ext2"
3591   [(set (match_operand:DF 0 "register_operand" "=&f")
3592         (match_operator:DF 1 "alpha_fp_comparison_operator"
3593                            [(match_operand:DF 2 "reg_or_0_operand" "fG")
3594                             (float_extend:DF
3595                              (match_operand:SF 3 "reg_or_0_operand" "fG"))]))]
3596   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
3597   "cmp%-%C1%/ %R2,%R3,%0"
3598   [(set_attr "type" "fadd")
3599    (set_attr "trap" "yes")
3600    (set_attr "trap_suffix" "su")])
3601
3602 (define_insn "*cmpdf_ext2"
3603   [(set (match_operand:DF 0 "register_operand" "=f")
3604         (match_operator:DF 1 "alpha_fp_comparison_operator"
3605                            [(match_operand:DF 2 "reg_or_0_operand" "fG")
3606                             (float_extend:DF
3607                              (match_operand:SF 3 "reg_or_0_operand" "fG"))]))]
3608   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
3609   "cmp%-%C1%/ %R2,%R3,%0"
3610   [(set_attr "type" "fadd")
3611    (set_attr "trap" "yes")
3612    (set_attr "trap_suffix" "su")])
3613
3614 (define_insn "*cmpdf_ieee_ext3"
3615   [(set (match_operand:DF 0 "register_operand" "=&f")
3616         (match_operator:DF 1 "alpha_fp_comparison_operator"
3617                            [(float_extend:DF
3618                              (match_operand:SF 2 "reg_or_0_operand" "fG"))
3619                             (float_extend:DF
3620                              (match_operand:SF 3 "reg_or_0_operand" "fG"))]))]
3621   "TARGET_FP && alpha_fptm >= ALPHA_FPTM_SU"
3622   "cmp%-%C1%/ %R2,%R3,%0"
3623   [(set_attr "type" "fadd")
3624    (set_attr "trap" "yes")
3625    (set_attr "trap_suffix" "su")])
3626
3627 (define_insn "*cmpdf_ext3"
3628   [(set (match_operand:DF 0 "register_operand" "=f")
3629         (match_operator:DF 1 "alpha_fp_comparison_operator"
3630                            [(float_extend:DF
3631                              (match_operand:SF 2 "reg_or_0_operand" "fG"))
3632                             (float_extend:DF
3633                              (match_operand:SF 3 "reg_or_0_operand" "fG"))]))]
3634   "TARGET_FP && alpha_fptm < ALPHA_FPTM_SU"
3635   "cmp%-%C1%/ %R2,%R3,%0"
3636   [(set_attr "type" "fadd")
3637    (set_attr "trap" "yes")
3638    (set_attr "trap_suffix" "su")])
3639
3640 (define_insn "*movdfcc_internal"
3641   [(set (match_operand:DF 0 "register_operand" "=f,f")
3642         (if_then_else:DF
3643          (match_operator 3 "signed_comparison_operator"
3644                          [(match_operand:DF 4 "reg_or_0_operand" "fG,fG")
3645                           (match_operand:DF 2 "const0_operand" "G,G")])
3646          (match_operand:DF 1 "reg_or_0_operand" "fG,0")
3647          (match_operand:DF 5 "reg_or_0_operand" "0,fG")))]
3648   "TARGET_FP"
3649   "@
3650    fcmov%C3 %R4,%R1,%0
3651    fcmov%D3 %R4,%R5,%0"
3652   [(set_attr "type" "fcmov")])
3653
3654 (define_insn "*movsfcc_internal"
3655   [(set (match_operand:SF 0 "register_operand" "=f,f")
3656         (if_then_else:SF
3657          (match_operator 3 "signed_comparison_operator"
3658                          [(match_operand:DF 4 "reg_or_0_operand" "fG,fG")
3659                           (match_operand:DF 2 "const0_operand" "G,G")])
3660          (match_operand:SF 1 "reg_or_0_operand" "fG,0")
3661          (match_operand:SF 5 "reg_or_0_operand" "0,fG")))]
3662   "TARGET_FP"
3663   "@
3664    fcmov%C3 %R4,%R1,%0
3665    fcmov%D3 %R4,%R5,%0"
3666   [(set_attr "type" "fcmov")])
3667
3668 (define_insn "*movdfcc_ext1"
3669   [(set (match_operand:DF 0 "register_operand" "=f,f")
3670         (if_then_else:DF
3671          (match_operator 3 "signed_comparison_operator"
3672                          [(match_operand:DF 4 "reg_or_0_operand" "fG,fG")
3673                           (match_operand:DF 2 "const0_operand" "G,G")])
3674          (float_extend:DF (match_operand:SF 1 "reg_or_0_operand" "fG,0"))
3675          (match_operand:DF 5 "reg_or_0_operand" "0,fG")))]
3676   "TARGET_FP"
3677   "@
3678    fcmov%C3 %R4,%R1,%0
3679    fcmov%D3 %R4,%R5,%0"
3680   [(set_attr "type" "fcmov")])
3681
3682 (define_insn "*movdfcc_ext2"
3683   [(set (match_operand:DF 0 "register_operand" "=f,f")
3684         (if_then_else:DF
3685          (match_operator 3 "signed_comparison_operator"
3686                          [(float_extend:DF
3687                            (match_operand:SF 4 "reg_or_0_operand" "fG,fG"))
3688                           (match_operand:DF 2 "const0_operand" "G,G")])
3689          (match_operand:DF 1 "reg_or_0_operand" "fG,0")
3690          (match_operand:DF 5 "reg_or_0_operand" "0,fG")))]
3691   "TARGET_FP"
3692   "@
3693    fcmov%C3 %R4,%R1,%0
3694    fcmov%D3 %R4,%R5,%0"
3695   [(set_attr "type" "fcmov")])
3696
3697 (define_insn "*movdfcc_ext3"
3698   [(set (match_operand:SF 0 "register_operand" "=f,f")
3699         (if_then_else:SF
3700          (match_operator 3 "signed_comparison_operator"
3701                          [(float_extend:DF
3702                            (match_operand:SF 4 "reg_or_0_operand" "fG,fG"))
3703                           (match_operand:DF 2 "const0_operand" "G,G")])
3704          (match_operand:SF 1 "reg_or_0_operand" "fG,0")
3705          (match_operand:SF 5 "reg_or_0_operand" "0,fG")))]
3706   "TARGET_FP"
3707   "@
3708    fcmov%C3 %R4,%R1,%0
3709    fcmov%D3 %R4,%R5,%0"
3710   [(set_attr "type" "fcmov")])
3711
3712 (define_insn "*movdfcc_ext4"
3713   [(set (match_operand:DF 0 "register_operand" "=f,f")
3714         (if_then_else:DF
3715          (match_operator 3 "signed_comparison_operator"
3716                          [(float_extend:DF
3717                            (match_operand:SF 4 "reg_or_0_operand" "fG,fG"))
3718                           (match_operand:DF 2 "const0_operand" "G,G")])
3719          (float_extend:DF (match_operand:SF 1 "reg_or_0_operand" "fG,0"))
3720          (match_operand:DF 5 "reg_or_0_operand" "0,fG")))]
3721   "TARGET_FP"
3722   "@
3723    fcmov%C3 %R4,%R1,%0
3724    fcmov%D3 %R4,%R5,%0"
3725   [(set_attr "type" "fcmov")])
3726
3727 (define_expand "maxdf3"
3728   [(set (match_dup 3)
3729         (le:DF (match_operand:DF 1 "reg_or_0_operand" "")
3730                (match_operand:DF 2 "reg_or_0_operand" "")))
3731    (set (match_operand:DF 0 "register_operand" "")
3732         (if_then_else:DF (eq (match_dup 3) (match_dup 4))
3733                          (match_dup 1) (match_dup 2)))]
3734   "TARGET_FP"
3735 {
3736   operands[3] = gen_reg_rtx (DFmode);
3737   operands[4] = CONST0_RTX (DFmode);
3738 })
3739
3740 (define_expand "mindf3"
3741   [(set (match_dup 3)
3742         (lt:DF (match_operand:DF 1 "reg_or_0_operand" "")
3743                (match_operand:DF 2 "reg_or_0_operand" "")))
3744    (set (match_operand:DF 0 "register_operand" "")
3745         (if_then_else:DF (ne (match_dup 3) (match_dup 4))
3746                          (match_dup 1) (match_dup 2)))]
3747   "TARGET_FP"
3748 {
3749   operands[3] = gen_reg_rtx (DFmode);
3750   operands[4] = CONST0_RTX (DFmode);
3751 })
3752
3753 (define_expand "maxsf3"
3754   [(set (match_dup 3)
3755         (le:DF (float_extend:DF (match_operand:SF 1 "reg_or_0_operand" ""))
3756                (float_extend:DF (match_operand:SF 2 "reg_or_0_operand" ""))))
3757    (set (match_operand:SF 0 "register_operand" "")
3758         (if_then_else:SF (eq (match_dup 3) (match_dup 4))
3759                          (match_dup 1) (match_dup 2)))]
3760   "TARGET_FP"
3761 {
3762   operands[3] = gen_reg_rtx (DFmode);
3763   operands[4] = CONST0_RTX (DFmode);
3764 })
3765
3766 (define_expand "minsf3"
3767   [(set (match_dup 3)
3768         (lt:DF (float_extend:DF (match_operand:SF 1 "reg_or_0_operand" ""))
3769                (float_extend:DF (match_operand:SF 2 "reg_or_0_operand" ""))))
3770    (set (match_operand:SF 0 "register_operand" "")
3771         (if_then_else:SF (ne (match_dup 3) (match_dup 4))
3772                       (match_dup 1) (match_dup 2)))]
3773   "TARGET_FP"
3774 {
3775   operands[3] = gen_reg_rtx (DFmode);
3776   operands[4] = CONST0_RTX (DFmode);
3777 })
3778
3779 (define_insn "*fbcc_normal"
3780   [(set (pc)
3781         (if_then_else
3782          (match_operator 1 "signed_comparison_operator"
3783                          [(match_operand:DF 2 "reg_or_0_operand" "fG")
3784                           (match_operand:DF 3 "const0_operand" "G")])
3785          (label_ref (match_operand 0 "" ""))
3786          (pc)))]
3787   "TARGET_FP"
3788   "fb%C1 %R2,%0"
3789   [(set_attr "type" "fbr")])
3790
3791 (define_insn "*fbcc_ext_normal"
3792   [(set (pc)
3793         (if_then_else
3794          (match_operator 1 "signed_comparison_operator"
3795                          [(float_extend:DF
3796                            (match_operand:SF 2 "reg_or_0_operand" "fG"))
3797                           (match_operand:DF 3 "const0_operand" "G")])
3798          (label_ref (match_operand 0 "" ""))
3799          (pc)))]
3800   "TARGET_FP"
3801   "fb%C1 %R2,%0"
3802   [(set_attr "type" "fbr")])
3803 \f
3804 ;; These are the main define_expand's used to make conditional branches
3805 ;; and compares.
3806
3807 (define_expand "cmpdf"
3808   [(set (cc0) (compare (match_operand:DF 0 "reg_or_0_operand" "")
3809                        (match_operand:DF 1 "reg_or_0_operand" "")))]
3810   "TARGET_FP"
3811 {
3812   alpha_compare.op0 = operands[0];
3813   alpha_compare.op1 = operands[1];
3814   alpha_compare.fp_p = 1;
3815   DONE;
3816 })
3817
3818 (define_expand "cmptf"
3819   [(set (cc0) (compare (match_operand:TF 0 "general_operand" "")
3820                        (match_operand:TF 1 "general_operand" "")))]
3821   "TARGET_HAS_XFLOATING_LIBS"
3822 {
3823   alpha_compare.op0 = operands[0];
3824   alpha_compare.op1 = operands[1];
3825   alpha_compare.fp_p = 1;
3826   DONE;
3827 })
3828
3829 (define_expand "cmpdi"
3830   [(set (cc0) (compare (match_operand:DI 0 "some_operand" "")
3831                        (match_operand:DI 1 "some_operand" "")))]
3832   ""
3833 {
3834   alpha_compare.op0 = operands[0];
3835   alpha_compare.op1 = operands[1];
3836   alpha_compare.fp_p = 0;
3837   DONE;
3838 })
3839
3840 (define_expand "beq"
3841   [(set (pc)
3842         (if_then_else (match_dup 1)
3843                       (label_ref (match_operand 0 "" ""))
3844                       (pc)))]
3845   ""
3846   "{ operands[1] = alpha_emit_conditional_branch (EQ); }")
3847
3848 (define_expand "bne"
3849   [(set (pc)
3850         (if_then_else (match_dup 1)
3851                       (label_ref (match_operand 0 "" ""))
3852                       (pc)))]
3853   ""
3854   "{ operands[1] = alpha_emit_conditional_branch (NE); }")
3855
3856 (define_expand "blt"
3857   [(set (pc)
3858         (if_then_else (match_dup 1)
3859                       (label_ref (match_operand 0 "" ""))
3860                       (pc)))]
3861   ""
3862   "{ operands[1] = alpha_emit_conditional_branch (LT); }")
3863
3864 (define_expand "ble"
3865   [(set (pc)
3866         (if_then_else (match_dup 1)
3867                       (label_ref (match_operand 0 "" ""))
3868                       (pc)))]
3869   ""
3870   "{ operands[1] = alpha_emit_conditional_branch (LE); }")
3871
3872 (define_expand "bgt"
3873   [(set (pc)
3874         (if_then_else (match_dup 1)
3875                       (label_ref (match_operand 0 "" ""))
3876                       (pc)))]
3877   ""
3878   "{ operands[1] = alpha_emit_conditional_branch (GT); }")
3879
3880 (define_expand "bge"
3881   [(set (pc)
3882         (if_then_else (match_dup 1)
3883                       (label_ref (match_operand 0 "" ""))
3884                       (pc)))]
3885   ""
3886   "{ operands[1] = alpha_emit_conditional_branch (GE); }")
3887
3888 (define_expand "bltu"
3889   [(set (pc)
3890         (if_then_else (match_dup 1)
3891                       (label_ref (match_operand 0 "" ""))
3892                       (pc)))]
3893   ""
3894   "{ operands[1] = alpha_emit_conditional_branch (LTU); }")
3895
3896 (define_expand "bleu"
3897   [(set (pc)
3898         (if_then_else (match_dup 1)
3899                       (label_ref (match_operand 0 "" ""))
3900                       (pc)))]
3901   ""
3902   "{ operands[1] = alpha_emit_conditional_branch (LEU); }")
3903
3904 (define_expand "bgtu"
3905   [(set (pc)
3906         (if_then_else (match_dup 1)
3907                       (label_ref (match_operand 0 "" ""))
3908                       (pc)))]
3909   ""
3910   "{ operands[1] = alpha_emit_conditional_branch (GTU); }")
3911
3912 (define_expand "bgeu"
3913   [(set (pc)
3914         (if_then_else (match_dup 1)
3915                       (label_ref (match_operand 0 "" ""))
3916                       (pc)))]
3917   ""
3918   "{ operands[1] = alpha_emit_conditional_branch (GEU); }")
3919
3920 (define_expand "bunordered"
3921   [(set (pc)
3922         (if_then_else (match_dup 1)
3923                       (label_ref (match_operand 0 "" ""))
3924                       (pc)))]
3925   ""
3926   "{ operands[1] = alpha_emit_conditional_branch (UNORDERED); }")
3927
3928 (define_expand "bordered"
3929   [(set (pc)
3930         (if_then_else (match_dup 1)
3931                       (label_ref (match_operand 0 "" ""))
3932                       (pc)))]
3933   ""
3934   "{ operands[1] = alpha_emit_conditional_branch (ORDERED); }")
3935
3936 (define_expand "seq"
3937   [(set (match_operand:DI 0 "register_operand" "")
3938         (match_dup 1))]
3939   ""
3940   "{ if ((operands[1] = alpha_emit_setcc (EQ)) == NULL_RTX) FAIL; }")
3941
3942 (define_expand "sne"
3943   [(set (match_operand:DI 0 "register_operand" "")
3944         (match_dup 1))]
3945   ""
3946   "{ if ((operands[1] = alpha_emit_setcc (NE)) == NULL_RTX) FAIL; }")
3947
3948 (define_expand "slt"
3949   [(set (match_operand:DI 0 "register_operand" "")
3950         (match_dup 1))]
3951   ""
3952   "{ if ((operands[1] = alpha_emit_setcc (LT)) == NULL_RTX) FAIL; }")
3953
3954 (define_expand "sle"
3955   [(set (match_operand:DI 0 "register_operand" "")
3956         (match_dup 1))]
3957   ""
3958   "{ if ((operands[1] = alpha_emit_setcc (LE)) == NULL_RTX) FAIL; }")
3959
3960 (define_expand "sgt"
3961   [(set (match_operand:DI 0 "register_operand" "")
3962         (match_dup 1))]
3963   ""
3964   "{ if ((operands[1] = alpha_emit_setcc (GT)) == NULL_RTX) FAIL; }")
3965
3966 (define_expand "sge"
3967   [(set (match_operand:DI 0 "register_operand" "")
3968         (match_dup 1))]
3969   ""
3970   "{ if ((operands[1] = alpha_emit_setcc (GE)) == NULL_RTX) FAIL; }")
3971
3972 (define_expand "sltu"
3973   [(set (match_operand:DI 0 "register_operand" "")
3974         (match_dup 1))]
3975   ""
3976   "{ if ((operands[1] = alpha_emit_setcc (LTU)) == NULL_RTX) FAIL; }")
3977
3978 (define_expand "sleu"
3979   [(set (match_operand:DI 0 "register_operand" "")
3980         (match_dup 1))]
3981   ""
3982   "{ if ((operands[1] = alpha_emit_setcc (LEU)) == NULL_RTX) FAIL; }")
3983
3984 (define_expand "sgtu"
3985   [(set (match_operand:DI 0 "register_operand" "")
3986         (match_dup 1))]
3987   ""
3988   "{ if ((operands[1] = alpha_emit_setcc (GTU)) == NULL_RTX) FAIL; }")
3989
3990 (define_expand "sgeu"
3991   [(set (match_operand:DI 0 "register_operand" "")
3992         (match_dup 1))]
3993   ""
3994   "{ if ((operands[1] = alpha_emit_setcc (GEU)) == NULL_RTX) FAIL; }")
3995
3996 (define_expand "sunordered"
3997   [(set (match_operand:DI 0 "register_operand" "")
3998         (match_dup 1))]
3999   ""
4000   "{ if ((operands[1] = alpha_emit_setcc (UNORDERED)) == NULL_RTX) FAIL; }")
4001
4002 (define_expand "sordered"
4003   [(set (match_operand:DI 0 "register_operand" "")
4004         (match_dup 1))]
4005   ""
4006   "{ if ((operands[1] = alpha_emit_setcc (ORDERED)) == NULL_RTX) FAIL; }")
4007 \f
4008 ;; These are the main define_expand's used to make conditional moves.
4009
4010 (define_expand "movsicc"
4011   [(set (match_operand:SI 0 "register_operand" "")
4012         (if_then_else:SI (match_operand 1 "comparison_operator" "")
4013                          (match_operand:SI 2 "reg_or_8bit_operand" "")
4014                          (match_operand:SI 3 "reg_or_8bit_operand" "")))]
4015   ""
4016 {
4017   if ((operands[1] = alpha_emit_conditional_move (operands[1], SImode)) == 0)
4018     FAIL;
4019 })
4020
4021 (define_expand "movdicc"
4022   [(set (match_operand:DI 0 "register_operand" "")
4023         (if_then_else:DI (match_operand 1 "comparison_operator" "")
4024                          (match_operand:DI 2 "reg_or_8bit_operand" "")
4025                          (match_operand:DI 3 "reg_or_8bit_operand" "")))]
4026   ""
4027 {
4028   if ((operands[1] = alpha_emit_conditional_move (operands[1], DImode)) == 0)
4029     FAIL;
4030 })
4031
4032 (define_expand "movsfcc"
4033   [(set (match_operand:SF 0 "register_operand" "")
4034         (if_then_else:SF (match_operand 1 "comparison_operator" "")
4035                          (match_operand:SF 2 "reg_or_8bit_operand" "")
4036                          (match_operand:SF 3 "reg_or_8bit_operand" "")))]
4037   ""
4038 {
4039   if ((operands[1] = alpha_emit_conditional_move (operands[1], SFmode)) == 0)
4040     FAIL;
4041 })
4042
4043 (define_expand "movdfcc"
4044   [(set (match_operand:DF 0 "register_operand" "")
4045         (if_then_else:DF (match_operand 1 "comparison_operator" "")
4046                          (match_operand:DF 2 "reg_or_8bit_operand" "")
4047                          (match_operand:DF 3 "reg_or_8bit_operand" "")))]
4048   ""
4049 {
4050   if ((operands[1] = alpha_emit_conditional_move (operands[1], DFmode)) == 0)
4051     FAIL;
4052 })
4053 \f
4054 ;; These define_split definitions are used in cases when comparisons have
4055 ;; not be stated in the correct way and we need to reverse the second
4056 ;; comparison.  For example, x >= 7 has to be done as x < 6 with the
4057 ;; comparison that tests the result being reversed.  We have one define_split
4058 ;; for each use of a comparison.  They do not match valid insns and need
4059 ;; not generate valid insns.
4060 ;;
4061 ;; We can also handle equality comparisons (and inequality comparisons in
4062 ;; cases where the resulting add cannot overflow) by doing an add followed by
4063 ;; a comparison with zero.  This is faster since the addition takes one
4064 ;; less cycle than a compare when feeding into a conditional move.
4065 ;; For this case, we also have an SImode pattern since we can merge the add
4066 ;; and sign extend and the order doesn't matter.
4067 ;;
4068 ;; We do not do this for floating-point, since it isn't clear how the "wrong"
4069 ;; operation could have been generated.
4070
4071 (define_split
4072   [(set (match_operand:DI 0 "register_operand" "")
4073         (if_then_else:DI
4074          (match_operator 1 "comparison_operator"
4075                          [(match_operand:DI 2 "reg_or_0_operand" "")
4076                           (match_operand:DI 3 "reg_or_cint_operand" "")])
4077          (match_operand:DI 4 "reg_or_cint_operand" "")
4078          (match_operand:DI 5 "reg_or_cint_operand" "")))
4079    (clobber (match_operand:DI 6 "register_operand" ""))]
4080   "operands[3] != const0_rtx"
4081   [(set (match_dup 6) (match_dup 7))
4082    (set (match_dup 0)
4083         (if_then_else:DI (match_dup 8) (match_dup 4) (match_dup 5)))]
4084 {
4085   enum rtx_code code = GET_CODE (operands[1]);
4086   int unsignedp = (code == GEU || code == LEU || code == GTU || code == LTU);
4087
4088   /* If we are comparing for equality with a constant and that constant
4089      appears in the arm when the register equals the constant, use the
4090      register since that is more likely to match (and to produce better code
4091      if both would).  */
4092
4093   if (code == EQ && GET_CODE (operands[3]) == CONST_INT
4094       && rtx_equal_p (operands[4], operands[3]))
4095     operands[4] = operands[2];
4096
4097   else if (code == NE && GET_CODE (operands[3]) == CONST_INT
4098            && rtx_equal_p (operands[5], operands[3]))
4099     operands[5] = operands[2];
4100
4101   if (code == NE || code == EQ
4102       || (extended_count (operands[2], DImode, unsignedp) >= 1
4103           && extended_count (operands[3], DImode, unsignedp) >= 1))
4104     {
4105       if (GET_CODE (operands[3]) == CONST_INT)
4106         operands[7] = gen_rtx_PLUS (DImode, operands[2],
4107                                     GEN_INT (- INTVAL (operands[3])));
4108       else
4109         operands[7] = gen_rtx_MINUS (DImode, operands[2], operands[3]);
4110
4111       operands[8] = gen_rtx_fmt_ee (code, VOIDmode, operands[6], const0_rtx);
4112     }
4113
4114   else if (code == EQ || code == LE || code == LT
4115            || code == LEU || code == LTU)
4116     {
4117       operands[7] = gen_rtx_fmt_ee (code, DImode, operands[2], operands[3]);
4118       operands[8] = gen_rtx_NE (VOIDmode, operands[6], const0_rtx);
4119     }
4120   else
4121     {
4122       operands[7] = gen_rtx_fmt_ee (reverse_condition (code), DImode,
4123                                     operands[2], operands[3]);
4124       operands[8] = gen_rtx_EQ (VOIDmode, operands[6], const0_rtx);
4125     }
4126 })
4127
4128 (define_split
4129   [(set (match_operand:DI 0 "register_operand" "")
4130         (if_then_else:DI
4131          (match_operator 1 "comparison_operator"
4132                          [(match_operand:SI 2 "reg_or_0_operand" "")
4133                           (match_operand:SI 3 "reg_or_cint_operand" "")])
4134          (match_operand:DI 4 "reg_or_8bit_operand" "")
4135          (match_operand:DI 5 "reg_or_8bit_operand" "")))
4136    (clobber (match_operand:DI 6 "register_operand" ""))]
4137   "operands[3] != const0_rtx
4138    && (GET_CODE (operands[1]) == EQ || GET_CODE (operands[1]) == NE)"
4139   [(set (match_dup 6) (match_dup 7))
4140    (set (match_dup 0)
4141         (if_then_else:DI (match_dup 8) (match_dup 4) (match_dup 5)))]
4142 {
4143   enum rtx_code code = GET_CODE (operands[1]);
4144   int unsignedp = (code == GEU || code == LEU || code == GTU || code == LTU);
4145   rtx tem;
4146
4147   if ((code != NE && code != EQ
4148        && ! (extended_count (operands[2], DImode, unsignedp) >= 1
4149              && extended_count (operands[3], DImode, unsignedp) >= 1)))
4150     FAIL;
4151
4152   if (GET_CODE (operands[3]) == CONST_INT)
4153     tem = gen_rtx_PLUS (SImode, operands[2],
4154                         GEN_INT (- INTVAL (operands[3])));
4155   else
4156     tem = gen_rtx_MINUS (SImode, operands[2], operands[3]);
4157
4158   operands[7] = gen_rtx_SIGN_EXTEND (DImode, tem);
4159   operands[8] = gen_rtx_fmt_ee (GET_CODE (operands[1]), VOIDmode,
4160                                 operands[6], const0_rtx);
4161 })
4162
4163 ;; Prefer to use cmp and arithmetic when possible instead of a cmove.
4164
4165 (define_split
4166   [(set (match_operand 0 "register_operand" "")
4167         (if_then_else (match_operator 1 "signed_comparison_operator"
4168                            [(match_operand:DI 2 "reg_or_0_operand" "")
4169                             (const_int 0)])
4170           (match_operand 3 "const_int_operand" "")
4171           (match_operand 4 "const_int_operand" "")))]
4172   ""
4173   [(const_int 0)]
4174 {
4175   if (alpha_split_conditional_move (GET_CODE (operands[1]), operands[0],
4176                                     operands[2], operands[3], operands[4]))
4177     DONE;
4178   else
4179     FAIL;
4180 })
4181
4182 ;; ??? Why combine is allowed to create such non-canonical rtl, I don't know.
4183 ;; Oh well, we match it in movcc, so it must be partially our fault.
4184 (define_split
4185   [(set (match_operand 0 "register_operand" "")
4186         (if_then_else (match_operator 1 "signed_comparison_operator"
4187                            [(const_int 0)
4188                             (match_operand:DI 2 "reg_or_0_operand" "")])
4189           (match_operand 3 "const_int_operand" "")
4190           (match_operand 4 "const_int_operand" "")))]
4191   ""
4192   [(const_int 0)]
4193 {
4194   if (alpha_split_conditional_move (swap_condition (GET_CODE (operands[1])),
4195                                     operands[0], operands[2], operands[3],
4196                                     operands[4]))
4197     DONE;
4198   else
4199     FAIL;
4200 })
4201
4202 (define_insn_and_split "*cmp_sadd_di"
4203   [(set (match_operand:DI 0 "register_operand" "=r")
4204         (plus:DI (if_then_else:DI
4205                    (match_operator 1 "alpha_zero_comparison_operator"
4206                      [(match_operand:DI 2 "reg_or_0_operand" "rJ")
4207                       (const_int 0)])
4208                    (match_operand:DI 3 "const48_operand" "I")
4209                    (const_int 0))
4210                  (match_operand:DI 4 "sext_add_operand" "rIO")))
4211    (clobber (match_scratch:DI 5 "=r"))]
4212   ""
4213   "#"
4214   "! no_new_pseudos || reload_completed"
4215   [(set (match_dup 5)
4216         (match_op_dup:DI 1 [(match_dup 2) (const_int 0)]))
4217    (set (match_dup 0)
4218         (plus:DI (mult:DI (match_dup 5) (match_dup 3))
4219                  (match_dup 4)))]
4220 {
4221   if (! no_new_pseudos)
4222     operands[5] = gen_reg_rtx (DImode);
4223   else if (reg_overlap_mentioned_p (operands[5], operands[4]))
4224     operands[5] = operands[0];
4225 })
4226
4227 (define_insn_and_split "*cmp_sadd_si"
4228   [(set (match_operand:SI 0 "register_operand" "=r")
4229         (plus:SI (if_then_else:SI
4230                    (match_operator 1 "alpha_zero_comparison_operator"
4231                      [(match_operand:DI 2 "reg_or_0_operand" "rJ")
4232                       (const_int 0)])
4233                    (match_operand:SI 3 "const48_operand" "I")
4234                    (const_int 0))
4235                  (match_operand:SI 4 "sext_add_operand" "rIO")))
4236    (clobber (match_scratch:SI 5 "=r"))]
4237   ""
4238   "#"
4239   "! no_new_pseudos || reload_completed"
4240   [(set (match_dup 5)
4241         (match_op_dup:SI 1 [(match_dup 2) (const_int 0)]))
4242    (set (match_dup 0)
4243         (plus:SI (mult:SI (match_dup 5) (match_dup 3))
4244                  (match_dup 4)))]
4245 {
4246   if (! no_new_pseudos)
4247     operands[5] = gen_reg_rtx (DImode);
4248   else if (reg_overlap_mentioned_p (operands[5], operands[4]))
4249     operands[5] = operands[0];
4250 })
4251
4252 (define_insn_and_split "*cmp_sadd_sidi"
4253   [(set (match_operand:DI 0 "register_operand" "=r")
4254         (sign_extend:DI
4255           (plus:SI (if_then_else:SI
4256                      (match_operator 1 "alpha_zero_comparison_operator"
4257                        [(match_operand:DI 2 "reg_or_0_operand" "rJ")
4258                         (const_int 0)])
4259                      (match_operand:SI 3 "const48_operand" "I")
4260                      (const_int 0))
4261                    (match_operand:SI 4 "sext_add_operand" "rIO"))))
4262    (clobber (match_scratch:SI 5 "=r"))]
4263   ""
4264   "#"
4265   "! no_new_pseudos || reload_completed"
4266   [(set (match_dup 5)
4267         (match_op_dup:SI 1 [(match_dup 2) (const_int 0)]))
4268    (set (match_dup 0)
4269         (sign_extend:DI (plus:SI (mult:SI (match_dup 5) (match_dup 3))
4270                                  (match_dup 4))))]
4271 {
4272   if (! no_new_pseudos)
4273     operands[5] = gen_reg_rtx (DImode);
4274   else if (reg_overlap_mentioned_p (operands[5], operands[4]))
4275     operands[5] = operands[0];
4276 })
4277
4278 (define_insn_and_split "*cmp_ssub_di"
4279   [(set (match_operand:DI 0 "register_operand" "=r")
4280         (minus:DI (if_then_else:DI
4281                     (match_operator 1 "alpha_zero_comparison_operator"
4282                       [(match_operand:DI 2 "reg_or_0_operand" "rJ")
4283                        (const_int 0)])
4284                     (match_operand:DI 3 "const48_operand" "I")
4285                     (const_int 0))
4286                   (match_operand:DI 4 "reg_or_8bit_operand" "rI")))
4287    (clobber (match_scratch:DI 5 "=r"))]
4288   ""
4289   "#"
4290   "! no_new_pseudos || reload_completed"
4291   [(set (match_dup 5)
4292         (match_op_dup:DI 1 [(match_dup 2) (const_int 0)]))
4293    (set (match_dup 0)
4294         (minus:DI (mult:DI (match_dup 5) (match_dup 3))
4295                   (match_dup 4)))]
4296 {
4297   if (! no_new_pseudos)
4298     operands[5] = gen_reg_rtx (DImode);
4299   else if (reg_overlap_mentioned_p (operands[5], operands[4]))
4300     operands[5] = operands[0];
4301 })
4302
4303 (define_insn_and_split "*cmp_ssub_si"
4304   [(set (match_operand:SI 0 "register_operand" "=r")
4305         (minus:SI (if_then_else:SI
4306                     (match_operator 1 "alpha_zero_comparison_operator"
4307                       [(match_operand:DI 2 "reg_or_0_operand" "rJ")
4308                        (const_int 0)])
4309                     (match_operand:SI 3 "const48_operand" "I")
4310                     (const_int 0))
4311                   (match_operand:SI 4 "reg_or_8bit_operand" "rI")))
4312    (clobber (match_scratch:SI 5 "=r"))]
4313   ""
4314   "#"
4315   "! no_new_pseudos || reload_completed"
4316   [(set (match_dup 5)
4317         (match_op_dup:SI 1 [(match_dup 2) (const_int 0)]))
4318    (set (match_dup 0)
4319         (minus:SI (mult:SI (match_dup 5) (match_dup 3))
4320                  (match_dup 4)))]
4321 {
4322   if (! no_new_pseudos)
4323     operands[5] = gen_reg_rtx (DImode);
4324   else if (reg_overlap_mentioned_p (operands[5], operands[4]))
4325     operands[5] = operands[0];
4326 })
4327
4328 (define_insn_and_split "*cmp_ssub_sidi"
4329   [(set (match_operand:DI 0 "register_operand" "=r")
4330         (sign_extend:DI
4331           (minus:SI (if_then_else:SI
4332                       (match_operator 1 "alpha_zero_comparison_operator"
4333                         [(match_operand:DI 2 "reg_or_0_operand" "rJ")
4334                          (const_int 0)])
4335                       (match_operand:SI 3 "const48_operand" "I")
4336                       (const_int 0))
4337                     (match_operand:SI 4 "reg_or_8bit_operand" "rI"))))
4338    (clobber (match_scratch:SI 5 "=r"))]
4339   ""
4340   "#"
4341   "! no_new_pseudos || reload_completed"
4342   [(set (match_dup 5)
4343         (match_op_dup:SI 1 [(match_dup 2) (const_int 0)]))
4344    (set (match_dup 0)
4345         (sign_extend:DI (minus:SI (mult:SI (match_dup 5) (match_dup 3))
4346                                   (match_dup 4))))]
4347 {
4348   if (! no_new_pseudos)
4349     operands[5] = gen_reg_rtx (DImode);
4350   else if (reg_overlap_mentioned_p (operands[5], operands[4]))
4351     operands[5] = operands[0];
4352 })
4353 \f
4354 ;; Here are the CALL and unconditional branch insns.  Calls on NT and OSF
4355 ;; work differently, so we have different patterns for each.
4356
4357 ;; On Unicos/Mk a call information word (CIW) must be generated for each
4358 ;; call. The CIW contains information about arguments passed in registers
4359 ;; and is stored in the caller's SSIB. Its offset relative to the beginning
4360 ;; of the SSIB is passed in $25. Handling this properly is quite complicated
4361 ;; in the presence of inlining since the CIWs for calls performed by the
4362 ;; inlined function must be stored in the SSIB of the function it is inlined
4363 ;; into as well. We encode the CIW in an unspec and append it to the list
4364 ;; of the CIWs for the current function only when the instruction for loading
4365 ;; $25 is generated.
4366
4367 (define_expand "call"
4368   [(use (match_operand:DI 0 "" ""))
4369    (use (match_operand 1 "" ""))
4370    (use (match_operand 2 "" ""))
4371    (use (match_operand 3 "" ""))]
4372   ""
4373 {
4374   if (TARGET_ABI_WINDOWS_NT)
4375     emit_call_insn (gen_call_nt (operands[0], operands[1]));
4376   else if (TARGET_ABI_OPEN_VMS)
4377     emit_call_insn (gen_call_vms (operands[0], operands[2]));
4378   else if (TARGET_ABI_UNICOSMK)
4379     emit_call_insn (gen_call_umk (operands[0], operands[2]));
4380   else
4381     emit_call_insn (gen_call_osf (operands[0], operands[1]));
4382   DONE;
4383 })
4384
4385 (define_expand "sibcall"
4386   [(parallel [(call (mem:DI (match_operand 0 "" ""))
4387                             (match_operand 1 "" ""))
4388               (unspec [(reg:DI 29)] UNSPEC_SIBCALL)])]
4389   "TARGET_ABI_OSF"
4390 {
4391   if (GET_CODE (operands[0]) != MEM)
4392     abort ();
4393   operands[0] = XEXP (operands[0], 0);
4394 })
4395
4396 (define_expand "call_osf"
4397   [(parallel [(call (mem:DI (match_operand 0 "" ""))
4398                     (match_operand 1 "" ""))
4399               (use (reg:DI 29))
4400               (clobber (reg:DI 26))])]
4401   ""
4402 {
4403   if (GET_CODE (operands[0]) != MEM)
4404     abort ();
4405
4406   operands[0] = XEXP (operands[0], 0);
4407   if (! call_operand (operands[0], Pmode))
4408     operands[0] = copy_to_mode_reg (Pmode, operands[0]);
4409 })
4410
4411 (define_expand "call_nt"
4412   [(parallel [(call (mem:DI (match_operand 0 "" ""))
4413                     (match_operand 1 "" ""))
4414               (clobber (reg:DI 26))])]
4415   ""
4416 {
4417   if (GET_CODE (operands[0]) != MEM)
4418     abort ();
4419
4420   operands[0] = XEXP (operands[0], 0);
4421   if (GET_CODE (operands[0]) != SYMBOL_REF && GET_CODE (operands[0]) != REG)
4422     operands[0] = force_reg (DImode, operands[0]);
4423 })
4424
4425 ;; Calls on Unicos/Mk are always indirect.
4426 ;; op 0: symbol ref for called function
4427 ;; op 1: CIW for $25 represented by an unspec
4428
4429 (define_expand "call_umk"
4430    [(parallel [(call (mem:DI (match_operand 0 "" ""))
4431                      (match_operand 1 "" ""))
4432                (use (reg:DI 25))
4433                (clobber (reg:DI 26))])]
4434    ""
4435 {
4436   if (GET_CODE (operands[0]) != MEM)
4437     abort ();
4438
4439   /* Always load the address of the called function into a register;
4440      load the CIW in $25.  */
4441
4442   operands[0] = XEXP (operands[0], 0);
4443   if (GET_CODE (operands[0]) != REG)
4444     operands[0] = force_reg (DImode, operands[0]);
4445
4446   emit_move_insn (gen_rtx_REG (DImode, 25), operands[1]);
4447 })
4448
4449 ;;
4450 ;; call openvms/alpha
4451 ;; op 0: symbol ref for called function
4452 ;; op 1: next_arg_reg (argument information value for R25)
4453 ;;
4454 (define_expand "call_vms"
4455   [(parallel [(call (mem:DI (match_operand 0 "" ""))
4456                     (match_operand 1 "" ""))
4457               (use (match_dup 2))
4458               (use (reg:DI 25))
4459               (use (reg:DI 26))
4460               (clobber (reg:DI 27))])]
4461   ""
4462 {
4463   if (GET_CODE (operands[0]) != MEM)
4464     abort ();
4465
4466   operands[0] = XEXP (operands[0], 0);
4467
4468   /* Always load AI with argument information, then handle symbolic and
4469      indirect call differently.  Load RA and set operands[2] to PV in
4470      both cases.  */
4471
4472   emit_move_insn (gen_rtx_REG (DImode, 25), operands[1]);
4473   if (GET_CODE (operands[0]) == SYMBOL_REF)
4474     {
4475       alpha_need_linkage (XSTR (operands[0], 0), 0);
4476
4477       operands[2] = const0_rtx;
4478     }
4479   else
4480     {
4481       emit_move_insn (gen_rtx_REG (Pmode, 26),
4482                       gen_rtx_MEM (Pmode, plus_constant (operands[0], 8)));
4483       operands[2] = operands[0];
4484     }
4485
4486 })
4487
4488 (define_expand "call_value"
4489   [(use (match_operand 0 "" ""))
4490    (use (match_operand:DI 1 "" ""))
4491    (use (match_operand 2 "" ""))
4492    (use (match_operand 3 "" ""))
4493    (use (match_operand 4 "" ""))]
4494   ""
4495 {
4496   if (TARGET_ABI_WINDOWS_NT)
4497     emit_call_insn (gen_call_value_nt (operands[0], operands[1], operands[2]));
4498   else if (TARGET_ABI_OPEN_VMS)
4499     emit_call_insn (gen_call_value_vms (operands[0], operands[1],
4500                                         operands[3]));
4501   else if (TARGET_ABI_UNICOSMK)
4502     emit_call_insn (gen_call_value_umk (operands[0], operands[1],
4503                                         operands[3]));
4504   else
4505     emit_call_insn (gen_call_value_osf (operands[0], operands[1],
4506                                         operands[2]));
4507   DONE;
4508 })
4509
4510 (define_expand "sibcall_value"
4511   [(parallel [(set (match_operand 0 "" "")
4512                    (call (mem:DI (match_operand 1 "" ""))
4513                          (match_operand 2 "" "")))
4514               (unspec [(reg:DI 29)] UNSPEC_SIBCALL)])]
4515   "TARGET_ABI_OSF"
4516 {
4517   if (GET_CODE (operands[1]) != MEM)
4518     abort ();
4519   operands[1] = XEXP (operands[1], 0);
4520 })
4521
4522 (define_expand "call_value_osf"
4523   [(parallel [(set (match_operand 0 "" "")
4524                    (call (mem:DI (match_operand 1 "" ""))
4525                          (match_operand 2 "" "")))
4526               (use (reg:DI 29))
4527               (clobber (reg:DI 26))])]
4528   ""
4529 {
4530   if (GET_CODE (operands[1]) != MEM)
4531     abort ();
4532
4533   operands[1] = XEXP (operands[1], 0);
4534   if (! call_operand (operands[1], Pmode))
4535     operands[1] = copy_to_mode_reg (Pmode, operands[1]);
4536 })
4537
4538 (define_expand "call_value_nt"
4539   [(parallel [(set (match_operand 0 "" "")
4540                    (call (mem:DI (match_operand 1 "" ""))
4541                          (match_operand 2 "" "")))
4542               (clobber (reg:DI 26))])]
4543   ""
4544 {
4545   if (GET_CODE (operands[1]) != MEM)
4546     abort ();
4547
4548   operands[1] = XEXP (operands[1], 0);
4549   if (GET_CODE (operands[1]) != SYMBOL_REF && GET_CODE (operands[1]) != REG)
4550     operands[1] = force_reg (DImode, operands[1]);
4551 })
4552
4553 (define_expand "call_value_vms"
4554   [(parallel [(set (match_operand 0 "" "")
4555                    (call (mem:DI (match_operand:DI 1 "" ""))
4556                          (match_operand 2 "" "")))
4557               (use (match_dup 3))
4558               (use (reg:DI 25))
4559               (use (reg:DI 26))
4560               (clobber (reg:DI 27))])]
4561   ""
4562 {
4563   if (GET_CODE (operands[1]) != MEM)
4564     abort ();
4565
4566   operands[1] = XEXP (operands[1], 0);
4567
4568   /* Always load AI with argument information, then handle symbolic and
4569      indirect call differently.  Load RA and set operands[3] to PV in
4570      both cases.  */
4571
4572   emit_move_insn (gen_rtx_REG (DImode, 25), operands[2]);
4573   if (GET_CODE (operands[1]) == SYMBOL_REF)
4574     {
4575       alpha_need_linkage (XSTR (operands[1], 0), 0);
4576
4577       operands[3] = const0_rtx;
4578     }
4579   else
4580     {
4581       emit_move_insn (gen_rtx_REG (Pmode, 26),
4582                       gen_rtx_MEM (Pmode, plus_constant (operands[1], 8)));
4583       operands[3] = operands[1];
4584     }
4585 })
4586
4587 (define_expand "call_value_umk"
4588   [(parallel [(set (match_operand 0 "" "")
4589                    (call (mem:DI (match_operand 1 "" ""))
4590                          (match_operand 2 "" "")))
4591               (use (reg:DI 25))
4592               (clobber (reg:DI 26))])]
4593   ""
4594 {
4595   if (GET_CODE (operands[1]) != MEM)
4596     abort ();
4597
4598   operands[1] = XEXP (operands[1], 0);
4599   if (GET_CODE (operands[1]) != REG)
4600     operands[1] = force_reg (DImode, operands[1]);
4601
4602   emit_move_insn (gen_rtx_REG (DImode, 25), operands[2]);
4603 })
4604
4605 (define_insn "*call_osf_1_er"
4606   [(call (mem:DI (match_operand:DI 0 "call_operand" "c,R,s"))
4607          (match_operand 1 "" ""))
4608    (use (reg:DI 29))
4609    (clobber (reg:DI 26))]
4610   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
4611   "@
4612    jsr $26,(%0),0\;ldah $29,0($26)\t\t!gpdisp!%*\;lda $29,0($29)\t\t!gpdisp!%*
4613    bsr $26,%0\t\t!samegp
4614    ldq $27,%0($29)\t\t!literal!%#\;jsr $26,($27),%0\t\t!lituse_jsr!%#\;ldah $29,0($26)\t\t!gpdisp!%*\;lda $29,0($29)\t\t!gpdisp!%*"
4615   [(set_attr "type" "jsr")
4616    (set_attr "length" "12,*,16")])
4617
4618 ;; We must use peep2 instead of a split because we need accurate life
4619 ;; information for $gp.  Consider the case of { bar(); while (1); }.
4620 (define_peephole2
4621   [(parallel [(call (mem:DI (match_operand:DI 0 "call_operand" ""))
4622                     (match_operand 1 "" ""))
4623               (use (reg:DI 29))
4624               (clobber (reg:DI 26))])]
4625   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF && reload_completed
4626    && ! samegp_function_operand (operands[0], Pmode)
4627    && (peep2_regno_dead_p (1, 29)
4628        || find_reg_note (insn, REG_NORETURN, NULL_RTX))"
4629   [(parallel [(call (mem:DI (match_dup 2))
4630                     (match_dup 1))
4631               (set (reg:DI 26) (plus:DI (pc) (const_int 4)))
4632               (unspec_volatile [(reg:DI 29)] UNSPECV_BLOCKAGE)
4633               (use (match_dup 0))
4634               (use (match_dup 3))])]
4635 {
4636   if (CONSTANT_P (operands[0]))
4637     {
4638       operands[2] = gen_rtx_REG (Pmode, 27);
4639       operands[3] = GEN_INT (alpha_next_sequence_number++);
4640       emit_insn (gen_movdi_er_high_g (operands[2], pic_offset_table_rtx,
4641                                       operands[0], operands[3]));
4642     }
4643   else
4644     {
4645       operands[2] = operands[0];
4646       operands[0] = const0_rtx;
4647       operands[3] = const0_rtx;
4648     }
4649 })
4650
4651 (define_peephole2
4652   [(parallel [(call (mem:DI (match_operand:DI 0 "call_operand" ""))
4653                     (match_operand 1 "" ""))
4654               (use (reg:DI 29))
4655               (clobber (reg:DI 26))])]
4656   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF && reload_completed
4657    && ! samegp_function_operand (operands[0], Pmode)
4658    && ! (peep2_regno_dead_p (1, 29)
4659          || find_reg_note (insn, REG_NORETURN, NULL_RTX))"
4660   [(parallel [(call (mem:DI (match_dup 2))
4661                     (match_dup 1))
4662               (set (reg:DI 26) (plus:DI (pc) (const_int 4)))
4663               (unspec_volatile [(reg:DI 29)] UNSPECV_BLOCKAGE)
4664               (use (match_dup 0))
4665               (use (match_dup 4))])
4666    (set (reg:DI 29)
4667         (unspec_volatile:DI [(reg:DI 26) (match_dup 3)] UNSPECV_LDGP1))
4668    (set (reg:DI 29)
4669         (unspec:DI [(reg:DI 29) (match_dup 3)] UNSPEC_LDGP2))]
4670 {
4671   if (CONSTANT_P (operands[0]))
4672     {
4673       operands[2] = gen_rtx_REG (Pmode, 27);
4674       operands[4] = GEN_INT (alpha_next_sequence_number++);
4675       emit_insn (gen_movdi_er_high_g (operands[2], pic_offset_table_rtx,
4676                                       operands[0], operands[4]));
4677     }
4678   else
4679     {
4680       operands[2] = operands[0];
4681       operands[0] = const0_rtx;
4682       operands[4] = const0_rtx;
4683     }
4684   operands[3] = GEN_INT (alpha_next_sequence_number++);
4685 })
4686
4687 ;; We add a blockage unspec_volatile to prevent insns from moving down
4688 ;; from above the call to in between the call and the ldah gpdisp.
4689
4690 (define_insn "*call_osf_2_er"
4691   [(call (mem:DI (match_operand:DI 0 "register_operand" "c"))
4692          (match_operand 1 "" ""))
4693    (set (reg:DI 26) (plus:DI (pc) (const_int 4)))
4694    (unspec_volatile [(reg:DI 29)] UNSPECV_BLOCKAGE)
4695    (use (match_operand 2 "" ""))
4696    (use (match_operand 3 "const_int_operand" ""))]
4697   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
4698   "jsr $26,(%0),%2%J3"
4699   [(set_attr "type" "jsr")
4700    (set_attr "cannot_copy" "true")])
4701
4702 ;; We output a nop after noreturn calls at the very end of the function to
4703 ;; ensure that the return address always remains in the caller's code range,
4704 ;; as not doing so might confuse unwinding engines.
4705 ;;
4706 ;; The potential change in insn length is not reflected in the length
4707 ;; attributes at this stage. Since the extra space is only actually added at
4708 ;; the very end of the compilation process (via final/print_operand), it
4709 ;; really seems harmless and not worth the trouble of some extra computation
4710 ;; cost and complexity.
4711
4712 (define_insn "*call_osf_1_noreturn"
4713   [(call (mem:DI (match_operand:DI 0 "call_operand" "c,R,s"))
4714          (match_operand 1 "" ""))
4715    (use (reg:DI 29))
4716    (clobber (reg:DI 26))]
4717   "! TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF
4718    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
4719   "@
4720    jsr $26,($27),0%+
4721    bsr $26,$%0..ng%+
4722    jsr $26,%0%+"
4723   [(set_attr "type" "jsr")
4724    (set_attr "length" "*,*,8")])
4725
4726 (define_insn "*call_osf_1"
4727   [(call (mem:DI (match_operand:DI 0 "call_operand" "c,R,s"))
4728          (match_operand 1 "" ""))
4729    (use (reg:DI 29))
4730    (clobber (reg:DI 26))]
4731   "! TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
4732   "@
4733    jsr $26,($27),0\;ldgp $29,0($26)
4734    bsr $26,$%0..ng
4735    jsr $26,%0\;ldgp $29,0($26)"
4736   [(set_attr "type" "jsr")
4737    (set_attr "length" "12,*,16")])
4738
4739 ;; Note that the DEC assembler expands "jmp foo" with $at, which
4740 ;; doesn't do what we want.
4741 (define_insn "*sibcall_osf_1_er"
4742   [(call (mem:DI (match_operand:DI 0 "symbolic_operand" "R,s"))
4743          (match_operand 1 "" ""))
4744    (unspec [(reg:DI 29)] UNSPEC_SIBCALL)]
4745   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
4746   "@
4747    br $31,%0\t\t!samegp
4748    ldq $27,%0($29)\t\t!literal!%#\;jmp $31,($27),%0\t\t!lituse_jsr!%#"
4749   [(set_attr "type" "jsr")
4750    (set_attr "length" "*,8")])
4751
4752 (define_insn "*sibcall_osf_1"
4753   [(call (mem:DI (match_operand:DI 0 "symbolic_operand" "R,s"))
4754          (match_operand 1 "" ""))
4755    (unspec [(reg:DI 29)] UNSPEC_SIBCALL)]
4756   "! TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
4757   "@
4758    br $31,$%0..ng
4759    lda $27,%0\;jmp $31,($27),%0"
4760   [(set_attr "type" "jsr")
4761    (set_attr "length" "*,8")])
4762
4763 (define_insn "*call_nt_1"
4764   [(call (mem:DI (match_operand:DI 0 "call_operand" "r,R,s"))
4765          (match_operand 1 "" ""))
4766    (clobber (reg:DI 26))]
4767   "TARGET_ABI_WINDOWS_NT"
4768   "@
4769    jsr $26,(%0)
4770    bsr $26,%0
4771    jsr $26,%0"
4772   [(set_attr "type" "jsr")
4773    (set_attr "length" "*,*,12")])
4774
4775 ; GAS relies on the order and position of instructions output below in order
4776 ; to generate relocs for VMS link to potentially optimize the call.
4777 ; Please do not molest.
4778 (define_insn "*call_vms_1"
4779   [(call (mem:DI (match_operand:DI 0 "call_operand" "r,s"))
4780          (match_operand 1 "" ""))
4781    (use (match_operand:DI 2 "nonmemory_operand" "r,n"))
4782    (use (reg:DI 25))
4783    (use (reg:DI 26))
4784    (clobber (reg:DI 27))]
4785   "TARGET_ABI_OPEN_VMS"
4786 {
4787   switch (which_alternative)
4788     {
4789     case 0:
4790         return "mov %2,$27\;jsr $26,0\;ldq $27,0($29)";
4791     case 1:
4792         operands [2] = alpha_use_linkage (operands [0], cfun->decl, 1, 0);
4793         operands [3] = alpha_use_linkage (operands [0], cfun->decl, 0, 0);
4794         return "ldq $26,%3\;ldq $27,%2\;jsr $26,%0\;ldq $27,0($29)";
4795     default:
4796       abort();
4797     }
4798 }
4799   [(set_attr "type" "jsr")
4800    (set_attr "length" "12,16")])
4801
4802 (define_insn "*call_umk_1"
4803   [(call (mem:DI (match_operand:DI 0 "call_operand" "r"))
4804          (match_operand 1 "" ""))
4805    (use (reg:DI 25))
4806    (clobber (reg:DI 26))]
4807   "TARGET_ABI_UNICOSMK"
4808   "jsr $26,(%0)"
4809   [(set_attr "type" "jsr")])
4810
4811 ;; Call subroutine returning any type.
4812
4813 (define_expand "untyped_call"
4814   [(parallel [(call (match_operand 0 "" "")
4815                     (const_int 0))
4816               (match_operand 1 "" "")
4817               (match_operand 2 "" "")])]
4818   ""
4819 {
4820   int i;
4821
4822   emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
4823
4824   for (i = 0; i < XVECLEN (operands[2], 0); i++)
4825     {
4826       rtx set = XVECEXP (operands[2], 0, i);
4827       emit_move_insn (SET_DEST (set), SET_SRC (set));
4828     }
4829
4830   /* The optimizer does not know that the call sets the function value
4831      registers we stored in the result block.  We avoid problems by
4832      claiming that all hard registers are used and clobbered at this
4833      point.  */
4834   emit_insn (gen_blockage ());
4835
4836   DONE;
4837 })
4838
4839 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
4840 ;; all of memory.  This blocks insns from being moved across this point.
4841
4842 (define_insn "blockage"
4843   [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
4844   ""
4845   ""
4846   [(set_attr "length" "0")
4847    (set_attr "type" "none")])
4848
4849 (define_insn "jump"
4850   [(set (pc)
4851         (label_ref (match_operand 0 "" "")))]
4852   ""
4853   "br $31,%l0"
4854   [(set_attr "type" "ibr")])
4855
4856 (define_expand "return"
4857   [(return)]
4858   "direct_return ()"
4859   "")
4860
4861 (define_insn "*return_internal"
4862   [(return)]
4863   "reload_completed"
4864   "ret $31,($26),1"
4865   [(set_attr "type" "ibr")])
4866
4867 (define_insn "indirect_jump"
4868   [(set (pc) (match_operand:DI 0 "register_operand" "r"))]
4869   ""
4870   "jmp $31,(%0),0"
4871   [(set_attr "type" "ibr")])
4872
4873 (define_expand "tablejump"
4874   [(parallel [(set (pc)
4875                    (match_operand 0 "register_operand" ""))
4876               (use (label_ref:DI (match_operand 1 "" "")))])]
4877   ""
4878 {
4879   if (TARGET_ABI_WINDOWS_NT)
4880     {
4881       rtx dest = gen_reg_rtx (DImode);
4882       emit_insn (gen_extendsidi2 (dest, operands[0]));
4883       operands[0] = dest;
4884     }
4885   else if (TARGET_ABI_OSF)
4886     {
4887       rtx dest = gen_reg_rtx (DImode);
4888       emit_insn (gen_extendsidi2 (dest, operands[0]));
4889       emit_insn (gen_adddi3 (dest, pic_offset_table_rtx, dest));        
4890       operands[0] = dest;
4891     }
4892 })
4893
4894 (define_insn "*tablejump_osf_nt_internal"
4895   [(set (pc)
4896         (match_operand:DI 0 "register_operand" "r"))
4897    (use (label_ref:DI (match_operand 1 "" "")))]
4898   "(TARGET_ABI_OSF || TARGET_ABI_WINDOWS_NT)
4899    && alpha_tablejump_addr_vec (insn)"
4900 {
4901   operands[2] = alpha_tablejump_best_label (insn);
4902   return "jmp $31,(%0),%2";
4903 }
4904   [(set_attr "type" "ibr")])
4905
4906 (define_insn "*tablejump_internal"
4907   [(set (pc)
4908         (match_operand:DI 0 "register_operand" "r"))
4909    (use (label_ref (match_operand 1 "" "")))]
4910   ""
4911   "jmp $31,(%0),0"
4912   [(set_attr "type" "ibr")])
4913
4914 ;; Cache flush.  Used by INITIALIZE_TRAMPOLINE.  0x86 is PAL_imb, but we don't
4915 ;; want to have to include pal.h in our .s file.
4916 ;;
4917 ;; Technically the type for call_pal is jsr, but we use that for determining
4918 ;; if we need a GP.  Use ibr instead since it has the same EV5 scheduling
4919 ;; characteristics.
4920 (define_insn "imb"
4921   [(unspec_volatile [(const_int 0)] UNSPECV_IMB)]
4922   ""
4923   "call_pal 0x86"
4924   [(set_attr "type" "callpal")])
4925
4926 ;; BUGCHK is documented common to OSF/1 and VMS PALcode.
4927 ;; NT does not document anything at 0x81 -- presumably it would generate
4928 ;; the equivalent of SIGILL, but this isn't that important.
4929 ;; ??? Presuming unicosmk uses either OSF/1 or VMS PALcode.
4930 (define_insn "trap"
4931   [(trap_if (const_int 1) (const_int 0))]
4932   "!TARGET_ABI_WINDOWS_NT"
4933   "call_pal 0x81"
4934   [(set_attr "type" "callpal")])
4935
4936 ;; For userland, we load the thread pointer from the TCB.
4937 ;; For the kernel, we load the per-cpu private value.
4938
4939 (define_insn "load_tp"
4940   [(set (match_operand:DI 0 "register_operand" "=v")
4941         (unspec:DI [(const_int 0)] UNSPEC_TP))]
4942   "TARGET_ABI_OSF"
4943 {
4944   if (TARGET_TLS_KERNEL)
4945     return "call_pal 0x32";
4946   else
4947     return "call_pal 0x9e";
4948 }
4949   [(set_attr "type" "callpal")])
4950
4951 ;; For completeness, and possibly a __builtin function, here's how to
4952 ;; set the thread pointer.  Since we don't describe enough of this
4953 ;; quantity for CSE, we have to use a volatile unspec, and then there's
4954 ;; not much point in creating an R16_REG register class.
4955
4956 (define_expand "set_tp"
4957   [(set (reg:DI 16) (match_operand:DI 0 "input_operand" ""))
4958    (unspec_volatile [(reg:DI 16)] UNSPECV_SET_TP)]
4959   "TARGET_ABI_OSF"
4960   "")
4961
4962 (define_insn "*set_tp"
4963   [(unspec_volatile [(reg:DI 16)] UNSPECV_SET_TP)]
4964   "TARGET_ABI_OSF"
4965 {
4966   if (TARGET_TLS_KERNEL)
4967     return "call_pal 0x31";
4968   else
4969     return "call_pal 0x9f";
4970 }
4971   [(set_attr "type" "callpal")])
4972 \f
4973 ;; Finally, we have the basic data motion insns.  The byte and word insns
4974 ;; are done via define_expand.  Start with the floating-point insns, since
4975 ;; they are simpler.
4976
4977 (define_insn "*movsf_nofix"
4978   [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,*r,*r,m,m")
4979         (match_operand:SF 1 "input_operand" "fG,m,*rG,m,fG,*r"))]
4980   "TARGET_FPREGS && ! TARGET_FIX
4981    && (register_operand (operands[0], SFmode)
4982        || reg_or_0_operand (operands[1], SFmode))"
4983   "@
4984    cpys %R1,%R1,%0
4985    ld%, %0,%1
4986    bis $31,%r1,%0
4987    ldl %0,%1
4988    st%, %R1,%0
4989    stl %r1,%0"
4990   [(set_attr "type" "fcpys,fld,ilog,ild,fst,ist")])
4991
4992 (define_insn "*movsf_fix"
4993   [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,*r,*r,m,m,f,*r")
4994         (match_operand:SF 1 "input_operand" "fG,m,*rG,m,fG,*r,*r,f"))]
4995   "TARGET_FPREGS && TARGET_FIX
4996    && (register_operand (operands[0], SFmode)
4997        || reg_or_0_operand (operands[1], SFmode))"
4998   "@
4999    cpys %R1,%R1,%0
5000    ld%, %0,%1
5001    bis $31,%r1,%0
5002    ldl %0,%1
5003    st%, %R1,%0
5004    stl %r1,%0
5005    itofs %1,%0
5006    ftois %1,%0"
5007   [(set_attr "type" "fcpys,fld,ilog,ild,fst,ist,itof,ftoi")])
5008
5009 (define_insn "*movsf_nofp"
5010   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m")
5011         (match_operand:SF 1 "input_operand" "rG,m,r"))]
5012   "! TARGET_FPREGS
5013    && (register_operand (operands[0], SFmode)
5014        || reg_or_0_operand (operands[1], SFmode))"
5015   "@
5016    bis $31,%r1,%0
5017    ldl %0,%1
5018    stl %r1,%0"
5019   [(set_attr "type" "ilog,ild,ist")])
5020
5021 (define_insn "*movdf_nofix"
5022   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,*r,*r,m,m")
5023         (match_operand:DF 1 "input_operand" "fG,m,*rG,m,fG,*r"))]
5024   "TARGET_FPREGS && ! TARGET_FIX
5025    && (register_operand (operands[0], DFmode)
5026        || reg_or_0_operand (operands[1], DFmode))"
5027   "@
5028    cpys %R1,%R1,%0
5029    ld%- %0,%1
5030    bis $31,%r1,%0
5031    ldq %0,%1
5032    st%- %R1,%0
5033    stq %r1,%0"
5034   [(set_attr "type" "fcpys,fld,ilog,ild,fst,ist")])
5035
5036 (define_insn "*movdf_fix"
5037   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,*r,*r,m,m,f,*r")
5038         (match_operand:DF 1 "input_operand" "fG,m,*rG,m,fG,*r,*r,f"))]
5039   "TARGET_FPREGS && TARGET_FIX
5040    && (register_operand (operands[0], DFmode)
5041        || reg_or_0_operand (operands[1], DFmode))"
5042   "@
5043    cpys %R1,%R1,%0
5044    ld%- %0,%1
5045    bis $31,%r1,%0
5046    ldq %0,%1
5047    st%- %R1,%0
5048    stq %r1,%0
5049    itoft %1,%0
5050    ftoit %1,%0"
5051   [(set_attr "type" "fcpys,fld,ilog,ild,fst,ist,itof,ftoi")])
5052
5053 (define_insn "*movdf_nofp"
5054   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m")
5055         (match_operand:DF 1 "input_operand" "rG,m,r"))]
5056   "! TARGET_FPREGS
5057    && (register_operand (operands[0], DFmode)
5058        || reg_or_0_operand (operands[1], DFmode))"
5059   "@
5060    bis $31,%r1,%0
5061    ldq %0,%1
5062    stq %r1,%0"
5063   [(set_attr "type" "ilog,ild,ist")])
5064
5065 ;; Subregs suck for register allocation.  Pretend we can move TFmode
5066 ;; data between general registers until after reload.
5067
5068 (define_insn_and_split "*movtf_internal"
5069   [(set (match_operand:TF 0 "nonimmediate_operand" "=r,o")
5070         (match_operand:TF 1 "input_operand" "roG,rG"))]
5071   "register_operand (operands[0], TFmode)
5072    || reg_or_0_operand (operands[1], TFmode)"
5073   "#"
5074   "reload_completed"
5075   [(set (match_dup 0) (match_dup 2))
5076    (set (match_dup 1) (match_dup 3))]
5077 {
5078   alpha_split_tfmode_pair (operands);
5079   if (reg_overlap_mentioned_p (operands[0], operands[3]))
5080     {
5081       rtx tmp;
5082       tmp = operands[0], operands[0] = operands[1], operands[1] = tmp;
5083       tmp = operands[2], operands[2] = operands[3], operands[3] = tmp;
5084     }
5085 })
5086
5087 (define_expand "movsf"
5088   [(set (match_operand:SF 0 "nonimmediate_operand" "")
5089         (match_operand:SF 1 "general_operand" ""))]
5090   ""
5091 {
5092   if (GET_CODE (operands[0]) == MEM
5093       && ! reg_or_0_operand (operands[1], SFmode))
5094     operands[1] = force_reg (SFmode, operands[1]);
5095 })
5096
5097 (define_expand "movdf"
5098   [(set (match_operand:DF 0 "nonimmediate_operand" "")
5099         (match_operand:DF 1 "general_operand" ""))]
5100   ""
5101 {
5102   if (GET_CODE (operands[0]) == MEM
5103       && ! reg_or_0_operand (operands[1], DFmode))
5104     operands[1] = force_reg (DFmode, operands[1]);
5105 })
5106
5107 (define_expand "movtf"
5108   [(set (match_operand:TF 0 "nonimmediate_operand" "")
5109         (match_operand:TF 1 "general_operand" ""))]
5110   ""
5111 {
5112   if (GET_CODE (operands[0]) == MEM
5113       && ! reg_or_0_operand (operands[1], TFmode))
5114     operands[1] = force_reg (TFmode, operands[1]);
5115 })
5116
5117 (define_insn "*movsi"
5118   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,m")
5119         (match_operand:SI 1 "input_operand" "rJ,K,L,m,rJ"))]
5120   "(TARGET_ABI_OSF || TARGET_ABI_UNICOSMK)
5121    && (register_operand (operands[0], SImode)
5122        || reg_or_0_operand (operands[1], SImode))"
5123   "@
5124    bis $31,%r1,%0
5125    lda %0,%1($31)
5126    ldah %0,%h1($31)
5127    ldl %0,%1
5128    stl %r1,%0"
5129   [(set_attr "type" "ilog,iadd,iadd,ild,ist")])
5130
5131 (define_insn "*movsi_nt_vms"
5132   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,r,m")
5133         (match_operand:SI 1 "input_operand" "rJ,K,L,s,m,rJ"))]
5134   "(TARGET_ABI_WINDOWS_NT || TARGET_ABI_OPEN_VMS)
5135     && (register_operand (operands[0], SImode)
5136         || reg_or_0_operand (operands[1], SImode))"
5137   "@
5138    bis $31,%1,%0
5139    lda %0,%1
5140    ldah %0,%h1
5141    lda %0,%1
5142    ldl %0,%1
5143    stl %r1,%0"
5144   [(set_attr "type" "ilog,iadd,iadd,ldsym,ild,ist")])
5145
5146 (define_insn "*movhi_nobwx"
5147   [(set (match_operand:HI 0 "register_operand" "=r,r")
5148         (match_operand:HI 1 "input_operand" "rJ,n"))]
5149   "! TARGET_BWX
5150    && (register_operand (operands[0], HImode)
5151        || register_operand (operands[1], HImode))"
5152   "@
5153    bis $31,%r1,%0
5154    lda %0,%L1($31)"
5155   [(set_attr "type" "ilog,iadd")])
5156
5157 (define_insn "*movhi_bwx"
5158   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
5159         (match_operand:HI 1 "input_operand" "rJ,n,m,rJ"))]
5160   "TARGET_BWX
5161    && (register_operand (operands[0], HImode)
5162        || reg_or_0_operand (operands[1], HImode))"
5163   "@
5164    bis $31,%r1,%0
5165    lda %0,%L1($31)
5166    ldwu %0,%1
5167    stw %r1,%0"
5168   [(set_attr "type" "ilog,iadd,ild,ist")])
5169
5170 (define_insn "*movqi_nobwx"
5171   [(set (match_operand:QI 0 "register_operand" "=r,r")
5172         (match_operand:QI 1 "input_operand" "rJ,n"))]
5173   "! TARGET_BWX
5174    && (register_operand (operands[0], QImode)
5175        || register_operand (operands[1], QImode))"
5176   "@
5177    bis $31,%r1,%0
5178    lda %0,%L1($31)"
5179   [(set_attr "type" "ilog,iadd")])
5180
5181 (define_insn "*movqi_bwx"
5182   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,r,m")
5183         (match_operand:QI 1 "input_operand" "rJ,n,m,rJ"))]
5184   "TARGET_BWX
5185    && (register_operand (operands[0], QImode)
5186        || reg_or_0_operand (operands[1], QImode))"
5187   "@
5188    bis $31,%r1,%0
5189    lda %0,%L1($31)
5190    ldbu %0,%1
5191    stb %r1,%0"
5192   [(set_attr "type" "ilog,iadd,ild,ist")])
5193
5194 ;; We do two major things here: handle mem->mem and construct long
5195 ;; constants.
5196
5197 (define_expand "movsi"
5198   [(set (match_operand:SI 0 "nonimmediate_operand" "")
5199         (match_operand:SI 1 "general_operand" ""))]
5200   ""
5201 {
5202   if (alpha_expand_mov (SImode, operands))
5203     DONE;
5204 })
5205
5206 ;; Split a load of a large constant into the appropriate two-insn
5207 ;; sequence.
5208
5209 (define_split
5210   [(set (match_operand:SI 0 "register_operand" "")
5211         (match_operand:SI 1 "const_int_operand" ""))]
5212   "! add_operand (operands[1], SImode)"
5213   [(set (match_dup 0) (match_dup 2))
5214    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
5215 {
5216   rtx tem
5217     = alpha_emit_set_const (operands[0], SImode, INTVAL (operands[1]), 2);
5218
5219   if (tem == operands[0])
5220     DONE;
5221   else
5222     FAIL;
5223 })
5224
5225 ;; Split the load of an address into a four-insn sequence on Unicos/Mk.
5226 ;; Always generate a REG_EQUAL note for the last instruction to facilitate
5227 ;; optimizations. If the symbolic operand is a label_ref, generate REG_LABEL
5228 ;; notes and update LABEL_NUSES because this is not done automatically.
5229 ;; Labels may be incorrectly deleted if we don't do this.
5230 ;;
5231 ;; Describing what the individual instructions do correctly is too complicated
5232 ;; so use UNSPECs for each of the three parts of an address.
5233
5234 (define_split
5235   [(set (match_operand:DI 0 "register_operand" "")
5236         (match_operand:DI 1 "symbolic_operand" ""))]
5237   "TARGET_ABI_UNICOSMK && reload_completed"
5238   [(const_int 0)]
5239 {
5240   rtx insn1, insn2, insn3;
5241
5242   insn1 = emit_insn (gen_umk_laum (operands[0], operands[1]));
5243   emit_insn (gen_ashldi3 (operands[0], operands[0], GEN_INT (32)));
5244   insn2 = emit_insn (gen_umk_lalm (operands[0], operands[0], operands[1]));
5245   insn3 = emit_insn (gen_umk_lal (operands[0], operands[0], operands[1]));
5246   REG_NOTES (insn3) = gen_rtx_EXPR_LIST (REG_EQUAL, operands[1],
5247                                          REG_NOTES (insn3));
5248   if (GET_CODE (operands[1]) == LABEL_REF)
5249     {
5250       rtx label;
5251
5252       label = XEXP (operands[1], 0);
5253       REG_NOTES (insn1) = gen_rtx_EXPR_LIST (REG_LABEL, label,
5254                                              REG_NOTES (insn1));
5255       REG_NOTES (insn2) = gen_rtx_EXPR_LIST (REG_LABEL, label,
5256                                              REG_NOTES (insn2));
5257       REG_NOTES (insn3) = gen_rtx_EXPR_LIST (REG_LABEL, label,
5258                                              REG_NOTES (insn3));
5259       LABEL_NUSES (label) += 3;
5260     }
5261   DONE;
5262 })
5263
5264 ;; Instructions for loading the three parts of an address on Unicos/Mk.
5265
5266 (define_insn "umk_laum"
5267   [(set (match_operand:DI 0 "register_operand" "=r")
5268         (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
5269                    UNSPEC_UMK_LAUM))]
5270   "TARGET_ABI_UNICOSMK"
5271   "laum %r0,%t1($31)"
5272   [(set_attr "type" "iadd")])
5273
5274 (define_insn "umk_lalm"
5275   [(set (match_operand:DI 0 "register_operand" "=r")
5276         (plus:DI (match_operand:DI 1 "register_operand" "r")
5277                  (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
5278                             UNSPEC_UMK_LALM)))] 
5279   "TARGET_ABI_UNICOSMK"
5280   "lalm %r0,%t2(%r1)"
5281   [(set_attr "type" "iadd")])
5282
5283 (define_insn "umk_lal"
5284   [(set (match_operand:DI 0 "register_operand" "=r")
5285         (plus:DI (match_operand:DI 1 "register_operand" "r")
5286                  (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
5287                             UNSPEC_UMK_LAL)))]
5288   "TARGET_ABI_UNICOSMK"
5289   "lal %r0,%t2(%r1)"
5290   [(set_attr "type" "iadd")])
5291
5292 ;; Add a new call information word to the current function's list of CIWs
5293 ;; and load its index into $25. Doing it here ensures that the CIW will be
5294 ;; associated with the correct function even in the presence of inlining.
5295
5296 (define_insn "*umk_load_ciw"
5297   [(set (reg:DI 25)
5298         (unspec:DI [(match_operand 0 "" "")] UNSPEC_UMK_LOAD_CIW))]
5299   "TARGET_ABI_UNICOSMK"
5300 {
5301   operands[0] = unicosmk_add_call_info_word (operands[0]);
5302   return "lda $25,%0";
5303 }
5304   [(set_attr "type" "iadd")])
5305
5306 (define_insn "*movdi_er_low_l"
5307   [(set (match_operand:DI 0 "register_operand" "=r")
5308         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
5309                    (match_operand:DI 2 "local_symbolic_operand" "")))]
5310   "TARGET_EXPLICIT_RELOCS"
5311 {
5312   if (true_regnum (operands[1]) == 29)
5313     return "lda %0,%2(%1)\t\t!gprel";
5314   else
5315     return "lda %0,%2(%1)\t\t!gprellow";
5316 }
5317   [(set_attr "usegp" "yes")])
5318
5319 (define_split
5320   [(set (match_operand:DI 0 "register_operand" "")
5321         (match_operand:DI 1 "small_symbolic_operand" ""))]
5322   "TARGET_EXPLICIT_RELOCS && reload_completed"
5323   [(set (match_dup 0)
5324         (lo_sum:DI (match_dup 2) (match_dup 1)))]
5325   "operands[2] = pic_offset_table_rtx;")
5326
5327 (define_split
5328   [(set (match_operand:DI 0 "register_operand" "")
5329         (match_operand:DI 1 "local_symbolic_operand" ""))]
5330   "TARGET_EXPLICIT_RELOCS && reload_completed"
5331   [(set (match_dup 0)
5332         (plus:DI (match_dup 2) (high:DI (match_dup 1))))
5333    (set (match_dup 0)
5334         (lo_sum:DI (match_dup 0) (match_dup 1)))]
5335   "operands[2] = pic_offset_table_rtx;")
5336
5337 (define_split
5338   [(match_operand 0 "some_small_symbolic_operand" "")]
5339   "TARGET_EXPLICIT_RELOCS && reload_completed"
5340   [(match_dup 0)]
5341   "operands[0] = split_small_symbolic_operand (operands[0]);")
5342
5343 ;; Accepts any symbolic, not just global, since function calls that
5344 ;; don't go via bsr still use !literal in hopes of linker relaxation.
5345 (define_insn "movdi_er_high_g"
5346   [(set (match_operand:DI 0 "register_operand" "=r")
5347         (unspec:DI [(match_operand:DI 1 "register_operand" "r")
5348                     (match_operand:DI 2 "symbolic_operand" "")
5349                     (match_operand 3 "const_int_operand" "")]
5350                    UNSPEC_LITERAL))]
5351   "TARGET_EXPLICIT_RELOCS"
5352 {
5353   if (INTVAL (operands[3]) == 0)
5354     return "ldq %0,%2(%1)\t\t!literal";
5355   else
5356     return "ldq %0,%2(%1)\t\t!literal!%3";
5357 }
5358   [(set_attr "type" "ldsym")])
5359
5360 (define_split
5361   [(set (match_operand:DI 0 "register_operand" "")
5362         (match_operand:DI 1 "global_symbolic_operand" ""))]
5363   "TARGET_EXPLICIT_RELOCS && reload_completed"
5364   [(set (match_dup 0)
5365         (unspec:DI [(match_dup 2)
5366                     (match_dup 1)
5367                     (const_int 0)] UNSPEC_LITERAL))]
5368   "operands[2] = pic_offset_table_rtx;")
5369
5370 ;; With RTL inlining, at -O3, rtl is generated, stored, then actually
5371 ;; compiled at the end of compilation.  In the meantime, someone can
5372 ;; re-encode-section-info on some symbol changing it e.g. from global
5373 ;; to local-not-small.  If this happens, we'd have emitted a plain
5374 ;; load rather than a high+losum load and not recognize the insn.
5375 ;;
5376 ;; So if rtl inlining is in effect, we delay the global/not-global
5377 ;; decision until rest_of_compilation by wrapping it in an UNSPEC_SYMBOL.
5378
5379 (define_insn_and_split "movdi_er_maybe_g"
5380   [(set (match_operand:DI 0 "register_operand" "=r")
5381         (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
5382                    UNSPEC_SYMBOL))]
5383   "TARGET_EXPLICIT_RELOCS && flag_inline_functions"
5384   "#"
5385   ""
5386   [(set (match_dup 0) (match_dup 1))]
5387 {
5388   if (local_symbolic_operand (operands[1], Pmode)
5389       && !small_symbolic_operand (operands[1], Pmode))
5390     {
5391       rtx subtarget = no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode);
5392       rtx tmp;
5393
5394       tmp = gen_rtx_HIGH (Pmode, operands[1]);
5395       if (reload_completed)
5396         tmp = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, tmp);
5397       emit_insn (gen_rtx_SET (VOIDmode, subtarget, tmp));
5398
5399       tmp = gen_rtx_LO_SUM (Pmode, subtarget, operands[1]);
5400       emit_insn (gen_rtx_SET (VOIDmode, operands[0], tmp));
5401       DONE;
5402     }
5403 })
5404
5405 (define_insn "movdi_er_tlsgd"
5406   [(set (match_operand:DI 0 "register_operand" "=r")
5407         (unspec:DI [(match_operand:DI 1 "register_operand" "r")
5408                     (match_operand:DI 2 "symbolic_operand" "")
5409                     (match_operand 3 "const_int_operand" "")]
5410                    UNSPEC_TLSGD))]
5411   "HAVE_AS_TLS"
5412 {
5413   if (INTVAL (operands[3]) == 0)
5414     return "lda %0,%2(%1)\t\t!tlsgd";
5415   else
5416     return "lda %0,%2(%1)\t\t!tlsgd!%3";
5417 })
5418
5419 (define_insn "movdi_er_tlsldm"
5420   [(set (match_operand:DI 0 "register_operand" "=r")
5421         (unspec:DI [(match_operand:DI 1 "register_operand" "r")
5422                     (match_operand 2 "const_int_operand" "")]
5423                    UNSPEC_TLSLDM))]
5424   "HAVE_AS_TLS"
5425 {
5426   if (INTVAL (operands[2]) == 0)
5427     return "lda %0,%&(%1)\t\t!tlsldm";
5428   else
5429     return "lda %0,%&(%1)\t\t!tlsldm!%2";
5430 })
5431
5432 (define_insn "*movdi_er_gotdtp"
5433   [(set (match_operand:DI 0 "register_operand" "=r")
5434         (unspec:DI [(match_operand:DI 1 "register_operand" "r")
5435                     (match_operand:DI 2 "symbolic_operand" "")]
5436                    UNSPEC_DTPREL))]
5437   "HAVE_AS_TLS"
5438   "ldq %0,%2(%1)\t\t!gotdtprel"
5439   [(set_attr "type" "ild")
5440    (set_attr "usegp" "yes")])
5441
5442 (define_split
5443   [(set (match_operand:DI 0 "register_operand" "")
5444         (match_operand:DI 1 "gotdtp_symbolic_operand" ""))]
5445   "HAVE_AS_TLS && reload_completed"
5446   [(set (match_dup 0)
5447         (unspec:DI [(match_dup 2)
5448                     (match_dup 1)] UNSPEC_DTPREL))]
5449 {
5450   operands[1] = XVECEXP (XEXP (operands[1], 0), 0, 0);
5451   operands[2] = pic_offset_table_rtx;
5452 })
5453
5454 (define_insn "*movdi_er_gottp"
5455   [(set (match_operand:DI 0 "register_operand" "=r")
5456         (unspec:DI [(match_operand:DI 1 "register_operand" "r")
5457                     (match_operand:DI 2 "symbolic_operand" "")]
5458                    UNSPEC_TPREL))]
5459   "HAVE_AS_TLS"
5460   "ldq %0,%2(%1)\t\t!gottprel"
5461   [(set_attr "type" "ild")
5462    (set_attr "usegp" "yes")])
5463
5464 (define_split
5465   [(set (match_operand:DI 0 "register_operand" "")
5466         (match_operand:DI 1 "gottp_symbolic_operand" ""))]
5467   "HAVE_AS_TLS && reload_completed"
5468   [(set (match_dup 0)
5469         (unspec:DI [(match_dup 2)
5470                     (match_dup 1)] UNSPEC_TPREL))]
5471 {
5472   operands[1] = XVECEXP (XEXP (operands[1], 0), 0, 0);
5473   operands[2] = pic_offset_table_rtx;
5474 })
5475
5476 (define_insn "*movdi_er_nofix"
5477   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,r,r,r,m,*f,*f,Q")
5478         (match_operand:DI 1 "input_operand" "rJ,K,L,T,s,m,rJ,*fJ,Q,*f"))]
5479   "TARGET_EXPLICIT_RELOCS && ! TARGET_FIX
5480    && (register_operand (operands[0], DImode)
5481        || reg_or_0_operand (operands[1], DImode))"
5482   "@
5483    mov %r1,%0
5484    lda %0,%1($31)
5485    ldah %0,%h1($31)
5486    #
5487    #
5488    ldq%A1 %0,%1
5489    stq%A0 %r1,%0
5490    fmov %R1,%0
5491    ldt %0,%1
5492    stt %R1,%0"
5493   [(set_attr "type" "ilog,iadd,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst")
5494    (set_attr "usegp" "*,*,*,yes,*,*,*,*,*,*")])
5495
5496 ;; The 'U' constraint matches symbolic operands on Unicos/Mk. Those should
5497 ;; have been split up by the rules above but we shouldn't reject the
5498 ;; possibility of them getting through.
5499
5500 (define_insn "*movdi_nofix"
5501   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,r,r,r,m,*f,*f,Q")
5502         (match_operand:DI 1 "input_operand" "rJ,K,L,U,s,m,rJ,*fJ,Q,*f"))]
5503   "! TARGET_FIX
5504    && (register_operand (operands[0], DImode)
5505        || reg_or_0_operand (operands[1], DImode))"
5506   "@
5507    bis $31,%r1,%0
5508    lda %0,%1($31)
5509    ldah %0,%h1($31)
5510    laum %0,%t1($31)\;sll %0,32,%0\;lalm %0,%t1(%0)\;lal %0,%t1(%0)
5511    lda %0,%1
5512    ldq%A1 %0,%1
5513    stq%A0 %r1,%0
5514    cpys %R1,%R1,%0
5515    ldt %0,%1
5516    stt %R1,%0"
5517   [(set_attr "type" "ilog,iadd,iadd,ldsym,ldsym,ild,ist,fcpys,fld,fst")
5518    (set_attr "length" "*,*,*,16,*,*,*,*,*,*")])
5519
5520 (define_insn "*movdi_er_fix"
5521   [(set (match_operand:DI 0 "nonimmediate_operand"
5522                                 "=r,r,r,r,r,r, m, *f,*f, Q, r,*f")
5523         (match_operand:DI 1 "input_operand"
5524                                 "rJ,K,L,T,s,m,rJ,*fJ, Q,*f,*f, r"))]
5525   "TARGET_EXPLICIT_RELOCS && TARGET_FIX
5526    && (register_operand (operands[0], DImode)
5527        || reg_or_0_operand (operands[1], DImode))"
5528   "@
5529    mov %r1,%0
5530    lda %0,%1($31)
5531    ldah %0,%h1($31)
5532    #
5533    #
5534    ldq%A1 %0,%1
5535    stq%A0 %r1,%0
5536    fmov %R1,%0
5537    ldt %0,%1
5538    stt %R1,%0
5539    ftoit %1,%0
5540    itoft %1,%0"
5541   [(set_attr "type" "ilog,iadd,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst,ftoi,itof")
5542    (set_attr "usegp" "*,*,*,yes,*,*,*,*,*,*,*,*")])
5543
5544 (define_insn "*movdi_fix"
5545   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,r,r,m,*f,*f,Q,r,*f")
5546         (match_operand:DI 1 "input_operand" "rJ,K,L,s,m,rJ,*fJ,Q,*f,*f,r"))]
5547   "! TARGET_EXPLICIT_RELOCS && TARGET_FIX
5548    && (register_operand (operands[0], DImode)
5549        || reg_or_0_operand (operands[1], DImode))"
5550   "@
5551    bis $31,%r1,%0
5552    lda %0,%1($31)
5553    ldah %0,%h1($31)
5554    lda %0,%1
5555    ldq%A1 %0,%1
5556    stq%A0 %r1,%0
5557    cpys %R1,%R1,%0
5558    ldt %0,%1
5559    stt %R1,%0
5560    ftoit %1,%0
5561    itoft %1,%0"
5562   [(set_attr "type" "ilog,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst,ftoi,itof")])
5563
5564 ;; VMS needs to set up "vms_base_regno" for unwinding.  This move
5565 ;; often appears dead to the life analysis code, at which point we
5566 ;; abort for emitting dead prologue instructions.  Force this live.
5567
5568 (define_insn "force_movdi"
5569   [(set (match_operand:DI 0 "register_operand" "=r")
5570         (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "r")]
5571                             UNSPECV_FORCE_MOV))]
5572   ""
5573   "mov %1,%0"
5574   [(set_attr "type" "ilog")])
5575
5576 ;; We do three major things here: handle mem->mem, put 64-bit constants in
5577 ;; memory, and construct long 32-bit constants.
5578
5579 (define_expand "movdi"
5580   [(set (match_operand:DI 0 "nonimmediate_operand" "")
5581         (match_operand:DI 1 "general_operand" ""))]
5582   ""
5583 {
5584   if (alpha_expand_mov (DImode, operands))
5585     DONE;
5586 })
5587
5588 ;; Split a load of a large constant into the appropriate two-insn
5589 ;; sequence.
5590
5591 (define_split
5592   [(set (match_operand:DI 0 "register_operand" "")
5593         (match_operand:DI 1 "const_int_operand" ""))]
5594   "! add_operand (operands[1], DImode)"
5595   [(set (match_dup 0) (match_dup 2))
5596    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
5597 {
5598   rtx tem
5599     = alpha_emit_set_const (operands[0], DImode, INTVAL (operands[1]), 2);
5600
5601   if (tem == operands[0])
5602     DONE;
5603   else
5604     FAIL;
5605 })
5606
5607 ;; These are the partial-word cases.
5608 ;;
5609 ;; First we have the code to load an aligned word.  Operand 0 is the register
5610 ;; in which to place the result.  It's mode is QImode or HImode.  Operand 1
5611 ;; is an SImode MEM at the low-order byte of the proper word.  Operand 2 is the
5612 ;; number of bits within the word that the value is.  Operand 3 is an SImode
5613 ;; scratch register.  If operand 0 is a hard register, operand 3 may be the
5614 ;; same register.  It is allowed to conflict with operand 1 as well.
5615
5616 (define_expand "aligned_loadqi"
5617   [(set (match_operand:SI 3 "register_operand" "")
5618         (match_operand:SI 1 "memory_operand" ""))
5619    (set (match_operand:DI 0 "register_operand" "")
5620         (zero_extract:DI (subreg:DI (match_dup 3) 0)
5621                          (const_int 8)
5622                          (match_operand:DI 2 "const_int_operand" "")))]
5623
5624   ""
5625   "")
5626
5627 (define_expand "aligned_loadhi"
5628   [(set (match_operand:SI 3 "register_operand" "")
5629         (match_operand:SI 1 "memory_operand" ""))
5630    (set (match_operand:DI 0 "register_operand" "")
5631         (zero_extract:DI (subreg:DI (match_dup 3) 0)
5632                          (const_int 16)
5633                          (match_operand:DI 2 "const_int_operand" "")))]
5634
5635   ""
5636   "")
5637
5638 ;; Similar for unaligned loads, where we use the sequence from the
5639 ;; Alpha Architecture manual. We have to distinguish between little-endian
5640 ;; and big-endian systems as the sequences are different.
5641 ;;
5642 ;; Operand 1 is the address.  Operands 2 and 3 are temporaries, where
5643 ;; operand 3 can overlap the input and output registers.
5644
5645 (define_expand "unaligned_loadqi"
5646   [(use (match_operand:DI 0 "register_operand" ""))
5647    (use (match_operand:DI 1 "address_operand" ""))
5648    (use (match_operand:DI 2 "register_operand" ""))
5649    (use (match_operand:DI 3 "register_operand" ""))]
5650   ""
5651 {
5652   if (WORDS_BIG_ENDIAN)
5653     emit_insn (gen_unaligned_loadqi_be (operands[0], operands[1],
5654                                         operands[2], operands[3]));
5655   else
5656     emit_insn (gen_unaligned_loadqi_le (operands[0], operands[1],
5657                                         operands[2], operands[3]));
5658   DONE;
5659 })
5660
5661 (define_expand "unaligned_loadqi_le"
5662   [(set (match_operand:DI 2 "register_operand" "")
5663         (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
5664                         (const_int -8))))
5665    (set (match_operand:DI 3 "register_operand" "")
5666         (match_dup 1))
5667    (set (match_operand:DI 0 "register_operand" "")
5668         (zero_extract:DI (match_dup 2)
5669                          (const_int 8)
5670                          (ashift:DI (match_dup 3) (const_int 3))))]
5671   "! WORDS_BIG_ENDIAN"
5672   "")
5673
5674 (define_expand "unaligned_loadqi_be"
5675   [(set (match_operand:DI 2 "register_operand" "")
5676         (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
5677                         (const_int -8))))
5678    (set (match_operand:DI 3 "register_operand" "")
5679         (match_dup 1))
5680    (set (match_operand:DI 0 "register_operand" "")
5681         (zero_extract:DI (match_dup 2)
5682                          (const_int 8)
5683                          (minus:DI
5684                            (const_int 56)
5685                            (ashift:DI (match_dup 3) (const_int 3)))))]
5686   "WORDS_BIG_ENDIAN"
5687   "")
5688
5689 (define_expand "unaligned_loadhi"
5690   [(use (match_operand:DI 0 "register_operand" ""))
5691    (use (match_operand:DI 1 "address_operand" ""))
5692    (use (match_operand:DI 2 "register_operand" ""))
5693    (use (match_operand:DI 3 "register_operand" ""))]
5694   ""
5695 {
5696   if (WORDS_BIG_ENDIAN)
5697     emit_insn (gen_unaligned_loadhi_be (operands[0], operands[1],
5698                                         operands[2], operands[3]));
5699   else
5700     emit_insn (gen_unaligned_loadhi_le (operands[0], operands[1],
5701                                         operands[2], operands[3]));
5702   DONE;
5703 })
5704
5705 (define_expand "unaligned_loadhi_le"
5706   [(set (match_operand:DI 2 "register_operand" "")
5707         (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
5708                         (const_int -8))))
5709    (set (match_operand:DI 3 "register_operand" "")
5710         (match_dup 1))
5711    (set (match_operand:DI 0 "register_operand" "")
5712         (zero_extract:DI (match_dup 2)
5713                          (const_int 16)
5714                          (ashift:DI (match_dup 3) (const_int 3))))]
5715   "! WORDS_BIG_ENDIAN"
5716   "")
5717
5718 (define_expand "unaligned_loadhi_be"
5719   [(set (match_operand:DI 2 "register_operand" "")
5720         (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
5721                         (const_int -8))))
5722    (set (match_operand:DI 3 "register_operand" "")
5723         (plus:DI (match_dup 1) (const_int 1)))
5724    (set (match_operand:DI 0 "register_operand" "")
5725         (zero_extract:DI (match_dup 2)
5726                          (const_int 16)
5727                          (minus:DI
5728                            (const_int 56)
5729                            (ashift:DI (match_dup 3) (const_int 3)))))]
5730   "WORDS_BIG_ENDIAN"
5731   "")
5732
5733 ;; Storing an aligned byte or word requires two temporaries.  Operand 0 is the
5734 ;; aligned SImode MEM.  Operand 1 is the register containing the
5735 ;; byte or word to store.  Operand 2 is the number of bits within the word that
5736 ;; the value should be placed.  Operands 3 and 4 are SImode temporaries.
5737
5738 (define_expand "aligned_store"
5739   [(set (match_operand:SI 3 "register_operand" "")
5740         (match_operand:SI 0 "memory_operand" ""))
5741    (set (subreg:DI (match_dup 3) 0)
5742         (and:DI (subreg:DI (match_dup 3) 0) (match_dup 5)))
5743    (set (subreg:DI (match_operand:SI 4 "register_operand" "") 0)
5744         (ashift:DI (zero_extend:DI (match_operand 1 "register_operand" ""))
5745                    (match_operand:DI 2 "const_int_operand" "")))
5746    (set (subreg:DI (match_dup 4) 0)
5747         (ior:DI (subreg:DI (match_dup 4) 0) (subreg:DI (match_dup 3) 0)))
5748    (set (match_dup 0) (match_dup 4))]
5749   ""
5750 {
5751   operands[5] = GEN_INT (~ (GET_MODE_MASK (GET_MODE (operands[1]))
5752                             << INTVAL (operands[2])));
5753 })
5754
5755 ;; For the unaligned byte and halfword cases, we use code similar to that
5756 ;; in the ;; Architecture book, but reordered to lower the number of registers
5757 ;; required.  Operand 0 is the address.  Operand 1 is the data to store.
5758 ;; Operands 2, 3, and 4 are DImode temporaries, where operands 2 and 4 may
5759 ;; be the same temporary, if desired.  If the address is in a register,
5760 ;; operand 2 can be that register.
5761
5762 (define_expand "unaligned_storeqi"
5763   [(use (match_operand:DI 0 "address_operand" ""))
5764    (use (match_operand:QI 1 "register_operand" ""))
5765    (use (match_operand:DI 2 "register_operand" ""))
5766    (use (match_operand:DI 3 "register_operand" ""))
5767    (use (match_operand:DI 4 "register_operand" ""))]
5768   ""
5769 {
5770   if (WORDS_BIG_ENDIAN)
5771     emit_insn (gen_unaligned_storeqi_be (operands[0], operands[1],
5772                                          operands[2], operands[3],
5773                                          operands[4]));
5774   else
5775     emit_insn (gen_unaligned_storeqi_le (operands[0], operands[1],
5776                                          operands[2], operands[3],
5777                                          operands[4]));
5778   DONE;
5779 })
5780
5781 (define_expand "unaligned_storeqi_le"
5782   [(set (match_operand:DI 3 "register_operand" "")
5783         (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
5784                         (const_int -8))))
5785    (set (match_operand:DI 2 "register_operand" "")
5786         (match_dup 0))
5787    (set (match_dup 3)
5788         (and:DI (not:DI (ashift:DI (const_int 255)
5789                                    (ashift:DI (match_dup 2) (const_int 3))))
5790                 (match_dup 3)))
5791    (set (match_operand:DI 4 "register_operand" "")
5792         (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" ""))
5793                    (ashift:DI (match_dup 2) (const_int 3))))
5794    (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
5795    (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
5796         (match_dup 4))]
5797   "! WORDS_BIG_ENDIAN"
5798   "")
5799
5800 (define_expand "unaligned_storeqi_be"
5801   [(set (match_operand:DI 3 "register_operand" "")
5802         (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
5803                         (const_int -8))))
5804    (set (match_operand:DI 2 "register_operand" "")
5805         (match_dup 0))
5806    (set (match_dup 3)
5807         (and:DI (not:DI (ashift:DI (const_int 255)
5808                           (minus:DI (const_int 56)
5809                                     (ashift:DI (match_dup 2) (const_int 3)))))
5810                 (match_dup 3)))
5811    (set (match_operand:DI 4 "register_operand" "")
5812         (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" ""))
5813                    (minus:DI (const_int 56)
5814                      (ashift:DI (match_dup 2) (const_int 3)))))
5815    (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
5816    (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
5817         (match_dup 4))]
5818   "WORDS_BIG_ENDIAN"
5819   "")
5820
5821 (define_expand "unaligned_storehi"
5822   [(use (match_operand:DI 0 "address_operand" ""))
5823    (use (match_operand:HI 1 "register_operand" ""))
5824    (use (match_operand:DI 2 "register_operand" ""))
5825    (use (match_operand:DI 3 "register_operand" ""))
5826    (use (match_operand:DI 4 "register_operand" ""))]
5827   ""
5828 {
5829   if (WORDS_BIG_ENDIAN)
5830     emit_insn (gen_unaligned_storehi_be (operands[0], operands[1],
5831                                          operands[2], operands[3],
5832                                          operands[4]));
5833   else
5834     emit_insn (gen_unaligned_storehi_le (operands[0], operands[1],
5835                                          operands[2], operands[3],
5836                                          operands[4]));
5837   DONE;
5838 })
5839
5840 (define_expand "unaligned_storehi_le"
5841   [(set (match_operand:DI 3 "register_operand" "")
5842         (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
5843                         (const_int -8))))
5844    (set (match_operand:DI 2 "register_operand" "")
5845         (match_dup 0))
5846    (set (match_dup 3)
5847         (and:DI (not:DI (ashift:DI (const_int 65535)
5848                                    (ashift:DI (match_dup 2) (const_int 3))))
5849                 (match_dup 3)))
5850    (set (match_operand:DI 4 "register_operand" "")
5851         (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" ""))
5852                    (ashift:DI (match_dup 2) (const_int 3))))
5853    (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
5854    (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
5855         (match_dup 4))]
5856   "! WORDS_BIG_ENDIAN"
5857   "")
5858
5859 (define_expand "unaligned_storehi_be"
5860   [(set (match_operand:DI 3 "register_operand" "")
5861         (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
5862                         (const_int -8))))
5863    (set (match_operand:DI 2 "register_operand" "")
5864         (plus:DI (match_dup 0) (const_int 1)))
5865    (set (match_dup 3)
5866         (and:DI (not:DI (ashift:DI
5867                           (const_int 65535)
5868                           (minus:DI (const_int 56)
5869                                     (ashift:DI (match_dup 2) (const_int 3)))))
5870                 (match_dup 3)))
5871    (set (match_operand:DI 4 "register_operand" "")
5872         (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" ""))
5873                    (minus:DI (const_int 56)
5874                              (ashift:DI (match_dup 2) (const_int 3)))))
5875    (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
5876    (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
5877         (match_dup 4))]
5878   "WORDS_BIG_ENDIAN"
5879   "")
5880 \f
5881 ;; Here are the define_expand's for QI and HI moves that use the above
5882 ;; patterns.  We have the normal sets, plus the ones that need scratch
5883 ;; registers for reload.
5884
5885 (define_expand "movqi"
5886   [(set (match_operand:QI 0 "nonimmediate_operand" "")
5887         (match_operand:QI 1 "general_operand" ""))]
5888   ""
5889 {
5890   if (TARGET_BWX
5891       ? alpha_expand_mov (QImode, operands)
5892       : alpha_expand_mov_nobwx (QImode, operands))
5893     DONE;
5894 })
5895
5896 (define_expand "movhi"
5897   [(set (match_operand:HI 0 "nonimmediate_operand" "")
5898         (match_operand:HI 1 "general_operand" ""))]
5899   ""
5900 {
5901   if (TARGET_BWX
5902       ? alpha_expand_mov (HImode, operands)
5903       : alpha_expand_mov_nobwx (HImode, operands))
5904     DONE;
5905 })
5906
5907 ;; Here are the versions for reload.  Note that in the unaligned cases
5908 ;; we know that the operand must not be a pseudo-register because stack
5909 ;; slots are always aligned references.
5910
5911 (define_expand "reload_inqi"
5912   [(parallel [(match_operand:QI 0 "register_operand" "=r")
5913               (match_operand:QI 1 "any_memory_operand" "m")
5914               (match_operand:TI 2 "register_operand" "=&r")])]
5915   "! TARGET_BWX"
5916 {
5917   rtx scratch, seq;
5918
5919   if (aligned_memory_operand (operands[1], QImode))
5920     {
5921       seq = gen_reload_inqi_help (operands[0], operands[1],
5922                                   gen_rtx_REG (SImode, REGNO (operands[2])));
5923     }
5924   else
5925     {
5926       rtx addr;
5927
5928       /* It is possible that one of the registers we got for operands[2]
5929          might coincide with that of operands[0] (which is why we made
5930          it TImode).  Pick the other one to use as our scratch.  */
5931       if (REGNO (operands[0]) == REGNO (operands[2]))
5932         scratch = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
5933       else
5934         scratch = gen_rtx_REG (DImode, REGNO (operands[2]));
5935
5936       addr = get_unaligned_address (operands[1], 0);
5937       operands[0] = gen_rtx_REG (DImode, REGNO (operands[0]));
5938       seq = gen_unaligned_loadqi (operands[0], addr, scratch, operands[0]);
5939       alpha_set_memflags (seq, operands[1]);
5940     }
5941   emit_insn (seq);
5942   DONE;
5943 })
5944
5945 (define_expand "reload_inhi"
5946   [(parallel [(match_operand:HI 0 "register_operand" "=r")
5947               (match_operand:HI 1 "any_memory_operand" "m")
5948               (match_operand:TI 2 "register_operand" "=&r")])]
5949   "! TARGET_BWX"
5950 {
5951   rtx scratch, seq;
5952
5953   if (aligned_memory_operand (operands[1], HImode))
5954     {
5955       seq = gen_reload_inhi_help (operands[0], operands[1],
5956                                   gen_rtx_REG (SImode, REGNO (operands[2])));
5957     }
5958   else
5959     {
5960       rtx addr;
5961
5962       /* It is possible that one of the registers we got for operands[2]
5963          might coincide with that of operands[0] (which is why we made
5964          it TImode).  Pick the other one to use as our scratch.  */
5965       if (REGNO (operands[0]) == REGNO (operands[2]))
5966         scratch = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
5967       else
5968         scratch = gen_rtx_REG (DImode, REGNO (operands[2]));
5969
5970       addr = get_unaligned_address (operands[1], 0);
5971       operands[0] = gen_rtx_REG (DImode, REGNO (operands[0]));
5972       seq = gen_unaligned_loadhi (operands[0], addr, scratch, operands[0]);
5973       alpha_set_memflags (seq, operands[1]);
5974     }
5975   emit_insn (seq);
5976   DONE;
5977 })
5978
5979 (define_expand "reload_outqi"
5980   [(parallel [(match_operand:QI 0 "any_memory_operand" "=m")
5981               (match_operand:QI 1 "register_operand" "r")
5982               (match_operand:TI 2 "register_operand" "=&r")])]
5983   "! TARGET_BWX"
5984 {
5985   if (aligned_memory_operand (operands[0], QImode))
5986     {
5987       emit_insn (gen_reload_outqi_help
5988                  (operands[0], operands[1],
5989                   gen_rtx_REG (SImode, REGNO (operands[2])),
5990                   gen_rtx_REG (SImode, REGNO (operands[2]) + 1)));
5991     }
5992   else
5993     {
5994       rtx addr = get_unaligned_address (operands[0], 0);
5995       rtx scratch1 = gen_rtx_REG (DImode, REGNO (operands[2]));
5996       rtx scratch2 = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
5997       rtx scratch3 = scratch1;
5998       rtx seq;
5999
6000       if (GET_CODE (addr) == REG)
6001         scratch1 = addr;
6002
6003       seq = gen_unaligned_storeqi (addr, operands[1], scratch1,
6004                                    scratch2, scratch3);
6005       alpha_set_memflags (seq, operands[0]);
6006       emit_insn (seq);
6007     }
6008   DONE;
6009 })
6010
6011 (define_expand "reload_outhi"
6012   [(parallel [(match_operand:HI 0 "any_memory_operand" "=m")
6013               (match_operand:HI 1 "register_operand" "r")
6014               (match_operand:TI 2 "register_operand" "=&r")])]
6015   "! TARGET_BWX"
6016 {
6017   if (aligned_memory_operand (operands[0], HImode))
6018     {
6019       emit_insn (gen_reload_outhi_help
6020                  (operands[0], operands[1],
6021                   gen_rtx_REG (SImode, REGNO (operands[2])),
6022                   gen_rtx_REG (SImode, REGNO (operands[2]) + 1)));
6023     }
6024   else
6025     {
6026       rtx addr = get_unaligned_address (operands[0], 0);
6027       rtx scratch1 = gen_rtx_REG (DImode, REGNO (operands[2]));
6028       rtx scratch2 = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
6029       rtx scratch3 = scratch1;
6030       rtx seq;
6031
6032       if (GET_CODE (addr) == REG)
6033         scratch1 = addr;
6034
6035       seq = gen_unaligned_storehi (addr, operands[1], scratch1,
6036                                    scratch2, scratch3);
6037       alpha_set_memflags (seq, operands[0]);
6038       emit_insn (seq);
6039     }
6040   DONE;
6041 })
6042
6043 ;; Helpers for the above.  The way reload is structured, we can't
6044 ;; always get a proper address for a stack slot during reload_foo
6045 ;; expansion, so we must delay our address manipulations until after.
6046
6047 (define_insn_and_split "reload_inqi_help"
6048   [(set (match_operand:QI 0 "register_operand" "=r")
6049         (match_operand:QI 1 "memory_operand" "m"))
6050    (clobber (match_operand:SI 2 "register_operand" "=r"))]
6051   "! TARGET_BWX && (reload_in_progress || reload_completed)"
6052   "#"
6053   "! TARGET_BWX && reload_completed"
6054   [(const_int 0)]
6055 {
6056   rtx aligned_mem, bitnum;
6057   get_aligned_mem (operands[1], &aligned_mem, &bitnum);
6058   operands[0] = gen_lowpart (DImode, operands[0]);
6059   emit_insn (gen_aligned_loadqi (operands[0], aligned_mem, bitnum,
6060                                  operands[2]));
6061   DONE;
6062 })
6063
6064 (define_insn_and_split "reload_inhi_help"
6065   [(set (match_operand:HI 0 "register_operand" "=r")
6066         (match_operand:HI 1 "memory_operand" "m"))
6067    (clobber (match_operand:SI 2 "register_operand" "=r"))]
6068   "! TARGET_BWX && (reload_in_progress || reload_completed)"
6069   "#"
6070   "! TARGET_BWX && reload_completed"
6071   [(const_int 0)]
6072 {
6073   rtx aligned_mem, bitnum;
6074   get_aligned_mem (operands[1], &aligned_mem, &bitnum);
6075   operands[0] = gen_lowpart (DImode, operands[0]);
6076   emit_insn (gen_aligned_loadhi (operands[0], aligned_mem, bitnum,
6077                                  operands[2]));
6078   DONE;
6079 })
6080
6081 (define_insn_and_split "reload_outqi_help"
6082   [(set (match_operand:QI 0 "memory_operand" "=m")
6083         (match_operand:QI 1 "register_operand" "r"))
6084    (clobber (match_operand:SI 2 "register_operand" "=r"))
6085    (clobber (match_operand:SI 3 "register_operand" "=r"))]
6086   "! TARGET_BWX && (reload_in_progress || reload_completed)"
6087   "#"
6088   "! TARGET_BWX && reload_completed"
6089   [(const_int 0)]
6090 {
6091   rtx aligned_mem, bitnum;
6092   get_aligned_mem (operands[0], &aligned_mem, &bitnum);
6093   emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
6094                                 operands[2], operands[3]));
6095   DONE;
6096 })
6097
6098 (define_insn_and_split "reload_outhi_help"
6099   [(set (match_operand:HI 0 "memory_operand" "=m")
6100         (match_operand:HI 1 "register_operand" "r"))
6101    (clobber (match_operand:SI 2 "register_operand" "=r"))
6102    (clobber (match_operand:SI 3 "register_operand" "=r"))]
6103   "! TARGET_BWX && (reload_in_progress || reload_completed)"
6104   "#"
6105   "! TARGET_BWX && reload_completed"
6106   [(const_int 0)]
6107 {
6108   rtx aligned_mem, bitnum;
6109   get_aligned_mem (operands[0], &aligned_mem, &bitnum);
6110   emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
6111                                 operands[2], operands[3]));
6112   DONE;
6113 })
6114 \f
6115 ;; Vector operations
6116
6117 (define_expand "movv8qi"
6118   [(set (match_operand:V8QI 0 "nonimmediate_operand" "")
6119         (match_operand:V8QI 1 "general_operand" ""))]
6120   ""
6121 {
6122   if (alpha_expand_mov (V8QImode, operands))
6123     DONE;
6124 })
6125
6126 (define_insn "*movv8qi_fix"
6127   [(set (match_operand:V8QI 0 "nonimmediate_operand" "=r,r,m,*f,*f,m,r,*f")
6128         (match_operand:V8QI 1 "input_operand" "rW,m,rW,*fW,m,*f,*f,r"))]
6129   "TARGET_FIX
6130    && (register_operand (operands[0], V8QImode)
6131        || reg_or_0_operand (operands[1], V8QImode))"
6132   "@
6133    bis $31,%r1,%0
6134    ldq %0,%1
6135    stq %r1,%0
6136    cpys %R1,%R1,%0
6137    ldt %0,%1
6138    stt %R1,%0
6139    ftoit %1,%0
6140    itoft %1,%0"
6141   [(set_attr "type" "ilog,ild,ist,fcpys,fld,fst,ftoi,itof")])
6142
6143 (define_insn "*movv8qi_nofix"
6144   [(set (match_operand:V8QI 0 "nonimmediate_operand" "=r,r,m,*f,*f,m")
6145         (match_operand:V8QI 1 "input_operand" "rW,m,rW,*fW,m,*f"))]
6146   "! TARGET_FIX
6147    && (register_operand (operands[0], V8QImode)
6148        || reg_or_0_operand (operands[1], V8QImode))"
6149   "@
6150    bis $31,%r1,%0
6151    ldq %0,%1
6152    stq %r1,%0
6153    cpys %R1,%R1,%0
6154    ldt %0,%1
6155    stt %R1,%0"
6156   [(set_attr "type" "ilog,ild,ist,fcpys,fld,fst")])
6157
6158 (define_expand "movv4hi"
6159   [(set (match_operand:V4HI 0 "nonimmediate_operand" "")
6160         (match_operand:V4HI 1 "general_operand" ""))]
6161   ""
6162 {
6163   if (alpha_expand_mov (V4HImode, operands))
6164     DONE;
6165 })
6166
6167 (define_insn "*movv4hi_fix"
6168   [(set (match_operand:V4HI 0 "nonimmediate_operand" "=r,r,m,*f,*f,m,r,*f")
6169         (match_operand:V4HI 1 "input_operand" "rW,m,rW,*fW,m,*f,*f,r"))]
6170   "TARGET_FIX
6171    && (register_operand (operands[0], V4HImode)
6172        || reg_or_0_operand (operands[1], V4HImode))"
6173   "@
6174    bis $31,%r1,%0
6175    ldq %0,%1
6176    stq %r1,%0
6177    cpys %R1,%R1,%0
6178    ldt %0,%1
6179    stt %R1,%0
6180    ftoit %1,%0
6181    itoft %1,%0"
6182   [(set_attr "type" "ilog,ild,ist,fcpys,fld,fst,ftoi,itof")])
6183
6184 (define_insn "*movv4hi_nofix"
6185   [(set (match_operand:V4HI 0 "nonimmediate_operand" "=r,r,m,*f,*f,m")
6186         (match_operand:V4HI 1 "input_operand" "rW,m,rW,*fW,m,*f"))]
6187   "! TARGET_FIX
6188    && (register_operand (operands[0], V4HImode)
6189        || reg_or_0_operand (operands[1], V4HImode))"
6190   "@
6191    bis $31,%r1,%0
6192    ldq %0,%1
6193    stq %r1,%0
6194    cpys %R1,%R1,%0
6195    ldt %0,%1
6196    stt %R1,%0"
6197   [(set_attr "type" "ilog,ild,ist,fcpys,fld,fst")])
6198
6199 (define_expand "movv2si"
6200   [(set (match_operand:V2SI 0 "nonimmediate_operand" "")
6201         (match_operand:V2SI 1 "general_operand" ""))]
6202   ""
6203 {
6204   if (alpha_expand_mov (V2SImode, operands))
6205     DONE;
6206 })
6207
6208 (define_insn "*movv2si_fix"
6209   [(set (match_operand:V2SI 0 "nonimmediate_operand" "=r,r,m,*f,*f,m,r,*f")
6210         (match_operand:V2SI 1 "input_operand" "rW,m,rW,*fW,m,*f,*f,r"))]
6211   "TARGET_FIX
6212    && (register_operand (operands[0], V2SImode)
6213        || reg_or_0_operand (operands[1], V2SImode))"
6214   "@
6215    bis $31,%r1,%0
6216    ldq %0,%1
6217    stq %r1,%0
6218    cpys %R1,%R1,%0
6219    ldt %0,%1
6220    stt %R1,%0
6221    ftoit %1,%0
6222    itoft %1,%0"
6223   [(set_attr "type" "ilog,ild,ist,fcpys,fld,fst,ftoi,itof")])
6224
6225 (define_insn "*movv2si_nofix"
6226   [(set (match_operand:V2SI 0 "nonimmediate_operand" "=r,r,m,*f,*f,m")
6227         (match_operand:V2SI 1 "input_operand" "rW,m,rW,*fW,m,*f"))]
6228   "! TARGET_FIX
6229    && (register_operand (operands[0], V2SImode)
6230        || reg_or_0_operand (operands[1], V2SImode))"
6231   "@
6232    bis $31,%r1,%0
6233    ldq %0,%1
6234    stq %r1,%0
6235    cpys %R1,%R1,%0
6236    ldt %0,%1
6237    stt %R1,%0"
6238   [(set_attr "type" "ilog,ild,ist,fcpys,fld,fst")])
6239
6240 (define_insn "uminv8qi3"
6241   [(set (match_operand:V8QI 0 "register_operand" "=r")
6242         (umin:V8QI (match_operand:V8QI 1 "reg_or_0_operand" "rW")
6243                    (match_operand:V8QI 2 "reg_or_0_operand" "rW")))]
6244   "TARGET_MAX"
6245   "minub8 %r1,%r2,%0"
6246   [(set_attr "type" "mvi")])
6247
6248 (define_insn "sminv8qi3"
6249   [(set (match_operand:V8QI 0 "register_operand" "=r")
6250         (smin:V8QI (match_operand:V8QI 1 "reg_or_0_operand" "rW")
6251                    (match_operand:V8QI 2 "reg_or_0_operand" "rW")))]
6252   "TARGET_MAX"
6253   "minsb8 %r1,%r2,%0"
6254   [(set_attr "type" "mvi")])
6255
6256 (define_insn "uminv4hi3"
6257   [(set (match_operand:V4HI 0 "register_operand" "=r")
6258         (umin:V4HI (match_operand:V4HI 1 "reg_or_0_operand" "rW")
6259                    (match_operand:V4HI 2 "reg_or_0_operand" "rW")))]
6260   "TARGET_MAX"
6261   "minuw4 %r1,%r2,%0"
6262   [(set_attr "type" "mvi")])
6263
6264 (define_insn "sminv4hi3"
6265   [(set (match_operand:V4HI 0 "register_operand" "=r")
6266         (smin:V4HI (match_operand:V4HI 1 "reg_or_0_operand" "rW")
6267                    (match_operand:V4HI 2 "reg_or_0_operand" "rW")))]
6268   "TARGET_MAX"
6269   "minsw4 %r1,%r2,%0"
6270   [(set_attr "type" "mvi")])
6271
6272 (define_insn "umaxv8qi3"
6273   [(set (match_operand:V8QI 0 "register_operand" "=r")
6274         (umax:V8QI (match_operand:V8QI 1 "reg_or_0_operand" "rW")
6275                    (match_operand:V8QI 2 "reg_or_0_operand" "rW")))]
6276   "TARGET_MAX"
6277   "maxub8 %r1,%r2,%0"
6278   [(set_attr "type" "mvi")])
6279
6280 (define_insn "smaxv8qi3"
6281   [(set (match_operand:V8QI 0 "register_operand" "=r")
6282         (smax:V8QI (match_operand:V8QI 1 "reg_or_0_operand" "rW")
6283                    (match_operand:V8QI 2 "reg_or_0_operand" "rW")))]
6284   "TARGET_MAX"
6285   "maxsb8 %r1,%r2,%0"
6286   [(set_attr "type" "mvi")])
6287
6288 (define_insn "umaxv4hi3"
6289   [(set (match_operand:V4HI 0 "register_operand" "=r")
6290         (umax:V4HI (match_operand:V4HI 1 "reg_or_0_operand" "rW")
6291                    (match_operand:V4HI 2 "reg_or_0_operand" "rW")))]
6292   "TARGET_MAX"
6293   "maxuw4 %r1,%r2,%0"
6294   [(set_attr "type" "mvi")])
6295
6296 (define_insn "smaxv4hi3"
6297   [(set (match_operand:V4HI 0 "register_operand" "=r")
6298         (smax:V4HI (match_operand:V4HI 1 "reg_or_0_operand" "rW")
6299                    (match_operand:V4HI 2 "reg_or_0_operand" "rW")))]
6300   "TARGET_MAX"
6301   "maxsw4 %r1,%r2,%0"
6302   [(set_attr "type" "mvi")])
6303 \f
6304 ;; Bit field extract patterns which use ext[wlq][lh]
6305
6306 (define_expand "extv"
6307   [(set (match_operand:DI 0 "register_operand" "")
6308         (sign_extract:DI (match_operand:QI 1 "memory_operand" "")
6309                          (match_operand:DI 2 "immediate_operand" "")
6310                          (match_operand:DI 3 "immediate_operand" "")))]
6311   ""
6312 {
6313   int ofs;
6314
6315   /* We can do 16, 32 and 64 bit fields, if aligned on byte boundaries.  */
6316   if (INTVAL (operands[3]) % 8 != 0
6317       || (INTVAL (operands[2]) != 16
6318           && INTVAL (operands[2]) != 32
6319           && INTVAL (operands[2]) != 64))
6320     FAIL;
6321
6322   /* From mips.md: extract_bit_field doesn't verify that our source
6323      matches the predicate, so we force it to be a MEM here.  */
6324   if (GET_CODE (operands[1]) != MEM)
6325     FAIL;
6326
6327   /* The bit number is relative to the mode of operand 1 which is
6328      usually QImode (this might actually be a bug in expmed.c). Note 
6329      that the bit number is negative in big-endian mode in this case.
6330      We have to convert that to the offset.  */
6331   if (WORDS_BIG_ENDIAN)
6332     ofs = GET_MODE_BITSIZE (GET_MODE (operands[1]))
6333           - INTVAL (operands[2]) - INTVAL (operands[3]);
6334   else
6335     ofs = INTVAL (operands[3]);
6336
6337   ofs = ofs / 8;
6338
6339   alpha_expand_unaligned_load (operands[0], operands[1],
6340                                INTVAL (operands[2]) / 8,
6341                                ofs, 1);
6342   DONE;
6343 })
6344
6345 (define_expand "extzv"
6346   [(set (match_operand:DI 0 "register_operand" "")
6347         (zero_extract:DI (match_operand:DI 1 "nonimmediate_operand" "")
6348                          (match_operand:DI 2 "immediate_operand" "")
6349                          (match_operand:DI 3 "immediate_operand" "")))]
6350   ""
6351 {
6352   /* We can do 8, 16, 32 and 64 bit fields, if aligned on byte boundaries.  */
6353   if (INTVAL (operands[3]) % 8 != 0
6354       || (INTVAL (operands[2]) != 8
6355           && INTVAL (operands[2]) != 16
6356           && INTVAL (operands[2]) != 32
6357           && INTVAL (operands[2]) != 64))
6358     FAIL;
6359
6360   if (GET_CODE (operands[1]) == MEM)
6361     {
6362       int ofs;
6363
6364       /* Fail 8 bit fields, falling back on a simple byte load.  */
6365       if (INTVAL (operands[2]) == 8)
6366         FAIL;
6367
6368       /* The bit number is relative to the mode of operand 1 which is
6369          usually QImode (this might actually be a bug in expmed.c). Note 
6370          that the bit number is negative in big-endian mode in this case.
6371          We have to convert that to the offset.  */
6372       if (WORDS_BIG_ENDIAN)
6373         ofs = GET_MODE_BITSIZE (GET_MODE (operands[1]))
6374               - INTVAL (operands[2]) - INTVAL (operands[3]);
6375       else
6376         ofs = INTVAL (operands[3]);
6377
6378       ofs = ofs / 8;
6379
6380       alpha_expand_unaligned_load (operands[0], operands[1],
6381                                    INTVAL (operands[2]) / 8,
6382                                    ofs, 0);
6383       DONE;
6384     }
6385 })
6386
6387 (define_expand "insv"
6388   [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "")
6389                          (match_operand:DI 1 "immediate_operand" "")
6390                          (match_operand:DI 2 "immediate_operand" ""))
6391         (match_operand:DI 3 "register_operand" ""))]
6392   ""
6393 {
6394   int ofs;
6395
6396   /* We can do 16, 32 and 64 bit fields, if aligned on byte boundaries.  */
6397   if (INTVAL (operands[2]) % 8 != 0
6398       || (INTVAL (operands[1]) != 16
6399           && INTVAL (operands[1]) != 32
6400           && INTVAL (operands[1]) != 64))
6401     FAIL;
6402
6403   /* From mips.md: store_bit_field doesn't verify that our source
6404      matches the predicate, so we force it to be a MEM here.  */
6405   if (GET_CODE (operands[0]) != MEM)
6406     FAIL;
6407
6408   /* The bit number is relative to the mode of operand 1 which is
6409      usually QImode (this might actually be a bug in expmed.c). Note 
6410      that the bit number is negative in big-endian mode in this case.
6411      We have to convert that to the offset.  */
6412   if (WORDS_BIG_ENDIAN)
6413     ofs = GET_MODE_BITSIZE (GET_MODE (operands[0]))
6414           - INTVAL (operands[1]) - INTVAL (operands[2]);
6415   else
6416     ofs = INTVAL (operands[2]);
6417
6418   ofs = ofs / 8;
6419
6420   alpha_expand_unaligned_store (operands[0], operands[3],
6421                                 INTVAL (operands[1]) / 8, ofs);
6422   DONE;
6423 })
6424
6425 ;; Block move/clear, see alpha.c for more details.
6426 ;; Argument 0 is the destination
6427 ;; Argument 1 is the source
6428 ;; Argument 2 is the length
6429 ;; Argument 3 is the alignment
6430
6431 (define_expand "movstrqi"
6432   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
6433                    (match_operand:BLK 1 "memory_operand" ""))
6434               (use (match_operand:DI 2 "immediate_operand" ""))
6435               (use (match_operand:DI 3 "immediate_operand" ""))])]
6436   ""
6437 {
6438   if (alpha_expand_block_move (operands))
6439     DONE;
6440   else
6441     FAIL;
6442 })
6443
6444 (define_expand "movstrdi"
6445   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
6446                    (match_operand:BLK 1 "memory_operand" ""))
6447               (use (match_operand:DI 2 "immediate_operand" ""))
6448               (use (match_operand:DI 3 "immediate_operand" ""))
6449               (use (match_dup 4))
6450               (clobber (reg:DI 25))
6451               (clobber (reg:DI 16))
6452               (clobber (reg:DI 17))
6453               (clobber (reg:DI 18))
6454               (clobber (reg:DI 19))
6455               (clobber (reg:DI 20))
6456               (clobber (reg:DI 26))
6457               (clobber (reg:DI 27))])]
6458   "TARGET_ABI_OPEN_VMS"
6459 {
6460   operands[4] = gen_rtx_SYMBOL_REF (Pmode, "OTS$MOVE");
6461   alpha_need_linkage (XSTR (operands[4], 0), 0);
6462 })
6463
6464 (define_insn "*movstrdi_1"
6465   [(set (match_operand:BLK 0 "memory_operand" "=m,=m")
6466         (match_operand:BLK 1 "memory_operand" "m,m"))
6467    (use (match_operand:DI 2 "nonmemory_operand" "r,i"))
6468    (use (match_operand:DI 3 "immediate_operand" ""))
6469    (use (match_operand:DI 4 "call_operand" "i,i"))
6470    (clobber (reg:DI 25))
6471    (clobber (reg:DI 16))
6472    (clobber (reg:DI 17))
6473    (clobber (reg:DI 18))
6474    (clobber (reg:DI 19))
6475    (clobber (reg:DI 20))
6476    (clobber (reg:DI 26))
6477    (clobber (reg:DI 27))]
6478   "TARGET_ABI_OPEN_VMS"
6479 {
6480   operands [5] = alpha_use_linkage (operands [4], cfun->decl, 0, 1);
6481   switch (which_alternative)
6482     {
6483     case 0:
6484         return "lda $16,%0\;bis $31,%2,$17\;lda $18,%1\;ldq $26,%5\;lda $25,3($31)\;jsr $26,%4\;ldq $27,0($29)";
6485     case 1:
6486         return "lda $16,%0\;lda $17,%2($31)\;lda $18,%1\;ldq $26,%5\;lda $25,3($31)\;jsr $26,%4\;ldq $27,0($29)";
6487     default:
6488       abort();
6489     }
6490 }
6491   [(set_attr "type" "multi")
6492    (set_attr "length" "28")])
6493
6494 (define_expand "clrstrqi"
6495   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
6496                    (const_int 0))
6497               (use (match_operand:DI 1 "immediate_operand" ""))
6498               (use (match_operand:DI 2 "immediate_operand" ""))])]
6499   ""
6500 {
6501   if (alpha_expand_block_clear (operands))
6502     DONE;
6503   else
6504     FAIL;
6505 })
6506
6507 (define_expand "clrstrdi"
6508   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
6509                    (const_int 0))
6510               (use (match_operand:DI 1 "immediate_operand" ""))
6511               (use (match_operand:DI 2 "immediate_operand" ""))
6512               (use (match_dup 3))
6513               (clobber (reg:DI 25))
6514               (clobber (reg:DI 16))
6515               (clobber (reg:DI 17))
6516               (clobber (reg:DI 26))
6517               (clobber (reg:DI 27))])]
6518   "TARGET_ABI_OPEN_VMS"
6519 {
6520   operands[3] = gen_rtx_SYMBOL_REF (Pmode, "OTS$ZERO");
6521   alpha_need_linkage (XSTR (operands[3], 0), 0);
6522 })
6523
6524 (define_insn "*clrstrdi_1"
6525   [(set (match_operand:BLK 0 "memory_operand" "=m,=m")
6526                    (const_int 0))
6527    (use (match_operand:DI 1 "nonmemory_operand" "r,i"))
6528    (use (match_operand:DI 2 "immediate_operand" ""))
6529    (use (match_operand:DI 3 "call_operand" "i,i"))
6530    (clobber (reg:DI 25))
6531    (clobber (reg:DI 16))
6532    (clobber (reg:DI 17))
6533    (clobber (reg:DI 26))
6534    (clobber (reg:DI 27))]
6535   "TARGET_ABI_OPEN_VMS"
6536 {
6537   operands [4] = alpha_use_linkage (operands [3], cfun->decl, 0, 1);
6538   switch (which_alternative)
6539     {
6540     case 0:
6541         return "lda $16,%0\;bis $31,%1,$17\;ldq $26,%4\;lda $25,2($31)\;jsr $26,%3\;ldq $27,0($29)";
6542     case 1:
6543         return "lda $16,%0\;lda $17,%1($31)\;ldq $26,%4\;lda $25,2($31)\;jsr $26,%3\;ldq $27,0($29)";
6544     default:
6545       abort();
6546     }
6547 }
6548   [(set_attr "type" "multi")
6549    (set_attr "length" "24")])
6550
6551 \f
6552 ;; Subroutine of stack space allocation.  Perform a stack probe.
6553 (define_expand "probe_stack"
6554   [(set (match_dup 1) (match_operand:DI 0 "const_int_operand" ""))]
6555   ""
6556 {
6557   operands[1] = gen_rtx_MEM (DImode, plus_constant (stack_pointer_rtx,
6558                                                     INTVAL (operands[0])));
6559   MEM_VOLATILE_P (operands[1]) = 1;
6560
6561   operands[0] = const0_rtx;
6562 })
6563
6564 ;; This is how we allocate stack space.  If we are allocating a
6565 ;; constant amount of space and we know it is less than 4096
6566 ;; bytes, we need do nothing.
6567 ;;
6568 ;; If it is more than 4096 bytes, we need to probe the stack
6569 ;; periodically.
6570 (define_expand "allocate_stack"
6571   [(set (reg:DI 30)
6572         (plus:DI (reg:DI 30)
6573                  (match_operand:DI 1 "reg_or_cint_operand" "")))
6574    (set (match_operand:DI 0 "register_operand" "=r")
6575         (match_dup 2))]
6576   ""
6577 {
6578   if (GET_CODE (operands[1]) == CONST_INT
6579       && INTVAL (operands[1]) < 32768)
6580     {
6581       if (INTVAL (operands[1]) >= 4096)
6582         {
6583           /* We do this the same way as in the prologue and generate explicit
6584              probes.  Then we update the stack by the constant.  */
6585
6586           int probed = 4096;
6587
6588           emit_insn (gen_probe_stack (GEN_INT (- probed)));
6589           while (probed + 8192 < INTVAL (operands[1]))
6590             emit_insn (gen_probe_stack (GEN_INT (- (probed += 8192))));
6591
6592           if (probed + 4096 < INTVAL (operands[1]))
6593             emit_insn (gen_probe_stack (GEN_INT (- INTVAL(operands[1]))));
6594         }
6595
6596       operands[1] = GEN_INT (- INTVAL (operands[1]));
6597       operands[2] = virtual_stack_dynamic_rtx;
6598     }
6599   else
6600     {
6601       rtx out_label = 0;
6602       rtx loop_label = gen_label_rtx ();
6603       rtx want = gen_reg_rtx (Pmode);
6604       rtx tmp = gen_reg_rtx (Pmode);
6605       rtx memref;
6606
6607       emit_insn (gen_subdi3 (want, stack_pointer_rtx,
6608                              force_reg (Pmode, operands[1])));
6609       emit_insn (gen_adddi3 (tmp, stack_pointer_rtx, GEN_INT (-4096)));
6610
6611       if (GET_CODE (operands[1]) != CONST_INT)
6612         {
6613           out_label = gen_label_rtx ();
6614           emit_insn (gen_cmpdi (want, tmp));
6615           emit_jump_insn (gen_bgeu (out_label));
6616         }
6617
6618       emit_label (loop_label);
6619       memref = gen_rtx_MEM (DImode, tmp);
6620       MEM_VOLATILE_P (memref) = 1;
6621       emit_move_insn (memref, const0_rtx);
6622       emit_insn (gen_adddi3 (tmp, tmp, GEN_INT(-8192)));
6623       emit_insn (gen_cmpdi (tmp, want));
6624       emit_jump_insn (gen_bgtu (loop_label));
6625
6626       memref = gen_rtx_MEM (DImode, want);
6627       MEM_VOLATILE_P (memref) = 1;
6628       emit_move_insn (memref, const0_rtx);
6629
6630       if (out_label)
6631         emit_label (out_label);
6632
6633       emit_move_insn (stack_pointer_rtx, want);
6634       emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
6635       DONE;
6636     }
6637 })
6638
6639 ;; This is used by alpha_expand_prolog to do the same thing as above,
6640 ;; except we cannot at that time generate new basic blocks, so we hide
6641 ;; the loop in this one insn.
6642
6643 (define_insn "prologue_stack_probe_loop"
6644   [(unspec_volatile [(match_operand:DI 0 "register_operand" "r")
6645                      (match_operand:DI 1 "register_operand" "r")]
6646                     UNSPECV_PSPL)]
6647   ""
6648 {
6649   operands[2] = gen_label_rtx ();
6650   (*targetm.asm_out.internal_label) (asm_out_file, "L",
6651                              CODE_LABEL_NUMBER (operands[2]));
6652
6653   return "stq $31,-8192(%1)\;subq %0,1,%0\;lda %1,-8192(%1)\;bne %0,%l2";
6654 }
6655   [(set_attr "length" "16")
6656    (set_attr "type" "multi")])
6657
6658 (define_expand "prologue"
6659   [(clobber (const_int 0))]
6660   ""
6661 {
6662   alpha_expand_prologue ();
6663   DONE;
6664 })
6665
6666 ;; These take care of emitting the ldgp insn in the prologue. This will be
6667 ;; an lda/ldah pair and we want to align them properly.  So we have two
6668 ;; unspec_volatile insns, the first of which emits the ldgp assembler macro
6669 ;; and the second of which emits nothing.  However, both are marked as type
6670 ;; IADD (the default) so the alignment code in alpha.c does the right thing
6671 ;; with them.
6672
6673 (define_expand "prologue_ldgp"
6674   [(set (match_dup 0)
6675         (unspec_volatile:DI [(match_dup 1) (match_dup 2)] UNSPECV_LDGP1))
6676    (set (match_dup 0)
6677         (unspec_volatile:DI [(match_dup 0) (match_dup 2)] UNSPECV_PLDGP2))]
6678   ""
6679 {
6680   operands[0] = pic_offset_table_rtx;
6681   operands[1] = gen_rtx_REG (Pmode, 27);
6682   operands[2] = (TARGET_EXPLICIT_RELOCS
6683                  ? GEN_INT (alpha_next_sequence_number++)
6684                  : const0_rtx);
6685 })
6686
6687 (define_insn "*ldgp_er_1"
6688   [(set (match_operand:DI 0 "register_operand" "=r")
6689         (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "r")
6690                              (match_operand 2 "const_int_operand" "")]
6691                             UNSPECV_LDGP1))]
6692   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
6693   "ldah %0,0(%1)\t\t!gpdisp!%2"
6694   [(set_attr "cannot_copy" "true")])
6695
6696 (define_insn "*ldgp_er_2"
6697   [(set (match_operand:DI 0 "register_operand" "=r")
6698         (unspec:DI [(match_operand:DI 1 "register_operand" "r")
6699                     (match_operand 2 "const_int_operand" "")]
6700                    UNSPEC_LDGP2))]
6701   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
6702   "lda %0,0(%1)\t\t!gpdisp!%2"
6703   [(set_attr "cannot_copy" "true")])
6704
6705 (define_insn "*prologue_ldgp_er_2"
6706   [(set (match_operand:DI 0 "register_operand" "=r")
6707         (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "r")
6708                              (match_operand 2 "const_int_operand" "")]
6709                             UNSPECV_PLDGP2))]
6710   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
6711   "lda %0,0(%1)\t\t!gpdisp!%2\n$%~..ng:"
6712   [(set_attr "cannot_copy" "true")])
6713
6714 (define_insn "*prologue_ldgp_1"
6715   [(set (match_operand:DI 0 "register_operand" "=r")
6716         (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "r")
6717                              (match_operand 2 "const_int_operand" "")]
6718                             UNSPECV_LDGP1))]
6719   ""
6720   "ldgp %0,0(%1)\n$%~..ng:"
6721   [(set_attr "cannot_copy" "true")])
6722
6723 (define_insn "*prologue_ldgp_2"
6724   [(set (match_operand:DI 0 "register_operand" "=r")
6725         (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "r")
6726                              (match_operand 2 "const_int_operand" "")]
6727                             UNSPECV_PLDGP2))]
6728   ""
6729   "")
6730
6731 ;; The _mcount profiling hook has special calling conventions, and
6732 ;; does not clobber all the registers that a normal call would.  So
6733 ;; hide the fact this is a call at all.
6734
6735 (define_insn "prologue_mcount"
6736   [(unspec_volatile [(const_int 0)] UNSPECV_MCOUNT)]
6737   ""
6738 {
6739   if (TARGET_EXPLICIT_RELOCS)
6740     /* Note that we cannot use a lituse_jsr reloc, since _mcount
6741        cannot be called via the PLT.  */
6742     return "ldq $28,_mcount($29)\t\t!literal\;jsr $28,($28),_mcount";
6743   else
6744     return "lda $28,_mcount\;jsr $28,($28),_mcount";
6745 }
6746   [(set_attr "type" "multi")
6747    (set_attr "length" "8")])
6748
6749 (define_insn "init_fp"
6750   [(set (match_operand:DI 0 "register_operand" "=r")
6751         (match_operand:DI 1 "register_operand" "r"))
6752    (clobber (mem:BLK (match_operand:DI 2 "register_operand" "=r")))]
6753   ""
6754   "bis $31,%1,%0")
6755
6756 (define_expand "epilogue"
6757   [(return)]
6758   ""
6759 {
6760   alpha_expand_epilogue ();
6761 })
6762
6763 (define_expand "sibcall_epilogue"
6764   [(return)]
6765   "TARGET_ABI_OSF"
6766 {
6767   alpha_expand_epilogue ();
6768   DONE;
6769 })
6770
6771 (define_expand "builtin_longjmp"
6772   [(use (match_operand:DI 0 "register_operand" "r"))]
6773   "TARGET_ABI_OSF"
6774 {
6775   /* The elements of the buffer are, in order:  */
6776   rtx fp = gen_rtx_MEM (Pmode, operands[0]);
6777   rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0], 8));
6778   rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0], 16));
6779   rtx pv = gen_rtx_REG (Pmode, 27);
6780
6781   /* This bit is the same as expand_builtin_longjmp.  */
6782   emit_move_insn (hard_frame_pointer_rtx, fp);
6783   emit_move_insn (pv, lab);
6784   emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
6785   emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
6786   emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
6787
6788   /* Load the label we are jumping through into $27 so that we know
6789      where to look for it when we get back to setjmp's function for
6790      restoring the gp.  */
6791   emit_jump_insn (gen_builtin_longjmp_internal (pv));
6792   emit_barrier ();
6793   DONE;
6794 })
6795
6796 ;; This is effectively a copy of indirect_jump, but constrained such
6797 ;; that register renaming cannot foil our cunning plan with $27.
6798 (define_insn "builtin_longjmp_internal"
6799   [(set (pc)
6800         (unspec_volatile [(match_operand:DI 0 "register_operand" "c")]
6801                          UNSPECV_LONGJMP))]
6802   ""
6803   "jmp $31,(%0),0"
6804   [(set_attr "type" "ibr")])
6805
6806 (define_insn "*builtin_setjmp_receiver_er_sl_1"
6807   [(unspec_volatile [(label_ref (match_operand 0 "" ""))] UNSPECV_SETJMPR)]
6808   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF && TARGET_AS_CAN_SUBTRACT_LABELS"
6809   "lda $27,$LSJ%=-%l0($27)\n$LSJ%=:")
6810   
6811 (define_insn "*builtin_setjmp_receiver_er_1"
6812   [(unspec_volatile [(label_ref (match_operand 0 "" ""))] UNSPECV_SETJMPR)]
6813   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
6814   "br $27,$LSJ%=\n$LSJ%=:"
6815   [(set_attr "type" "ibr")])
6816
6817 (define_split
6818   [(unspec_volatile [(label_ref (match_operand 0 "" ""))] UNSPECV_SETJMPR)]
6819   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF
6820    && prev_nonnote_insn (insn) == operands[0]"
6821   [(const_int 0)]
6822   "
6823 {
6824   emit_note (NOTE_INSN_DELETED);
6825   DONE;
6826 }")
6827
6828 (define_insn "*builtin_setjmp_receiver_1"
6829   [(unspec_volatile [(label_ref (match_operand 0 "" ""))] UNSPECV_SETJMPR)]
6830   "TARGET_ABI_OSF"
6831   "br $27,$LSJ%=\n$LSJ%=:\;ldgp $29,0($27)"
6832   [(set_attr "length" "12")
6833    (set_attr "type" "multi")])
6834
6835 (define_expand "builtin_setjmp_receiver_er"
6836   [(unspec_volatile [(label_ref (match_operand 0 "" ""))] UNSPECV_SETJMPR)
6837    (set (match_dup 1)
6838         (unspec_volatile:DI [(match_dup 2) (match_dup 3)] UNSPECV_LDGP1))
6839    (set (match_dup 1)
6840         (unspec:DI [(match_dup 1) (match_dup 3)] UNSPEC_LDGP2))]
6841   ""
6842 {
6843   operands[1] = pic_offset_table_rtx;
6844   operands[2] = gen_rtx_REG (Pmode, 27);
6845   operands[3] = GEN_INT (alpha_next_sequence_number++);
6846 })
6847
6848 (define_expand "builtin_setjmp_receiver"
6849   [(unspec_volatile [(label_ref (match_operand 0 "" ""))] UNSPECV_SETJMPR)]
6850   "TARGET_ABI_OSF"
6851 {
6852   if (TARGET_EXPLICIT_RELOCS)
6853     {
6854       emit_insn (gen_builtin_setjmp_receiver_er (operands[0]));
6855       DONE;
6856     }
6857 })
6858
6859 (define_expand "exception_receiver_er"
6860   [(set (match_dup 0)
6861         (unspec_volatile:DI [(match_dup 1) (match_dup 2)] UNSPECV_LDGP1))
6862    (set (match_dup 0)
6863         (unspec:DI [(match_dup 0) (match_dup 2)] UNSPEC_LDGP2))]
6864   ""
6865 {
6866   operands[0] = pic_offset_table_rtx;
6867   operands[1] = gen_rtx_REG (Pmode, 26);
6868   operands[2] = GEN_INT (alpha_next_sequence_number++);
6869 })
6870
6871 (define_expand "exception_receiver"
6872   [(unspec_volatile [(match_dup 0)] UNSPECV_EHR)]
6873   "TARGET_ABI_OSF"
6874 {
6875   if (TARGET_LD_BUGGY_LDGP)
6876     operands[0] = alpha_gp_save_rtx ();
6877   else if (TARGET_EXPLICIT_RELOCS)
6878     {
6879       emit_insn (gen_exception_receiver_er ());
6880       DONE;
6881     }
6882   else
6883     operands[0] = const0_rtx;
6884 })
6885
6886 (define_insn "*exception_receiver_1"
6887   [(unspec_volatile [(const_int 0)] UNSPECV_EHR)]
6888   "! TARGET_LD_BUGGY_LDGP"
6889   "ldgp $29,0($26)"
6890   [(set_attr "length" "8")
6891    (set_attr "type" "multi")])
6892
6893 (define_insn "*exception_receiver_2"
6894   [(unspec_volatile [(match_operand:DI 0 "memory_operand" "m")] UNSPECV_EHR)]
6895   "TARGET_LD_BUGGY_LDGP"
6896   "ldq $29,%0"
6897   [(set_attr "type" "ild")])
6898
6899 (define_expand "nonlocal_goto_receiver"
6900   [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
6901    (set (reg:DI 27) (mem:DI (reg:DI 29)))
6902    (unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
6903    (use (reg:DI 27))]
6904   "TARGET_ABI_OPEN_VMS"
6905   "")
6906
6907 (define_insn "arg_home"
6908   [(unspec [(const_int 0)] UNSPEC_ARG_HOME)
6909    (use (reg:DI 1))
6910    (use (reg:DI 25))
6911    (use (reg:DI 16))
6912    (use (reg:DI 17))
6913    (use (reg:DI 18))
6914    (use (reg:DI 19))
6915    (use (reg:DI 20))
6916    (use (reg:DI 21))
6917    (use (reg:DI 48))
6918    (use (reg:DI 49))
6919    (use (reg:DI 50))
6920    (use (reg:DI 51))
6921    (use (reg:DI 52))
6922    (use (reg:DI 53))
6923    (clobber (mem:BLK (const_int 0)))
6924    (clobber (reg:DI 24))
6925    (clobber (reg:DI 25))
6926    (clobber (reg:DI 0))]
6927   "TARGET_ABI_OPEN_VMS"
6928   "lda $0,OTS$HOME_ARGS\;ldq $0,8($0)\;jsr $0,OTS$HOME_ARGS"
6929   [(set_attr "length" "16")
6930    (set_attr "type" "multi")])
6931
6932 ;; Load the CIW into r2 for calling __T3E_MISMATCH
6933
6934 (define_expand "umk_mismatch_args"
6935   [(set:DI (match_dup 1) (mem:DI (plus:DI (reg:DI 15) (const_int -16))))
6936    (set:DI (match_dup 2) (mem:DI (plus:DI (match_dup 1) (const_int -32))))
6937    (set:DI (reg:DI 1) (match_operand:DI 0 "const_int_operand" ""))
6938    (set:DI (match_dup 3) (plus:DI (mult:DI (reg:DI 25)
6939                                            (const_int 8))
6940                                   (match_dup 2)))
6941    (set:DI (reg:DI 2) (mem:DI (match_dup 3)))]
6942   "TARGET_ABI_UNICOSMK"
6943 {
6944   operands[1] = gen_reg_rtx (DImode);
6945   operands[2] = gen_reg_rtx (DImode);
6946   operands[3] = gen_reg_rtx (DImode);
6947 })
6948
6949 (define_insn "arg_home_umk"
6950   [(unspec [(const_int 0)] UNSPEC_ARG_HOME)
6951    (use (reg:DI 1))
6952    (use (reg:DI 2))
6953    (use (reg:DI 16))
6954    (use (reg:DI 17))
6955    (use (reg:DI 18))
6956    (use (reg:DI 19))
6957    (use (reg:DI 20))
6958    (use (reg:DI 21))
6959    (use (reg:DI 48))
6960    (use (reg:DI 49))
6961    (use (reg:DI 50))
6962    (use (reg:DI 51))
6963    (use (reg:DI 52))
6964    (use (reg:DI 53))
6965    (clobber (mem:BLK (const_int 0)))
6966    (parallel [
6967    (clobber (reg:DI 22))
6968    (clobber (reg:DI 23))
6969    (clobber (reg:DI 24))
6970    (clobber (reg:DI 0))
6971    (clobber (reg:DI 1))
6972    (clobber (reg:DI 2))
6973    (clobber (reg:DI 3))
6974    (clobber (reg:DI 4))
6975    (clobber (reg:DI 5))
6976    (clobber (reg:DI 6))
6977    (clobber (reg:DI 7))
6978    (clobber (reg:DI 8))])]
6979   "TARGET_ABI_UNICOSMK"
6980   "laum $4,__T3E_MISMATCH($31)\;sll $4,32,$4\;lalm $4,__T3E_MISMATCH($4)\;lal $4,__T3E_MISMATCH($4)\;jsr $3,($4)"
6981   [(set_attr "length" "16")
6982    (set_attr "type" "multi")])
6983
6984 ;; Prefetch data.  
6985 ;;
6986 ;; On EV4, these instructions are nops -- no load occurs.
6987 ;;
6988 ;; On EV5, these instructions act as a normal load, and thus can trap
6989 ;; if the address is invalid.  The OS may (or may not) handle this in
6990 ;; the entMM fault handler and suppress the fault.  If so, then this
6991 ;; has the effect of a read prefetch instruction.
6992 ;;
6993 ;; On EV6, these become official prefetch instructions.
6994
6995 (define_insn "prefetch"
6996   [(prefetch (match_operand:DI 0 "address_operand" "p")
6997              (match_operand:DI 1 "const_int_operand" "n")
6998              (match_operand:DI 2 "const_int_operand" "n"))]
6999   "TARGET_FIXUP_EV5_PREFETCH || TARGET_CPU_EV6"
7000 {
7001   /* Interpret "no temporal locality" as this data should be evicted once
7002      it is used.  The "evict next" alternatives load the data into the cache
7003      and leave the LRU eviction counter pointing to that block.  */
7004   static const char * const alt[2][2] = {
7005     { 
7006       "ldq $31,%a0",            /* read, evict next */
7007       "ldl $31,%a0",            /* read, evict last */
7008     },
7009     {
7010       "ldt $f31,%a0",           /* write, evict next */
7011       "lds $f31,%a0",           /* write, evict last */
7012     }
7013   };
7014
7015   bool write = INTVAL (operands[1]) != 0;
7016   bool lru = INTVAL (operands[2]) != 0;
7017
7018   return alt[write][lru];
7019 }
7020   [(set_attr "type" "ild")])
7021
7022 ;; Close the trap shadow of preceding instructions.  This is generated
7023 ;; by alpha_reorg.
7024
7025 (define_insn "trapb"
7026   [(unspec_volatile [(const_int 0)] UNSPECV_TRAPB)]
7027   ""
7028   "trapb"
7029   [(set_attr "type" "misc")])
7030
7031 ;; No-op instructions used by machine-dependent reorg to preserve
7032 ;; alignment for instruction issue.
7033 ;; The Unicos/Mk assembler does not support these opcodes.
7034
7035 (define_insn "nop"
7036   [(const_int 0)]
7037   ""
7038   "bis $31,$31,$31"
7039   [(set_attr "type" "ilog")])
7040
7041 (define_insn "fnop"
7042   [(const_int 1)]
7043   "TARGET_FP"
7044   "cpys $f31,$f31,$f31"
7045   [(set_attr "type" "fcpys")])
7046
7047 (define_insn "unop"
7048   [(const_int 2)]
7049   ""
7050   "ldq_u $31,0($30)")
7051
7052 ;; On Unicos/Mk we use a macro for aligning code.
7053
7054 (define_insn "realign"
7055   [(unspec_volatile [(match_operand 0 "immediate_operand" "i")]
7056                     UNSPECV_REALIGN)]
7057   ""
7058 {
7059   if (TARGET_ABI_UNICOSMK)
7060     return "gcc@code@align %0";
7061   else
7062     return ".align %0 #realign";
7063 })
7064 \f
7065 ;; Instructions to be emitted from __builtins.
7066
7067 (define_insn "builtin_cmpbge"
7068   [(set (match_operand:DI 0 "register_operand" "=r")
7069         (unspec:DI [(match_operand:DI 1 "reg_or_0_operand" "rJ")
7070                     (match_operand:DI 2 "reg_or_8bit_operand" "rI")]
7071                    UNSPEC_CMPBGE))]
7072   ""
7073   "cmpbge %r1,%2,%0"
7074   ;; The EV6 data sheets list this as ILOG.  OTOH, EV6 doesn't 
7075   ;; actually differentiate between ILOG and ICMP in the schedule.
7076   [(set_attr "type" "icmp")])
7077
7078 (define_expand "builtin_extbl"
7079   [(match_operand:DI 0 "register_operand" "")
7080    (match_operand:DI 1 "reg_or_0_operand" "")
7081    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7082   ""
7083 {
7084   rtx (*gen) (rtx, rtx, rtx, rtx);
7085   if (WORDS_BIG_ENDIAN)
7086     gen = gen_extxl_be;
7087   else
7088     gen = gen_extxl_le;
7089   emit_insn ((*gen) (operands[0], operands[1], GEN_INT (8), operands[2]));
7090   DONE;
7091 })
7092
7093 (define_expand "builtin_extwl"
7094   [(match_operand:DI 0 "register_operand" "")
7095    (match_operand:DI 1 "reg_or_0_operand" "")
7096    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7097   ""
7098 {
7099   rtx (*gen) (rtx, rtx, rtx, rtx);
7100   if (WORDS_BIG_ENDIAN)
7101     gen = gen_extxl_be;
7102   else
7103     gen = gen_extxl_le;
7104   emit_insn ((*gen) (operands[0], operands[1], GEN_INT (16), operands[2]));
7105   DONE;
7106 })
7107
7108 (define_expand "builtin_extll"
7109   [(match_operand:DI 0 "register_operand" "")
7110    (match_operand:DI 1 "reg_or_0_operand" "")
7111    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7112   ""
7113 {
7114   rtx (*gen) (rtx, rtx, rtx, rtx);
7115   if (WORDS_BIG_ENDIAN)
7116     gen = gen_extxl_be;
7117   else
7118     gen = gen_extxl_le;
7119   emit_insn ((*gen) (operands[0], operands[1], GEN_INT (32), operands[2]));
7120   DONE;
7121 })
7122
7123 (define_expand "builtin_extql"
7124   [(match_operand:DI 0 "register_operand" "")
7125    (match_operand:DI 1 "reg_or_0_operand" "")
7126    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7127   ""
7128 {
7129   rtx (*gen) (rtx, rtx, rtx, rtx);
7130   if (WORDS_BIG_ENDIAN)
7131     gen = gen_extxl_be;
7132   else
7133     gen = gen_extxl_le;
7134   emit_insn ((*gen) (operands[0], operands[1], GEN_INT (64), operands[2]));
7135   DONE;
7136 })
7137
7138 (define_expand "builtin_extwh"
7139   [(match_operand:DI 0 "register_operand" "")
7140    (match_operand:DI 1 "reg_or_0_operand" "")
7141    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7142   ""
7143 {
7144   rtx (*gen) (rtx, rtx, rtx);
7145   if (WORDS_BIG_ENDIAN)
7146     gen = gen_extwh_be;
7147   else
7148     gen = gen_extwh_le;
7149   emit_insn ((*gen) (operands[0], operands[1], operands[2]));
7150   DONE;
7151 })
7152
7153 (define_expand "builtin_extlh"
7154   [(match_operand:DI 0 "register_operand" "")
7155    (match_operand:DI 1 "reg_or_0_operand" "")
7156    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7157   ""
7158 {
7159   rtx (*gen) (rtx, rtx, rtx);
7160   if (WORDS_BIG_ENDIAN)
7161     gen = gen_extlh_be;
7162   else
7163     gen = gen_extlh_le;
7164   emit_insn ((*gen) (operands[0], operands[1], operands[2]));
7165   DONE;
7166 })
7167
7168 (define_expand "builtin_extqh"
7169   [(match_operand:DI 0 "register_operand" "")
7170    (match_operand:DI 1 "reg_or_0_operand" "")
7171    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7172   ""
7173 {
7174   rtx (*gen) (rtx, rtx, rtx);
7175   if (WORDS_BIG_ENDIAN)
7176     gen = gen_extqh_be;
7177   else
7178     gen = gen_extqh_le;
7179   emit_insn ((*gen) (operands[0], operands[1], operands[2]));
7180   DONE;
7181 })
7182
7183 (define_expand "builtin_insbl"
7184   [(match_operand:DI 0 "register_operand" "")
7185    (match_operand:DI 1 "reg_or_0_operand" "")
7186    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7187   ""
7188 {
7189   rtx (*gen) (rtx, rtx, rtx);
7190   if (WORDS_BIG_ENDIAN)
7191     gen = gen_insbl_be;
7192   else
7193     gen = gen_insbl_le;
7194   operands[1] = gen_lowpart (QImode, operands[1]);
7195   emit_insn ((*gen) (operands[0], operands[1], operands[2]));
7196   DONE;
7197 })
7198
7199 (define_expand "builtin_inswl"
7200   [(match_operand:DI 0 "register_operand" "")
7201    (match_operand:DI 1 "reg_or_0_operand" "")
7202    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7203   ""
7204 {
7205   rtx (*gen) (rtx, rtx, rtx);
7206   if (WORDS_BIG_ENDIAN)
7207     gen = gen_inswl_be;
7208   else
7209     gen = gen_inswl_le;
7210   operands[1] = gen_lowpart (HImode, operands[1]);
7211   emit_insn ((*gen) (operands[0], operands[1], operands[2]));
7212   DONE;
7213 })
7214
7215 (define_expand "builtin_insll"
7216   [(match_operand:DI 0 "register_operand" "")
7217    (match_operand:DI 1 "reg_or_0_operand" "")
7218    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7219   ""
7220 {
7221   rtx (*gen) (rtx, rtx, rtx);
7222   if (WORDS_BIG_ENDIAN)
7223     gen = gen_insll_be;
7224   else
7225     gen = gen_insll_le;
7226   operands[1] = gen_lowpart (SImode, operands[1]);
7227   emit_insn ((*gen) (operands[0], operands[1], operands[2]));
7228   emit_insn ((*gen) (operands[0], operands[1], operands[2]));
7229   DONE;
7230 })
7231
7232 (define_expand "builtin_insql"
7233   [(match_operand:DI 0 "register_operand" "")
7234    (match_operand:DI 1 "reg_or_0_operand" "")
7235    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7236   ""
7237 {
7238   rtx (*gen) (rtx, rtx, rtx);
7239   if (WORDS_BIG_ENDIAN)
7240     gen = gen_insql_be;
7241   else
7242     gen = gen_insql_le;
7243   emit_insn ((*gen) (operands[0], operands[1], operands[2]));
7244   DONE;
7245 })
7246
7247 (define_expand "builtin_inswh"
7248   [(match_operand:DI 0 "register_operand" "")
7249    (match_operand:DI 1 "register_operand" "")
7250    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7251   ""
7252 {
7253   emit_insn (gen_insxh (operands[0], operands[1], GEN_INT (16), operands[2]));
7254   DONE;
7255 })
7256
7257 (define_expand "builtin_inslh"
7258   [(match_operand:DI 0 "register_operand" "")
7259    (match_operand:DI 1 "register_operand" "")
7260    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7261   ""
7262 {
7263   emit_insn (gen_insxh (operands[0], operands[1], GEN_INT (32), operands[2]));
7264   DONE;
7265 })
7266
7267 (define_expand "builtin_insqh"
7268   [(match_operand:DI 0 "register_operand" "")
7269    (match_operand:DI 1 "register_operand" "")
7270    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7271   ""
7272 {
7273   emit_insn (gen_insxh (operands[0], operands[1], GEN_INT (64), operands[2]));
7274   DONE;
7275 })
7276
7277 (define_expand "builtin_mskbl"
7278   [(match_operand:DI 0 "register_operand" "")
7279    (match_operand:DI 1 "reg_or_0_operand" "")
7280    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7281   ""
7282 {
7283   rtx (*gen) (rtx, rtx, rtx, rtx);
7284   rtx mask;
7285   if (WORDS_BIG_ENDIAN)
7286     gen = gen_mskxl_be;
7287   else
7288     gen = gen_mskxl_le;
7289   mask = GEN_INT (0xff);
7290   emit_insn ((*gen) (operands[0], operands[1], mask, operands[2]));
7291   DONE;
7292 })
7293
7294 (define_expand "builtin_mskwl"
7295   [(match_operand:DI 0 "register_operand" "")
7296    (match_operand:DI 1 "reg_or_0_operand" "")
7297    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7298   ""
7299 {
7300   rtx (*gen) (rtx, rtx, rtx, rtx);
7301   rtx mask;
7302   if (WORDS_BIG_ENDIAN)
7303     gen = gen_mskxl_be;
7304   else
7305     gen = gen_mskxl_le;
7306   mask = GEN_INT (0xffff);
7307   emit_insn ((*gen) (operands[0], operands[1], mask, operands[2]));
7308   DONE;
7309 })
7310
7311 (define_expand "builtin_mskll"
7312   [(match_operand:DI 0 "register_operand" "")
7313    (match_operand:DI 1 "reg_or_0_operand" "")
7314    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7315   ""
7316 {
7317   rtx (*gen) (rtx, rtx, rtx, rtx);
7318   rtx mask;
7319   if (WORDS_BIG_ENDIAN)
7320     gen = gen_mskxl_be;
7321   else
7322     gen = gen_mskxl_le;
7323   mask = immed_double_const (0xffffffff, 0, DImode);
7324   emit_insn ((*gen) (operands[0], operands[1], mask, operands[2]));
7325   DONE;
7326 })
7327
7328 (define_expand "builtin_mskql"
7329   [(match_operand:DI 0 "register_operand" "")
7330    (match_operand:DI 1 "reg_or_0_operand" "")
7331    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7332   ""
7333 {
7334   rtx (*gen) (rtx, rtx, rtx, rtx);
7335   rtx mask;
7336   if (WORDS_BIG_ENDIAN)
7337     gen = gen_mskxl_be;
7338   else
7339     gen = gen_mskxl_le;
7340   mask = constm1_rtx;
7341   emit_insn ((*gen) (operands[0], operands[1], mask, operands[2]));
7342   DONE;
7343 })
7344
7345 (define_expand "builtin_mskwh"
7346   [(match_operand:DI 0 "register_operand" "")
7347    (match_operand:DI 1 "register_operand" "")
7348    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7349   ""
7350 {
7351   emit_insn (gen_mskxh (operands[0], operands[1], GEN_INT (16), operands[2]));
7352   DONE;
7353 })
7354
7355 (define_expand "builtin_msklh"
7356   [(match_operand:DI 0 "register_operand" "")
7357    (match_operand:DI 1 "register_operand" "")
7358    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7359   ""
7360 {
7361   emit_insn (gen_mskxh (operands[0], operands[1], GEN_INT (32), operands[2]));
7362   DONE;
7363 })
7364
7365 (define_expand "builtin_mskqh"
7366   [(match_operand:DI 0 "register_operand" "")
7367    (match_operand:DI 1 "register_operand" "")
7368    (match_operand:DI 2 "reg_or_8bit_operand" "")]
7369   ""
7370 {
7371   emit_insn (gen_mskxh (operands[0], operands[1], GEN_INT (64), operands[2]));
7372   DONE;
7373 })
7374
7375 (define_expand "builtin_zap"
7376   [(set (match_operand:DI 0 "register_operand" "")
7377         (and:DI (unspec:DI
7378                   [(match_operand:DI 2 "reg_or_const_int_operand" "")]
7379                   UNSPEC_ZAP)
7380                 (match_operand:DI 1 "reg_or_const_int_operand" "")))]
7381   ""
7382 {
7383   if (GET_CODE (operands[2]) == CONST_INT)
7384     {
7385       rtx mask = alpha_expand_zap_mask (INTVAL (operands[2]));
7386
7387       if (mask == const0_rtx)
7388         {
7389           emit_move_insn (operands[0], const0_rtx);
7390           DONE;
7391         }
7392       if (mask == constm1_rtx)
7393         {
7394           emit_move_insn (operands[0], operands[1]);
7395           DONE;
7396         }
7397
7398       operands[1] = force_reg (DImode, operands[1]);
7399       emit_insn (gen_anddi3 (operands[0], operands[1], mask));
7400       DONE;
7401     }
7402
7403   operands[1] = force_reg (DImode, operands[1]);
7404   operands[2] = gen_lowpart (QImode, operands[2]);
7405 })
7406
7407 (define_insn "*builtin_zap_1"
7408   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r")
7409         (and:DI (unspec:DI
7410                   [(match_operand:QI 2 "reg_or_const_int_operand" "n,n,r,r")]
7411                   UNSPEC_ZAP)
7412                 (match_operand:DI 1 "reg_or_const_int_operand" "n,r,J,r")))]
7413   ""
7414   "@
7415    #
7416    #
7417    bis $31,$31,%0
7418    zap %r1,%2,%0"
7419   [(set_attr "type" "shift,shift,ilog,shift")])
7420
7421 (define_split
7422   [(set (match_operand:DI 0 "register_operand" "")
7423         (and:DI (unspec:DI
7424                   [(match_operand:QI 2 "const_int_operand" "")]
7425                   UNSPEC_ZAP)
7426                 (match_operand:DI 1 "const_int_operand" "")))]
7427   ""
7428   [(const_int 0)]
7429 {
7430   rtx mask = alpha_expand_zap_mask (INTVAL (operands[2]));
7431   if (HOST_BITS_PER_WIDE_INT >= 64 || GET_CODE (mask) == CONST_INT)
7432     operands[1] = gen_int_mode (INTVAL (operands[1]) & INTVAL (mask), DImode);
7433   else
7434     {
7435       HOST_WIDE_INT c_lo = INTVAL (operands[1]);
7436       HOST_WIDE_INT c_hi = (c_lo < 0 ? -1 : 0);
7437       operands[1] = immed_double_const (c_lo & CONST_DOUBLE_LOW (mask),
7438                                         c_hi & CONST_DOUBLE_HIGH (mask),
7439                                         DImode);
7440     }
7441   emit_move_insn (operands[0], operands[1]);
7442   DONE;
7443 })
7444
7445 (define_split
7446   [(set (match_operand:DI 0 "register_operand" "")
7447         (and:DI (unspec:DI
7448                   [(match_operand:QI 2 "const_int_operand" "")]
7449                   UNSPEC_ZAP)
7450                 (match_operand:DI 1 "register_operand" "")))]
7451   ""
7452   [(set (match_dup 0)
7453         (and:DI (match_dup 1) (match_dup 2)))]
7454 {
7455   operands[2] = alpha_expand_zap_mask (INTVAL (operands[2]));
7456   if (operands[2] == const0_rtx)
7457     {
7458       emit_move_insn (operands[0], const0_rtx);
7459       DONE;
7460     }
7461   if (operands[2] == constm1_rtx)
7462     {
7463       emit_move_insn (operands[0], operands[1]);
7464       DONE;
7465     }
7466 })
7467
7468 (define_expand "builtin_zapnot"
7469   [(set (match_operand:DI 0 "register_operand" "")
7470         (and:DI (unspec:DI
7471                   [(not:QI (match_operand:DI 2 "reg_or_const_int_operand" ""))]
7472                   UNSPEC_ZAP)
7473                 (match_operand:DI 1 "reg_or_const_int_operand" "")))]
7474   ""
7475 {
7476   if (GET_CODE (operands[2]) == CONST_INT)
7477     {
7478       rtx mask = alpha_expand_zap_mask (~ INTVAL (operands[2]));
7479
7480       if (mask == const0_rtx)
7481         {
7482           emit_move_insn (operands[0], const0_rtx);
7483           DONE;
7484         }
7485       if (mask == constm1_rtx)
7486         {
7487           emit_move_insn (operands[0], operands[1]);
7488           DONE;
7489         }
7490
7491       operands[1] = force_reg (DImode, operands[1]);
7492       emit_insn (gen_anddi3 (operands[0], operands[1], mask));
7493       DONE;
7494     }
7495
7496   operands[1] = force_reg (DImode, operands[1]);
7497   operands[2] = gen_lowpart (QImode, operands[2]);
7498 })
7499
7500 (define_insn "*builtin_zapnot_1"
7501   [(set (match_operand:DI 0 "register_operand" "=r")
7502         (and:DI (unspec:DI
7503                   [(not:QI (match_operand:QI 2 "register_operand" "r"))]
7504                   UNSPEC_ZAP)
7505                 (match_operand:DI 1 "reg_or_0_operand" "rJ")))]
7506   ""
7507   "zapnot %r1,%2,%0"
7508   [(set_attr "type" "shift")])
7509
7510 (define_insn "builtin_amask"
7511   [(set (match_operand:DI 0 "register_operand" "=r")
7512         (unspec:DI [(match_operand:DI 1 "reg_or_8bit_operand" "rI")]
7513                    UNSPEC_AMASK))]
7514   ""
7515   "amask %1,%0"
7516   [(set_attr "type" "ilog")])
7517
7518 (define_insn "builtin_implver"
7519   [(set (match_operand:DI 0 "register_operand" "=r")
7520         (unspec:DI [(const_int 0)] UNSPEC_IMPLVER))]
7521   ""
7522   "implver %0"
7523   [(set_attr "type" "ilog")])
7524
7525 (define_insn "builtin_rpcc"
7526   [(set (match_operand:DI 0 "register_operand" "=r")
7527         (unspec_volatile:DI [(const_int 0)] UNSPECV_RPCC))]
7528   ""
7529   "rpcc %0"
7530   [(set_attr "type" "ilog")])
7531
7532 (define_expand "builtin_minub8"
7533   [(match_operand:DI 0 "register_operand" "")
7534    (match_operand:DI 1 "reg_or_0_operand" "")
7535    (match_operand:DI 2 "reg_or_0_operand" "")]
7536   "TARGET_MAX"
7537 {
7538   alpha_expand_builtin_vector_binop (gen_uminv8qi3, V8QImode, operands[0],
7539                                      operands[1], operands[2]);
7540   DONE;
7541 })
7542
7543 (define_expand "builtin_minsb8"
7544   [(match_operand:DI 0 "register_operand" "")
7545    (match_operand:DI 1 "reg_or_0_operand" "")
7546    (match_operand:DI 2 "reg_or_0_operand" "")]
7547   "TARGET_MAX"
7548 {
7549   alpha_expand_builtin_vector_binop (gen_sminv8qi3, V8QImode, operands[0],
7550                                      operands[1], operands[2]);
7551   DONE;
7552 })
7553
7554 (define_expand "builtin_minuw4"
7555   [(match_operand:DI 0 "register_operand" "")
7556    (match_operand:DI 1 "reg_or_0_operand" "")
7557    (match_operand:DI 2 "reg_or_0_operand" "")]
7558   "TARGET_MAX"
7559 {
7560   alpha_expand_builtin_vector_binop (gen_uminv4hi3, V4HImode, operands[0],
7561                                      operands[1], operands[2]);
7562   DONE;
7563 })
7564
7565 (define_expand "builtin_minsw4"
7566   [(match_operand:DI 0 "register_operand" "")
7567    (match_operand:DI 1 "reg_or_0_operand" "")
7568    (match_operand:DI 2 "reg_or_0_operand" "")]
7569   "TARGET_MAX"
7570 {
7571   alpha_expand_builtin_vector_binop (gen_sminv4hi3, V4HImode, operands[0],
7572                                      operands[1], operands[2]);
7573   DONE;
7574 })
7575
7576 (define_expand "builtin_maxub8"
7577   [(match_operand:DI 0 "register_operand" "")
7578    (match_operand:DI 1 "reg_or_0_operand" "")
7579    (match_operand:DI 2 "reg_or_0_operand" "")]
7580   "TARGET_MAX"
7581 {
7582   alpha_expand_builtin_vector_binop (gen_umaxv8qi3, V8QImode, operands[0],
7583                                      operands[1], operands[2]);
7584   DONE;
7585 })
7586
7587 (define_expand "builtin_maxsb8"
7588   [(match_operand:DI 0 "register_operand" "")
7589    (match_operand:DI 1 "reg_or_0_operand" "")
7590    (match_operand:DI 2 "reg_or_0_operand" "")]
7591   "TARGET_MAX"
7592 {
7593   alpha_expand_builtin_vector_binop (gen_smaxv8qi3, V8QImode, operands[0],
7594                                      operands[1], operands[2]);
7595   DONE;
7596 })
7597
7598 (define_expand "builtin_maxuw4"
7599   [(match_operand:DI 0 "register_operand" "")
7600    (match_operand:DI 1 "reg_or_0_operand" "")
7601    (match_operand:DI 2 "reg_or_0_operand" "")]
7602   "TARGET_MAX"
7603 {
7604   alpha_expand_builtin_vector_binop (gen_umaxv4hi3, V4HImode, operands[0],
7605                                      operands[1], operands[2]);
7606   DONE;
7607 })
7608
7609 (define_expand "builtin_maxsw4"
7610   [(match_operand:DI 0 "register_operand" "")
7611    (match_operand:DI 1 "reg_or_0_operand" "")
7612    (match_operand:DI 2 "reg_or_0_operand" "")]
7613   "TARGET_MAX"
7614 {
7615   alpha_expand_builtin_vector_binop (gen_smaxv4hi3, V4HImode, operands[0],
7616                                      operands[1], operands[2]);
7617   DONE;
7618 })
7619
7620 (define_insn "builtin_perr"
7621   [(set (match_operand:DI 0 "register_operand" "=r")
7622         (unspec:DI [(match_operand:DI 1 "reg_or_0_operand" "%rJ")
7623                     (match_operand:DI 2 "reg_or_8bit_operand" "rJ")]
7624                    UNSPEC_PERR))]
7625   "TARGET_MAX"
7626   "perr %r1,%r2,%0"
7627   [(set_attr "type" "mvi")])
7628
7629 (define_expand "builtin_pklb"
7630   [(set (match_operand:DI 0 "register_operand" "")
7631         (vec_concat:V8QI
7632           (vec_concat:V4QI
7633             (truncate:V2QI (match_operand:DI 1 "register_operand" ""))
7634             (match_dup 2))
7635           (match_dup 3)))]
7636   "TARGET_MAX"
7637 {
7638   operands[0] = gen_lowpart (V8QImode, operands[0]);
7639   operands[1] = gen_lowpart (V2SImode, operands[1]);
7640   operands[2] = CONST0_RTX (V2QImode);
7641   operands[3] = CONST0_RTX (V4QImode);
7642 })
7643
7644 (define_insn "*pklb"
7645   [(set (match_operand:V8QI 0 "register_operand" "=r")
7646         (vec_concat:V8QI
7647           (vec_concat:V4QI
7648             (truncate:V2QI (match_operand:V2SI 1 "register_operand" "r"))
7649             (match_operand:V2QI 2 "const0_operand" ""))
7650           (match_operand:V4QI 3 "const0_operand" "")))]
7651   "TARGET_MAX"
7652   "pklb %r1,%0"
7653   [(set_attr "type" "mvi")])
7654
7655 (define_expand "builtin_pkwb"
7656   [(set (match_operand:DI 0 "register_operand" "")
7657         (vec_concat:V8QI
7658           (truncate:V4QI (match_operand:DI 1 "register_operand" ""))
7659           (match_dup 2)))]
7660   "TARGET_MAX"
7661 {
7662   operands[0] = gen_lowpart (V8QImode, operands[0]);
7663   operands[1] = gen_lowpart (V4HImode, operands[1]);
7664   operands[2] = CONST0_RTX (V4QImode);
7665 })
7666
7667 (define_insn "*pkwb"
7668   [(set (match_operand:V8QI 0 "register_operand" "=r")
7669         (vec_concat:V8QI
7670           (truncate:V4QI (match_operand:V4HI 1 "register_operand" "r"))
7671           (match_operand:V4QI 2 "const0_operand" "")))]
7672   "TARGET_MAX"
7673   "pkwb %r1,%0"
7674   [(set_attr "type" "mvi")])
7675
7676 (define_expand "builtin_unpkbl"
7677   [(set (match_operand:DI 0 "register_operand" "")
7678         (zero_extend:V2SI
7679           (vec_select:V2QI (match_operand:DI 1 "register_operand" "")
7680                            (parallel [(const_int 0) (const_int 1)]))))]
7681   "TARGET_MAX"
7682 {
7683   operands[0] = gen_lowpart (V2SImode, operands[0]);
7684   operands[1] = gen_lowpart (V8QImode, operands[1]);
7685 })
7686
7687 (define_insn "*unpkbl"
7688   [(set (match_operand:V2SI 0 "register_operand" "=r")
7689         (zero_extend:V2SI
7690           (vec_select:V2QI (match_operand:V8QI 1 "reg_or_0_operand" "rW")
7691                            (parallel [(const_int 0) (const_int 1)]))))]
7692   "TARGET_MAX"
7693   "unpkbl %r1,%0"
7694   [(set_attr "type" "mvi")])
7695
7696 (define_expand "builtin_unpkbw"
7697   [(set (match_operand:DI 0 "register_operand" "")
7698         (zero_extend:V4HI
7699           (vec_select:V4QI (match_operand:DI 1 "register_operand" "")
7700                            (parallel [(const_int 0)
7701                                       (const_int 1)
7702                                       (const_int 2)
7703                                       (const_int 3)]))))]
7704   "TARGET_MAX"
7705 {
7706   operands[0] = gen_lowpart (V4HImode, operands[0]);
7707   operands[1] = gen_lowpart (V8QImode, operands[1]);
7708 })
7709
7710 (define_insn "*unpkbw"
7711   [(set (match_operand:V4HI 0 "register_operand" "=r")
7712         (zero_extend:V4HI
7713           (vec_select:V4QI (match_operand:V8QI 1 "reg_or_0_operand" "rW")
7714                            (parallel [(const_int 0)
7715                                       (const_int 1)
7716                                       (const_int 2)
7717                                       (const_int 3)]))))]
7718   "TARGET_MAX"
7719   "unpkbw %r1,%0"
7720   [(set_attr "type" "mvi")])
7721
7722 (define_expand "builtin_cttz"
7723   [(set (match_operand:DI 0 "register_operand" "")
7724         (unspec:DI [(match_operand:DI 1 "register_operand" "")]
7725                    UNSPEC_CTTZ))]
7726   "TARGET_CIX"
7727   "")
7728
7729 (define_insn "builtin_ctlz"
7730   [(set (match_operand:DI 0 "register_operand" "=r")
7731         (unspec:DI [(match_operand:DI 1 "register_operand" "r")]
7732                    UNSPEC_CTLZ))]
7733   "TARGET_CIX"
7734   "ctlz %1,%0"
7735   [(set_attr "type" "mvi")])
7736
7737 (define_insn "builtin_ctpop"
7738   [(set (match_operand:DI 0 "register_operand" "=r")
7739         (unspec:DI [(match_operand:DI 1 "register_operand" "r")]
7740                    UNSPEC_CTPOP))]
7741   "TARGET_CIX"
7742   "ctpop %1,%0"
7743   [(set_attr "type" "mvi")])
7744 \f
7745 ;; The call patterns are at the end of the file because their
7746 ;; wildcard operand0 interferes with nice recognition.
7747
7748 (define_insn "*call_value_osf_1_er"
7749   [(set (match_operand 0 "" "")
7750         (call (mem:DI (match_operand:DI 1 "call_operand" "c,R,s"))
7751               (match_operand 2 "" "")))
7752    (use (reg:DI 29))
7753    (clobber (reg:DI 26))]
7754   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
7755   "@
7756    jsr $26,(%1),0\;ldah $29,0($26)\t\t!gpdisp!%*\;lda $29,0($29)\t\t!gpdisp!%*
7757    bsr $26,%1\t\t!samegp
7758    ldq $27,%1($29)\t\t!literal!%#\;jsr $26,($27),0\t\t!lituse_jsr!%#\;ldah $29,0($26)\t\t!gpdisp!%*\;lda $29,0($29)\t\t!gpdisp!%*"
7759   [(set_attr "type" "jsr")
7760    (set_attr "length" "12,*,16")])
7761
7762 ;; We must use peep2 instead of a split because we need accurate life
7763 ;; information for $gp.  Consider the case of { bar(); while (1); }.
7764 (define_peephole2
7765   [(parallel [(set (match_operand 0 "" "")
7766                    (call (mem:DI (match_operand:DI 1 "call_operand" ""))
7767                          (match_operand 2 "" "")))
7768               (use (reg:DI 29))
7769               (clobber (reg:DI 26))])]
7770   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF && reload_completed
7771    && ! samegp_function_operand (operands[1], Pmode)
7772    && (peep2_regno_dead_p (1, 29)
7773        || find_reg_note (insn, REG_NORETURN, NULL_RTX))"
7774   [(parallel [(set (match_dup 0)
7775                    (call (mem:DI (match_dup 3))
7776                          (match_dup 2)))
7777               (set (reg:DI 26) (plus:DI (pc) (const_int 4)))
7778               (unspec_volatile [(reg:DI 29)] UNSPECV_BLOCKAGE)
7779               (use (match_dup 1))
7780               (use (match_dup 4))])]
7781 {
7782   if (CONSTANT_P (operands[1]))
7783     {
7784       operands[3] = gen_rtx_REG (Pmode, 27);
7785       operands[4] = GEN_INT (alpha_next_sequence_number++);
7786       emit_insn (gen_movdi_er_high_g (operands[3], pic_offset_table_rtx,
7787                                       operands[1], operands[4]));
7788     }
7789   else
7790     {
7791       operands[3] = operands[1];
7792       operands[1] = const0_rtx;
7793       operands[4] = const0_rtx;
7794     }
7795 })
7796
7797 (define_peephole2
7798   [(parallel [(set (match_operand 0 "" "")
7799                    (call (mem:DI (match_operand:DI 1 "call_operand" ""))
7800                          (match_operand 2 "" "")))
7801               (use (reg:DI 29))
7802               (clobber (reg:DI 26))])]
7803   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF && reload_completed
7804    && ! samegp_function_operand (operands[1], Pmode)
7805    && ! (peep2_regno_dead_p (1, 29)
7806          || find_reg_note (insn, REG_NORETURN, NULL_RTX))"
7807   [(parallel [(set (match_dup 0)
7808                    (call (mem:DI (match_dup 3))
7809                          (match_dup 2)))
7810               (set (reg:DI 26) (plus:DI (pc) (const_int 4)))
7811               (unspec_volatile [(reg:DI 29)] UNSPECV_BLOCKAGE)
7812               (use (match_dup 1))
7813               (use (match_dup 5))])
7814    (set (reg:DI 29)
7815         (unspec_volatile:DI [(reg:DI 26) (match_dup 4)] UNSPECV_LDGP1))
7816    (set (reg:DI 29)
7817         (unspec:DI [(reg:DI 29) (match_dup 4)] UNSPEC_LDGP2))]
7818 {
7819   if (CONSTANT_P (operands[1]))
7820     {
7821       operands[3] = gen_rtx_REG (Pmode, 27);
7822       operands[5] = GEN_INT (alpha_next_sequence_number++);
7823       emit_insn (gen_movdi_er_high_g (operands[3], pic_offset_table_rtx,
7824                                       operands[1], operands[5]));
7825     }
7826   else
7827     {
7828       operands[3] = operands[1];
7829       operands[1] = const0_rtx;
7830       operands[5] = const0_rtx;
7831     }
7832   operands[4] = GEN_INT (alpha_next_sequence_number++);
7833 })
7834
7835 ;; We add a blockage unspec_volatile to prevent insns from moving down
7836 ;; from above the call to in between the call and the ldah gpdisp.
7837 (define_insn "*call_value_osf_2_er"
7838   [(set (match_operand 0 "" "")
7839         (call (mem:DI (match_operand:DI 1 "register_operand" "c"))
7840               (match_operand 2 "" "")))
7841    (set (reg:DI 26)
7842         (plus:DI (pc) (const_int 4)))
7843    (unspec_volatile [(reg:DI 29)] UNSPECV_BLOCKAGE)
7844    (use (match_operand 3 "" ""))
7845    (use (match_operand 4 "" ""))]
7846   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
7847   "jsr $26,(%1),%3%J4"
7848   [(set_attr "type" "jsr")
7849    (set_attr "cannot_copy" "true")])
7850
7851 (define_insn "*call_value_osf_1_noreturn"
7852   [(set (match_operand 0 "" "")
7853         (call (mem:DI (match_operand:DI 1 "call_operand" "c,R,s"))
7854               (match_operand 2 "" "")))
7855    (use (reg:DI 29))
7856    (clobber (reg:DI 26))]
7857   "! TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF
7858    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7859   "@
7860    jsr $26,($27),0%+
7861    bsr $26,$%1..ng%+
7862    jsr $26,%1%+"
7863   [(set_attr "type" "jsr")
7864    (set_attr "length" "*,*,8")])
7865
7866 (define_insn_and_split "call_value_osf_tlsgd"
7867   [(set (match_operand 0 "" "")
7868         (call (mem:DI (match_operand:DI 1 "symbolic_operand" ""))
7869               (const_int 0)))
7870    (unspec [(match_operand:DI 2 "const_int_operand" "")] UNSPEC_TLSGD_CALL)
7871    (use (reg:DI 29))
7872    (clobber (reg:DI 26))]
7873   "HAVE_AS_TLS"
7874   "#"
7875   "&& reload_completed"
7876   [(set (match_dup 3)
7877         (unspec:DI [(match_dup 5)
7878                     (match_dup 1)
7879                     (match_dup 2)] UNSPEC_LITERAL))
7880    (parallel [(set (match_dup 0)
7881                    (call (mem:DI (match_dup 3))
7882                          (const_int 0)))
7883               (set (reg:DI 26) (plus:DI (pc) (const_int 4)))
7884               (unspec_volatile [(match_dup 5)] UNSPECV_BLOCKAGE)
7885               (use (match_dup 1))
7886               (use (unspec [(match_dup 2)] UNSPEC_TLSGD_CALL))])
7887    (set (match_dup 5)
7888         (unspec_volatile:DI [(reg:DI 26) (match_dup 4)] UNSPECV_LDGP1))
7889    (set (match_dup 5)
7890         (unspec:DI [(match_dup 5) (match_dup 4)] UNSPEC_LDGP2))]
7891 {
7892   operands[3] = gen_rtx_REG (Pmode, 27);
7893   operands[4] = GEN_INT (alpha_next_sequence_number++);
7894   operands[5] = pic_offset_table_rtx;
7895 }
7896   [(set_attr "type" "multi")])
7897
7898 (define_insn_and_split "call_value_osf_tlsldm"
7899   [(set (match_operand 0 "" "")
7900         (call (mem:DI (match_operand:DI 1 "symbolic_operand" ""))
7901               (const_int 0)))
7902    (unspec [(match_operand:DI 2 "const_int_operand" "")] UNSPEC_TLSLDM_CALL)
7903    (use (reg:DI 29))
7904    (clobber (reg:DI 26))]
7905   "HAVE_AS_TLS"
7906   "#"
7907   "&& reload_completed"
7908   [(set (match_dup 3)
7909         (unspec:DI [(match_dup 5)
7910                     (match_dup 1)
7911                     (match_dup 2)] UNSPEC_LITERAL))
7912    (parallel [(set (match_dup 0)
7913                    (call (mem:DI (match_dup 3))
7914                          (const_int 0)))
7915               (set (reg:DI 26) (plus:DI (pc) (const_int 4)))
7916               (unspec_volatile [(match_dup 5)] UNSPECV_BLOCKAGE)
7917               (use (match_dup 1))
7918               (use (unspec [(match_dup 2)] UNSPEC_TLSLDM_CALL))])
7919    (set (reg:DI 29)
7920         (unspec_volatile:DI [(reg:DI 26) (match_dup 4)] UNSPECV_LDGP1))
7921    (set (reg:DI 29)
7922         (unspec:DI [(reg:DI 29) (match_dup 4)] UNSPEC_LDGP2))]
7923 {
7924   operands[3] = gen_rtx_REG (Pmode, 27);
7925   operands[4] = GEN_INT (alpha_next_sequence_number++);
7926   operands[5] = pic_offset_table_rtx;
7927 }
7928   [(set_attr "type" "multi")])
7929
7930 (define_insn "*call_value_osf_1"
7931   [(set (match_operand 0 "" "")
7932         (call (mem:DI (match_operand:DI 1 "call_operand" "c,R,s"))
7933               (match_operand 2 "" "")))
7934    (use (reg:DI 29))
7935    (clobber (reg:DI 26))]
7936   "! TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
7937   "@
7938    jsr $26,($27),0\;ldgp $29,0($26)
7939    bsr $26,$%1..ng
7940    jsr $26,%1\;ldgp $29,0($26)"
7941   [(set_attr "type" "jsr")
7942    (set_attr "length" "12,*,16")])
7943
7944 (define_insn "*sibcall_value_osf_1_er"
7945   [(set (match_operand 0 "" "")
7946         (call (mem:DI (match_operand:DI 1 "symbolic_operand" "R,s"))
7947               (match_operand 2 "" "")))
7948    (unspec [(reg:DI 29)] UNSPEC_SIBCALL)]
7949   "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
7950   "@
7951    br $31,%1\t\t!samegp
7952    ldq $27,%1($29)\t\t!literal!%#\;jmp $31,($27),%1\t\t!lituse_jsr!%#"
7953   [(set_attr "type" "jsr")
7954    (set_attr "length" "*,8")])
7955
7956 (define_insn "*sibcall_value_osf_1"
7957   [(set (match_operand 0 "" "")
7958         (call (mem:DI (match_operand:DI 1 "symbolic_operand" "R,s"))
7959               (match_operand 2 "" "")))
7960    (unspec [(reg:DI 29)] UNSPEC_SIBCALL)]
7961   "! TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
7962   "@
7963    br $31,$%1..ng
7964    lda $27,%1\;jmp $31,($27),%1"
7965   [(set_attr "type" "jsr")
7966    (set_attr "length" "*,8")])
7967
7968 (define_insn "*call_value_nt_1"
7969   [(set (match_operand 0 "" "")
7970         (call (mem:DI (match_operand:DI 1 "call_operand" "r,R,s"))
7971               (match_operand 2 "" "")))
7972    (clobber (reg:DI 26))]
7973   "TARGET_ABI_WINDOWS_NT"
7974   "@
7975    jsr $26,(%1)
7976    bsr $26,%1
7977    jsr $26,%1"
7978   [(set_attr "type" "jsr")
7979    (set_attr "length" "*,*,12")])
7980
7981 ; GAS relies on the order and position of instructions output below in order
7982 ; to generate relocs for VMS link to potentially optimize the call.
7983 ; Please do not molest.
7984 (define_insn "*call_value_vms_1"
7985   [(set (match_operand 0 "" "")
7986         (call (mem:DI (match_operand:DI 1 "call_operand" "r,s"))
7987               (match_operand 2 "" "")))
7988    (use (match_operand:DI 3 "nonmemory_operand" "r,n"))
7989    (use (reg:DI 25))
7990    (use (reg:DI 26))
7991    (clobber (reg:DI 27))]
7992   "TARGET_ABI_OPEN_VMS"
7993 {
7994   switch (which_alternative)
7995     {
7996     case 0:
7997         return "mov %3,$27\;jsr $26,0\;ldq $27,0($29)";
7998     case 1:
7999         operands [3] = alpha_use_linkage (operands [1], cfun->decl, 1, 0);
8000         operands [4] = alpha_use_linkage (operands [1], cfun->decl, 0, 0);
8001         return "ldq $26,%4\;ldq $27,%3\;jsr $26,%1\;ldq $27,0($29)";
8002     default:
8003       abort();
8004     }
8005 }
8006   [(set_attr "type" "jsr")
8007    (set_attr "length" "12,16")])
8008
8009 (define_insn "*call_value_umk"
8010   [(set (match_operand 0 "" "")
8011         (call (mem:DI (match_operand:DI 1 "call_operand" "r"))
8012               (match_operand 2 "" "")))
8013    (use (reg:DI 25))
8014    (clobber (reg:DI 26))]
8015   "TARGET_ABI_UNICOSMK"
8016   "jsr $26,(%1)"
8017   [(set_attr "type" "jsr")])