OSDN Git Service

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