OSDN Git Service

* alpha.c (aligned_memory_operand): Handle out of range stack slots.
[pf3gnuchains/gcc-fork.git] / gcc / config / alpha / alpha.md
1 ;; Machine description for DEC Alpha for GNU C compiler
2 ;; Copyright (C) 1992, 93-98, 1999 Free Software Foundation, Inc.
3 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
4
5 ;; This file is part of GNU CC.
6
7 ;; GNU CC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; any later version.
11
12 ;; GNU CC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU CC; see the file COPYING.  If not, write to
19 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
21
22 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
23
24 ;; Uses of UNSPEC in this file:
25 ;;
26 ;;      0       arg_home
27 ;;      1       cttz
28 ;;      2       insxh
29 ;;      3       mskxh
30 ;;      4       cvtlq
31 ;;      5       cvtql
32 ;;      
33 ;; UNSPEC_VOLATILE:
34 ;;
35 ;;      0       imb
36 ;;      1       blockage
37 ;;      2       builtin_setjmp_receiver
38 ;;      3       builtin_longjmp
39 ;;      4       trapb
40 ;;      5       prologue_stack_probe_loop
41 ;;      6       realign
42 ;;      7       exception_receiver
43 \f
44 ;; Processor type -- this attribute must exactly match the processor_type
45 ;; enumeration in alpha.h.
46
47 (define_attr "cpu" "ev4,ev5,ev6"
48   (const (symbol_ref "alpha_cpu")))
49
50 ;; Define an insn type attribute.  This is used in function unit delay
51 ;; computations, among other purposes.  For the most part, we use the names
52 ;; defined in the EV4 documentation, but add a few that we have to know about
53 ;; separately.
54
55 (define_attr "type"
56   "ild,fld,ldsym,ist,fst,ibr,fbr,jsr,iadd,ilog,shift,icmov,fcmov,icmp,imul,fadd,fmul,fcpys,fdiv,fsqrt,misc,mvi,ftoi,itof,multi"
57   (const_string "iadd"))
58
59 ;; Describe a user's asm statement.
60 (define_asm_attributes
61   [(set_attr "type" "multi")])
62
63 ;; Define the operand size an insn operates on.  Used primarily by mul
64 ;; and div operations that have size dependant timings.
65
66 (define_attr "opsize" "si,di,udi" (const_string "di"))
67
68 ;; The TRAP_TYPE attribute marks instructions that may generate traps
69 ;; (which are imprecise and may need a trapb if software completion
70 ;; is desired).
71
72 (define_attr "trap" "no,yes" (const_string "no"))
73
74 ;; The length of an instruction sequence in bytes.
75
76 (define_attr "length" "" (const_int 4))
77 \f
78 ;; On EV4 there are two classes of resources to consider: resources needed
79 ;; to issue, and resources needed to execute.  IBUS[01] are in the first
80 ;; category.  ABOX, BBOX, EBOX, FBOX, IMUL & FDIV make up the second.
81 ;; (There are a few other register-like resources, but ...)
82
83 ; First, describe all of the issue constraints with single cycle delays.
84 ; All insns need a bus, but all except loads require one or the other.
85 (define_function_unit "ev4_ibus0" 1 0
86   (and (eq_attr "cpu" "ev4")
87        (eq_attr "type" "fst,fbr,iadd,imul,ilog,shift,icmov,icmp"))
88   1 1)
89
90 (define_function_unit "ev4_ibus1" 1 0
91   (and (eq_attr "cpu" "ev4")
92        (eq_attr "type" "ist,ibr,jsr,fadd,fcmov,fcpys,fmul,fdiv,misc"))
93   1 1)
94
95 ; Memory delivers its result in three cycles.  Actually return one and
96 ; take care of this in adjust_cost, since we want to handle user-defined
97 ; memory latencies.
98 (define_function_unit "ev4_abox" 1 0
99   (and (eq_attr "cpu" "ev4")
100        (eq_attr "type" "ild,fld,ldsym,ist,fst"))
101   1 1)
102
103 ; Branches have no delay cost, but do tie up the unit for two cycles.
104 (define_function_unit "ev4_bbox" 1 1
105   (and (eq_attr "cpu" "ev4")
106        (eq_attr "type" "ibr,fbr,jsr"))
107   2 2)
108
109 ; Arithmetic insns are normally have their results available after
110 ; two cycles.  There are a number of exceptions.  They are encoded in
111 ; ADJUST_COST.  Some of the other insns have similar exceptions.
112 (define_function_unit "ev4_ebox" 1 0
113   (and (eq_attr "cpu" "ev4")
114        (eq_attr "type" "iadd,ilog,shift,icmov,icmp,misc"))
115   2 1)
116
117 (define_function_unit "imul" 1 0
118   (and (eq_attr "cpu" "ev4")
119        (and (eq_attr "type" "imul")
120             (eq_attr "opsize" "si")))
121   21 19)
122
123 (define_function_unit "imul" 1 0
124   (and (eq_attr "cpu" "ev4")
125        (and (eq_attr "type" "imul")
126             (eq_attr "opsize" "!si")))
127   23 21)
128
129 (define_function_unit "ev4_fbox" 1 0
130   (and (eq_attr "cpu" "ev4")
131        (eq_attr "type" "fadd,fmul,fcpys,fcmov"))
132   6 1)
133
134 (define_function_unit "fdiv" 1 0
135   (and (eq_attr "cpu" "ev4")
136        (and (eq_attr "type" "fdiv")
137             (eq_attr "opsize" "si")))
138   34 30)
139
140 (define_function_unit "fdiv" 1 0
141   (and (eq_attr "cpu" "ev4")
142        (and (eq_attr "type" "fdiv")
143             (eq_attr "opsize" "di")))
144   63 59)
145 \f
146 ;; EV5 scheduling.  EV5 can issue 4 insns per clock.
147 ;;
148 ;; EV5 has two asymetric integer units.  Model this with E0 & E1 along
149 ;; with the combined resource EBOX.
150
151 (define_function_unit "ev5_ebox" 2 0
152   (and (eq_attr "cpu" "ev5")
153        (eq_attr "type" "!fbr,fcmov,fadd,fmul,fcpys,fdiv"))
154   1 1)
155
156 ; Memory takes at least 2 clocks.  Return one from here and fix up with
157 ; user-defined latencies in adjust_cost.
158 (define_function_unit "ev5_ebox" 2 0
159   (and (eq_attr "cpu" "ev5")
160        (eq_attr "type" "ild,fld,ldsym"))
161   1 1)
162
163 ; Loads can dual issue with one another, but loads and stores do not mix.
164 (define_function_unit "ev5_e0" 1 0
165   (and (eq_attr "cpu" "ev5")
166        (eq_attr "type" "ild,fld,ldsym"))
167   1 1
168   [(eq_attr "type" "ist,fst")])
169
170 ; Stores, shifts, multiplies can only issue to E0
171 (define_function_unit "ev5_e0" 1 0
172   (and (eq_attr "cpu" "ev5")
173        (eq_attr "type" "ist,fst,shift,imul"))
174   1 1)
175
176 ; Motion video insns also issue only to E0, and take two ticks.
177 (define_function_unit "ev5_e0" 1 0
178   (and (eq_attr "cpu" "ev5")
179        (eq_attr "type" "mvi"))
180   2 1)
181
182 ; Conditional moves always take 2 ticks.
183 (define_function_unit "ev5_ebox" 2 0
184   (and (eq_attr "cpu" "ev5")
185        (eq_attr "type" "icmov"))
186   2 1)
187
188 ; Branches can only issue to E1
189 (define_function_unit "ev5_e1" 1 0
190   (and (eq_attr "cpu" "ev5")
191        (eq_attr "type" "ibr,jsr"))
192   1 1)
193
194 ; Multiplies also use the integer multiplier.
195 ; ??? How to: "No instruction can be issued to pipe E0 exactly two
196 ; cycles before an integer multiplication completes."
197 (define_function_unit "imul" 1 0
198   (and (eq_attr "cpu" "ev5")
199        (and (eq_attr "type" "imul")
200             (eq_attr "opsize" "si")))
201   8 4)
202
203 (define_function_unit "imul" 1 0
204   (and (eq_attr "cpu" "ev5")
205        (and (eq_attr "type" "imul")
206             (eq_attr "opsize" "di")))
207   12 8)
208
209 (define_function_unit "imul" 1 0
210   (and (eq_attr "cpu" "ev5")
211        (and (eq_attr "type" "imul")
212             (eq_attr "opsize" "udi")))
213   14 8)
214
215 ;; Similarly for the FPU we have two asymetric units.  But fcpys can issue
216 ;; on either so we have to play the game again.
217
218 (define_function_unit "ev5_fbox" 2 0
219   (and (eq_attr "cpu" "ev5")
220        (eq_attr "type" "fadd,fcmov,fmul,fcpys,fbr,fdiv"))
221   4 1)
222   
223 (define_function_unit "ev5_fm" 1 0
224   (and (eq_attr "cpu" "ev5")
225        (eq_attr "type" "fmul"))
226   4 1)
227
228 ; Add and cmov as you would expect; fbr never produces a result;
229 ; fdiv issues through fa to the divider, 
230 (define_function_unit "ev5_fa" 1 0
231   (and (eq_attr "cpu" "ev5")
232        (eq_attr "type" "fadd,fcmov,fbr,fdiv"))
233   4 1)
234
235 ; ??? How to: "No instruction can be issued to pipe FA exactly five
236 ; cycles before a floating point divide completes."
237 (define_function_unit "fdiv" 1 0
238   (and (eq_attr "cpu" "ev5")
239        (and (eq_attr "type" "fdiv")
240             (eq_attr "opsize" "si")))
241   15 15)                                ; 15 to 31 data dependant
242
243 (define_function_unit "fdiv" 1 0
244   (and (eq_attr "cpu" "ev5")
245        (and (eq_attr "type" "fdiv")
246             (eq_attr "opsize" "di")))
247   22 22)                                ; 22 to 60 data dependant
248 \f
249 ;; EV6 scheduling.  EV6 can issue 4 insns per clock.
250 ;;
251 ;; EV6 has two symmetric pairs ("clusters") of two asymetric integer units
252 ;; ("upper" and "lower"), yielding pipe names U0, U1, L0, L1.
253
254 ;; Conditional moves decompose into two independant primitives, each 
255 ;; taking one cycle.  Since ev6 is out-of-order, we can't see anything
256 ;; but two cycles.
257 (define_function_unit "ev6_ebox" 4 0
258   (and (eq_attr "cpu" "ev6")
259        (eq_attr "type" "icmov"))
260   2 1)
261
262 (define_function_unit "ev6_ebox" 4 0
263   (and (eq_attr "cpu" "ev6")
264        (eq_attr "type" "!fbr,fcmov,fadd,fmul,fcpys,fdiv,fsqrt"))
265   1 1)
266
267 ;; Integer loads take at least 3 clocks, and only issue to lower units.
268 ;; Return one from here and fix up with user-defined latencies in adjust_cost.
269 (define_function_unit "ev6_l" 2 0
270   (and (eq_attr "cpu" "ev6")
271        (eq_attr "type" "ild,ldsym,ist,fst"))
272   1 1)
273
274 ;; FP loads take at least 4 clocks.  Return two from here...
275 (define_function_unit "ev6_l" 2 0
276   (and (eq_attr "cpu" "ev6")
277        (eq_attr "type" "fld"))
278   2 1)
279
280 ;; Motion video insns also issue only to U0, and take three ticks.
281 (define_function_unit "ev6_u0" 1 0
282   (and (eq_attr "cpu" "ev6")
283        (eq_attr "type" "mvi"))
284   3 1)
285
286 (define_function_unit "ev6_u" 2 0
287   (and (eq_attr "cpu" "ev6")
288        (eq_attr "type" "mvi"))
289   3 1)
290
291 ;; Shifts issue to either upper pipe.
292 (define_function_unit "ev6_u" 2 0
293   (and (eq_attr "cpu" "ev6")
294        (eq_attr "type" "shift"))
295   1 1)
296
297 ;; Multiplies issue only to U1, and all take 7 ticks.
298 ;; Rather than create a new function unit just for U1, reuse IMUL
299 (define_function_unit "imul" 1 0
300   (and (eq_attr "cpu" "ev6")
301        (eq_attr "type" "imul"))
302   7 1)
303
304 (define_function_unit "ev6_u" 2 0
305   (and (eq_attr "cpu" "ev6")
306        (eq_attr "type" "imul"))
307   7 1)
308
309 ;; Branches issue to either upper pipe
310 (define_function_unit "ev6_u" 2 0
311   (and (eq_attr "cpu" "ev6")
312        (eq_attr "type" "ibr"))
313   3 1)
314
315 ;; Calls only issue to L0.
316 (define_function_unit "ev6_l0" 1 0
317   (and (eq_attr "cpu" "ev6")
318        (eq_attr "type" "jsr"))
319   1 1)
320
321 (define_function_unit "ev6_l" 2 0
322   (and (eq_attr "cpu" "ev6")
323        (eq_attr "type" "jsr"))
324   1 1)
325
326 ;; Ftoi/itof only issue to lower pipes
327 (define_function_unit "ev6_l" 2 0
328   (and (eq_attr "cpu" "ev6")
329        (eq_attr "type" "ftoi"))
330   3 1)
331
332 (define_function_unit "ev6_l" 2 0
333   (and (eq_attr "cpu" "ev6")
334        (eq_attr "type" "itof"))
335   4 1)
336
337 ;; For the FPU we are very similar to EV5, except there's no insn that
338 ;; can issue to fm & fa, so we get to leave that out.
339   
340 (define_function_unit "ev6_fm" 1 0
341   (and (eq_attr "cpu" "ev6")
342        (eq_attr "type" "fmul"))
343   4 1)
344
345 (define_function_unit "ev6_fa" 1 0
346   (and (eq_attr "cpu" "ev6")
347        (eq_attr "type" "fadd,fcpys,fbr,fdiv,fsqrt"))
348   4 1)
349
350 (define_function_unit "ev6_fa" 1 0
351   (and (eq_attr "cpu" "ev6")
352        (eq_attr "type" "fcmov"))
353   8 1)
354
355 (define_function_unit "fdiv" 1 0
356   (and (eq_attr "cpu" "ev6")
357        (and (eq_attr "type" "fdiv")
358             (eq_attr "opsize" "si")))
359   12 10)
360
361 (define_function_unit "fdiv" 1 0
362   (and (eq_attr "cpu" "ev6")
363        (and (eq_attr "type" "fdiv")
364             (eq_attr "opsize" "di")))
365   15 13)
366
367 (define_function_unit "fsqrt" 1 0
368   (and (eq_attr "cpu" "ev6")
369        (and (eq_attr "type" "fsqrt")
370             (eq_attr "opsize" "si")))
371   16 14)
372
373 (define_function_unit "fsqrt" 1 0
374   (and (eq_attr "cpu" "ev6")
375        (and (eq_attr "type" "fsqrt")
376             (eq_attr "opsize" "di")))
377   32 30)
378
379 ; ??? The FPU communicates with memory and the integer register file
380 ; via two fp store units.  We need a slot in the fst immediately, and
381 ; a slot in LOW after the operand data is ready.  At which point the
382 ; data may be moved either to the store queue or the integer register
383 ; file and the insn retired.
384
385 \f
386 ;; First define the arithmetic insns.  Note that the 32-bit forms also
387 ;; sign-extend.
388
389 ;; Handle 32-64 bit extension from memory to a floating point register
390 ;; specially, since this ocurrs frequently in int->double conversions.
391 ;; This is done with a define_split after reload converting the plain
392 ;; sign-extension into a load+unspec, which of course results in lds+cvtlq.
393 ;;
394 ;; Note that while we must retain the =f case in the insn for reload's
395 ;; benefit, it should be eliminated after reload, so we should never emit
396 ;; code for that case.  But we don't reject the possibility.
397
398 (define_insn "extendsidi2"
399   [(set (match_operand:DI 0 "register_operand" "=r,r,?f")
400         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "r,m,m")))]
401   ""
402   "@
403    addl %1,$31,%0
404    ldl %0,%1
405    lds %0,%1\;cvtlq %0,%0"
406   [(set_attr "type" "iadd,ild,fld")
407    (set_attr "length" "*,*,8")])
408
409 ;; Due to issues with CLASS_CANNOT_CHANGE_SIZE, we cannot use a subreg here.
410 (define_split
411   [(set (match_operand:DI 0 "hard_fp_register_operand" "")
412         (sign_extend:DI (match_operand:SI 1 "memory_operand" "")))]
413   "reload_completed"
414   [(set (match_dup 2) (match_dup 1))
415    (set (match_dup 0) (unspec:DI [(match_dup 2)] 4))]
416   "operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]));")
417
418 (define_insn ""
419   [(set (match_operand:DI 0 "register_operand" "=f")
420         (unspec:DI [(match_operand:SI 1 "register_operand" "f")] 4))]
421   ""
422   "cvtlq %1,%0"
423   [(set_attr "type" "fadd")])
424
425 ;; Do addsi3 the way expand_binop would do if we didn't have one.  This
426 ;; generates better code.  We have the anonymous addsi3 pattern below in
427 ;; case combine wants to make it.
428 (define_expand "addsi3"
429   [(set (match_operand:SI 0 "register_operand" "")
430         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "")
431                  (match_operand:SI 2 "add_operand" "")))]
432   ""
433   "
434 {
435   if (optimize)
436     {
437       rtx op1 = gen_lowpart (DImode, operands[1]);
438       rtx op2 = gen_lowpart (DImode, operands[2]);
439
440       if (! cse_not_expected)
441         {
442           rtx tmp = gen_reg_rtx (DImode);
443           emit_insn (gen_adddi3 (tmp, op1, op2));
444           emit_move_insn (gen_lowpart (DImode, operands[0]), tmp);
445         }
446       else
447         emit_insn (gen_adddi3 (gen_lowpart (DImode, operands[0]), op1, op2));
448       DONE;
449     }
450 }")
451
452 (define_insn ""
453   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
454         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ,rJ,rJ,rJ")
455                  (match_operand:SI 2 "add_operand" "rI,O,K,L")))]
456   ""
457   "@
458    addl %r1,%2,%0
459    subl %r1,%n2,%0
460    lda %0,%2(%r1)
461    ldah %0,%h2(%r1)")
462
463 (define_split
464   [(set (match_operand:SI 0 "register_operand" "")
465         (plus:SI (match_operand:SI 1 "register_operand" "")
466                  (match_operand:SI 2 "const_int_operand" "")))]
467   "! add_operand (operands[2], SImode)"
468   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
469    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
470   "
471 {
472   HOST_WIDE_INT val = INTVAL (operands[2]);
473   HOST_WIDE_INT low = (val & 0xffff) - 2 * (val & 0x8000);
474   HOST_WIDE_INT rest = val - low;
475
476   operands[3] = GEN_INT (rest);
477   operands[4] = GEN_INT (low);
478 }")
479
480 (define_insn ""
481   [(set (match_operand:DI 0 "register_operand" "=r,r")
482         (sign_extend:DI
483          (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ,rJ")
484                   (match_operand:SI 2 "sext_add_operand" "rI,O"))))]
485   ""
486   "@
487    addl %r1,%2,%0
488    subl %r1,%n2,%0")
489
490 (define_split
491   [(set (match_operand:DI 0 "register_operand" "")
492         (sign_extend:DI
493          (plus:SI (match_operand:SI 1 "register_operand" "")
494                   (match_operand:SI 2 "const_int_operand" ""))))
495    (clobber (match_operand:SI 3 "reg_not_elim_operand" ""))]
496   "! sext_add_operand (operands[2], SImode) && INTVAL (operands[2]) > 0
497    && INTVAL (operands[2]) % 4 == 0"
498   [(set (match_dup 3) (match_dup 4))
499    (set (match_dup 0) (sign_extend:DI (plus:SI (mult:SI (match_dup 3)
500                                                         (match_dup 5))
501                                                (match_dup 1))))]
502   "
503 {
504   HOST_WIDE_INT val = INTVAL (operands[2]) / 4;
505   int mult = 4;
506
507   if (val % 2 == 0)
508     val /= 2, mult = 8;
509
510   operands[4] = GEN_INT (val);
511   operands[5] = GEN_INT (mult);
512 }")
513
514 (define_split
515   [(set (match_operand:DI 0 "register_operand" "")
516         (sign_extend:DI
517          (plus:SI (match_operator:SI 1 "comparison_operator"
518                                      [(match_operand 2 "" "")
519                                       (match_operand 3 "" "")])
520                   (match_operand:SI 4 "add_operand" ""))))
521    (clobber (match_operand:DI 5 "register_operand" ""))]
522   ""
523   [(set (match_dup 5) (match_dup 6))
524    (set (match_dup 0) (sign_extend:DI (plus:SI (match_dup 7) (match_dup 4))))]
525   "
526 {
527   operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[1]), DImode,
528                                 operands[2], operands[3]);
529   operands[7] = gen_lowpart (SImode, operands[5]);
530 }")
531
532 (define_insn "adddi3"
533   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r")
534         (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ,rJ,rJ")
535                  (match_operand:DI 2 "add_operand" "rI,O,K,L")))]
536   ""
537   "@
538    addq %r1,%2,%0
539    subq %r1,%n2,%0
540    lda %0,%2(%r1)
541    ldah %0,%h2(%r1)")
542
543 ;; Don't do this if we are adjusting SP since we don't want to do
544 ;; it in two steps. 
545 (define_split
546   [(set (match_operand:DI 0 "register_operand" "")
547         (plus:DI (match_operand:DI 1 "register_operand" "")
548                  (match_operand:DI 2 "const_int_operand" "")))]
549   "! add_operand (operands[2], DImode)
550    && operands[0] != stack_pointer_rtx"
551   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
552    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
553   "
554 {
555   HOST_WIDE_INT val = INTVAL (operands[2]);
556   HOST_WIDE_INT low = (val & 0xffff) - 2 * (val & 0x8000);
557   HOST_WIDE_INT rest = val - low;
558
559   operands[3] = GEN_INT (rest);
560   operands[4] = GEN_INT (low);
561 }")
562
563 (define_insn ""
564   [(set (match_operand:SI 0 "register_operand" "=r,r")
565         (plus:SI (mult:SI (match_operand:SI 1 "reg_not_elim_operand" "r,r")
566                           (match_operand:SI 2 "const48_operand" "I,I"))
567                  (match_operand:SI 3 "sext_add_operand" "rI,O")))]
568   ""
569   "@
570    s%2addl %1,%3,%0
571    s%2subl %1,%n3,%0")
572
573 (define_insn ""
574   [(set (match_operand:DI 0 "register_operand" "=r,r")
575         (sign_extend:DI
576          (plus:SI (mult:SI (match_operand:SI 1 "reg_not_elim_operand" "r,r")
577                            (match_operand:SI 2 "const48_operand" "I,I"))
578                   (match_operand:SI 3 "sext_add_operand" "rI,O"))))]
579   ""
580   "@
581    s%2addl %1,%3,%0
582    s%2subl %1,%n3,%0")
583
584 (define_split
585   [(set (match_operand:DI 0 "register_operand" "")
586         (sign_extend:DI
587          (plus:SI (mult:SI (match_operator:SI 1 "comparison_operator"
588                                               [(match_operand 2 "" "")
589                                                (match_operand 3 "" "")])
590                            (match_operand:SI 4 "const48_operand" ""))
591                   (match_operand:SI 5 "add_operand" ""))))
592    (clobber (match_operand:DI 6 "reg_not_elim_operand" ""))]
593   ""
594   [(set (match_dup 6) (match_dup 7))
595    (set (match_dup 0)
596         (sign_extend:DI (plus:SI (mult:SI (match_dup 8) (match_dup 4))
597                                  (match_dup 5))))]
598   "
599 {
600   operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[1]), DImode,
601                                 operands[2], operands[3]);
602   operands[8] = gen_lowpart (SImode, operands[6]);
603 }")
604
605 (define_insn ""
606   [(set (match_operand:DI 0 "register_operand" "=r,r")
607         (plus:DI (mult:DI (match_operand:DI 1 "reg_not_elim_operand" "r,r")
608                           (match_operand:DI 2 "const48_operand" "I,I"))
609                  (match_operand:DI 3 "sext_add_operand" "rI,O")))]
610   ""
611   "@
612    s%2addq %1,%3,%0
613    s%2subq %1,%n3,%0")
614
615 ;; These variants of the above insns can occur if the third operand
616 ;; is the frame pointer.  This is a kludge, but there doesn't
617 ;; seem to be a way around it.  Only recognize them while reloading.
618
619 (define_insn ""
620   [(set (match_operand:DI 0 "some_operand" "=&r")
621         (plus:DI (plus:DI (match_operand:DI 1 "some_operand" "r")
622                           (match_operand:DI 2 "some_operand" "r"))
623                  (match_operand:DI 3 "some_operand" "rIOKL")))]
624   "reload_in_progress"
625   "#")
626
627 (define_split
628   [(set (match_operand:DI 0 "register_operand" "")
629         (plus:DI (plus:DI (match_operand:DI 1 "register_operand" "")
630                           (match_operand:DI 2 "register_operand" ""))
631                  (match_operand:DI 3 "add_operand" "")))]
632   "reload_completed"
633   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
634    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
635   "")
636                                            
637 (define_insn ""
638   [(set (match_operand:SI 0 "some_operand" "=&r")
639         (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "some_operand" "rJ")
640                                    (match_operand:SI 2 "const48_operand" "I"))
641                           (match_operand:SI 3 "some_operand" "r"))
642                  (match_operand:SI 4 "some_operand" "rIOKL")))]
643   "reload_in_progress"
644   "#")
645
646 (define_split
647   [(set (match_operand:SI 0 "register_operand" "r")
648         (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "reg_or_0_operand" "")
649                                    (match_operand:SI 2 "const48_operand" ""))
650                           (match_operand:SI 3 "register_operand" ""))
651                  (match_operand:SI 4 "add_operand" "rIOKL")))]
652   "reload_completed"
653   [(set (match_dup 0)
654         (plus:SI (mult:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
655    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
656   "")
657
658 (define_insn ""
659   [(set (match_operand:DI 0 "some_operand" "=&r")
660         (sign_extend:DI
661          (plus:SI (plus:SI
662                    (mult:SI (match_operand:SI 1 "some_operand" "rJ")
663                             (match_operand:SI 2 "const48_operand" "I"))
664                    (match_operand:SI 3 "some_operand" "r"))
665                   (match_operand:SI 4 "some_operand" "rIOKL"))))]
666   "reload_in_progress"
667   "#")
668
669 (define_split
670   [(set (match_operand:DI 0 "register_operand" "")
671         (sign_extend:DI
672          (plus:SI (plus:SI
673                    (mult:SI (match_operand:SI 1 "reg_or_0_operand" "")
674                             (match_operand:SI 2 "const48_operand" ""))
675                    (match_operand:SI 3 "register_operand" ""))
676                   (match_operand:SI 4 "add_operand" ""))))]
677   "reload_completed"
678   [(set (match_dup 5)
679         (plus:SI (mult:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
680    (set (match_dup 0) (sign_extend:DI (plus:SI (match_dup 5) (match_dup 4))))]
681   "operands[5] = gen_lowpart (SImode, operands[0]);")
682
683 (define_insn ""
684   [(set (match_operand:DI 0 "some_operand" "=&r")
685         (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "some_operand" "rJ")
686                                    (match_operand:DI 2 "const48_operand" "I"))
687                           (match_operand:DI 3 "some_operand" "r"))
688                  (match_operand:DI 4 "some_operand" "rIOKL")))]
689   "reload_in_progress"
690   "#")
691
692 (define_split
693   [(set (match_operand:DI 0 "register_operand" "=")
694         (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "reg_or_0_operand" "")
695                                    (match_operand:DI 2 "const48_operand" ""))
696                           (match_operand:DI 3 "register_operand" ""))
697                  (match_operand:DI 4 "add_operand" "")))]
698   "reload_completed"
699   [(set (match_dup 0)
700         (plus:DI (mult:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
701    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
702   "")
703
704 (define_insn "negsi2"
705   [(set (match_operand:SI 0 "register_operand" "=r")
706         (neg:SI (match_operand:SI 1 "reg_or_8bit_operand" "rI")))]
707   ""
708   "subl $31,%1,%0")
709
710 (define_insn ""
711   [(set (match_operand:DI 0 "register_operand" "=r")
712         (sign_extend:DI (neg:SI
713                          (match_operand:SI 1 "reg_or_8bit_operand" "rI"))))]
714   ""
715   "subl $31,%1,%0")
716
717 (define_insn "negdi2"
718   [(set (match_operand:DI 0 "register_operand" "=r")
719         (neg:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI")))]
720   ""
721   "subq $31,%1,%0")
722
723 (define_expand "subsi3"
724   [(set (match_operand:SI 0 "register_operand" "")
725         (minus:SI (match_operand:SI 1 "reg_or_0_operand" "")
726                   (match_operand:SI 2 "reg_or_8bit_operand" "")))]
727   ""
728   "
729 {
730   if (optimize)
731     {
732       rtx op1 = gen_lowpart (DImode, operands[1]);
733       rtx op2 = gen_lowpart (DImode, operands[2]);
734
735       if (! cse_not_expected)
736         {
737           rtx tmp = gen_reg_rtx (DImode);
738           emit_insn (gen_subdi3 (tmp, op1, op2));
739           emit_move_insn (gen_lowpart (DImode, operands[0]), tmp);
740         }
741       else
742         emit_insn (gen_subdi3 (gen_lowpart (DImode, operands[0]), op1, op2));
743       DONE;
744     }
745 } ")
746
747 (define_insn ""
748   [(set (match_operand:SI 0 "register_operand" "=r")
749         (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
750                   (match_operand:SI 2 "reg_or_8bit_operand" "rI")))]
751   ""
752   "subl %r1,%2,%0")
753
754 (define_insn ""
755   [(set (match_operand:DI 0 "register_operand" "=r")
756         (sign_extend:DI (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
757                                   (match_operand:SI 2 "reg_or_8bit_operand" "rI"))))]
758   ""
759   "subl %r1,%2,%0")
760
761 (define_insn "subdi3"
762   [(set (match_operand:DI 0 "register_operand" "=r")
763         (minus:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
764                   (match_operand:DI 2 "reg_or_8bit_operand" "rI")))]
765   ""
766   "subq %r1,%2,%0")
767
768 (define_insn ""
769   [(set (match_operand:SI 0 "register_operand" "=r")
770         (minus:SI (mult:SI (match_operand:SI 1 "reg_not_elim_operand" "r")
771                            (match_operand:SI 2 "const48_operand" "I"))
772                   (match_operand:SI 3 "reg_or_8bit_operand" "rI")))]
773   ""
774   "s%2subl %1,%3,%0")
775
776 (define_insn ""
777   [(set (match_operand:DI 0 "register_operand" "=r")
778         (sign_extend:DI
779          (minus:SI (mult:SI (match_operand:SI 1 "reg_not_elim_operand" "r")
780                             (match_operand:SI 2 "const48_operand" "I"))
781                    (match_operand:SI 3 "reg_or_8bit_operand" "rI"))))]
782   ""
783   "s%2subl %1,%3,%0")
784
785 (define_insn ""
786   [(set (match_operand:DI 0 "register_operand" "=r")
787         (minus:DI (mult:DI (match_operand:DI 1 "reg_not_elim_operand" "r")
788                            (match_operand:DI 2 "const48_operand" "I"))
789                   (match_operand:DI 3 "reg_or_8bit_operand" "rI")))]
790   ""
791   "s%2subq %1,%3,%0")
792
793 (define_insn "mulsi3"
794   [(set (match_operand:SI 0 "register_operand" "=r")
795         (mult:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
796                  (match_operand:SI 2 "reg_or_8bit_operand" "rI")))]
797   ""
798   "mull %r1,%2,%0"
799   [(set_attr "type" "imul")
800    (set_attr "opsize" "si")])
801
802 (define_insn ""
803   [(set (match_operand:DI 0 "register_operand" "=r")
804         (sign_extend:DI
805           (mult:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
806                    (match_operand:SI 2 "reg_or_8bit_operand" "rI"))))]
807   ""
808   "mull %r1,%2,%0"
809   [(set_attr "type" "imul")
810    (set_attr "opsize" "si")])
811
812 (define_insn "muldi3"
813   [(set (match_operand:DI 0 "register_operand" "=r")
814         (mult:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ")
815                  (match_operand:DI 2 "reg_or_8bit_operand" "rI")))]
816   ""
817   "mulq %r1,%2,%0"
818   [(set_attr "type" "imul")])
819
820 (define_insn "umuldi3_highpart"
821   [(set (match_operand:DI 0 "register_operand" "=r")
822         (truncate:DI
823          (lshiftrt:TI
824           (mult:TI (zero_extend:TI
825                      (match_operand:DI 1 "reg_or_0_operand" "%rJ"))
826                    (zero_extend:TI
827                      (match_operand:DI 2 "reg_or_8bit_operand" "rI")))
828           (const_int 64))))]
829   ""
830   "umulh %r1,%2,%0"
831   [(set_attr "type" "imul")
832    (set_attr "opsize" "udi")])
833
834 (define_insn ""
835   [(set (match_operand:DI 0 "register_operand" "=r")
836         (truncate:DI
837          (lshiftrt:TI
838           (mult:TI (zero_extend:TI (match_operand:DI 1 "register_operand" "r"))
839                    (match_operand:TI 2 "cint8_operand" "I"))
840           (const_int 64))))]
841   ""
842   "umulh %1,%2,%0"
843   [(set_attr "type" "imul")
844    (set_attr "opsize" "udi")])
845 \f
846 ;; The divide and remainder operations always take their inputs from
847 ;; r24 and r25, put their output in r27, and clobber r23 and r28.
848
849 ;; ??? Force sign-extension here because some versions of OSF/1 don't
850 ;; do the right thing if the inputs are not properly sign-extended.
851 ;; But Linux, for instance, does not have this problem.  Is it worth
852 ;; the complication here to eliminate the sign extension?
853
854 (define_expand "divsi3"
855   [(set (reg:DI 24)
856         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))
857    (set (reg:DI 25)
858         (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "")))
859    (parallel [(set (reg:DI 27)
860                    (sign_extend:DI (div:SI (reg:DI 24) (reg:DI 25))))
861               (clobber (reg:DI 23))
862               (clobber (reg:DI 28))])
863    (set (match_operand:SI 0 "general_operand" "")
864         (subreg:SI (reg:DI 27) 0))]
865   "!TARGET_OPEN_VMS"
866   "")
867
868 (define_expand "udivsi3"
869   [(set (reg:DI 24)
870         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))
871    (set (reg:DI 25)
872         (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "")))
873    (parallel [(set (reg:DI 27)
874                    (sign_extend:DI (udiv:SI (reg:DI 24) (reg:DI 25))))
875               (clobber (reg:DI 23))
876               (clobber (reg:DI 28))])
877    (set (match_operand:SI 0 "general_operand" "")
878         (subreg:SI (reg:DI 27) 0))]
879   "!TARGET_OPEN_VMS"
880   "")
881
882 (define_expand "modsi3"
883   [(set (reg:DI 24)
884         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))
885    (set (reg:DI 25)
886         (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "")))
887    (parallel [(set (reg:DI 27)
888                    (sign_extend:DI (mod:SI (reg:DI 24) (reg:DI 25))))
889               (clobber (reg:DI 23))
890               (clobber (reg:DI 28))])
891    (set (match_operand:SI 0 "general_operand" "")
892         (subreg:SI (reg:DI 27) 0))]
893   "!TARGET_OPEN_VMS"
894   "")
895
896 (define_expand "umodsi3"
897   [(set (reg:DI 24)
898         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))
899    (set (reg:DI 25)
900         (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "")))
901    (parallel [(set (reg:DI 27)
902                    (sign_extend:DI (umod:SI (reg:DI 24) (reg:DI 25))))
903               (clobber (reg:DI 23))
904               (clobber (reg:DI 28))])
905    (set (match_operand:SI 0 "general_operand" "")
906         (subreg:SI (reg:DI 27) 0))]
907   "!TARGET_OPEN_VMS"
908   "")
909
910 (define_expand "divdi3"
911   [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
912    (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
913    (parallel [(set (reg:DI 27)
914                    (div:DI (reg:DI 24)
915                            (reg:DI 25)))
916               (clobber (reg:DI 23))
917               (clobber (reg:DI 28))])
918    (set (match_operand:DI 0 "general_operand" "")
919         (reg:DI 27))]
920   "!TARGET_OPEN_VMS"
921   "")
922
923 (define_expand "udivdi3"
924   [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
925    (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
926    (parallel [(set (reg:DI 27)
927                    (udiv:DI (reg:DI 24)
928                             (reg:DI 25)))
929               (clobber (reg:DI 23))
930               (clobber (reg:DI 28))])
931    (set (match_operand:DI 0 "general_operand" "")
932         (reg:DI 27))]
933   "!TARGET_OPEN_VMS"
934   "")
935
936 (define_expand "moddi3"
937   [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
938    (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
939    (parallel [(set (reg:DI 27)
940                    (mod:DI (reg:DI 24)
941                            (reg:DI 25)))
942               (clobber (reg:DI 23))
943               (clobber (reg:DI 28))])
944    (set (match_operand:DI 0 "general_operand" "")
945         (reg:DI 27))]
946   "!TARGET_OPEN_VMS"
947   "")
948
949 (define_expand "umoddi3"
950   [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
951    (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
952    (parallel [(set (reg:DI 27)
953                    (umod:DI (reg:DI 24)
954                             (reg:DI 25)))
955               (clobber (reg:DI 23))
956               (clobber (reg:DI 28))])
957    (set (match_operand:DI 0 "general_operand" "")
958         (reg:DI 27))]
959   "!TARGET_OPEN_VMS"
960   "")
961
962 ;; Lengths of 8 for ldq $t12,__divq($gp); jsr $t9,($t12),__divq as
963 ;; expanded by the assembler.
964 (define_insn ""
965   [(set (reg:DI 27)
966         (sign_extend:DI (match_operator:SI 1 "divmod_operator"
967                         [(reg:DI 24) (reg:DI 25)])))
968    (clobber (reg:DI 23))
969    (clobber (reg:DI 28))]
970   "!TARGET_OPEN_VMS"
971   "%E1 $24,$25,$27"
972   [(set_attr "type" "jsr")
973    (set_attr "length" "8")])
974
975 (define_insn ""
976   [(set (reg:DI 27)
977         (match_operator:DI 1 "divmod_operator"
978                         [(reg:DI 24) (reg:DI 25)]))
979    (clobber (reg:DI 23))
980    (clobber (reg:DI 28))]
981   "!TARGET_OPEN_VMS"
982   "%E1 $24,$25,$27"
983   [(set_attr "type" "jsr")
984    (set_attr "length" "8")])
985 \f
986 ;; Next are the basic logical operations.  These only exist in DImode.
987
988 (define_insn "anddi3"
989   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
990         (and:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ,rJ")
991                 (match_operand:DI 2 "and_operand" "rI,N,MH")))]
992   ""
993   "@
994    and %r1,%2,%0
995    bic %r1,%N2,%0
996    zapnot %r1,%m2,%0"
997   [(set_attr "type" "ilog,ilog,shift")])
998
999 ;; There are times when we can split an AND into two AND insns.  This occurs
1000 ;; when we can first clear any bytes and then clear anything else.  For
1001 ;; example "I & 0xffff07" is "(I & 0xffffff) & 0xffffffffffffff07".
1002 ;; Only do this when running on 64-bit host since the computations are
1003 ;; too messy otherwise.
1004
1005 (define_split
1006   [(set (match_operand:DI 0 "register_operand" "")
1007         (and:DI (match_operand:DI 1 "register_operand" "")
1008                 (match_operand:DI 2 "const_int_operand" "")))]
1009   "HOST_BITS_PER_WIDE_INT == 64 && ! and_operand (operands[2], DImode)"
1010   [(set (match_dup 0) (and:DI (match_dup 1) (match_dup 3)))
1011    (set (match_dup 0) (and:DI (match_dup 0) (match_dup 4)))]
1012   "
1013 {
1014   unsigned HOST_WIDE_INT mask1 = INTVAL (operands[2]);
1015   unsigned HOST_WIDE_INT mask2 = mask1;
1016   int i;
1017
1018   /* For each byte that isn't all zeros, make it all ones.  */
1019   for (i = 0; i < 64; i += 8)
1020     if ((mask1 & ((HOST_WIDE_INT) 0xff << i)) != 0)
1021       mask1 |= (HOST_WIDE_INT) 0xff << i;
1022
1023   /* Now turn on any bits we've just turned off.  */
1024   mask2 |= ~ mask1;
1025
1026   operands[3] = GEN_INT (mask1);
1027   operands[4] = GEN_INT (mask2);
1028 }")
1029
1030 (define_insn "zero_extendqihi2"
1031   [(set (match_operand:HI 0 "register_operand" "=r")
1032         (zero_extend:HI (match_operand:QI 1 "register_operand" "r")))]
1033   ""
1034   "and %1,0xff,%0"
1035   [(set_attr "type" "ilog")])
1036
1037 (define_insn ""
1038   [(set (match_operand:SI 0 "register_operand" "=r,r")
1039         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
1040   "TARGET_BWX"
1041   "@
1042    and %1,0xff,%0
1043    ldbu %0,%1"
1044   [(set_attr "type" "ilog,ild")])
1045
1046 (define_insn ""
1047   [(set (match_operand:SI 0 "register_operand" "=r")
1048         (zero_extend:SI (match_operand:QI 1 "register_operand" "r")))]
1049   "! TARGET_BWX"
1050   "and %1,0xff,%0"
1051   [(set_attr "type" "ilog")])
1052
1053 (define_expand "zero_extendqisi2"
1054   [(set (match_operand:SI 0 "register_operand" "")
1055         (zero_extend:SI (match_operand:QI 1 "register_operand" "")))]
1056   ""
1057   "")
1058
1059 (define_insn ""
1060   [(set (match_operand:DI 0 "register_operand" "=r,r")
1061         (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
1062   "TARGET_BWX"
1063   "@
1064    and %1,0xff,%0
1065    ldbu %0,%1"
1066   [(set_attr "type" "ilog,ild")])
1067
1068 (define_insn ""
1069   [(set (match_operand:DI 0 "register_operand" "=r")
1070         (zero_extend:DI (match_operand:QI 1 "register_operand" "r")))]
1071   "! TARGET_BWX"
1072   "and %1,0xff,%0"
1073   [(set_attr "type" "ilog")])
1074   
1075 (define_expand "zero_extendqidi2"
1076   [(set (match_operand:DI 0 "register_operand" "")
1077         (zero_extend:DI (match_operand:QI 1 "register_operand" "")))]
1078   ""
1079   "")
1080   
1081 (define_insn ""
1082   [(set (match_operand:SI 0 "register_operand" "=r,r")
1083         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
1084   "TARGET_BWX"
1085   "@
1086    zapnot %1,3,%0
1087    ldwu %0,%1"
1088   [(set_attr "type" "shift,ild")])
1089
1090 (define_insn ""
1091   [(set (match_operand:SI 0 "register_operand" "=r")
1092         (zero_extend:SI (match_operand:HI 1 "register_operand" "r")))]
1093   "! TARGET_BWX"
1094   "zapnot %1,3,%0"
1095   [(set_attr "type" "shift")])
1096
1097 (define_expand "zero_extendhisi2"
1098   [(set (match_operand:SI 0 "register_operand" "")
1099         (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
1100   ""
1101   "")
1102
1103 (define_insn ""
1104   [(set (match_operand:DI 0 "register_operand" "=r,r")
1105         (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
1106   "TARGET_BWX"
1107   "@
1108    zapnot %1,3,%0
1109    ldwu %0,%1"
1110   [(set_attr "type" "shift,ild")])
1111
1112 (define_insn ""
1113   [(set (match_operand:DI 0 "register_operand" "=r")
1114         (zero_extend:DI (match_operand:HI 1 "register_operand" "r")))]
1115   ""
1116   "zapnot %1,3,%0"
1117   [(set_attr "type" "shift")])
1118
1119 (define_expand "zero_extendhidi2"
1120   [(set (match_operand:DI 0 "register_operand" "")
1121         (zero_extend:DI (match_operand:HI 1 "register_operand" "")))]
1122   ""
1123   "")
1124
1125 (define_insn "zero_extendsidi2"
1126   [(set (match_operand:DI 0 "register_operand" "=r")
1127         (zero_extend:DI (match_operand:SI 1 "register_operand" "r")))]
1128   ""
1129   "zapnot %1,15,%0"
1130   [(set_attr "type" "shift")])
1131
1132 (define_insn  ""
1133   [(set (match_operand:DI 0 "register_operand" "=r")
1134         (and:DI (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI"))
1135                 (match_operand:DI 2 "reg_or_0_operand" "rJ")))]
1136   ""
1137   "bic %r2,%1,%0"
1138   [(set_attr "type" "ilog")])
1139
1140 (define_insn "iordi3"
1141   [(set (match_operand:DI 0 "register_operand" "=r,r")
1142         (ior:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ")
1143                 (match_operand:DI 2 "or_operand" "rI,N")))]
1144   ""
1145   "@
1146    bis %r1,%2,%0
1147    ornot %r1,%N2,%0"
1148   [(set_attr "type" "ilog")])
1149
1150 (define_insn "one_cmpldi2"
1151   [(set (match_operand:DI 0 "register_operand" "=r")
1152         (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI")))]
1153   ""
1154   "ornot $31,%1,%0"
1155   [(set_attr "type" "ilog")])
1156
1157 (define_insn ""
1158   [(set (match_operand:DI 0 "register_operand" "=r")
1159         (ior:DI (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI"))
1160                 (match_operand:DI 2 "reg_or_0_operand" "rJ")))]
1161   ""
1162   "ornot %r2,%1,%0"
1163   [(set_attr "type" "ilog")])
1164
1165 (define_insn "xordi3"
1166   [(set (match_operand:DI 0 "register_operand" "=r,r")
1167         (xor:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ")
1168                 (match_operand:DI 2 "or_operand" "rI,N")))]
1169   ""
1170   "@
1171    xor %r1,%2,%0
1172    eqv %r1,%N2,%0"
1173   [(set_attr "type" "ilog")])
1174
1175 (define_insn ""
1176   [(set (match_operand:DI 0 "register_operand" "=r")
1177         (not:DI (xor:DI (match_operand:DI 1 "register_operand" "%rJ")
1178                         (match_operand:DI 2 "register_operand" "rI"))))]
1179   ""
1180   "eqv %r1,%2,%0"
1181   [(set_attr "type" "ilog")])
1182 \f
1183 ;; Handle the FFS insn if we support CIX. 
1184
1185 (define_expand "ffsdi2"
1186   [(set (match_dup 2)
1187         (unspec [(match_operand:DI 1 "register_operand" "")] 1))
1188    (set (match_dup 3)
1189         (plus:DI (match_dup 2) (const_int 1)))
1190    (set (match_operand:DI 0 "register_operand" "")
1191         (if_then_else:DI (eq (match_dup 1) (const_int 0))
1192                          (const_int 0) (match_dup 3)))]
1193   "TARGET_CIX"
1194   "
1195 {
1196   operands[2] = gen_reg_rtx (DImode);
1197   operands[3] = gen_reg_rtx (DImode);
1198 }")
1199
1200 (define_insn ""
1201   [(set (match_operand:DI 0 "register_operand" "=r")
1202         (unspec [(match_operand:DI 1 "register_operand" "r")] 1))]
1203   "TARGET_CIX"
1204   "cttz %1,%0"
1205   ; ev6 calls all mvi and cttz/ctlz/popc class imisc, so just 
1206   ; reuse the existing type name.
1207   [(set_attr "type" "mvi")])
1208 \f
1209 ;; Next come the shifts and the various extract and insert operations.
1210
1211 (define_insn "ashldi3"
1212   [(set (match_operand:DI 0 "register_operand" "=r,r")
1213         (ashift:DI (match_operand:DI 1 "reg_or_0_operand" "rJ,rJ")
1214                    (match_operand:DI 2 "reg_or_6bit_operand" "P,rS")))]
1215   ""
1216   "*
1217 {
1218   switch (which_alternative)
1219     {
1220     case 0:
1221       if (operands[2] == const1_rtx)
1222         return \"addq %r1,%r1,%0\";
1223       else
1224         return \"s%P2addq %r1,0,%0\";
1225     case 1:
1226       return \"sll %r1,%2,%0\";
1227     default:
1228       abort();
1229     }
1230 }"
1231   [(set_attr "type" "iadd,shift")])
1232
1233 ;; ??? The following pattern is made by combine, but earlier phases
1234 ;; (specifically flow) can't handle it.  This occurs in jump.c.  Deal
1235 ;; with this in a better way at some point.
1236 ;;(define_insn ""
1237 ;;  [(set (match_operand:DI 0 "register_operand" "=r")
1238 ;;      (sign_extend:DI
1239 ;;       (subreg:SI (ashift:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1240 ;;                             (match_operand:DI 2 "const_int_operand" "P"))
1241 ;;                  0)))]
1242 ;;  "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3"
1243 ;;  "*
1244 ;;{
1245 ;;  if (operands[2] == const1_rtx)
1246 ;;    return \"addl %r1,%r1,%0\";
1247 ;;  else
1248 ;;    return \"s%P2addl %r1,0,%0\";
1249 ;; }"
1250 ;;  [(set_attr "type" "iadd")])
1251                           
1252 (define_insn "lshrdi3"
1253   [(set (match_operand:DI 0 "register_operand" "=r")
1254         (lshiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1255                      (match_operand:DI 2 "reg_or_6bit_operand" "rS")))]
1256   ""
1257   "srl %r1,%2,%0"
1258   [(set_attr "type" "shift")])
1259
1260 (define_insn "ashrdi3"
1261   [(set (match_operand:DI 0 "register_operand" "=r")
1262         (ashiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1263                      (match_operand:DI 2 "reg_or_6bit_operand" "rS")))]
1264   ""
1265   "sra %r1,%2,%0"
1266   [(set_attr "type" "shift")])
1267
1268 (define_expand "extendqihi2"
1269   [(set (match_dup 2)
1270         (ashift:DI (match_operand:QI 1 "some_operand" "")
1271                    (const_int 56)))
1272    (set (match_operand:HI 0 "register_operand" "")
1273         (ashiftrt:DI (match_dup 2)
1274                      (const_int 56)))]
1275   ""
1276   "
1277 {
1278   if (TARGET_BWX)
1279     {
1280       emit_insn (gen_extendqihi2x (operands[0],
1281                                    force_reg (QImode, operands[1])));
1282       DONE;
1283     }
1284  
1285  /* If we have an unaligned MEM, extend to DImode (which we do
1286      specially) and then copy to the result.  */
1287   if (unaligned_memory_operand (operands[1], HImode))
1288     {
1289       rtx temp = gen_reg_rtx (DImode);
1290
1291       emit_insn (gen_extendqidi2 (temp, operands[1]));
1292       emit_move_insn (operands[0], gen_lowpart (HImode, temp));
1293       DONE;
1294     }
1295
1296   operands[0] = gen_lowpart (DImode, operands[0]);
1297   operands[1] = gen_lowpart (DImode, force_reg (QImode, operands[1]));
1298   operands[2] = gen_reg_rtx (DImode);
1299 }")
1300
1301 (define_insn "extendqidi2x"
1302   [(set (match_operand:DI 0 "register_operand" "=r")
1303         (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
1304   "TARGET_BWX"
1305   "sextb %1,%0"
1306   [(set_attr "type" "shift")])
1307
1308 (define_insn "extendhidi2x"
1309   [(set (match_operand:DI 0 "register_operand" "=r")
1310         (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
1311   "TARGET_BWX"
1312   "sextw %1,%0"
1313   [(set_attr "type" "shift")])
1314
1315 (define_insn "extendqisi2x"
1316   [(set (match_operand:SI 0 "register_operand" "=r")
1317         (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
1318   "TARGET_BWX"
1319   "sextb %1,%0"
1320   [(set_attr "type" "shift")])
1321
1322 (define_insn "extendhisi2x"
1323   [(set (match_operand:SI 0 "register_operand" "=r")
1324         (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
1325   "TARGET_BWX"
1326   "sextw %1,%0"
1327   [(set_attr "type" "shift")])
1328
1329 (define_insn "extendqihi2x"
1330   [(set (match_operand:HI 0 "register_operand" "=r")
1331         (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
1332   "TARGET_BWX"
1333   "sextb %1,%0"
1334   [(set_attr "type" "shift")])
1335
1336 (define_expand "extendqisi2"
1337   [(set (match_dup 2)
1338         (ashift:DI (match_operand:QI 1 "some_operand" "")
1339                    (const_int 56)))
1340    (set (match_operand:SI 0 "register_operand" "")
1341         (ashiftrt:DI (match_dup 2)
1342                      (const_int 56)))]
1343   ""
1344   "
1345 {
1346   if (TARGET_BWX)
1347     {
1348       emit_insn (gen_extendqisi2x (operands[0],
1349                                    force_reg (QImode, operands[1])));
1350       DONE;
1351     }
1352
1353   /* If we have an unaligned MEM, extend to a DImode form of
1354      the result (which we do specially).  */
1355   if (unaligned_memory_operand (operands[1], QImode))
1356     {
1357       rtx temp = gen_reg_rtx (DImode);
1358
1359       emit_insn (gen_extendqidi2 (temp, operands[1]));
1360       emit_move_insn (operands[0], gen_lowpart (SImode, temp));
1361       DONE;
1362     }
1363
1364   operands[0] = gen_lowpart (DImode, operands[0]);
1365   operands[1] = gen_lowpart (DImode, force_reg (QImode, operands[1]));
1366   operands[2] = gen_reg_rtx (DImode);
1367 }")
1368
1369 (define_expand "extendqidi2"
1370   [(set (match_dup 2)
1371         (ashift:DI (match_operand:QI 1 "some_operand" "")
1372                    (const_int 56)))
1373    (set (match_operand:DI 0 "register_operand" "")
1374         (ashiftrt:DI (match_dup 2)
1375                      (const_int 56)))]
1376   ""
1377   "
1378 {
1379   if (TARGET_BWX)
1380     {
1381       emit_insn (gen_extendqidi2x (operands[0],
1382                                    force_reg (QImode, operands[1])));
1383       DONE;
1384     }
1385
1386   if (unaligned_memory_operand (operands[1], QImode))
1387     {
1388       rtx seq
1389         = gen_unaligned_extendqidi (operands[0],
1390                                     get_unaligned_address (operands[1], 1));
1391
1392       alpha_set_memflags (seq, operands[1]);
1393       emit_insn (seq);
1394       DONE;
1395     }
1396
1397   operands[1] = gen_lowpart (DImode, force_reg (QImode, operands[1]));
1398   operands[2] = gen_reg_rtx (DImode);
1399 }")
1400
1401 (define_expand "extendhisi2"
1402   [(set (match_dup 2)
1403         (ashift:DI (match_operand:HI 1 "some_operand" "")
1404                    (const_int 48)))
1405    (set (match_operand:SI 0 "register_operand" "")
1406         (ashiftrt:DI (match_dup 2)
1407                      (const_int 48)))]
1408   ""
1409   "
1410 {
1411   if (TARGET_BWX)
1412     {
1413       emit_insn (gen_extendhisi2x (operands[0],
1414                                    force_reg (HImode, operands[1])));
1415       DONE;
1416     }
1417
1418   /* If we have an unaligned MEM, extend to a DImode form of
1419      the result (which we do specially).  */
1420   if (unaligned_memory_operand (operands[1], HImode))
1421     {
1422       rtx temp = gen_reg_rtx (DImode);
1423
1424       emit_insn (gen_extendhidi2 (temp, operands[1]));
1425       emit_move_insn (operands[0], gen_lowpart (SImode, temp));
1426       DONE;
1427     }
1428
1429   operands[0] = gen_lowpart (DImode, operands[0]);
1430   operands[1] = gen_lowpart (DImode, force_reg (HImode, operands[1]));
1431   operands[2] = gen_reg_rtx (DImode);
1432 }")
1433
1434 (define_expand "extendhidi2"
1435   [(set (match_dup 2)
1436         (ashift:DI (match_operand:HI 1 "some_operand" "")
1437                    (const_int 48)))
1438    (set (match_operand:DI 0 "register_operand" "")
1439         (ashiftrt:DI (match_dup 2)
1440                      (const_int 48)))]
1441   ""
1442   "
1443 {
1444   if (TARGET_BWX)
1445     {
1446       emit_insn (gen_extendhidi2x (operands[0],
1447                                    force_reg (HImode, operands[1])));
1448       DONE;
1449     }
1450
1451   if (unaligned_memory_operand (operands[1], HImode))
1452     {
1453       rtx seq
1454         = gen_unaligned_extendhidi (operands[0],
1455                                     get_unaligned_address (operands[1], 2));
1456
1457       alpha_set_memflags (seq, operands[1]);
1458       emit_insn (seq);
1459       DONE;
1460     }
1461
1462   operands[1] = gen_lowpart (DImode, force_reg (HImode, operands[1]));
1463   operands[2] = gen_reg_rtx (DImode);
1464 }")
1465
1466 ;; Here's how we sign extend an unaligned byte and halfword.  Doing this
1467 ;; as a pattern saves one instruction.  The code is similar to that for
1468 ;; the unaligned loads (see below).
1469 ;;
1470 ;; Operand 1 is the address + 1 (+2 for HI), operand 0 is the result.
1471 (define_expand "unaligned_extendqidi"
1472   [(set (match_dup 2) (match_operand:DI 1 "address_operand" ""))
1473    (set (match_dup 3)
1474         (mem:DI (and:DI (plus:DI (match_dup 2) (const_int -1))
1475                         (const_int -8))))
1476    (set (match_dup 4)
1477         (ashift:DI (match_dup 3)
1478                    (minus:DI (const_int 56)
1479                              (ashift:DI
1480                               (and:DI (plus:DI (match_dup 2) (const_int -1))
1481                                       (const_int 7))
1482                               (const_int 3)))))
1483    (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
1484         (ashiftrt:DI (match_dup 4) (const_int 56)))]
1485   ""
1486   "
1487 { operands[2] = gen_reg_rtx (DImode);
1488   operands[3] = gen_reg_rtx (DImode);
1489   operands[4] = gen_reg_rtx (DImode);
1490 }")
1491
1492 (define_expand "unaligned_extendhidi"
1493   [(set (match_dup 2) (match_operand:DI 1 "address_operand" ""))
1494    (set (match_dup 3)
1495         (mem:DI (and:DI (plus:DI (match_dup 2) (const_int -2))
1496                         (const_int -8))))
1497    (set (match_dup 4)
1498         (ashift:DI (match_dup 3)
1499                    (minus:DI (const_int 56)
1500                              (ashift:DI
1501                               (and:DI (plus:DI (match_dup 2) (const_int -1))
1502                                       (const_int 7))
1503                               (const_int 3)))))
1504    (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
1505         (ashiftrt:DI (match_dup 4) (const_int 48)))]
1506   ""
1507   "
1508 { operands[2] = gen_reg_rtx (DImode);
1509   operands[3] = gen_reg_rtx (DImode);
1510   operands[4] = gen_reg_rtx (DImode);
1511 }")
1512
1513 (define_insn ""
1514   [(set (match_operand:DI 0 "register_operand" "=r")
1515         (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1516                          (match_operand:DI 2 "mode_width_operand" "n")
1517                          (match_operand:DI 3 "mul8_operand" "I")))]
1518   ""
1519   "ext%M2l %r1,%s3,%0"
1520   [(set_attr "type" "shift")])
1521
1522 (define_insn "extxl"
1523   [(set (match_operand:DI 0 "register_operand" "=r")
1524         (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1525                          (match_operand:DI 2 "mode_width_operand" "n")
1526                          (ashift:DI (match_operand:DI 3 "reg_or_8bit_operand" "rI")
1527                                     (const_int 3))))]
1528   ""
1529   "ext%M2l %r1,%3,%0"
1530   [(set_attr "type" "shift")])
1531
1532 ;; Combine has some strange notion of preserving existing undefined behaviour
1533 ;; in shifts larger than a word size.  So capture these patterns that it 
1534 ;; should have turned into zero_extracts.
1535
1536 (define_insn ""
1537   [(set (match_operand:DI 0 "register_operand" "=r")
1538         (and (lshiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1539                 (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1540                            (const_int 3)))
1541              (match_operand:DI 3 "mode_mask_operand" "n")))]
1542   ""
1543   "ext%U3l %1,%2,%0"
1544   [(set_attr "type" "shift")])
1545
1546 (define_insn ""
1547   [(set (match_operand:DI 0 "register_operand" "=r")
1548         (lshiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1549           (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1550                      (const_int 3))))]
1551   ""
1552   "extql %1,%2,%0"
1553   [(set_attr "type" "shift")])
1554
1555 (define_insn "extqh"
1556   [(set (match_operand:DI 0 "register_operand" "=r")
1557         (ashift:DI
1558          (match_operand:DI 1 "reg_or_0_operand" "rJ")
1559           (minus:DI (const_int 56)
1560                     (ashift:DI
1561                      (and:DI
1562                       (plus:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1563                                (const_int -1))
1564                       (const_int 7))
1565                      (const_int 3)))))]
1566   ""
1567   "extqh %r1,%2,%0"
1568   [(set_attr "type" "shift")])
1569
1570 (define_insn "extlh"
1571   [(set (match_operand:DI 0 "register_operand" "=r")
1572         (ashift:DI
1573          (and:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1574                  (const_int 2147483647))
1575          (minus:DI (const_int 56)
1576                     (ashift:DI
1577                      (and:DI
1578                       (plus:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1579                                (const_int -1))
1580                       (const_int 7))
1581                      (const_int 3)))))]
1582   ""
1583   "extlh %r1,%2,%0"
1584   [(set_attr "type" "shift")])
1585
1586 (define_insn "extwh"
1587   [(set (match_operand:DI 0 "register_operand" "=r")
1588         (ashift:DI
1589          (and:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1590                  (const_int 65535))
1591          (minus:DI (const_int 56)
1592                     (ashift:DI
1593                      (and:DI
1594                       (plus:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1595                                (const_int -1))
1596                       (const_int 7))
1597                      (const_int 3)))))]
1598   ""
1599   "extwh %r1,%2,%0"
1600   [(set_attr "type" "shift")])
1601
1602 ;; This converts an extXl into an extXh with an appropriate adjustment
1603 ;; to the address calculation.
1604
1605 ;;(define_split
1606 ;;  [(set (match_operand:DI 0 "register_operand" "")
1607 ;;      (ashift:DI (zero_extract:DI (match_operand:DI 1 "register_operand" "")
1608 ;;                                  (match_operand:DI 2 "mode_width_operand" "")
1609 ;;                                  (ashift:DI (match_operand:DI 3 "" "")
1610 ;;                                             (const_int 3)))
1611 ;;                 (match_operand:DI 4 "const_int_operand" "")))
1612 ;;   (clobber (match_operand:DI 5 "register_operand" ""))]
1613 ;;  "INTVAL (operands[4]) == 64 - INTVAL (operands[2])"
1614 ;;  [(set (match_dup 5) (match_dup 6))
1615 ;;   (set (match_dup 0)
1616 ;;      (ashift:DI (zero_extract:DI (match_dup 1) (match_dup 2)
1617 ;;                                  (ashift:DI (plus:DI (match_dup 5)
1618 ;;                                                      (match_dup 7))
1619 ;;                                             (const_int 3)))
1620 ;;                 (match_dup 4)))]
1621 ;;  "
1622 ;;{
1623 ;;  operands[6] = plus_constant (operands[3], 
1624 ;;                             INTVAL (operands[2]) / BITS_PER_UNIT);
1625 ;;  operands[7] = GEN_INT (- INTVAL (operands[2]) / BITS_PER_UNIT);
1626 ;;}")
1627   
1628 (define_insn ""
1629   [(set (match_operand:DI 0 "register_operand" "=r")
1630         (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" "r"))
1631                    (match_operand:DI 2 "mul8_operand" "I")))]
1632   ""
1633   "insbl %1,%s2,%0"
1634   [(set_attr "type" "shift")])
1635
1636 (define_insn ""
1637   [(set (match_operand:DI 0 "register_operand" "=r")
1638         (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" "r"))
1639                    (match_operand:DI 2 "mul8_operand" "I")))]
1640   ""
1641   "inswl %1,%s2,%0"
1642   [(set_attr "type" "shift")])
1643
1644 (define_insn ""
1645   [(set (match_operand:DI 0 "register_operand" "=r")
1646         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
1647                    (match_operand:DI 2 "mul8_operand" "I")))]
1648   ""
1649   "insll %1,%s2,%0"
1650   [(set_attr "type" "shift")])
1651
1652 (define_insn "insbl"
1653   [(set (match_operand:DI 0 "register_operand" "=r")
1654         (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" "r"))
1655                    (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1656                               (const_int 3))))]
1657   ""
1658   "insbl %1,%2,%0"
1659   [(set_attr "type" "shift")])
1660
1661 (define_insn "inswl"
1662   [(set (match_operand:DI 0 "register_operand" "=r")
1663         (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" "r"))
1664                    (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1665                               (const_int 3))))]
1666   ""
1667   "inswl %1,%2,%0"
1668   [(set_attr "type" "shift")])
1669
1670 (define_insn "insll"
1671   [(set (match_operand:DI 0 "register_operand" "=r")
1672         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
1673                    (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1674                               (const_int 3))))]
1675   ""
1676   "insll %1,%2,%0"
1677   [(set_attr "type" "shift")])
1678
1679 (define_insn "insql"
1680   [(set (match_operand:DI 0 "register_operand" "=r")
1681         (ashift:DI (match_operand:DI 1 "register_operand" "r")
1682                    (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1683                               (const_int 3))))]
1684   ""
1685   "insql %1,%2,%0"
1686   [(set_attr "type" "shift")])
1687
1688 ;; Combine has this sometimes habit of moving the and outside of the
1689 ;; shift, making life more interesting.
1690
1691 (define_insn ""
1692   [(set (match_operand:DI 0 "register_operand" "=r")
1693         (and:DI (ashift:DI (match_operand:DI 1 "register_operand" "r")
1694                            (match_operand:DI 2 "mul8_operand" "I"))
1695                 (match_operand:DI 3 "immediate_operand" "i")))]
1696   "HOST_BITS_PER_WIDE_INT == 64
1697    && GET_CODE (operands[3]) == CONST_INT
1698    && (((unsigned HOST_WIDE_INT) 0xff << INTVAL (operands[2])
1699         == (unsigned HOST_WIDE_INT) INTVAL (operands[3]))
1700        || ((unsigned HOST_WIDE_INT) 0xffff << INTVAL (operands[2])
1701         == (unsigned HOST_WIDE_INT) INTVAL (operands[3]))
1702        || ((unsigned HOST_WIDE_INT) 0xffffffff << INTVAL (operands[2])
1703         == (unsigned HOST_WIDE_INT) INTVAL (operands[3])))"
1704   "*
1705 {
1706 #if HOST_BITS_PER_WIDE_INT == 64
1707   if ((unsigned HOST_WIDE_INT) 0xff << INTVAL (operands[2])
1708       == (unsigned HOST_WIDE_INT) INTVAL (operands[3]))
1709     return \"insbl %1,%s2,%0\";
1710   if ((unsigned HOST_WIDE_INT) 0xffff << INTVAL (operands[2])
1711       == (unsigned HOST_WIDE_INT) INTVAL (operands[3]))
1712     return \"inswl %1,%s2,%0\";
1713   if ((unsigned HOST_WIDE_INT) 0xffffffff << INTVAL (operands[2])
1714       == (unsigned HOST_WIDE_INT) INTVAL (operands[3]))
1715     return \"insll %1,%s2,%0\";
1716 #endif
1717   abort();
1718 }"
1719   [(set_attr "type" "shift")])
1720
1721 ;; We do not include the insXh insns because they are complex to express
1722 ;; and it does not appear that we would ever want to generate them.
1723 ;;
1724 ;; Since we need them for block moves, though, cop out and use unspec.
1725
1726 (define_insn "insxh"
1727   [(set (match_operand:DI 0 "register_operand" "=r")
1728         (unspec [(match_operand:DI 1 "register_operand" "r")
1729                  (match_operand:DI 2 "mode_width_operand" "n")
1730                  (match_operand:DI 3 "reg_or_8bit_operand" "rI")] 2))]
1731   ""
1732   "ins%M2h %1,%3,%0"
1733   [(set_attr "type" "shift")])
1734
1735 (define_insn "mskxl"
1736   [(set (match_operand:DI 0 "register_operand" "=r")
1737         (and:DI (not:DI (ashift:DI
1738                          (match_operand:DI 2 "mode_mask_operand" "n")
1739                          (ashift:DI
1740                           (match_operand:DI 3 "reg_or_8bit_operand" "rI")
1741                           (const_int 3))))
1742                 (match_operand:DI 1 "reg_or_0_operand" "rJ")))]
1743   ""
1744   "msk%U2l %r1,%3,%0"
1745   [(set_attr "type" "shift")])
1746
1747 ;; We do not include the mskXh insns because it does not appear we would
1748 ;; ever generate one.
1749 ;;
1750 ;; Again, we do for block moves and we use unspec again.
1751
1752 (define_insn "mskxh"
1753   [(set (match_operand:DI 0 "register_operand" "=r")
1754         (unspec [(match_operand:DI 1 "register_operand" "r")
1755                  (match_operand:DI 2 "mode_width_operand" "n")
1756                  (match_operand:DI 3 "reg_or_8bit_operand" "rI")] 3))]
1757   ""
1758   "msk%M2h %1,%3,%0"
1759   [(set_attr "type" "shift")])
1760 \f
1761 ;; Floating-point operations.  All the double-precision insns can extend
1762 ;; from single, so indicate that.  The exception are the ones that simply
1763 ;; play with the sign bits; it's not clear what to do there.
1764
1765 (define_insn "abssf2"
1766   [(set (match_operand:SF 0 "register_operand" "=f")
1767         (abs:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")))]
1768   "TARGET_FP"
1769   "cpys $f31,%R1,%0"
1770   [(set_attr "type" "fcpys")])
1771
1772 (define_insn "absdf2"
1773   [(set (match_operand:DF 0 "register_operand" "=f")
1774         (abs:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
1775   "TARGET_FP"
1776   "cpys $f31,%R1,%0"
1777   [(set_attr "type" "fcpys")])
1778
1779 (define_insn "negsf2"
1780   [(set (match_operand:SF 0 "register_operand" "=f")
1781         (neg:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")))]
1782   "TARGET_FP"
1783   "cpysn %R1,%R1,%0"
1784   [(set_attr "type" "fadd")])
1785
1786 (define_insn "negdf2"
1787   [(set (match_operand:DF 0 "register_operand" "=f")
1788         (neg:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
1789   "TARGET_FP"
1790   "cpysn %R1,%R1,%0"
1791   [(set_attr "type" "fadd")])
1792
1793 (define_insn ""
1794   [(set (match_operand:SF 0 "register_operand" "=&f")
1795         (plus:SF (match_operand:SF 1 "reg_or_fp0_operand" "%fG")
1796                  (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
1797   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
1798   "add%,%)%& %R1,%R2,%0"
1799   [(set_attr "type" "fadd")
1800    (set_attr "trap" "yes")])
1801
1802 (define_insn "addsf3"
1803   [(set (match_operand:SF 0 "register_operand" "=f")
1804         (plus:SF (match_operand:SF 1 "reg_or_fp0_operand" "%fG")
1805                  (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
1806   "TARGET_FP"
1807   "add%,%)%& %R1,%R2,%0"
1808   [(set_attr "type" "fadd")
1809    (set_attr "trap" "yes")])
1810
1811 (define_insn ""
1812   [(set (match_operand:DF 0 "register_operand" "=&f")
1813         (plus:DF (match_operand:DF 1 "reg_or_fp0_operand" "%fG")
1814                  (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1815   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
1816   "add%-%)%& %R1,%R2,%0"
1817   [(set_attr "type" "fadd")
1818    (set_attr "trap" "yes")])
1819
1820 (define_insn "adddf3"
1821   [(set (match_operand:DF 0 "register_operand" "=f")
1822         (plus:DF (match_operand:DF 1 "reg_or_fp0_operand" "%fG")
1823                  (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1824   "TARGET_FP"
1825   "add%-%)%& %R1,%R2,%0"
1826   [(set_attr "type" "fadd")
1827    (set_attr "trap" "yes")])
1828
1829 (define_insn ""
1830   [(set (match_operand:DF 0 "register_operand" "=f")
1831         (plus:DF (float_extend:DF
1832                   (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
1833                  (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1834   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
1835   "add%-%)%& %R1,%R2,%0"
1836   [(set_attr "type" "fadd")
1837    (set_attr "trap" "yes")])
1838
1839 (define_insn ""
1840   [(set (match_operand:DF 0 "register_operand" "=f")
1841         (plus:DF (float_extend:DF
1842                   (match_operand:SF 1 "reg_or_fp0_operand" "%fG"))
1843                  (float_extend:DF
1844                   (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
1845   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
1846   "add%-%)%& %R1,%R2,%0"
1847   [(set_attr "type" "fadd")
1848    (set_attr "trap" "yes")])
1849
1850 ;; Define conversion operators between DFmode and SImode, using the cvtql
1851 ;; instruction.  To allow combine et al to do useful things, we keep the
1852 ;; operation as a unit until after reload, at which point we split the
1853 ;; instructions.
1854 ;;
1855 ;; Note that we (attempt to) only consider this optimization when the
1856 ;; ultimate destination is memory.  If we will be doing further integer
1857 ;; processing, it is cheaper to do the truncation in the int regs.
1858
1859 (define_insn "*cvtql"
1860   [(set (match_operand:SI 0 "register_operand" "=f")
1861         (unspec:SI [(match_operand:DI 1 "reg_or_fp0_operand" "fG")] 5))]
1862   "TARGET_FP"
1863   "cvtql%` %R1,%0"
1864   [(set_attr "type" "fadd")
1865    (set_attr "trap" "yes")])
1866
1867 (define_split
1868   [(set (match_operand:SI 0 "memory_operand" "")
1869         (subreg:SI (fix:DI (match_operand:DF 1 "reg_or_fp0_operand" "")) 0))
1870    (clobber (match_scratch:DI 2 ""))
1871    (clobber (match_scratch:SI 3 ""))]
1872   "TARGET_FP && reload_completed"
1873   [(set (match_dup 2) (fix:DI (match_dup 1)))
1874    (set (match_dup 3) (unspec:SI [(match_dup 2)] 5))
1875    (set (match_dup 0) (match_dup 3))]
1876   "")
1877
1878 (define_split
1879   [(set (match_operand:SI 0 "memory_operand" "")
1880         (subreg:SI (fix:DI (match_operand:DF 1 "reg_or_fp0_operand" "")) 0))
1881    (clobber (match_scratch:DI 2 ""))]
1882   "TARGET_FP && reload_completed"
1883   [(set (match_dup 2) (fix:DI (match_dup 1)))
1884    (set (match_dup 3) (unspec:SI [(match_dup 2)] 5))
1885    (set (match_dup 0) (match_dup 3))]
1886   ;; Due to REG_CANNOT_CHANGE_SIZE issues, we cannot simply use SUBREG.
1887   "operands[3] = gen_rtx_REG (SImode, REGNO (operands[2]));")
1888
1889 (define_insn ""
1890   [(set (match_operand:SI 0 "memory_operand" "=m")
1891         (subreg:SI (fix:DI (match_operand:DF 1 "reg_or_fp0_operand" "fG")) 0))
1892    (clobber (match_scratch:DI 2 "=&f"))
1893    (clobber (match_scratch:SI 3 "=&f"))]
1894   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
1895   "#"
1896   [(set_attr "type" "fadd")
1897    (set_attr "trap" "yes")])
1898
1899 (define_insn ""
1900   [(set (match_operand:SI 0 "memory_operand" "=m")
1901         (subreg:SI (fix:DI (match_operand:DF 1 "reg_or_fp0_operand" "fG")) 0))
1902    (clobber (match_scratch:DI 2 "=f"))]
1903   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
1904   "#"
1905   [(set_attr "type" "fadd")
1906    (set_attr "trap" "yes")])
1907
1908 (define_insn ""
1909   [(set (match_operand:DI 0 "register_operand" "=&f")
1910         (fix:DI (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
1911   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
1912   "cvt%-q%(c %R1,%0"
1913   [(set_attr "type" "fadd")
1914    (set_attr "trap" "yes")])
1915
1916 (define_insn "fix_truncdfdi2"
1917   [(set (match_operand:DI 0 "register_operand" "=f")
1918         (fix:DI (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
1919   "TARGET_FP"
1920   "cvt%-q%(c %R1,%0"
1921   [(set_attr "type" "fadd")
1922    (set_attr "trap" "yes")])
1923
1924 ;; Likewise between SFmode and SImode.
1925
1926 (define_split
1927   [(set (match_operand:SI 0 "memory_operand" "")
1928         (subreg:SI (fix:DI (float_extend:DF
1929                  (match_operand:SF 1 "reg_or_fp0_operand" ""))) 0))
1930    (clobber (match_scratch:DI 2 ""))
1931    (clobber (match_scratch:SI 3 ""))]
1932   "TARGET_FP && reload_completed"
1933   [(set (match_dup 2) (fix:DI (float_extend:DF (match_dup 1))))
1934    (set (match_dup 3) (unspec:SI [(match_dup 2)] 5))
1935    (set (match_dup 0) (match_dup 3))]
1936   "")
1937
1938 (define_split
1939   [(set (match_operand:SI 0 "memory_operand" "")
1940         (subreg:SI (fix:DI (float_extend:DF
1941                  (match_operand:SF 1 "reg_or_fp0_operand" ""))) 0))
1942    (clobber (match_scratch:DI 2 ""))]
1943   "TARGET_FP && reload_completed"
1944   [(set (match_dup 2) (fix:DI (float_extend:DF (match_dup 1))))
1945    (set (match_dup 3) (unspec:SI [(match_dup 2)] 5))
1946    (set (match_dup 0) (match_dup 3))]
1947   ;; Due to REG_CANNOT_CHANGE_SIZE issues, we cannot simply use SUBREG.
1948   "operands[3] = gen_rtx_REG (SImode, REGNO (operands[2]));")
1949
1950 (define_insn ""
1951   [(set (match_operand:SI 0 "memory_operand" "=m")
1952         (subreg:SI (fix:DI (float_extend:DF
1953                  (match_operand:SF 1 "reg_or_fp0_operand" "fG"))) 0))
1954    (clobber (match_scratch:DI 2 "=&f"))
1955    (clobber (match_scratch:SI 3 "=&f"))]
1956   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
1957   "#"
1958   [(set_attr "type" "fadd")
1959    (set_attr "trap" "yes")])
1960
1961 (define_insn ""
1962   [(set (match_operand:SI 0 "memory_operand" "=m")
1963         (subreg:SI (fix:DI (float_extend:DF
1964                  (match_operand:SF 1 "reg_or_fp0_operand" "fG"))) 0))
1965    (clobber (match_scratch:DI 2 "=f"))]
1966   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
1967   "#"
1968   [(set_attr "type" "fadd")
1969    (set_attr "trap" "yes")])
1970
1971 (define_insn ""
1972   [(set (match_operand:DI 0 "register_operand" "=&f")
1973         (fix:DI (float_extend:DF
1974                  (match_operand:SF 1 "reg_or_fp0_operand" "fG"))))]
1975   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
1976   "cvt%-q%(c %R1,%0"
1977   [(set_attr "type" "fadd")
1978    (set_attr "trap" "yes")])
1979
1980 (define_insn "fix_truncsfdi2"
1981   [(set (match_operand:DI 0 "register_operand" "=f")
1982         (fix:DI (float_extend:DF
1983                  (match_operand:SF 1 "reg_or_fp0_operand" "fG"))))]
1984   "TARGET_FP"
1985   "cvt%-q%(c %R1,%0"
1986   [(set_attr "type" "fadd")
1987    (set_attr "trap" "yes")])
1988
1989 (define_insn ""
1990   [(set (match_operand:SF 0 "register_operand" "=&f")
1991         (float:SF (match_operand:DI 1 "reg_no_subreg_operand" "f")))]
1992   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
1993   "cvtq%,%+%& %1,%0"
1994   [(set_attr "type" "fadd")
1995    (set_attr "trap" "yes")])
1996
1997 (define_insn "floatdisf2"
1998   [(set (match_operand:SF 0 "register_operand" "=f")
1999         (float:SF (match_operand:DI 1 "reg_no_subreg_operand" "f")))]
2000   "TARGET_FP"
2001   "cvtq%,%+%& %1,%0"
2002   [(set_attr "type" "fadd")
2003    (set_attr "trap" "yes")])
2004
2005 (define_insn ""
2006   [(set (match_operand:DF 0 "register_operand" "=&f")
2007         (float:DF (match_operand:DI 1 "reg_no_subreg_operand" "f")))]
2008   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2009   "cvtq%-%+%& %1,%0"
2010   [(set_attr "type" "fadd")
2011    (set_attr "trap" "yes")])
2012
2013 (define_insn "floatdidf2"
2014   [(set (match_operand:DF 0 "register_operand" "=f")
2015         (float:DF (match_operand:DI 1 "reg_no_subreg_operand" "f")))]
2016   "TARGET_FP"
2017   "cvtq%-%+%& %1,%0"
2018   [(set_attr "type" "fadd")
2019    (set_attr "trap" "yes")])
2020
2021 (define_expand "extendsfdf2"
2022   [(use (match_operand:DF 0 "register_operand" ""))
2023    (use (match_operand:SF 1 "nonimmediate_operand" ""))]
2024   "TARGET_FP"
2025 "
2026 {
2027   if (alpha_tp == ALPHA_TP_INSN)
2028     emit_insn (gen_extendsfdf2_tp (operands[0],
2029                                    force_reg (SFmode, operands[1])));
2030   else
2031     emit_insn (gen_extendsfdf2_no_tp (operands[0], operands[1]));
2032
2033   DONE;
2034 }")
2035 ;; FIXME
2036 (define_insn "extendsfdf2_tp"
2037   [(set (match_operand:DF 0 "register_operand" "=&f")
2038         (float_extend:DF (match_operand:SF 1 "register_operand" "f")))]
2039   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2040   "cvtsts %1,%0"
2041   [(set_attr "type" "fadd")
2042    (set_attr "trap" "yes")])
2043
2044 (define_insn "extendsfdf2_no_tp"
2045   [(set (match_operand:DF 0 "register_operand" "=f,f,m")
2046         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,m,f")))]
2047   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2048   "@
2049    fmov %1,%0
2050    ld%, %0,%1
2051    st%- %1,%0"
2052   [(set_attr "type" "fcpys,fld,fst")
2053    (set_attr "trap" "yes")])
2054
2055 (define_insn ""
2056   [(set (match_operand:SF 0 "register_operand" "=&f")
2057         (float_truncate:SF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
2058   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2059   "cvt%-%,%)%& %R1,%0"
2060   [(set_attr "type" "fadd")
2061    (set_attr "trap" "yes")])
2062
2063 (define_insn "truncdfsf2"
2064   [(set (match_operand:SF 0 "register_operand" "=f")
2065         (float_truncate:SF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
2066   "TARGET_FP"
2067   "cvt%-%,%)%& %R1,%0"
2068   [(set_attr "type" "fadd")
2069    (set_attr "trap" "yes")])
2070
2071 (define_insn ""
2072   [(set (match_operand:SF 0 "register_operand" "=&f")
2073         (div:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")
2074                 (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
2075   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2076   "div%,%)%& %R1,%R2,%0"
2077   [(set_attr "type" "fdiv")
2078    (set_attr "opsize" "si")
2079    (set_attr "trap" "yes")])
2080
2081 (define_insn "divsf3"
2082   [(set (match_operand:SF 0 "register_operand" "=f")
2083         (div:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")
2084                 (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
2085   "TARGET_FP"
2086   "div%,%)%& %R1,%R2,%0"
2087   [(set_attr "type" "fdiv")
2088    (set_attr "opsize" "si")
2089    (set_attr "trap" "yes")])
2090
2091 (define_insn ""
2092   [(set (match_operand:DF 0 "register_operand" "=&f")
2093         (div:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
2094                 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2095   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2096   "div%-%)%& %R1,%R2,%0"
2097   [(set_attr "type" "fdiv")
2098    (set_attr "trap" "yes")])
2099
2100 (define_insn "divdf3"
2101   [(set (match_operand:DF 0 "register_operand" "=f")
2102         (div:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
2103                 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2104   "TARGET_FP"
2105   "div%-%)%& %R1,%R2,%0"
2106   [(set_attr "type" "fdiv")
2107    (set_attr "trap" "yes")])
2108
2109 (define_insn ""
2110   [(set (match_operand:DF 0 "register_operand" "=f")
2111         (div:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
2112                 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2113   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2114   "div%-%)%& %R1,%R2,%0"
2115   [(set_attr "type" "fdiv")
2116    (set_attr "trap" "yes")])
2117
2118 (define_insn ""
2119   [(set (match_operand:DF 0 "register_operand" "=f")
2120         (div:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
2121                 (float_extend:DF
2122                  (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
2123   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2124   "div%-%)%& %R1,%R2,%0"
2125   [(set_attr "type" "fdiv")
2126    (set_attr "trap" "yes")])
2127
2128 (define_insn ""
2129   [(set (match_operand:DF 0 "register_operand" "=f")
2130         (div:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
2131                 (float_extend:DF (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
2132   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2133   "div%-%)%& %R1,%R2,%0"
2134   [(set_attr "type" "fdiv")
2135    (set_attr "trap" "yes")])
2136
2137 (define_insn ""
2138   [(set (match_operand:SF 0 "register_operand" "=&f")
2139         (mult:SF (match_operand:SF 1 "reg_or_fp0_operand" "%fG")
2140                  (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
2141   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2142   "mul%,%)%& %R1,%R2,%0"
2143   [(set_attr "type" "fmul")
2144    (set_attr "trap" "yes")])
2145
2146 (define_insn "mulsf3"
2147   [(set (match_operand:SF 0 "register_operand" "=f")
2148         (mult:SF (match_operand:SF 1 "reg_or_fp0_operand" "%fG")
2149                  (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
2150   "TARGET_FP"
2151   "mul%,%)%& %R1,%R2,%0"
2152   [(set_attr "type" "fmul")
2153    (set_attr "trap" "yes")])
2154
2155 (define_insn ""
2156   [(set (match_operand:DF 0 "register_operand" "=&f")
2157         (mult:DF (match_operand:DF 1 "reg_or_fp0_operand" "%fG")
2158                  (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2159   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2160   "mul%-%)%& %R1,%R2,%0"
2161   [(set_attr "type" "fmul")
2162    (set_attr "trap" "yes")])
2163
2164 (define_insn "muldf3"
2165   [(set (match_operand:DF 0 "register_operand" "=f")
2166         (mult:DF (match_operand:DF 1 "reg_or_fp0_operand" "%fG")
2167                  (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2168   "TARGET_FP"
2169   "mul%-%)%& %R1,%R2,%0"
2170   [(set_attr "type" "fmul")
2171    (set_attr "trap" "yes")])
2172
2173 (define_insn ""
2174   [(set (match_operand:DF 0 "register_operand" "=f")
2175         (mult:DF (float_extend:DF
2176                   (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
2177                  (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2178   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2179   "mul%-%)%& %R1,%R2,%0"
2180   [(set_attr "type" "fmul")
2181    (set_attr "trap" "yes")])
2182
2183 (define_insn ""
2184   [(set (match_operand:DF 0 "register_operand" "=f")
2185         (mult:DF (float_extend:DF
2186                   (match_operand:SF 1 "reg_or_fp0_operand" "%fG"))
2187                  (float_extend:DF
2188                   (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
2189   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2190   "mul%-%)%& %R1,%R2,%0"
2191   [(set_attr "type" "fmul")
2192    (set_attr "trap" "yes")])
2193
2194 (define_insn ""
2195   [(set (match_operand:SF 0 "register_operand" "=&f")
2196         (minus:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")
2197                   (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
2198   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2199   "sub%,%)%& %R1,%R2,%0"
2200   [(set_attr "type" "fadd")
2201    (set_attr "trap" "yes")])
2202
2203 (define_insn "subsf3"
2204   [(set (match_operand:SF 0 "register_operand" "=f")
2205         (minus:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")
2206                   (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
2207   "TARGET_FP"
2208   "sub%,%)%& %R1,%R2,%0"
2209   [(set_attr "type" "fadd")
2210    (set_attr "trap" "yes")])
2211
2212 (define_insn ""
2213   [(set (match_operand:DF 0 "register_operand" "=&f")
2214         (minus:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
2215                   (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2216   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2217   "sub%-%)%& %R1,%R2,%0"
2218   [(set_attr "type" "fadd")
2219    (set_attr "trap" "yes")])
2220
2221 (define_insn "subdf3"
2222   [(set (match_operand:DF 0 "register_operand" "=f")
2223         (minus:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
2224                   (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2225   "TARGET_FP"
2226   "sub%-%)%& %R1,%R2,%0"
2227   [(set_attr "type" "fadd")
2228    (set_attr "trap" "yes")])
2229
2230 (define_insn ""
2231   [(set (match_operand:DF 0 "register_operand" "=f")
2232         (minus:DF (float_extend:DF
2233                    (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
2234                   (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2235   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2236   "sub%-%)%& %R1,%R2,%0"
2237   [(set_attr "type" "fadd")
2238    (set_attr "trap" "yes")])
2239
2240 (define_insn ""
2241   [(set (match_operand:DF 0 "register_operand" "=f")
2242         (minus:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
2243                   (float_extend:DF
2244                    (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
2245   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2246   "sub%-%)%& %R1,%R2,%0"
2247   [(set_attr "type" "fadd")
2248    (set_attr "trap" "yes")])
2249
2250 (define_insn ""
2251   [(set (match_operand:DF 0 "register_operand" "=f")
2252         (minus:DF (float_extend:DF
2253                    (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
2254                   (float_extend:DF
2255                    (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
2256   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2257   "sub%-%)%& %R1,%R2,%0"
2258   [(set_attr "type" "fadd")
2259    (set_attr "trap" "yes")])
2260
2261 (define_insn ""
2262   [(set (match_operand:SF 0 "register_operand" "=&f")
2263         (sqrt:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")))]
2264   "TARGET_FP && TARGET_CIX && alpha_tp == ALPHA_TP_INSN"
2265   "sqrt%,%)%& %R1,%0"
2266   [(set_attr "type" "fsqrt")
2267    (set_attr "opsize" "si")
2268    (set_attr "trap" "yes")])
2269
2270 (define_insn "sqrtsf2"
2271   [(set (match_operand:SF 0 "register_operand" "=f")
2272         (sqrt:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")))]
2273   "TARGET_FP && TARGET_CIX"
2274   "sqrt%,%)%& %R1,%0"
2275   [(set_attr "type" "fsqrt")
2276    (set_attr "opsize" "si")
2277    (set_attr "trap" "yes")])
2278
2279 (define_insn ""
2280   [(set (match_operand:DF 0 "register_operand" "=&f")
2281         (sqrt:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
2282   "TARGET_FP && TARGET_CIX && alpha_tp == ALPHA_TP_INSN"
2283   "sqrt%-%)%& %R1,%0"
2284   [(set_attr "type" "fsqrt")
2285    (set_attr "trap" "yes")])
2286
2287 (define_insn "sqrtdf2"
2288   [(set (match_operand:DF 0 "register_operand" "=f")
2289         (sqrt:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
2290   "TARGET_FP && TARGET_CIX"
2291   "sqrt%-%)%& %1,%0"
2292   [(set_attr "type" "fsqrt")
2293    (set_attr "trap" "yes")])
2294 \f
2295 ;; Next are all the integer comparisons, and conditional moves and branches
2296 ;; and some of the related define_expand's and define_split's.
2297
2298 (define_insn ""
2299   [(set (match_operand:DI 0 "register_operand" "=r")
2300         (match_operator:DI 1 "alpha_comparison_operator"
2301                            [(match_operand:DI 2 "reg_or_0_operand" "rJ")
2302                             (match_operand:DI 3 "reg_or_8bit_operand" "rI")]))]
2303   ""
2304   "cmp%C1 %r2,%3,%0"
2305   [(set_attr "type" "icmp")])
2306
2307 (define_insn ""
2308   [(set (match_operand:DI 0 "register_operand" "=r")
2309         (match_operator:DI 1 "alpha_swapped_comparison_operator"
2310                            [(match_operand:DI 2 "reg_or_8bit_operand" "rI")
2311                             (match_operand:DI 3 "reg_or_0_operand" "rJ")]))]
2312   ""
2313   "cmp%c1 %r3,%2,%0"
2314   [(set_attr "type" "icmp")])
2315
2316 ;; This pattern exists so conditional moves of SImode values are handled.
2317 ;; Comparisons are still done in DImode though.
2318
2319 (define_insn ""
2320   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
2321         (if_then_else:SI
2322          (match_operator 2 "signed_comparison_operator"
2323                          [(match_operand:DI 3 "reg_or_0_operand" "rJ,rJ,J,J")
2324                           (match_operand:DI 4 "reg_or_0_operand" "J,J,rJ,rJ")])
2325          (match_operand:SI 1 "reg_or_8bit_operand" "rI,0,rI,0")
2326          (match_operand:SI 5 "reg_or_8bit_operand" "0,rI,0,rI")))]
2327   "operands[3] == const0_rtx || operands[4] == const0_rtx"
2328   "@
2329    cmov%C2 %r3,%1,%0
2330    cmov%D2 %r3,%5,%0
2331    cmov%c2 %r4,%1,%0
2332    cmov%d2 %r4,%5,%0"
2333   [(set_attr "type" "icmov")])
2334
2335 (define_insn ""
2336   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r")
2337         (if_then_else:DI
2338          (match_operator 2 "signed_comparison_operator"
2339                          [(match_operand:DI 3 "reg_or_0_operand" "rJ,rJ,J,J")
2340                           (match_operand:DI 4 "reg_or_0_operand" "J,J,rJ,rJ")])
2341          (match_operand:DI 1 "reg_or_8bit_operand" "rI,0,rI,0")
2342          (match_operand:DI 5 "reg_or_8bit_operand" "0,rI,0,rI")))]
2343   "operands[3] == const0_rtx || operands[4] == const0_rtx"
2344   "@
2345    cmov%C2 %r3,%1,%0
2346    cmov%D2 %r3,%5,%0
2347    cmov%c2 %r4,%1,%0
2348    cmov%d2 %r4,%5,%0"
2349   [(set_attr "type" "icmov")])
2350
2351 (define_insn ""
2352   [(set (match_operand:DI 0 "register_operand" "=r,r")
2353         (if_then_else:DI
2354          (eq (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
2355                               (const_int 1)
2356                               (const_int 0))
2357              (const_int 0))
2358          (match_operand:DI 1 "reg_or_8bit_operand" "rI,0")
2359          (match_operand:DI 3 "reg_or_8bit_operand" "0,rI")))]
2360   ""
2361   "@
2362    cmovlbc %r2,%1,%0
2363    cmovlbs %r2,%3,%0"
2364   [(set_attr "type" "icmov")])
2365
2366 (define_insn ""
2367   [(set (match_operand:DI 0 "register_operand" "=r,r")
2368         (if_then_else:DI
2369          (ne (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
2370                               (const_int 1)
2371                               (const_int 0))
2372              (const_int 0))
2373          (match_operand:DI 1 "reg_or_8bit_operand" "rI,0")
2374          (match_operand:DI 3 "reg_or_8bit_operand" "0,rI")))]
2375   ""
2376   "@
2377    cmovlbs %r2,%1,%0
2378    cmovlbc %r2,%3,%0"
2379   [(set_attr "type" "icmov")])
2380
2381 ;; For ABS, we have two choices, depending on whether the input and output
2382 ;; registers are the same or not.
2383 (define_expand "absdi2"
2384   [(set (match_operand:DI 0 "register_operand" "")
2385         (abs:DI (match_operand:DI 1 "register_operand" "")))]
2386   ""
2387   "
2388 { if (rtx_equal_p (operands[0], operands[1]))
2389     emit_insn (gen_absdi2_same (operands[0], gen_reg_rtx (DImode)));
2390   else
2391     emit_insn (gen_absdi2_diff (operands[0], operands[1]));
2392
2393   DONE;
2394 }")
2395
2396 (define_expand "absdi2_same"
2397   [(set (match_operand:DI 1 "register_operand" "")
2398         (neg:DI (match_operand:DI 0 "register_operand" "")))
2399    (set (match_dup 0)
2400         (if_then_else:DI (ge (match_dup 0) (const_int 0))
2401                          (match_dup 0)
2402                          (match_dup 1)))]
2403   ""
2404   "")
2405
2406 (define_expand "absdi2_diff"
2407   [(set (match_operand:DI 0 "register_operand" "")
2408         (neg:DI (match_operand:DI 1 "register_operand" "")))
2409    (set (match_dup 0)
2410         (if_then_else:DI (lt (match_dup 1) (const_int 0))
2411                          (match_dup 0)
2412                          (match_dup 1)))]
2413   ""
2414   "")
2415
2416 (define_split
2417   [(set (match_operand:DI 0 "register_operand" "")
2418         (abs:DI (match_dup 0)))
2419    (clobber (match_operand:DI 2 "register_operand" ""))]
2420   ""
2421   [(set (match_dup 1) (neg:DI (match_dup 0)))
2422    (set (match_dup 0) (if_then_else:DI (ge (match_dup 0) (const_int 0))
2423                                        (match_dup 0) (match_dup 1)))]
2424   "")
2425
2426 (define_split
2427   [(set (match_operand:DI 0 "register_operand" "")
2428         (abs:DI (match_operand:DI 1 "register_operand" "")))]
2429   "! rtx_equal_p (operands[0], operands[1])"
2430   [(set (match_dup 0) (neg:DI (match_dup 1)))
2431    (set (match_dup 0) (if_then_else:DI (lt (match_dup 1) (const_int 0))
2432                                        (match_dup 0) (match_dup 1)))]
2433   "")
2434
2435 (define_split
2436   [(set (match_operand:DI 0 "register_operand" "")
2437         (neg:DI (abs:DI (match_dup 0))))
2438    (clobber (match_operand:DI 2 "register_operand" ""))]
2439   ""
2440   [(set (match_dup 1) (neg:DI (match_dup 0)))
2441    (set (match_dup 0) (if_then_else:DI (le (match_dup 0) (const_int 0))
2442                                        (match_dup 0) (match_dup 1)))]
2443   "")
2444
2445 (define_split
2446   [(set (match_operand:DI 0 "register_operand" "")
2447         (neg:DI (abs:DI (match_operand:DI 1 "register_operand" ""))))]
2448   "! rtx_equal_p (operands[0], operands[1])"
2449   [(set (match_dup 0) (neg:DI (match_dup 1)))
2450    (set (match_dup 0) (if_then_else:DI (gt (match_dup 1) (const_int 0))
2451                                        (match_dup 0) (match_dup 1)))]
2452   "")
2453
2454 (define_insn "sminqi3"
2455   [(set (match_operand:QI 0 "register_operand" "=r")
2456         (smin:QI (match_operand:QI 1 "reg_or_0_operand" "%rJ")
2457                  (match_operand:QI 2 "reg_or_8bit_operand" "rI")))]
2458   "TARGET_MAX"
2459   "minsb8 %r1,%2,%0"
2460   [(set_attr "type" "mvi")])
2461
2462 (define_insn "uminqi3"
2463   [(set (match_operand:QI 0 "register_operand" "=r")
2464         (umin:QI (match_operand:QI 1 "reg_or_0_operand" "%rJ")
2465                  (match_operand:QI 2 "reg_or_8bit_operand" "rI")))]
2466   "TARGET_MAX"
2467   "minub8 %r1,%2,%0"
2468   [(set_attr "type" "mvi")])
2469
2470 (define_insn "smaxqi3"
2471   [(set (match_operand:QI 0 "register_operand" "=r")
2472         (smax:QI (match_operand:QI 1 "reg_or_0_operand" "%rJ")
2473                  (match_operand:QI 2 "reg_or_8bit_operand" "rI")))]
2474   "TARGET_MAX"
2475   "maxsb8 %r1,%2,%0"
2476   [(set_attr "type" "mvi")])
2477
2478 (define_insn "umaxqi3"
2479   [(set (match_operand:QI 0 "register_operand" "=r")
2480         (umax:QI (match_operand:QI 1 "reg_or_0_operand" "%rJ")
2481                  (match_operand:QI 2 "reg_or_8bit_operand" "rI")))]
2482   "TARGET_MAX"
2483   "maxub8 %r1,%2,%0"
2484   [(set_attr "type" "mvi")])
2485
2486 (define_insn "sminhi3"
2487   [(set (match_operand:HI 0 "register_operand" "=r")
2488         (smin:HI (match_operand:HI 1 "reg_or_0_operand" "%rJ")
2489                  (match_operand:HI 2 "reg_or_8bit_operand" "rI")))]
2490   "TARGET_MAX"
2491   "minsw4 %r1,%2,%0"
2492   [(set_attr "type" "mvi")])
2493
2494 (define_insn "uminhi3"
2495   [(set (match_operand:HI 0 "register_operand" "=r")
2496         (umin:HI (match_operand:HI 1 "reg_or_0_operand" "%rJ")
2497                  (match_operand:HI 2 "reg_or_8bit_operand" "rI")))]
2498   "TARGET_MAX"
2499   "minuw4 %r1,%2,%0"
2500   [(set_attr "type" "mvi")])
2501
2502 (define_insn "smaxhi3"
2503   [(set (match_operand:HI 0 "register_operand" "=r")
2504         (smax:HI (match_operand:HI 1 "reg_or_0_operand" "%rJ")
2505                  (match_operand:HI 2 "reg_or_8bit_operand" "rI")))]
2506   "TARGET_MAX"
2507   "maxsw4 %r1,%2,%0"
2508   [(set_attr "type" "mvi")])
2509
2510 (define_insn "umaxhi3"
2511   [(set (match_operand:HI 0 "register_operand" "=r")
2512         (umax:HI (match_operand:HI 1 "reg_or_0_operand" "%rJ")
2513                  (match_operand:HI 2 "reg_or_8bit_operand" "rI")))]
2514   "TARGET_MAX"
2515   "maxuw4 %r1,%2,%0"
2516   [(set_attr "type" "shift")])
2517
2518 (define_expand "smaxdi3"
2519   [(set (match_dup 3)
2520         (le:DI (match_operand:DI 1 "reg_or_0_operand" "")
2521                (match_operand:DI 2 "reg_or_8bit_operand" "")))
2522    (set (match_operand:DI 0 "register_operand" "")
2523         (if_then_else:DI (eq (match_dup 3) (const_int 0))
2524                          (match_dup 1) (match_dup 2)))]
2525   ""
2526   "
2527 { operands[3] = gen_reg_rtx (DImode);
2528 }")
2529
2530 (define_split
2531   [(set (match_operand:DI 0 "register_operand" "")
2532         (smax:DI (match_operand:DI 1 "reg_or_0_operand" "")
2533                  (match_operand:DI 2 "reg_or_8bit_operand" "")))
2534    (clobber (match_operand:DI 3 "register_operand" ""))]
2535   "operands[2] != const0_rtx"
2536   [(set (match_dup 3) (le:DI (match_dup 1) (match_dup 2)))
2537    (set (match_dup 0) (if_then_else:DI (eq (match_dup 3) (const_int 0))
2538                                        (match_dup 1) (match_dup 2)))]
2539   "")
2540
2541 (define_insn ""
2542   [(set (match_operand:DI 0 "register_operand" "=r")
2543         (smax:DI (match_operand:DI 1 "register_operand" "0")
2544                  (const_int 0)))]
2545   ""
2546   "cmovlt %0,0,%0"
2547   [(set_attr "type" "icmov")])
2548
2549 (define_expand "smindi3"
2550   [(set (match_dup 3)
2551         (lt:DI (match_operand:DI 1 "reg_or_0_operand" "")
2552                (match_operand:DI 2 "reg_or_8bit_operand" "")))
2553    (set (match_operand:DI 0 "register_operand" "")
2554         (if_then_else:DI (ne (match_dup 3) (const_int 0))
2555                          (match_dup 1) (match_dup 2)))]
2556   ""
2557   "
2558 { operands[3] = gen_reg_rtx (DImode);
2559 }")
2560
2561 (define_split
2562   [(set (match_operand:DI 0 "register_operand" "")
2563         (smin:DI (match_operand:DI 1 "reg_or_0_operand" "")
2564                  (match_operand:DI 2 "reg_or_8bit_operand" "")))
2565    (clobber (match_operand:DI 3 "register_operand" ""))]
2566   "operands[2] != const0_rtx"
2567   [(set (match_dup 3) (lt:DI (match_dup 1) (match_dup 2)))
2568    (set (match_dup 0) (if_then_else:DI (ne (match_dup 3) (const_int 0))
2569                                        (match_dup 1) (match_dup 2)))]
2570   "")
2571
2572 (define_insn ""
2573   [(set (match_operand:DI 0 "register_operand" "=r")
2574         (smin:DI (match_operand:DI 1 "register_operand" "0")
2575                  (const_int 0)))]
2576   ""
2577   "cmovgt %0,0,%0"
2578   [(set_attr "type" "icmov")])
2579
2580 (define_expand "umaxdi3"
2581   [(set (match_dup 3) 
2582         (leu:DI (match_operand:DI 1 "reg_or_0_operand" "")
2583                 (match_operand:DI 2 "reg_or_8bit_operand" "")))
2584    (set (match_operand:DI 0 "register_operand" "")
2585         (if_then_else:DI (eq (match_dup 3) (const_int 0))
2586                          (match_dup 1) (match_dup 2)))]
2587   ""
2588   "
2589 { operands[3] = gen_reg_rtx (DImode);
2590 }")
2591
2592 (define_split
2593   [(set (match_operand:DI 0 "register_operand" "")
2594         (umax:DI (match_operand:DI 1 "reg_or_0_operand" "")
2595                  (match_operand:DI 2 "reg_or_8bit_operand" "")))
2596    (clobber (match_operand:DI 3 "register_operand" ""))]
2597   "operands[2] != const0_rtx"
2598   [(set (match_dup 3) (leu:DI (match_dup 1) (match_dup 2)))
2599    (set (match_dup 0) (if_then_else:DI (eq (match_dup 3) (const_int 0))
2600                                        (match_dup 1) (match_dup 2)))]
2601   "")
2602
2603 (define_expand "umindi3"
2604   [(set (match_dup 3)
2605         (ltu:DI (match_operand:DI 1 "reg_or_0_operand" "")
2606                 (match_operand:DI 2 "reg_or_8bit_operand" "")))
2607    (set (match_operand:DI 0 "register_operand" "")
2608         (if_then_else:DI (ne (match_dup 3) (const_int 0))
2609                          (match_dup 1) (match_dup 2)))]
2610   ""
2611   "
2612 { operands[3] = gen_reg_rtx (DImode);
2613 }")
2614
2615 (define_split
2616   [(set (match_operand:DI 0 "register_operand" "")
2617         (umin:DI (match_operand:DI 1 "reg_or_0_operand" "")
2618                  (match_operand:DI 2 "reg_or_8bit_operand" "")))
2619    (clobber (match_operand:DI 3 "register_operand" ""))]
2620   "operands[2] != const0_rtx"
2621   [(set (match_dup 3) (ltu:DI (match_dup 1) (match_dup 2)))
2622    (set (match_dup 0) (if_then_else:DI (ne (match_dup 3) (const_int 0))
2623                                        (match_dup 1) (match_dup 2)))]
2624   "")
2625
2626 (define_insn ""
2627   [(set (pc)
2628         (if_then_else
2629          (match_operator 1 "signed_comparison_operator"
2630                          [(match_operand:DI 2 "reg_or_0_operand" "rJ")
2631                           (const_int 0)])
2632          (label_ref (match_operand 0 "" ""))
2633          (pc)))]
2634   ""
2635   "b%C1 %r2,%0"
2636   [(set_attr "type" "ibr")])
2637
2638 (define_insn ""
2639   [(set (pc)
2640         (if_then_else
2641          (match_operator 1 "signed_comparison_operator"
2642                          [(const_int 0)
2643                           (match_operand:DI 2 "register_operand" "r")])
2644          (label_ref (match_operand 0 "" ""))
2645          (pc)))]
2646   ""
2647   "b%c1 %2,%0"
2648   [(set_attr "type" "ibr")])
2649
2650 (define_insn ""
2651   [(set (pc)
2652         (if_then_else
2653          (ne (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
2654                               (const_int 1)
2655                               (const_int 0))
2656              (const_int 0))
2657          (label_ref (match_operand 0 "" ""))
2658          (pc)))]
2659   ""
2660   "blbs %r1,%0"
2661   [(set_attr "type" "ibr")])
2662
2663 (define_insn ""
2664   [(set (pc)
2665         (if_then_else
2666          (eq (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
2667                               (const_int 1)
2668                               (const_int 0))
2669              (const_int 0))
2670          (label_ref (match_operand 0 "" ""))
2671          (pc)))]
2672   ""
2673   "blbc %r1,%0"
2674   [(set_attr "type" "ibr")])
2675
2676 (define_split
2677   [(parallel
2678     [(set (pc)
2679           (if_then_else
2680            (match_operator 1 "comparison_operator"
2681                            [(zero_extract:DI (match_operand:DI 2 "register_operand" "")
2682                                              (const_int 1)
2683                                              (match_operand:DI 3 "const_int_operand" ""))
2684                             (const_int 0)])
2685            (label_ref (match_operand 0 "" ""))
2686            (pc)))
2687      (clobber (match_operand:DI 4 "register_operand" ""))])]
2688   "INTVAL (operands[3]) != 0"
2689   [(set (match_dup 4)
2690         (lshiftrt:DI (match_dup 2) (match_dup 3)))
2691    (set (pc)
2692         (if_then_else (match_op_dup 1
2693                                     [(zero_extract:DI (match_dup 4)
2694                                                       (const_int 1)
2695                                                       (const_int 0))
2696                                      (const_int 0)])
2697                       (label_ref (match_dup 0))
2698                       (pc)))]
2699   "")
2700 \f
2701 ;; The following are the corresponding floating-point insns.  Recall
2702 ;; we need to have variants that expand the arguments from SF mode
2703 ;; to DFmode.
2704
2705 (define_insn ""
2706   [(set (match_operand:DF 0 "register_operand" "=&f")
2707         (match_operator:DF 1 "alpha_comparison_operator"
2708                            [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2709                             (match_operand:DF 3 "reg_or_fp0_operand" "fG")]))]
2710   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2711   "cmp%-%C1%' %R2,%R3,%0"
2712   [(set_attr "type" "fadd")
2713    (set_attr "trap" "yes")])
2714
2715 (define_insn ""
2716   [(set (match_operand:DF 0 "register_operand" "=f")
2717         (match_operator:DF 1 "alpha_comparison_operator"
2718                            [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2719                             (match_operand:DF 3 "reg_or_fp0_operand" "fG")]))]
2720   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2721   "cmp%-%C1%' %R2,%R3,%0"
2722   [(set_attr "type" "fadd")
2723    (set_attr "trap" "yes")])
2724
2725 (define_insn ""
2726   [(set (match_operand:DF 0 "register_operand" "=&f")
2727         (match_operator:DF 1 "alpha_comparison_operator"
2728                            [(float_extend:DF
2729                              (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
2730                             (match_operand:DF 3 "reg_or_fp0_operand" "fG")]))]
2731   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2732   "cmp%-%C1%' %R2,%R3,%0"
2733   [(set_attr "type" "fadd")
2734    (set_attr "trap" "yes")])
2735
2736 (define_insn ""
2737   [(set (match_operand:DF 0 "register_operand" "=f")
2738         (match_operator:DF 1 "alpha_comparison_operator"
2739                            [(float_extend:DF
2740                              (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
2741                             (match_operand:DF 3 "reg_or_fp0_operand" "fG")]))]
2742   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2743   "cmp%-%C1%' %R2,%R3,%0"
2744   [(set_attr "type" "fadd")
2745    (set_attr "trap" "yes")])
2746
2747 (define_insn ""
2748   [(set (match_operand:DF 0 "register_operand" "=&f")
2749         (match_operator:DF 1 "alpha_comparison_operator"
2750                            [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2751                             (float_extend:DF
2752                              (match_operand:SF 3 "reg_or_fp0_operand" "fG"))]))]
2753   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2754   "cmp%-%C1%' %R2,%R3,%0"
2755   [(set_attr "type" "fadd")
2756    (set_attr "trap" "yes")])
2757
2758 (define_insn ""
2759   [(set (match_operand:DF 0 "register_operand" "=f")
2760         (match_operator:DF 1 "alpha_comparison_operator"
2761                            [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2762                             (float_extend:DF
2763                              (match_operand:SF 3 "reg_or_fp0_operand" "fG"))]))]
2764   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2765   "cmp%-%C1%' %R2,%R3,%0"
2766   [(set_attr "type" "fadd")
2767    (set_attr "trap" "yes")])
2768
2769 (define_insn ""
2770   [(set (match_operand:DF 0 "register_operand" "=&f")
2771         (match_operator:DF 1 "alpha_comparison_operator"
2772                            [(float_extend:DF
2773                              (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
2774                             (float_extend:DF
2775                              (match_operand:SF 3 "reg_or_fp0_operand" "fG"))]))]
2776   "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2777   "cmp%-%C1%' %R2,%R3,%0"
2778   [(set_attr "type" "fadd")
2779    (set_attr "trap" "yes")])
2780
2781 (define_insn ""
2782   [(set (match_operand:DF 0 "register_operand" "=f")
2783         (match_operator:DF 1 "alpha_comparison_operator"
2784                            [(float_extend:DF
2785                              (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
2786                             (float_extend:DF
2787                              (match_operand:SF 3 "reg_or_fp0_operand" "fG"))]))]
2788   "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2789   "cmp%-%C1%' %R2,%R3,%0"
2790   [(set_attr "type" "fadd")
2791    (set_attr "trap" "yes")])
2792
2793 (define_insn ""
2794   [(set (match_operand:DF 0 "register_operand" "=f,f")
2795         (if_then_else:DF 
2796          (match_operator 3 "signed_comparison_operator"
2797                          [(match_operand:DF 4 "reg_or_fp0_operand" "fG,fG")
2798                           (match_operand:DF 2 "fp0_operand" "G,G")])
2799          (match_operand:DF 1 "reg_or_fp0_operand" "fG,0")
2800          (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2801   "TARGET_FP"
2802   "@
2803    fcmov%C3 %R4,%R1,%0
2804    fcmov%D3 %R4,%R5,%0"
2805   [(set_attr "type" "fcmov")])
2806
2807 (define_insn ""
2808   [(set (match_operand:SF 0 "register_operand" "=f,f")
2809         (if_then_else:SF 
2810          (match_operator 3 "signed_comparison_operator"
2811                          [(match_operand:DF 4 "reg_or_fp0_operand" "fG,fG")
2812                           (match_operand:DF 2 "fp0_operand" "G,G")])
2813          (match_operand:SF 1 "reg_or_fp0_operand" "fG,0")
2814          (match_operand:SF 5 "reg_or_fp0_operand" "0,fG")))]
2815   "TARGET_FP"
2816   "@
2817    fcmov%C3 %R4,%R1,%0
2818    fcmov%D3 %R4,%R5,%0"
2819   [(set_attr "type" "fcmov")])
2820
2821 (define_insn ""
2822   [(set (match_operand:DF 0 "register_operand" "=f,f")
2823         (if_then_else:DF 
2824          (match_operator 3 "signed_comparison_operator"
2825                          [(match_operand:DF 4 "reg_or_fp0_operand" "fG,fG")
2826                           (match_operand:DF 2 "fp0_operand" "G,G")])
2827          (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG,0"))
2828          (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2829   "TARGET_FP"
2830   "@
2831    fcmov%C3 %R4,%R1,%0
2832    fcmov%D3 %R4,%R5,%0"
2833   [(set_attr "type" "fcmov")])
2834
2835 (define_insn ""
2836   [(set (match_operand:DF 0 "register_operand" "=f,f")
2837         (if_then_else:DF 
2838          (match_operator 3 "signed_comparison_operator"
2839                          [(float_extend:DF 
2840                            (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
2841                           (match_operand:DF 2 "fp0_operand" "G,G")])
2842          (match_operand:DF 1 "reg_or_fp0_operand" "fG,0")
2843          (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2844   "TARGET_FP"
2845   "@
2846    fcmov%C3 %R4,%R1,%0
2847    fcmov%D3 %R4,%R5,%0"
2848   [(set_attr "type" "fcmov")])
2849
2850 (define_insn ""
2851   [(set (match_operand:SF 0 "register_operand" "=f,f")
2852         (if_then_else:SF 
2853          (match_operator 3 "signed_comparison_operator"
2854                          [(float_extend:DF
2855                            (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
2856                           (match_operand:DF 2 "fp0_operand" "G,G")])
2857          (match_operand:SF 1 "reg_or_fp0_operand" "fG,0")
2858          (match_operand:SF 5 "reg_or_fp0_operand" "0,fG")))]
2859   "TARGET_FP"
2860   "@
2861    fcmov%C3 %R4,%R1,%0
2862    fcmov%D3 %R4,%R5,%0"
2863   [(set_attr "type" "fcmov")])
2864
2865 (define_insn ""
2866   [(set (match_operand:DF 0 "register_operand" "=f,f")
2867         (if_then_else:DF 
2868          (match_operator 3 "signed_comparison_operator"
2869                          [(float_extend:DF
2870                            (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
2871                           (match_operand:DF 2 "fp0_operand" "G,G")])
2872          (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG,0"))
2873          (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2874   "TARGET_FP"
2875   "@
2876    fcmov%C3 %R4,%R1,%0
2877    fcmov%D3 %R4,%R5,%0"
2878   [(set_attr "type" "fcmov")])
2879
2880 (define_expand "maxdf3"
2881   [(set (match_dup 3)
2882         (le:DF (match_operand:DF 1 "reg_or_fp0_operand" "")
2883                (match_operand:DF 2 "reg_or_fp0_operand" "")))
2884    (set (match_operand:DF 0 "register_operand" "")
2885         (if_then_else:DF (eq (match_dup 3) (match_dup 4))
2886                          (match_dup 1) (match_dup 2)))]
2887   "TARGET_FP"
2888   "
2889 { operands[3] = gen_reg_rtx (DFmode);
2890   operands[4] = CONST0_RTX (DFmode);
2891 }")
2892
2893 (define_expand "mindf3"
2894   [(set (match_dup 3)
2895         (lt:DF (match_operand:DF 1 "reg_or_fp0_operand" "")
2896                (match_operand:DF 2 "reg_or_fp0_operand" "")))
2897    (set (match_operand:DF 0 "register_operand" "")
2898         (if_then_else:DF (ne (match_dup 3) (match_dup 4))
2899                          (match_dup 1) (match_dup 2)))]
2900   "TARGET_FP"
2901   "
2902 { operands[3] = gen_reg_rtx (DFmode);
2903   operands[4] = CONST0_RTX (DFmode);
2904 }")
2905
2906 (define_expand "maxsf3"
2907   [(set (match_dup 3)
2908         (le:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" ""))
2909                (float_extend:DF (match_operand:SF 2 "reg_or_fp0_operand" ""))))
2910    (set (match_operand:SF 0 "register_operand" "")
2911         (if_then_else:SF (eq (match_dup 3) (match_dup 4))
2912                          (match_dup 1) (match_dup 2)))]
2913   "TARGET_FP"
2914   "
2915 { operands[3] = gen_reg_rtx (DFmode);
2916   operands[4] = CONST0_RTX (DFmode);
2917 }")
2918
2919 (define_expand "minsf3"
2920   [(set (match_dup 3)
2921         (lt:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" ""))
2922                (float_extend:DF (match_operand:SF 2 "reg_or_fp0_operand" ""))))
2923    (set (match_operand:SF 0 "register_operand" "")
2924         (if_then_else:SF (ne (match_dup 3) (match_dup 4))
2925                       (match_dup 1) (match_dup 2)))]
2926   "TARGET_FP"
2927   "
2928 { operands[3] = gen_reg_rtx (DFmode);
2929   operands[4] = CONST0_RTX (DFmode);
2930 }")
2931
2932 (define_insn ""
2933   [(set (pc)
2934         (if_then_else
2935          (match_operator 1 "signed_comparison_operator"
2936                          [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2937                           (match_operand:DF 3 "fp0_operand" "G")])
2938          (label_ref (match_operand 0 "" ""))
2939          (pc)))]
2940   "TARGET_FP"
2941   "fb%C1 %R2,%0"
2942   [(set_attr "type" "fbr")])
2943
2944 (define_insn ""
2945   [(set (pc)
2946         (if_then_else
2947          (match_operator 1 "signed_comparison_operator"
2948                          [(float_extend:DF
2949                            (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
2950                           (match_operand:DF 3 "fp0_operand" "G")])
2951          (label_ref (match_operand 0 "" ""))
2952          (pc)))]
2953   "TARGET_FP"
2954   "fb%C1 %R2,%0"
2955   [(set_attr "type" "fbr")])
2956 \f
2957 ;; These are the main define_expand's used to make conditional branches
2958 ;; and compares.
2959
2960 (define_expand "cmpdf"
2961   [(set (cc0) (compare (match_operand:DF 0 "reg_or_fp0_operand" "")
2962                        (match_operand:DF 1 "reg_or_fp0_operand" "")))]
2963   "TARGET_FP"
2964   "
2965 {
2966   alpha_compare_op0 = operands[0];
2967   alpha_compare_op1 = operands[1];
2968   alpha_compare_fp_p = 1;
2969   DONE;
2970 }")
2971
2972 (define_expand "cmpdi"
2973   [(set (cc0) (compare (match_operand:DI 0 "reg_or_0_operand" "")
2974                        (match_operand:DI 1 "reg_or_8bit_operand" "")))]
2975   ""
2976   "
2977 {
2978   alpha_compare_op0 = operands[0];
2979   alpha_compare_op1 = operands[1];
2980   alpha_compare_fp_p = 0;
2981   DONE;
2982 }")
2983
2984 (define_expand "beq"
2985   [(set (pc)
2986         (if_then_else (match_dup 1)
2987                       (label_ref (match_operand 0 "" ""))
2988                       (pc)))]
2989   ""
2990   "{ operands[1] = alpha_emit_conditional_branch (EQ); }")
2991
2992 (define_expand "bne"
2993   [(set (pc)
2994         (if_then_else (match_dup 1)
2995                       (label_ref (match_operand 0 "" ""))
2996                       (pc)))]
2997   ""
2998   "{ operands[1] = alpha_emit_conditional_branch (NE); }")
2999
3000 (define_expand "blt"
3001   [(set (pc)
3002         (if_then_else (match_dup 1)
3003                       (label_ref (match_operand 0 "" ""))
3004                       (pc)))]
3005   ""
3006   "{ operands[1] = alpha_emit_conditional_branch (LT); }")
3007
3008 (define_expand "ble"
3009   [(set (pc)
3010         (if_then_else (match_dup 1)
3011                       (label_ref (match_operand 0 "" ""))
3012                       (pc)))]
3013   ""
3014   "{ operands[1] = alpha_emit_conditional_branch (LE); }")
3015
3016 (define_expand "bgt"
3017   [(set (pc)
3018         (if_then_else (match_dup 1)
3019                       (label_ref (match_operand 0 "" ""))
3020                       (pc)))]
3021   ""
3022   "{ operands[1] = alpha_emit_conditional_branch (GT); }")
3023
3024 (define_expand "bge"
3025   [(set (pc)
3026         (if_then_else (match_dup 1)
3027                       (label_ref (match_operand 0 "" ""))
3028                       (pc)))]
3029   ""
3030   "{ operands[1] = alpha_emit_conditional_branch (GE); }")
3031
3032 (define_expand "bltu"
3033   [(set (pc)
3034         (if_then_else (match_dup 1)
3035                       (label_ref (match_operand 0 "" ""))
3036                       (pc)))]
3037   ""
3038   "{ operands[1] = alpha_emit_conditional_branch (LTU); }")
3039
3040 (define_expand "bleu"
3041   [(set (pc)
3042         (if_then_else (match_dup 1)
3043                       (label_ref (match_operand 0 "" ""))
3044                       (pc)))]
3045   ""
3046   "{ operands[1] = alpha_emit_conditional_branch (LEU); }")
3047
3048 (define_expand "bgtu"
3049   [(set (pc)
3050         (if_then_else (match_dup 1)
3051                       (label_ref (match_operand 0 "" ""))
3052                       (pc)))]
3053   ""
3054   "{ operands[1] = alpha_emit_conditional_branch (GTU); }")
3055
3056 (define_expand "bgeu"
3057   [(set (pc)
3058         (if_then_else (match_dup 1)
3059                       (label_ref (match_operand 0 "" ""))
3060                       (pc)))]
3061   ""
3062   "{ operands[1] = alpha_emit_conditional_branch (GEU); }")
3063
3064 (define_expand "seq"
3065   [(set (match_operand:DI 0 "register_operand" "")
3066         (match_dup 1))]
3067   ""
3068   "
3069 {
3070   if (alpha_compare_fp_p)
3071     FAIL;
3072
3073   operands[1] = gen_rtx_EQ (DImode, alpha_compare_op0, alpha_compare_op1);
3074 }")
3075
3076 (define_expand "sne"
3077   [(set (match_operand:DI 0 "register_operand" "")
3078         (match_dup 1))
3079    (set (match_dup 0) (xor:DI (match_dup 0) (const_int 1)))]
3080   ""
3081   "
3082 {
3083   if (alpha_compare_fp_p)
3084     FAIL;
3085
3086   operands[1] = gen_rtx_EQ (DImode, alpha_compare_op0, alpha_compare_op1);
3087 }")
3088
3089 (define_expand "slt"
3090   [(set (match_operand:DI 0 "register_operand" "")
3091         (match_dup 1))]
3092   ""
3093   "
3094 {
3095   if (alpha_compare_fp_p)
3096     FAIL;
3097
3098   operands[1] = gen_rtx_LT (DImode, alpha_compare_op0, alpha_compare_op1);
3099 }")
3100
3101 (define_expand "sle"
3102   [(set (match_operand:DI 0 "register_operand" "")
3103         (match_dup 1))]
3104   ""
3105   "
3106 {
3107   if (alpha_compare_fp_p)
3108     FAIL;
3109
3110   operands[1] = gen_rtx_LE (DImode, alpha_compare_op0, alpha_compare_op1);
3111 }")
3112
3113 (define_expand "sgt"
3114   [(set (match_operand:DI 0 "register_operand" "")
3115         (match_dup 1))]
3116   ""
3117   "
3118 {
3119   if (alpha_compare_fp_p)
3120     FAIL;
3121
3122   operands[1] = gen_rtx_LT (DImode, force_reg (DImode, alpha_compare_op1),
3123                             alpha_compare_op0);
3124 }")
3125
3126 (define_expand "sge"
3127   [(set (match_operand:DI 0 "register_operand" "")
3128         (match_dup 1))]
3129   ""
3130   "
3131 {
3132   if (alpha_compare_fp_p)
3133     FAIL;
3134
3135   operands[1] = gen_rtx_LE (DImode, force_reg (DImode, alpha_compare_op1),
3136                             alpha_compare_op0);
3137 }")
3138
3139 (define_expand "sltu"
3140   [(set (match_operand:DI 0 "register_operand" "")
3141         (match_dup 1))]
3142   ""
3143   "
3144 {
3145   if (alpha_compare_fp_p)
3146     FAIL;
3147
3148   operands[1] = gen_rtx_LTU (DImode, alpha_compare_op0, alpha_compare_op1);
3149 }")
3150
3151 (define_expand "sleu"
3152   [(set (match_operand:DI 0 "register_operand" "")
3153         (match_dup 1))]
3154   ""
3155   "
3156 {
3157   if (alpha_compare_fp_p)
3158     FAIL;
3159
3160   operands[1] = gen_rtx_LEU (DImode, alpha_compare_op0, alpha_compare_op1);
3161 }")
3162
3163 (define_expand "sgtu"
3164   [(set (match_operand:DI 0 "register_operand" "")
3165         (match_dup 1))]
3166   ""
3167   "
3168 {
3169   if (alpha_compare_fp_p)
3170     FAIL;
3171
3172   operands[1] = gen_rtx_LTU (DImode, force_reg (DImode, alpha_compare_op1),
3173                              alpha_compare_op0);
3174 }")
3175
3176 (define_expand "sgeu"
3177   [(set (match_operand:DI 0 "register_operand" "")
3178         (match_dup 1))]
3179   ""
3180   "
3181 {
3182   if (alpha_compare_fp_p)
3183     FAIL;
3184
3185   operands[1] = gen_rtx_LEU (DImode, force_reg (DImode, alpha_compare_op1),
3186                              alpha_compare_op0);
3187 }")
3188 \f
3189 ;; These are the main define_expand's used to make conditional moves.
3190
3191 (define_expand "movsicc"
3192   [(set (match_operand:SI 0 "register_operand" "")
3193         (if_then_else:SI (match_operand 1 "comparison_operator" "")
3194                          (match_operand:SI 2 "reg_or_8bit_operand" "")
3195                          (match_operand:SI 3 "reg_or_8bit_operand" "")))]
3196   ""
3197   "
3198 {
3199   if ((operands[1] = alpha_emit_conditional_move (operands[1], SImode)) == 0)
3200     FAIL;
3201 }")
3202
3203 (define_expand "movdicc"
3204   [(set (match_operand:DI 0 "register_operand" "")
3205         (if_then_else:DI (match_operand 1 "comparison_operator" "")
3206                          (match_operand:DI 2 "reg_or_8bit_operand" "")
3207                          (match_operand:DI 3 "reg_or_8bit_operand" "")))]
3208   ""
3209   "
3210 {
3211   if ((operands[1] = alpha_emit_conditional_move (operands[1], DImode)) == 0)
3212     FAIL;
3213 }")
3214
3215 (define_expand "movsfcc"
3216   [(set (match_operand:SF 0 "register_operand" "")
3217         (if_then_else:SF (match_operand 1 "comparison_operator" "")
3218                          (match_operand:SF 2 "reg_or_8bit_operand" "")
3219                          (match_operand:SF 3 "reg_or_8bit_operand" "")))]
3220   ""
3221   "
3222 {
3223   if ((operands[1] = alpha_emit_conditional_move (operands[1], SFmode)) == 0)
3224     FAIL;
3225 }")
3226
3227 (define_expand "movdfcc"
3228   [(set (match_operand:DF 0 "register_operand" "")
3229         (if_then_else:DF (match_operand 1 "comparison_operator" "")
3230                          (match_operand:DF 2 "reg_or_8bit_operand" "")
3231                          (match_operand:DF 3 "reg_or_8bit_operand" "")))]
3232   ""
3233   "
3234 {
3235   if ((operands[1] = alpha_emit_conditional_move (operands[1], DFmode)) == 0)
3236     FAIL;
3237 }")
3238 \f
3239 ;; These define_split definitions are used in cases when comparisons have
3240 ;; not be stated in the correct way and we need to reverse the second
3241 ;; comparison.  For example, x >= 7 has to be done as x < 6 with the
3242 ;; comparison that tests the result being reversed.  We have one define_split
3243 ;; for each use of a comparison.  They do not match valid insns and need
3244 ;; not generate valid insns.
3245 ;;
3246 ;; We can also handle equality comparisons (and inequality comparisons in
3247 ;; cases where the resulting add cannot overflow) by doing an add followed by
3248 ;; a comparison with zero.  This is faster since the addition takes one
3249 ;; less cycle than a compare when feeding into a conditional move.
3250 ;; For this case, we also have an SImode pattern since we can merge the add
3251 ;; and sign extend and the order doesn't matter.
3252 ;;
3253 ;; We do not do this for floating-point, since it isn't clear how the "wrong"
3254 ;; operation could have been generated.
3255
3256 (define_split
3257   [(set (match_operand:DI 0 "register_operand" "")
3258         (if_then_else:DI
3259          (match_operator 1 "comparison_operator"
3260                          [(match_operand:DI 2 "reg_or_0_operand" "")
3261                           (match_operand:DI 3 "reg_or_cint_operand" "")])
3262          (match_operand:DI 4 "reg_or_cint_operand" "")
3263          (match_operand:DI 5 "reg_or_cint_operand" "")))
3264    (clobber (match_operand:DI 6 "register_operand" ""))]
3265   "operands[3] != const0_rtx"
3266   [(set (match_dup 6) (match_dup 7))
3267    (set (match_dup 0)
3268         (if_then_else:DI (match_dup 8) (match_dup 4) (match_dup 5)))]
3269   "
3270 { enum rtx_code code = GET_CODE (operands[1]);
3271   int unsignedp = (code == GEU || code == LEU || code == GTU || code == LTU);
3272
3273   /* If we are comparing for equality with a constant and that constant
3274      appears in the arm when the register equals the constant, use the
3275      register since that is more likely to match (and to produce better code
3276      if both would).  */
3277
3278   if (code == EQ && GET_CODE (operands[3]) == CONST_INT
3279       && rtx_equal_p (operands[4], operands[3]))
3280     operands[4] = operands[2];
3281
3282   else if (code == NE && GET_CODE (operands[3]) == CONST_INT
3283            && rtx_equal_p (operands[5], operands[3]))
3284     operands[5] = operands[2];
3285
3286   if (code == NE || code == EQ
3287       || (extended_count (operands[2], DImode, unsignedp) >= 1
3288           && extended_count (operands[3], DImode, unsignedp) >= 1))
3289     {
3290       if (GET_CODE (operands[3]) == CONST_INT)
3291         operands[7] = gen_rtx_PLUS (DImode, operands[2],
3292                                     GEN_INT (- INTVAL (operands[3])));
3293       else
3294         operands[7] = gen_rtx_MINUS (DImode, operands[2], operands[3]);
3295
3296       operands[8] = gen_rtx_fmt_ee (code, VOIDmode, operands[6], const0_rtx);
3297     }
3298
3299   else if (code == EQ || code == LE || code == LT
3300            || code == LEU || code == LTU)
3301     {
3302       operands[7] = gen_rtx_fmt_ee (code, DImode, operands[2], operands[3]);
3303       operands[8] = gen_rtx_NE (VOIDmode, operands[6], const0_rtx);
3304     }
3305   else
3306     {
3307       operands[7] = gen_rtx_fmt_ee (reverse_condition (code), DImode,
3308                                     operands[2], operands[3]);
3309       operands[8] = gen_rtx_EQ (VOIDmode, operands[6], const0_rtx);
3310     }
3311 }")
3312
3313 (define_split
3314   [(set (match_operand:DI 0 "register_operand" "")
3315         (if_then_else:DI
3316          (match_operator 1 "comparison_operator"
3317                          [(match_operand:SI 2 "reg_or_0_operand" "")
3318                           (match_operand:SI 3 "reg_or_cint_operand" "")])
3319          (match_operand:DI 4 "reg_or_8bit_operand" "")
3320          (match_operand:DI 5 "reg_or_8bit_operand" "")))
3321    (clobber (match_operand:DI 6 "register_operand" ""))]
3322   "operands[3] != const0_rtx
3323    && (GET_CODE (operands[1]) == EQ || GET_CODE (operands[1]) == NE)"
3324   [(set (match_dup 6) (match_dup 7))
3325    (set (match_dup 0)
3326         (if_then_else:DI (match_dup 8) (match_dup 4) (match_dup 5)))]
3327   "
3328 { enum rtx_code code = GET_CODE (operands[1]);
3329   int unsignedp = (code == GEU || code == LEU || code == GTU || code == LTU);
3330   rtx tem;
3331
3332   if ((code != NE && code != EQ
3333        && ! (extended_count (operands[2], DImode, unsignedp) >= 1
3334              && extended_count (operands[3], DImode, unsignedp) >= 1)))
3335     FAIL;
3336  
3337   if (GET_CODE (operands[3]) == CONST_INT)
3338     tem = gen_rtx_PLUS (SImode, operands[2],
3339                         GEN_INT (- INTVAL (operands[3])));
3340   else
3341     tem = gen_rtx_MINUS (SImode, operands[2], operands[3]);
3342
3343   operands[7] = gen_rtx_SIGN_EXTEND (DImode, tem);
3344   operands[8] = gen_rtx_fmt_ee (GET_CODE (operands[1]), VOIDmode,
3345                                 operands[6], const0_rtx);
3346 }")
3347
3348 (define_split
3349   [(set (pc)
3350         (if_then_else
3351          (match_operator 1 "comparison_operator"
3352                          [(match_operand:DI 2 "reg_or_0_operand" "")
3353                           (match_operand:DI 3 "reg_or_cint_operand" "")])
3354          (label_ref (match_operand 0 "" ""))
3355          (pc)))
3356    (clobber (match_operand:DI 4 "register_operand" ""))]
3357   "operands[3] != const0_rtx"
3358   [(set (match_dup 4) (match_dup 5))
3359    (set (pc) (if_then_else (match_dup 6) (label_ref (match_dup 0)) (pc)))]
3360   "
3361 { enum rtx_code code = GET_CODE (operands[1]);
3362   int unsignedp = (code == GEU || code == LEU || code == GTU || code == LTU);
3363
3364   if (code == NE || code == EQ
3365       || (extended_count (operands[2], DImode, unsignedp) >= 1
3366           && extended_count (operands[3], DImode, unsignedp) >= 1))
3367     {
3368       if (GET_CODE (operands[3]) == CONST_INT)
3369         operands[5] = gen_rtx_PLUS (DImode, operands[2],
3370                                     GEN_INT (- INTVAL (operands[3])));
3371       else
3372         operands[5] = gen_rtx_MINUS (DImode, operands[2], operands[3]);
3373
3374       operands[6] = gen_rtx_fmt_ee (code, VOIDmode, operands[4], const0_rtx);
3375     }
3376
3377   else if (code == EQ || code == LE || code == LT
3378            || code == LEU || code == LTU)
3379     {
3380       operands[5] = gen_rtx_fmt_ee (code, DImode, operands[2], operands[3]);
3381       operands[6] = gen_rtx_NE (VOIDmode, operands[4], const0_rtx);
3382     }
3383   else
3384     {
3385       operands[5] = gen_rtx_fmt_ee (reverse_condition (code), DImode,
3386                                     operands[2], operands[3]);
3387       operands[6] = gen_rtx_EQ (VOIDmode, operands[4], const0_rtx);
3388     }
3389 }")
3390
3391 (define_split
3392   [(set (pc)
3393         (if_then_else
3394          (match_operator 1 "comparison_operator"
3395                          [(match_operand:SI 2 "reg_or_0_operand" "")
3396                           (match_operand:SI 3 "const_int_operand" "")])
3397          (label_ref (match_operand 0 "" ""))
3398          (pc)))
3399    (clobber (match_operand:DI 4 "register_operand" ""))]
3400   "operands[3] != const0_rtx
3401    && (GET_CODE (operands[1]) == EQ || GET_CODE (operands[1]) == NE)"
3402   [(set (match_dup 4) (match_dup 5))
3403    (set (pc) (if_then_else (match_dup 6) (label_ref (match_dup 0)) (pc)))]
3404   "
3405 { rtx tem;
3406
3407   if (GET_CODE (operands[3]) == CONST_INT)
3408     tem = gen_rtx_PLUS (SImode, operands[2],
3409                         GEN_INT (- INTVAL (operands[3])));
3410   else
3411     tem = gen_rtx_MINUS (SImode, operands[2], operands[3]);
3412   
3413   operands[5] = gen_rtx_SIGN_EXTEND (DImode, tem);
3414   operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[1]), VOIDmode,
3415                                 operands[4], const0_rtx);
3416 }")
3417
3418 ;; We can convert such things as "a > 0xffff" to "t = a & ~ 0xffff; t != 0".
3419 ;; This eliminates one, and sometimes two, insns when the AND can be done
3420 ;; with a ZAP.
3421 (define_split
3422   [(set (match_operand:DI 0 "register_operand" "")
3423         (match_operator 1 "comparison_operator"
3424                         [(match_operand:DI 2 "register_operand" "")
3425                          (match_operand:DI 3 "const_int_operand" "")]))
3426    (clobber (match_operand:DI 4 "register_operand" ""))]
3427   "exact_log2 (INTVAL (operands[3]) + 1) >= 0
3428    && (GET_CODE (operands[1]) == GTU
3429        || GET_CODE (operands[1]) == LEU
3430        || ((GET_CODE (operands[1]) == GT || GET_CODE (operands[1]) == LE)
3431            && extended_count (operands[2], DImode, 1) > 0))"
3432   [(set (match_dup 4) (and:DI (match_dup 2) (match_dup 5)))
3433    (set (match_dup 0) (match_dup 6))]
3434   "
3435 {
3436   operands[5] = GEN_INT (~ INTVAL (operands[3]));
3437   operands[6] = gen_rtx_fmt_ee (((GET_CODE (operands[1]) == GTU
3438                                   || GET_CODE (operands[1]) == GT)
3439                                  ? NE : EQ),
3440                                 DImode, operands[4], const0_rtx);
3441 }")
3442 \f
3443 ;; Here are the CALL and unconditional branch insns.  Calls on NT and OSF
3444 ;; work differently, so we have different patterns for each.
3445
3446 (define_expand "call"
3447   [(use (match_operand:DI 0 "" ""))
3448    (use (match_operand 1 "" ""))
3449    (use (match_operand 2 "" ""))
3450    (use (match_operand 3 "" ""))]
3451   ""
3452   "
3453 { if (TARGET_WINDOWS_NT)
3454     emit_call_insn (gen_call_nt (operands[0], operands[1]));
3455   else if (TARGET_OPEN_VMS)
3456     emit_call_insn (gen_call_vms (operands[0], operands[2]));
3457   else
3458     emit_call_insn (gen_call_osf (operands[0], operands[1]));
3459
3460   DONE;
3461 }")
3462
3463 (define_expand "call_osf"
3464   [(parallel [(call (mem:DI (match_operand 0 "" ""))
3465                     (match_operand 1 "" ""))
3466               (clobber (reg:DI 27))
3467               (clobber (reg:DI 26))])]
3468   ""
3469   "
3470 { if (GET_CODE (operands[0]) != MEM)
3471     abort ();
3472
3473   operands[0] = XEXP (operands[0], 0);
3474
3475   if (GET_CODE (operands[0]) != SYMBOL_REF
3476       && ! (GET_CODE (operands[0]) == REG && REGNO (operands[0]) == 27))
3477     {
3478       rtx tem = gen_rtx_REG (DImode, 27);
3479       emit_move_insn (tem, operands[0]);
3480       operands[0] = tem;
3481     }
3482 }")
3483
3484 (define_expand "call_nt"
3485   [(parallel [(call (mem:DI (match_operand 0 "" ""))
3486                     (match_operand 1 "" ""))
3487               (clobber (reg:DI 26))])]
3488   ""
3489   "
3490 { if (GET_CODE (operands[0]) != MEM)
3491     abort ();
3492
3493   operands[0] = XEXP (operands[0], 0);
3494   if (GET_CODE (operands[0]) != SYMBOL_REF && GET_CODE (operands[0]) != REG)
3495     operands[0] = force_reg (DImode, operands[0]);
3496 }")
3497
3498 ;;
3499 ;; call openvms/alpha
3500 ;; op 0: symbol ref for called function
3501 ;; op 1: next_arg_reg (argument information value for R25)
3502 ;;
3503 (define_expand "call_vms"
3504   [(parallel [(call (mem:DI (match_operand 0 "" ""))
3505                     (match_operand 1 "" ""))
3506               (use (match_dup 2))
3507               (use (reg:DI 25))
3508               (use (reg:DI 26))
3509               (clobber (reg:DI 27))])]
3510   ""
3511   "
3512 { if (GET_CODE (operands[0]) != MEM)
3513     abort ();
3514
3515   operands[0] = XEXP (operands[0], 0);
3516
3517   /* Always load AI with argument information, then handle symbolic and
3518      indirect call differently.  Load RA and set operands[2] to PV in
3519      both cases.  */
3520
3521   emit_move_insn (gen_rtx_REG (DImode, 25), operands[1]);
3522   if (GET_CODE (operands[0]) == SYMBOL_REF)
3523     {
3524       extern char *savealloc ();
3525       char *linksym, *symbol = XSTR (operands[0], 0);
3526       rtx linkage;
3527
3528       if (*symbol == '*')
3529         symbol++;
3530       linksym = savealloc (strlen (symbol) + 6);
3531
3532       alpha_need_linkage (symbol, 0);
3533
3534       linksym[0] = '$';
3535       strcpy (linksym+1, symbol);
3536       strcat (linksym, \"..lk\");
3537       linkage = gen_rtx_SYMBOL_REF (Pmode, linksym);
3538
3539       emit_move_insn (gen_rtx_REG (Pmode, 26), gen_rtx_MEM (Pmode, linkage));
3540
3541       operands[2]
3542         = validize_mem (gen_rtx_MEM (Pmode, plus_constant (linkage, 8)));
3543     }
3544   else
3545     {
3546       emit_move_insn (gen_rtx_REG (Pmode, 26),
3547                       gen_rtx_MEM (Pmode, plus_constant (operands[0], 8)));
3548
3549       operands[2] = operands[0];
3550     }
3551
3552 }")
3553
3554 (define_expand "call_value"
3555   [(use (match_operand 0 "" ""))
3556    (use (match_operand:DI 1 "" ""))
3557    (use (match_operand 2 "" ""))
3558    (use (match_operand 3 "" ""))
3559    (use (match_operand 4 "" ""))]
3560   ""
3561   "
3562 { if (TARGET_WINDOWS_NT)
3563     emit_call_insn (gen_call_value_nt (operands[0], operands[1], operands[2]));
3564   else if (TARGET_OPEN_VMS)
3565     emit_call_insn (gen_call_value_vms (operands[0], operands[1],
3566                                         operands[3]));
3567   else
3568     emit_call_insn (gen_call_value_osf (operands[0], operands[1],
3569                                         operands[2]));
3570   DONE;
3571 }")
3572
3573 (define_expand "call_value_osf"
3574   [(parallel [(set (match_operand 0 "" "")
3575                    (call (mem:DI (match_operand 1 "" ""))
3576                          (match_operand 2 "" "")))
3577               (clobber (reg:DI 27))
3578               (clobber (reg:DI 26))])]
3579   ""
3580   "
3581 { if (GET_CODE (operands[1]) != MEM)
3582     abort ();
3583
3584   operands[1] = XEXP (operands[1], 0);
3585
3586   if (GET_CODE (operands[1]) != SYMBOL_REF
3587       && ! (GET_CODE (operands[1]) == REG && REGNO (operands[1]) == 27))
3588     {
3589       rtx tem = gen_rtx_REG (DImode, 27);
3590       emit_move_insn (tem, operands[1]);
3591       operands[1] = tem;
3592     }
3593 }")
3594
3595 (define_expand "call_value_nt"
3596   [(parallel [(set (match_operand 0 "" "")
3597                    (call (mem:DI (match_operand 1 "" ""))
3598                          (match_operand 2 "" "")))
3599               (clobber (reg:DI 26))])]
3600   ""
3601   "
3602 { if (GET_CODE (operands[1]) != MEM)
3603     abort ();
3604
3605   operands[1] = XEXP (operands[1], 0);
3606   if (GET_CODE (operands[0]) != SYMBOL_REF && GET_CODE (operands[0]) != REG)
3607     operands[1] = force_reg (DImode, operands[1]);
3608 }")
3609
3610 (define_expand "call_value_vms"
3611   [(parallel [(set (match_operand 0 "" "")
3612                    (call (mem:DI (match_operand:DI 1 "" ""))
3613                          (match_operand 2 "" "")))
3614               (use (match_dup 3))
3615               (use (reg:DI 25))
3616               (use (reg:DI 26))
3617               (clobber (reg:DI 27))])]
3618   ""
3619   "
3620 { if (GET_CODE (operands[1]) != MEM)
3621     abort ();
3622
3623   operands[1] = XEXP (operands[1], 0);
3624
3625   /* Always load AI with argument information, then handle symbolic and
3626      indirect call differently.  Load RA and set operands[3] to PV in
3627      both cases.  */
3628
3629   emit_move_insn (gen_rtx_REG (DImode, 25), operands[2]);
3630   if (GET_CODE (operands[1]) == SYMBOL_REF)
3631     {
3632       extern char *savealloc ();
3633       char *linksym, *symbol = XSTR (operands[1], 0);
3634       rtx linkage;
3635
3636       if (*symbol == '*')
3637         symbol++;
3638       linksym = savealloc (strlen (symbol) + 6);
3639
3640       alpha_need_linkage (symbol, 0);
3641       linksym[0] = '$';
3642       strcpy (linksym+1, symbol);
3643       strcat (linksym, \"..lk\");
3644       linkage = gen_rtx_SYMBOL_REF (Pmode, linksym);
3645
3646       emit_move_insn (gen_rtx_REG (Pmode, 26), gen_rtx_MEM (Pmode, linkage));
3647
3648       operands[3]
3649         = validize_mem (gen_rtx_MEM (Pmode, plus_constant (linkage, 8)));
3650     }
3651   else
3652     {
3653       emit_move_insn (gen_rtx_REG (Pmode, 26),
3654                       gen_rtx_MEM (Pmode, plus_constant (operands[1], 8)));
3655
3656       operands[3] = operands[1];
3657     }
3658 }")
3659
3660 (define_insn ""
3661   [(call (mem:DI (match_operand:DI 0 "call_operand" "r,R,i"))
3662          (match_operand 1 "" ""))
3663    (clobber (reg:DI 27))
3664    (clobber (reg:DI 26))]
3665   "! TARGET_WINDOWS_NT && ! TARGET_OPEN_VMS"
3666   "@
3667    jsr $26,($27),0\;ldgp $29,0($26)
3668    bsr $26,$%0..ng
3669    jsr $26,%0\;ldgp $29,0($26)"
3670   [(set_attr "type" "jsr")
3671    (set_attr "length" "12,*,16")])
3672       
3673 (define_insn ""
3674   [(call (mem:DI (match_operand:DI 0 "call_operand" "r,R,i"))
3675          (match_operand 1 "" ""))
3676    (clobber (reg:DI 26))]
3677   "TARGET_WINDOWS_NT"
3678   "@
3679    jsr $26,(%0)
3680    bsr $26,%0
3681    jsr $26,%0"
3682   [(set_attr "type" "jsr")
3683    (set_attr "length" "*,*,12")])
3684       
3685 (define_insn ""
3686   [(call (mem:DI (match_operand:DI 0 "call_operand" "r,i"))
3687          (match_operand 1 "" ""))
3688    (use (match_operand:DI 2 "general_operand" "r,m"))
3689    (use (reg:DI 25))
3690    (use (reg:DI 26))
3691    (clobber (reg:DI 27))]
3692   "TARGET_OPEN_VMS"
3693   "@
3694    mov %2,$27\;jsr $26,0\;ldq $27,0($29)
3695    ldq $27,%2\;jsr $26,%0\;ldq $27,0($29)"
3696   [(set_attr "type" "jsr")
3697    (set_attr "length" "12,16")])
3698
3699 (define_insn ""
3700   [(set (match_operand 0 "register_operand" "=rf,rf,rf")
3701         (call (mem:DI (match_operand:DI 1 "call_operand" "r,R,i"))
3702               (match_operand 2 "" "")))
3703    (clobber (reg:DI 27))
3704    (clobber (reg:DI 26))]
3705   "! TARGET_WINDOWS_NT && ! TARGET_OPEN_VMS"
3706   "@
3707    jsr $26,($27),0\;ldgp $29,0($26)
3708    bsr $26,$%1..ng
3709    jsr $26,%1\;ldgp $29,0($26)"
3710   [(set_attr "type" "jsr")
3711    (set_attr "length" "12,*,16")])
3712
3713 (define_insn ""
3714   [(set (match_operand 0 "register_operand" "=rf,rf,rf")
3715         (call (mem:DI (match_operand:DI 1 "call_operand" "r,R,i"))
3716               (match_operand 2 "" "")))
3717    (clobber (reg:DI 26))]
3718   "TARGET_WINDOWS_NT"
3719   "@
3720    jsr $26,(%1)
3721    bsr $26,%1
3722    jsr $26,%1"
3723   [(set_attr "type" "jsr")
3724    (set_attr "length" "*,*,12")])
3725
3726 (define_insn ""
3727   [(set (match_operand 0 "register_operand" "")
3728         (call (mem:DI (match_operand:DI 1 "call_operand" "r,i"))
3729               (match_operand 2 "" "")))
3730    (use (match_operand:DI 3 "general_operand" "r,m"))
3731    (use (reg:DI 25))
3732    (use (reg:DI 26))
3733    (clobber (reg:DI 27))]
3734   "TARGET_OPEN_VMS"
3735   "@
3736    mov %3,$27\;jsr $26,0\;ldq $27,0($29)
3737    ldq $27,%3\;jsr $26,%1\;ldq $27,0($29)"
3738   [(set_attr "type" "jsr")
3739    (set_attr "length" "12,16")])
3740
3741 ;; Call subroutine returning any type.
3742
3743 (define_expand "untyped_call"
3744   [(parallel [(call (match_operand 0 "" "")
3745                     (const_int 0))
3746               (match_operand 1 "" "")
3747               (match_operand 2 "" "")])]
3748   ""
3749   "
3750 {
3751   int i;
3752
3753   emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx));
3754
3755   for (i = 0; i < XVECLEN (operands[2], 0); i++)
3756     {
3757       rtx set = XVECEXP (operands[2], 0, i);
3758       emit_move_insn (SET_DEST (set), SET_SRC (set));
3759     }
3760
3761   /* The optimizer does not know that the call sets the function value
3762      registers we stored in the result block.  We avoid problems by
3763      claiming that all hard registers are used and clobbered at this
3764      point.  */
3765   emit_insn (gen_blockage ());
3766
3767   DONE;
3768 }")
3769
3770 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
3771 ;; all of memory.  This blocks insns from being moved across this point.
3772
3773 (define_insn "blockage"
3774   [(unspec_volatile [(const_int 0)] 1)]
3775   ""
3776   ""
3777   [(set_attr "length" "0")])
3778
3779 (define_insn "jump"
3780   [(set (pc)
3781         (label_ref (match_operand 0 "" "")))]
3782   ""
3783   "br $31,%l0"
3784   [(set_attr "type" "ibr")])
3785
3786 (define_insn "return"
3787   [(return)]
3788   "direct_return ()"
3789   "ret $31,($26),1"
3790   [(set_attr "type" "ibr")])
3791
3792 ;; Use a different pattern for functions which have non-trivial
3793 ;; epilogues so as not to confuse jump and reorg.
3794 (define_insn "return_internal"
3795   [(use (reg:DI 26))
3796    (return)]
3797   ""
3798   "ret $31,($26),1"
3799   [(set_attr "type" "ibr")])
3800
3801 (define_insn "indirect_jump"
3802   [(set (pc) (match_operand:DI 0 "register_operand" "r"))]
3803   ""
3804   "jmp $31,(%0),0"
3805   [(set_attr "type" "ibr")])
3806
3807 (define_expand "tablejump"
3808   [(use (match_operand:SI 0 "register_operand" ""))
3809    (use (match_operand:SI 1 "" ""))]
3810   ""
3811   "
3812 {
3813   if (TARGET_WINDOWS_NT)
3814     emit_jump_insn (gen_tablejump_nt (operands[0], operands[1]));
3815   else if (TARGET_OPEN_VMS)
3816     emit_jump_insn (gen_tablejump_vms (operands[0], operands[1]));
3817   else
3818     emit_jump_insn (gen_tablejump_osf (operands[0], operands[1]));
3819
3820   DONE;
3821 }")
3822
3823 (define_expand "tablejump_osf"
3824   [(set (match_dup 3)
3825         (sign_extend:DI (match_operand:SI 0 "register_operand" "")))
3826    (parallel [(set (pc)
3827                    (plus:DI (match_dup 3)
3828                             (label_ref:DI (match_operand 1 "" ""))))
3829               (clobber (match_scratch:DI 2 "=r"))])]
3830   ""
3831   "
3832 { operands[3] = gen_reg_rtx (DImode); }")
3833
3834 (define_expand "tablejump_nt"
3835   [(set (match_dup 3)
3836         (sign_extend:DI (match_operand:SI 0 "register_operand" "")))
3837    (parallel [(set (pc)
3838                    (match_dup 3))
3839               (use (label_ref (match_operand 1 "" "")))])]
3840   ""
3841   "
3842 { operands[3] = gen_reg_rtx (DImode); }")
3843
3844 ;;
3845 ;; tablejump, openVMS way
3846 ;; op 0: offset
3847 ;; op 1: label preceding jump-table
3848 ;;
3849 (define_expand "tablejump_vms"
3850   [(set (match_dup 2)
3851       (match_operand:DI 0 "register_operand" ""))
3852         (set (pc)
3853         (plus:DI (match_dup 2)
3854                 (label_ref:DI (match_operand 1 "" ""))))]
3855   ""
3856   "
3857 { operands[2] = gen_reg_rtx (DImode); }")
3858
3859 (define_insn ""
3860   [(set (pc)
3861         (plus:DI (match_operand:DI 0 "register_operand" "r")
3862                  (label_ref:DI (match_operand 1 "" ""))))
3863    (clobber (match_scratch:DI 2 "=r"))]
3864   "! TARGET_WINDOWS_NT && ! TARGET_OPEN_VMS && next_active_insn (insn) != 0
3865    && GET_CODE (PATTERN (next_active_insn (insn))) == ADDR_DIFF_VEC
3866    && PREV_INSN (next_active_insn (insn)) == operands[1]"
3867   "*
3868 { rtx best_label = 0;
3869   rtx jump_table_insn = next_active_insn (operands[1]);
3870
3871   if (GET_CODE (jump_table_insn) == JUMP_INSN
3872       && GET_CODE (PATTERN (jump_table_insn)) == ADDR_DIFF_VEC)
3873     {
3874       rtx jump_table = PATTERN (jump_table_insn);
3875       int n_labels = XVECLEN (jump_table, 1);
3876       int best_count = -1;
3877       int i, j;
3878
3879       for (i = 0; i < n_labels; i++)
3880         {
3881           int count = 1;
3882
3883           for (j = i + 1; j < n_labels; j++)
3884             if (XEXP (XVECEXP (jump_table, 1, i), 0)
3885                 == XEXP (XVECEXP (jump_table, 1, j), 0))
3886               count++;
3887
3888           if (count > best_count)
3889             best_count = count, best_label = XVECEXP (jump_table, 1, i);
3890         }
3891     }
3892
3893   if (best_label)
3894     {
3895       operands[3] = best_label;
3896       return \"addq %0,$29,%2\;jmp $31,(%2),%3\";
3897     }
3898   else
3899     return \"addq %0,$29,%2\;jmp $31,(%2),0\";
3900 }"
3901   [(set_attr "type" "ibr")
3902    (set_attr "length" "8")])
3903
3904 (define_insn ""
3905   [(set (pc)
3906         (match_operand:DI 0 "register_operand" "r"))
3907    (use (label_ref (match_operand 1 "" "")))]
3908   "TARGET_WINDOWS_NT && next_active_insn (insn) != 0
3909    && GET_CODE (PATTERN (next_active_insn (insn))) == ADDR_DIFF_VEC
3910    && PREV_INSN (next_active_insn (insn)) == operands[1]"
3911   "*
3912 { rtx best_label = 0;
3913   rtx jump_table_insn = next_active_insn (operands[1]);
3914
3915   if (GET_CODE (jump_table_insn) == JUMP_INSN
3916       && GET_CODE (PATTERN (jump_table_insn)) == ADDR_DIFF_VEC)
3917     {
3918       rtx jump_table = PATTERN (jump_table_insn);
3919       int n_labels = XVECLEN (jump_table, 1);
3920       int best_count = -1;
3921       int i, j;
3922
3923       for (i = 0; i < n_labels; i++)
3924         {
3925           int count = 1;
3926
3927           for (j = i + 1; j < n_labels; j++)
3928             if (XEXP (XVECEXP (jump_table, 1, i), 0)
3929                 == XEXP (XVECEXP (jump_table, 1, j), 0))
3930               count++;
3931
3932           if (count > best_count)
3933             best_count = count, best_label = XVECEXP (jump_table, 1, i);
3934         }
3935     }
3936
3937   if (best_label)
3938     {
3939       operands[2] = best_label;
3940       return \"jmp $31,(%0),%2\";
3941     }
3942   else
3943     return \"jmp $31,(%0),0\";
3944 }"
3945   [(set_attr "type" "ibr")])
3946
3947 ;;
3948 ;; op 0 is table offset
3949 ;; op 1 is table label
3950 ;;
3951
3952 (define_insn ""
3953   [(set (pc)
3954         (plus:DI (match_operand 0 "register_operand" "r")
3955                 (label_ref (match_operand 1 "" ""))))]
3956   "TARGET_OPEN_VMS"
3957   "jmp $31,(%0),0"
3958   [(set_attr "type" "ibr")])
3959
3960 ;; Cache flush.  Used by INITIALIZE_TRAMPOLINE.  0x86 is PAL_imb, but we don't
3961 ;; want to have to include pal.h in our .s file.
3962 ;;
3963 ;; Technically the type for call_pal is jsr, but we use that for determining
3964 ;; if we need a GP.  Use ibr instead since it has the same EV5 scheduling
3965 ;; characteristics.
3966 (define_insn "imb"
3967   [(unspec_volatile [(const_int 0)] 0)]
3968   ""
3969   "call_pal 0x86"
3970   [(set_attr "type" "ibr")])
3971 \f
3972 ;; Finally, we have the basic data motion insns.  The byte and word insns
3973 ;; are done via define_expand.  Start with the floating-point insns, since
3974 ;; they are simpler.
3975
3976 (define_insn ""
3977   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m,f,f,m")
3978         (match_operand:SF 1 "input_operand" "rG,m,r,fG,m,fG"))]
3979   "! TARGET_CIX
3980    && (register_operand (operands[0], SFmode)
3981        || reg_or_fp0_operand (operands[1], SFmode))"
3982   "@
3983    mov %r1,%0
3984    ldl %0,%1
3985    stl %r1,%0
3986    fmov %R1,%0
3987    ld%, %0,%1
3988    st%, %R1,%0"
3989   [(set_attr "type" "ilog,ild,ist,fcpys,fld,fst")])
3990
3991 (define_insn ""
3992   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m,f,f,m,f,*r")
3993         (match_operand:SF 1 "input_operand" "rG,m,r,fG,m,fG,r,*f"))]
3994   "TARGET_CIX
3995    && (register_operand (operands[0], SFmode)
3996        || reg_or_fp0_operand (operands[1], SFmode))"
3997   "@
3998    mov %r1,%0
3999    ldl %0,%1
4000    stl %r1,%0
4001    fmov %R1,%0
4002    ld%, %0,%1
4003    st%, %R1,%0
4004    itofs %1,%0
4005    ftois %1,%0"
4006   [(set_attr "type" "ilog,ild,ist,fcpys,fld,fst,itof,ftoi")])
4007
4008 (define_insn ""
4009   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,f,f,m")
4010         (match_operand:DF 1 "input_operand" "rG,m,r,fG,m,fG"))]
4011   "! TARGET_CIX
4012    && (register_operand (operands[0], DFmode)
4013        || reg_or_fp0_operand (operands[1], DFmode))"
4014   "@
4015    mov %r1,%0
4016    ldq %0,%1
4017    stq %r1,%0
4018    fmov %R1,%0
4019    ld%- %0,%1
4020    st%- %R1,%0"
4021   [(set_attr "type" "ilog,ild,ist,fcpys,fld,fst")])
4022
4023 (define_insn ""
4024   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,f,f,m,f,*r")
4025         (match_operand:DF 1 "input_operand" "rG,m,r,fG,m,fG,r,*f"))]
4026   "TARGET_CIX
4027    && (register_operand (operands[0], DFmode)
4028        || reg_or_fp0_operand (operands[1], DFmode))"
4029   "@
4030    mov %r1,%0
4031    ldq %0,%1
4032    stq %r1,%0
4033    fmov %R1,%0
4034    ld%- %0,%1
4035    st%- %R1,%0
4036    itoft %1,%0
4037    ftoit %1,%0"
4038   [(set_attr "type" "ilog,ild,ist,fcpys,fld,fst,itof,ftoi")])
4039
4040 (define_expand "movsf"
4041   [(set (match_operand:SF 0 "nonimmediate_operand" "")
4042         (match_operand:SF 1 "general_operand" ""))]
4043   ""
4044   "
4045 {
4046   if (GET_CODE (operands[0]) == MEM
4047       && ! reg_or_fp0_operand (operands[1], SFmode))
4048     operands[1] = force_reg (SFmode, operands[1]);
4049 }")
4050
4051 (define_expand "movdf"
4052   [(set (match_operand:DF 0 "nonimmediate_operand" "")
4053         (match_operand:DF 1 "general_operand" ""))]
4054   ""
4055   "
4056 {
4057   if (GET_CODE (operands[0]) == MEM
4058       && ! reg_or_fp0_operand (operands[1], DFmode))
4059     operands[1] = force_reg (DFmode, operands[1]);
4060 }")
4061
4062 (define_insn ""
4063   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,m,f,f,m")
4064         (match_operand:SI 1 "input_operand" "rJ,K,L,m,rJ,fJ,m,f"))]
4065   "! TARGET_WINDOWS_NT && ! TARGET_OPEN_VMS && ! TARGET_CIX
4066    && (register_operand (operands[0], SImode)
4067        || reg_or_0_operand (operands[1], SImode))"
4068   "@
4069    mov %r1,%0
4070    lda %0,%1
4071    ldah %0,%h1
4072    ldl %0,%1
4073    stl %r1,%0
4074    fmov %R1,%0
4075    ld%, %0,%1
4076    st%, %R1,%0"
4077   [(set_attr "type" "ilog,iadd,iadd,ild,ist,fcpys,fld,fst")])
4078
4079 (define_insn ""
4080   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,m,f,f,m,r,*f")
4081         (match_operand:SI 1 "input_operand" "rJ,K,L,m,rJ,fJ,m,f,f,*r"))]
4082   "! TARGET_WINDOWS_NT && ! TARGET_OPEN_VMS && TARGET_CIX
4083    && (register_operand (operands[0], SImode)
4084        || reg_or_0_operand (operands[1], SImode))"
4085   "@
4086    mov %r1,%0
4087    lda %0,%1
4088    ldah %0,%h1
4089    ldl %0,%1
4090    stl %r1,%0
4091    fmov %R1,%0
4092    ld%, %0,%1
4093    st%, %R1,%0
4094    ftois %1,%0
4095    itofs %1,%0"
4096   [(set_attr "type" "ilog,iadd,iadd,ild,ist,fcpys,fld,fst,ftoi,itof")])
4097
4098 (define_insn ""
4099   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,r,m,f,f,m")
4100         (match_operand:SI 1 "input_operand" "rJ,K,L,s,m,rJ,fJ,m,f"))]
4101   "(TARGET_WINDOWS_NT || TARGET_OPEN_VMS)
4102     && (register_operand (operands[0], SImode)
4103         || reg_or_0_operand (operands[1], SImode))"
4104   "@
4105    mov %1,%0
4106    lda %0,%1
4107    ldah %0,%h1
4108    lda %0,%1
4109    ldl %0,%1
4110    stl %r1,%0
4111    fmov %R1,%0
4112    ld%, %0,%1
4113    st%, %R1,%0"
4114   [(set_attr "type" "ilog,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst")])
4115
4116 (define_insn ""
4117   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,f")
4118         (match_operand:HI 1 "input_operand" "rJ,n,fJ"))]
4119   "! TARGET_BWX
4120    && (register_operand (operands[0], HImode)
4121        || register_operand (operands[1], HImode))"
4122   "@
4123    mov %r1,%0
4124    lda %0,%L1
4125    fmov %R1,%0"
4126   [(set_attr "type" "ilog,iadd,fcpys")])
4127
4128 (define_insn ""
4129   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m,f")
4130         (match_operand:HI 1 "input_operand" "rJ,n,m,rJ,fJ"))]
4131   "TARGET_BWX
4132    && (register_operand (operands[0], HImode)
4133        || reg_or_0_operand (operands[1], HImode))"
4134   "@
4135    mov %r1,%0
4136    lda %0,%L1
4137    ldwu %0,%1
4138    stw %r1,%0
4139    fmov %R1,%0"
4140   [(set_attr "type" "ilog,iadd,ild,ist,fcpys")])
4141
4142 (define_insn ""
4143   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,f")
4144         (match_operand:QI 1 "input_operand" "rJ,n,fJ"))]
4145   "! TARGET_BWX
4146    && (register_operand (operands[0], QImode)
4147        || register_operand (operands[1], QImode))"
4148   "@
4149    mov %r1,%0
4150    lda %0,%L1
4151    fmov %R1,%0"
4152   [(set_attr "type" "ilog,iadd,fcpys")])
4153
4154 (define_insn ""
4155   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,r,m,f")
4156         (match_operand:QI 1 "input_operand" "rJ,n,m,rJ,fJ"))]
4157   "TARGET_BWX
4158    && (register_operand (operands[0], QImode)
4159        || reg_or_0_operand (operands[1], QImode))"
4160   "@
4161    mov %r1,%0
4162    lda %0,%L1
4163    ldbu %0,%1
4164    stb %r1,%0
4165    fmov %R1,%0"
4166   [(set_attr "type" "ilog,iadd,ild,ist,fcpys")])
4167
4168 ;; We do two major things here: handle mem->mem and construct long
4169 ;; constants.
4170
4171 (define_expand "movsi"
4172   [(set (match_operand:SI 0 "general_operand" "")
4173         (match_operand:SI 1 "general_operand" ""))]
4174   ""
4175   "
4176 {
4177   if (GET_CODE (operands[0]) == MEM
4178       && ! reg_or_0_operand (operands[1], SImode))
4179     operands[1] = force_reg (SImode, operands[1]);
4180
4181   if (! CONSTANT_P (operands[1]) || input_operand (operands[1], SImode))
4182     ;
4183   else if (GET_CODE (operands[1]) == CONST_INT)
4184     {
4185       operands[1]
4186         = alpha_emit_set_const (operands[0], SImode, INTVAL (operands[1]), 3);
4187       if (rtx_equal_p (operands[0], operands[1]))
4188         DONE;
4189     }
4190 }")
4191
4192 ;; Split a load of a large constant into the appropriate two-insn
4193 ;; sequence.
4194
4195 (define_split
4196   [(set (match_operand:SI 0 "register_operand" "")
4197         (match_operand:SI 1 "const_int_operand" ""))]
4198   "! add_operand (operands[1], SImode)"
4199   [(set (match_dup 0) (match_dup 2))
4200    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
4201   "
4202 { rtx tem
4203     = alpha_emit_set_const (operands[0], SImode, INTVAL (operands[1]), 2);
4204
4205   if (tem == operands[0])
4206     DONE;
4207   else
4208     FAIL;
4209 }")
4210
4211 (define_insn ""
4212   [(set (match_operand:DI 0 "general_operand" "=r,r,r,r,r,m,f,f,Q")
4213         (match_operand:DI 1 "input_operand" "rJ,K,L,s,m,rJ,fJ,Q,f"))]
4214   "! TARGET_CIX
4215    && (register_operand (operands[0], DImode)
4216        || reg_or_0_operand (operands[1], DImode))"
4217   "@
4218    mov %r1,%0
4219    lda %0,%1
4220    ldah %0,%h1
4221    lda %0,%1
4222    ldq%A1 %0,%1
4223    stq%A0 %r1,%0
4224    fmov %R1,%0
4225    ldt %0,%1
4226    stt %R1,%0"
4227   [(set_attr "type" "ilog,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst")])
4228
4229 (define_insn ""
4230   [(set (match_operand:DI 0 "general_operand" "=r,r,r,r,r,m,f,f,Q,r,*f")
4231         (match_operand:DI 1 "input_operand" "rJ,K,L,s,m,rJ,fJ,Q,f,f,*r"))]
4232   "TARGET_CIX
4233    && (register_operand (operands[0], DImode)
4234        || reg_or_0_operand (operands[1], DImode))"
4235   "@
4236    mov %r1,%0
4237    lda %0,%1
4238    ldah %0,%h1
4239    lda %0,%1
4240    ldq%A1 %0,%1
4241    stq%A0 %r1,%0
4242    fmov %R1,%0
4243    ldt %0,%1
4244    stt %R1,%0
4245    ftoit %1,%0
4246    itoft %1,%0"
4247   [(set_attr "type" "ilog,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst,ftoi,itof")])
4248
4249 ;; We do three major things here: handle mem->mem, put 64-bit constants in
4250 ;; memory, and construct long 32-bit constants.
4251
4252 (define_expand "movdi"
4253   [(set (match_operand:DI 0 "general_operand" "")
4254         (match_operand:DI 1 "general_operand" ""))]
4255   ""
4256   "
4257 {
4258   rtx tem;
4259
4260   if (GET_CODE (operands[0]) == MEM
4261       && ! reg_or_0_operand (operands[1], DImode))
4262     operands[1] = force_reg (DImode, operands[1]);
4263
4264   if (! CONSTANT_P (operands[1]) || input_operand (operands[1], DImode))
4265     ;
4266   else if (GET_CODE (operands[1]) == CONST_INT
4267            && (tem = alpha_emit_set_const (operands[0], DImode,
4268                                            INTVAL (operands[1]), 3)) != 0)
4269     {
4270       if (rtx_equal_p (tem, operands[0]))
4271         DONE;
4272       else
4273         operands[1] = tem;
4274     }
4275   else if (CONSTANT_P (operands[1]))
4276     {
4277       if (TARGET_BUILD_CONSTANTS)
4278         {
4279           HOST_WIDE_INT i0, i1;
4280
4281           if (GET_CODE (operands[1]) == CONST_INT)
4282             {
4283               i0 = INTVAL (operands[1]);
4284               i1 = -(i0 < 0);
4285             }
4286           else if (GET_CODE (operands[1]) == CONST_DOUBLE)
4287             {
4288 #if HOST_BITS_PER_WIDE_INT >= 64
4289               i0 = CONST_DOUBLE_LOW (operands[1]);
4290               i1 = -(i0 < 0);
4291 #else
4292               i0 = CONST_DOUBLE_LOW (operands[1]);
4293               i1 = CONST_DOUBLE_HIGH (operands[1]);
4294 #endif
4295             }
4296           else
4297             abort();
4298           
4299           tem = alpha_emit_set_long_const (operands[0], i0, i1);
4300           if (rtx_equal_p (tem, operands[0]))
4301             DONE;
4302           else
4303             operands[1] = tem;
4304         }
4305       else
4306         {
4307           operands[1] = force_const_mem (DImode, operands[1]);
4308           if (reload_in_progress)
4309             {
4310               emit_move_insn (operands[0], XEXP (operands[1], 0));
4311               operands[1] = copy_rtx (operands[1]);
4312               XEXP (operands[1], 0) = operands[0];
4313             }
4314           else
4315             operands[1] = validize_mem (operands[1]);
4316         }
4317     }
4318   else
4319     abort ();
4320 }")
4321
4322 ;; Split a load of a large constant into the appropriate two-insn
4323 ;; sequence.
4324
4325 (define_split
4326   [(set (match_operand:DI 0 "register_operand" "")
4327         (match_operand:DI 1 "const_int_operand" ""))]
4328   "! add_operand (operands[1], DImode)"
4329   [(set (match_dup 0) (match_dup 2))
4330    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
4331   "
4332 { rtx tem
4333     = alpha_emit_set_const (operands[0], DImode, INTVAL (operands[1]), 2);
4334
4335   if (tem == operands[0])
4336     DONE;
4337   else
4338     FAIL;
4339 }")
4340
4341 ;; These are the partial-word cases.
4342 ;;
4343 ;; First we have the code to load an aligned word.  Operand 0 is the register
4344 ;; in which to place the result.  It's mode is QImode or HImode.  Operand 1
4345 ;; is an SImode MEM at the low-order byte of the proper word.  Operand 2 is the
4346 ;; number of bits within the word that the value is.  Operand 3 is an SImode
4347 ;; scratch register.  If operand 0 is a hard register, operand 3 may be the
4348 ;; same register.  It is allowed to conflict with operand 1 as well.
4349
4350 (define_expand "aligned_loadqi"
4351   [(set (match_operand:SI 3 "register_operand" "")
4352         (match_operand:SI 1 "memory_operand" ""))
4353    (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
4354         (zero_extract:DI (subreg:DI (match_dup 3) 0)
4355                          (const_int 8)
4356                          (match_operand:DI 2 "const_int_operand" "")))]
4357          
4358   ""
4359   "")
4360   
4361 (define_expand "aligned_loadhi"
4362   [(set (match_operand:SI 3 "register_operand" "")
4363         (match_operand:SI 1 "memory_operand" ""))
4364    (set (subreg:DI (match_operand:HI 0 "register_operand" "") 0)
4365         (zero_extract:DI (subreg:DI (match_dup 3) 0)
4366                          (const_int 16)
4367                          (match_operand:DI 2 "const_int_operand" "")))]
4368          
4369   ""
4370   "")
4371   
4372 ;; Similar for unaligned loads, where we use the sequence from the
4373 ;; Alpha Architecture manual.
4374 ;;
4375 ;; Operand 1 is the address.  Operands 2 and 3 are temporaries, where
4376 ;; operand 3 can overlap the input and output registers.
4377
4378 (define_expand "unaligned_loadqi"
4379   [(set (match_operand:DI 2 "register_operand" "")
4380         (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
4381                         (const_int -8))))
4382    (set (match_operand:DI 3 "register_operand" "")
4383         (match_dup 1))
4384    (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
4385         (zero_extract:DI (match_dup 2)
4386                          (const_int 8)
4387                          (ashift:DI (match_dup 3) (const_int 3))))]
4388   ""
4389   "")
4390
4391 (define_expand "unaligned_loadhi"
4392   [(set (match_operand:DI 2 "register_operand" "")
4393         (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
4394                         (const_int -8))))
4395    (set (match_operand:DI 3 "register_operand" "")
4396         (match_dup 1))
4397    (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
4398         (zero_extract:DI (match_dup 2)
4399                          (const_int 16)
4400                          (ashift:DI (match_dup 3) (const_int 3))))]
4401   ""
4402   "")
4403
4404 ;; Storing an aligned byte or word requires two temporaries.  Operand 0 is the
4405 ;; aligned SImode MEM.  Operand 1 is the register containing the 
4406 ;; byte or word to store.  Operand 2 is the number of bits within the word that
4407 ;; the value should be placed.  Operands 3 and 4 are SImode temporaries.
4408
4409 (define_expand "aligned_store"
4410   [(set (match_operand:SI 3 "register_operand" "")
4411         (match_operand:SI 0 "memory_operand" ""))
4412    (set (subreg:DI (match_dup 3) 0)
4413         (and:DI (subreg:DI (match_dup 3) 0) (match_dup 5)))
4414    (set (subreg:DI (match_operand:SI 4 "register_operand" "") 0)
4415         (ashift:DI (zero_extend:DI (match_operand 1 "register_operand" ""))
4416                    (match_operand:DI 2 "const_int_operand" "")))
4417    (set (subreg:DI (match_dup 4) 0)
4418         (ior:DI (subreg:DI (match_dup 4) 0) (subreg:DI (match_dup 3) 0)))
4419    (set (match_dup 0) (match_dup 4))]
4420   ""
4421   "
4422 { operands[5] = GEN_INT (~ (GET_MODE_MASK (GET_MODE (operands[1]))
4423                             << INTVAL (operands[2])));
4424 }")
4425
4426 ;; For the unaligned byte and halfword cases, we use code similar to that
4427 ;; in the ;; Architecture book, but reordered to lower the number of registers
4428 ;; required.  Operand 0 is the address.  Operand 1 is the data to store.
4429 ;; Operands 2, 3, and 4 are DImode temporaries, where operands 2 and 4 may
4430 ;; be the same temporary, if desired.  If the address is in a register,
4431 ;; operand 2 can be that register.
4432
4433 (define_expand "unaligned_storeqi"
4434   [(set (match_operand:DI 3 "register_operand" "")
4435         (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
4436                         (const_int -8))))
4437    (set (match_operand:DI 2 "register_operand" "")
4438         (match_dup 0))
4439    (set (match_dup 3)
4440         (and:DI (not:DI (ashift:DI (const_int 255)
4441                                    (ashift:DI (match_dup 2) (const_int 3))))
4442                 (match_dup 3)))
4443    (set (match_operand:DI 4 "register_operand" "")
4444         (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" ""))
4445                    (ashift:DI (match_dup 2) (const_int 3))))
4446    (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
4447    (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
4448         (match_dup 4))]
4449   ""
4450   "")
4451
4452 (define_expand "unaligned_storehi"
4453   [(set (match_operand:DI 3 "register_operand" "")
4454         (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
4455                         (const_int -8))))
4456    (set (match_operand:DI 2 "register_operand" "")
4457         (match_dup 0))
4458    (set (match_dup 3)
4459         (and:DI (not:DI (ashift:DI (const_int 65535)
4460                                    (ashift:DI (match_dup 2) (const_int 3))))
4461                 (match_dup 3)))
4462    (set (match_operand:DI 4 "register_operand" "")
4463         (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" ""))
4464                    (ashift:DI (match_dup 2) (const_int 3))))
4465    (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
4466    (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
4467         (match_dup 4))]
4468   ""
4469   "")
4470 \f
4471 ;; Here are the define_expand's for QI and HI moves that use the above
4472 ;; patterns.  We have the normal sets, plus the ones that need scratch
4473 ;; registers for reload.
4474
4475 (define_expand "movqi"
4476   [(set (match_operand:QI 0 "general_operand" "")
4477         (match_operand:QI 1 "general_operand" ""))]
4478   ""
4479   "
4480 {
4481   if (TARGET_BWX)
4482     {
4483       if (GET_CODE (operands[0]) == MEM
4484           && ! reg_or_0_operand (operands[1], QImode))
4485         operands[1] = force_reg (QImode, operands[1]);
4486
4487       if (GET_CODE (operands[1]) == CONST_INT
4488                && ! input_operand (operands[1], QImode))
4489         {
4490           operands[1] = alpha_emit_set_const (operands[0], QImode,
4491                                               INTVAL (operands[1]), 3);
4492
4493           if (rtx_equal_p (operands[0], operands[1]))
4494             DONE;
4495         }
4496
4497       goto def;
4498     }
4499
4500   /* If the output is not a register, the input must be.  */
4501   if (GET_CODE (operands[0]) == MEM)
4502     operands[1] = force_reg (QImode, operands[1]);
4503
4504   /* Handle four memory cases, unaligned and aligned for either the input
4505      or the output.  The only case where we can be called during reload is
4506      for aligned loads; all other cases require temporaries.  */
4507
4508   if (GET_CODE (operands[1]) == MEM
4509       || (GET_CODE (operands[1]) == SUBREG
4510           && GET_CODE (SUBREG_REG (operands[1])) == MEM)
4511       || (reload_in_progress && GET_CODE (operands[1]) == REG
4512           && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER)
4513       || (reload_in_progress && GET_CODE (operands[1]) == SUBREG
4514           && GET_CODE (SUBREG_REG (operands[1])) == REG
4515           && REGNO (SUBREG_REG (operands[1])) >= FIRST_PSEUDO_REGISTER))
4516     {
4517       if (aligned_memory_operand (operands[1], QImode))
4518         {
4519           rtx aligned_mem, bitnum;
4520           rtx scratch = (reload_in_progress
4521                          ? gen_rtx_REG (SImode, REGNO (operands[0]))
4522                          : gen_reg_rtx (SImode));
4523
4524           get_aligned_mem (operands[1], scratch, &aligned_mem, &bitnum);
4525
4526           emit_insn (gen_aligned_loadqi (operands[0], aligned_mem, bitnum,
4527                                          scratch));
4528         }
4529       else
4530         {
4531           /* Don't pass these as parameters since that makes the generated
4532              code depend on parameter evaluation order which will cause
4533              bootstrap failures.  */
4534
4535           rtx temp1 = gen_reg_rtx (DImode);
4536           rtx temp2 = gen_reg_rtx (DImode);
4537           rtx seq
4538             = gen_unaligned_loadqi (operands[0],
4539                                     get_unaligned_address (operands[1], 0),
4540                                     temp1, temp2);
4541
4542           alpha_set_memflags (seq, operands[1]);
4543           emit_insn (seq);
4544         }
4545
4546       DONE;
4547     }
4548
4549   else if (GET_CODE (operands[0]) == MEM
4550            || (GET_CODE (operands[0]) == SUBREG 
4551                && GET_CODE (SUBREG_REG (operands[0])) == MEM)
4552            || (reload_in_progress && GET_CODE (operands[0]) == REG
4553                && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER)
4554            || (reload_in_progress && GET_CODE (operands[0]) == SUBREG
4555                && GET_CODE (SUBREG_REG (operands[0])) == REG
4556                && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER))
4557     {
4558       if (aligned_memory_operand (operands[0], QImode))
4559         {
4560           rtx aligned_mem, bitnum;
4561           rtx temp1 = gen_reg_rtx (SImode);
4562           rtx temp2 = gen_reg_rtx (SImode);
4563
4564           get_aligned_mem (operands[0], NULL_RTX, &aligned_mem, &bitnum);
4565
4566           emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
4567                                         temp1, temp2));
4568         }
4569       else
4570         {
4571           rtx temp1 = gen_reg_rtx (DImode);
4572           rtx temp2 = gen_reg_rtx (DImode);
4573           rtx temp3 = gen_reg_rtx (DImode);
4574           rtx seq
4575             = gen_unaligned_storeqi (get_unaligned_address (operands[0], 0),
4576                                            operands[1], temp1, temp2, temp3);
4577
4578           alpha_set_memflags (seq, operands[0]);
4579           emit_insn (seq);
4580         }
4581       DONE;
4582     }
4583  def:;
4584 }")
4585
4586 (define_expand "movhi"
4587   [(set (match_operand:HI 0 "general_operand" "")
4588         (match_operand:HI 1 "general_operand" ""))]
4589   ""
4590   "
4591 {
4592   if (TARGET_BWX)
4593     {
4594       if (GET_CODE (operands[0]) == MEM
4595           && ! reg_or_0_operand (operands[1], HImode))
4596         operands[1] = force_reg (HImode, operands[1]);
4597
4598       if (GET_CODE (operands[1]) == CONST_INT
4599                && ! input_operand (operands[1], HImode))
4600         {
4601           operands[1] = alpha_emit_set_const (operands[0], HImode,
4602                                               INTVAL (operands[1]), 3);
4603
4604           if (rtx_equal_p (operands[0], operands[1]))
4605             DONE;
4606         }
4607
4608       goto def;
4609     }
4610
4611   /* If the output is not a register, the input must be.  */
4612   if (GET_CODE (operands[0]) == MEM)
4613     operands[1] = force_reg (HImode, operands[1]);
4614
4615   /* Handle four memory cases, unaligned and aligned for either the input
4616      or the output.  The only case where we can be called during reload is
4617      for aligned loads; all other cases require temporaries.  */
4618
4619   if (GET_CODE (operands[1]) == MEM
4620       || (GET_CODE (operands[1]) == SUBREG
4621           && GET_CODE (SUBREG_REG (operands[1])) == MEM)
4622       || (reload_in_progress && GET_CODE (operands[1]) == REG
4623           && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER)
4624       || (reload_in_progress && GET_CODE (operands[1]) == SUBREG
4625           && GET_CODE (SUBREG_REG (operands[1])) == REG
4626           && REGNO (SUBREG_REG (operands[1])) >= FIRST_PSEUDO_REGISTER))
4627     {
4628       if (aligned_memory_operand (operands[1], HImode))
4629         {
4630           rtx aligned_mem, bitnum;
4631           rtx scratch = (reload_in_progress
4632                          ? gen_rtx_REG (SImode, REGNO (operands[0]))
4633                          : gen_reg_rtx (SImode));
4634
4635           get_aligned_mem (operands[1], scratch, &aligned_mem, &bitnum);
4636
4637           emit_insn (gen_aligned_loadhi (operands[0], aligned_mem, bitnum,
4638                                          scratch));
4639         }
4640       else
4641         {
4642           /* Don't pass these as parameters since that makes the generated
4643              code depend on parameter evaluation order which will cause
4644              bootstrap failures.  */
4645
4646           rtx temp1 = gen_reg_rtx (DImode);
4647           rtx temp2 = gen_reg_rtx (DImode);
4648           rtx seq
4649             = gen_unaligned_loadhi (operands[0],
4650                                     get_unaligned_address (operands[1], 0),
4651                                     temp1, temp2);
4652
4653           alpha_set_memflags (seq, operands[1]);
4654           emit_insn (seq);
4655         }
4656
4657       DONE;
4658     }
4659
4660   else if (GET_CODE (operands[0]) == MEM
4661            || (GET_CODE (operands[0]) == SUBREG 
4662                && GET_CODE (SUBREG_REG (operands[0])) == MEM)
4663            || (reload_in_progress && GET_CODE (operands[0]) == REG
4664                && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER)
4665            || (reload_in_progress && GET_CODE (operands[0]) == SUBREG
4666                && GET_CODE (SUBREG_REG (operands[0])) == REG
4667                && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER))
4668     {
4669       if (aligned_memory_operand (operands[0], HImode))
4670         {
4671           rtx aligned_mem, bitnum;
4672           rtx temp1 = gen_reg_rtx (SImode);
4673           rtx temp2 = gen_reg_rtx (SImode);
4674
4675           get_aligned_mem (operands[0], NULL_RTX, &aligned_mem, &bitnum);
4676
4677           emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
4678                                         temp1, temp2));
4679         }
4680       else
4681         {
4682           rtx temp1 = gen_reg_rtx (DImode);
4683           rtx temp2 = gen_reg_rtx (DImode);
4684           rtx temp3 = gen_reg_rtx (DImode);
4685           rtx seq
4686             = gen_unaligned_storehi (get_unaligned_address (operands[0], 0),
4687                                      operands[1], temp1, temp2, temp3);
4688
4689           alpha_set_memflags (seq, operands[0]);
4690           emit_insn (seq);
4691         }
4692
4693       DONE;
4694     }
4695  def:;
4696 }")
4697
4698 ;; Here are the versions for reload.  Note that in the unaligned cases
4699 ;; we know that the operand must not be a pseudo-register because stack
4700 ;; slots are always aligned references.
4701
4702 (define_expand "reload_inqi"
4703   [(parallel [(match_operand:QI 0 "register_operand" "=r")
4704               (match_operand:QI 1 "unaligned_memory_operand" "m")
4705               (match_operand:TI 2 "register_operand" "=&r")])]
4706   "! TARGET_BWX"
4707   "
4708 {
4709   rtx scratch, seq;
4710
4711   if (aligned_memory_operand (operands[1], QImode))
4712     {
4713       rtx aligned_mem, bitnum;
4714
4715       get_aligned_mem (operands[1],
4716                        gen_rtx_REG (DImode, REGNO (operands[2]) + 1),
4717                        &aligned_mem, &bitnum);
4718       seq = gen_aligned_loadqi (operands[0], aligned_mem, bitnum,
4719                                 gen_rtx_REG (SImode, REGNO (operands[2])));
4720     }
4721   else
4722     {
4723       rtx addr;
4724
4725       /* It is possible that one of the registers we got for operands[2]
4726          might coincide with that of operands[0] (which is why we made
4727          it TImode).  Pick the other one to use as our scratch.  */
4728       if (REGNO (operands[0]) == REGNO (operands[2]))
4729         scratch = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
4730       else
4731         scratch = gen_rtx_REG (DImode, REGNO (operands[2]));
4732
4733       addr = get_unaligned_address (operands[1], 0);
4734       seq = gen_unaligned_loadqi (operands[0], addr, scratch,
4735                                   gen_rtx_REG (DImode, REGNO (operands[0])));
4736     }
4737   alpha_set_memflags (seq, operands[1]);
4738   emit_insn (seq);
4739   DONE;
4740 }")
4741
4742 (define_expand "reload_inhi"
4743   [(parallel [(match_operand:HI 0 "register_operand" "=r")
4744               (match_operand:HI 1 "any_memory_operand" "m")
4745               (match_operand:TI 2 "register_operand" "=&r")])]
4746   "! TARGET_BWX"
4747   "
4748 {
4749   rtx scratch, seq;
4750
4751   if (aligned_memory_operand (operands[1], HImode))
4752     {
4753       rtx aligned_mem, bitnum;
4754
4755       get_aligned_mem (operands[1],
4756                        gen_rtx_REG (DImode, REGNO (operands[2]) + 1),
4757                        &aligned_mem, &bitnum);
4758       seq = gen_aligned_loadhi (operands[0], aligned_mem, bitnum,
4759                                 gen_rtx_REG (SImode, REGNO (operands[2])));
4760     }
4761   else
4762     {
4763       rtx addr;
4764
4765       /* It is possible that one of the registers we got for operands[2]
4766          might coincide with that of operands[0] (which is why we made
4767          it TImode).  Pick the other one to use as our scratch.  */
4768       if (REGNO (operands[0]) == REGNO (operands[2]))
4769         scratch = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
4770       else
4771         scratch = gen_rtx_REG (DImode, REGNO (operands[2]));
4772
4773       addr = get_unaligned_address (operands[1], 0);
4774       seq = gen_unaligned_loadhi (operands[0], addr, scratch,
4775                                   gen_rtx_REG (DImode, REGNO (operands[0])));
4776     }
4777   alpha_set_memflags (seq, operands[1]);
4778   emit_insn (seq);
4779   DONE;
4780 }")
4781
4782 (define_expand "reload_outqi"
4783   [(parallel [(match_operand:QI 0 "any_memory_operand" "=m")
4784               (match_operand:QI 1 "register_operand" "r")
4785               (match_operand:TI 2 "register_operand" "=&r")])]
4786   "! TARGET_BWX"
4787   "
4788 {
4789   if (aligned_memory_operand (operands[0], QImode))
4790     {
4791       rtx aligned_mem, bitnum;
4792
4793       get_aligned_mem (operands[0], NULL_RTX, &aligned_mem, &bitnum);
4794
4795       emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
4796                                     gen_rtx_REG (SImode, REGNO (operands[2])),
4797                                     gen_rtx_REG (SImode,
4798                                                  REGNO (operands[2]) + 1)));
4799     }
4800   else
4801     {
4802       rtx addr = get_unaligned_address (operands[0], 0);
4803       rtx scratch1 = gen_rtx_REG (DImode, REGNO (operands[2]));
4804       rtx scratch2 = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
4805       rtx scratch3 = scratch1;
4806       rtx seq;
4807
4808       if (GET_CODE (addr) == REG)
4809         scratch1 = addr;
4810
4811       seq = gen_unaligned_storeqi (addr, operands[1], scratch1,
4812                                    scratch2, scratch3);
4813       alpha_set_memflags (seq, operands[0]);
4814       emit_insn (seq);
4815     }
4816
4817   DONE;
4818 }")
4819
4820 (define_expand "reload_outhi"
4821   [(parallel [(match_operand:HI 0 "any_memory_operand" "=m")
4822               (match_operand:HI 1 "register_operand" "r")
4823               (match_operand:TI 2 "register_operand" "=&r")])]
4824   "! TARGET_BWX"
4825   "
4826 {
4827   if (aligned_memory_operand (operands[0], HImode))
4828     {
4829       rtx aligned_mem, bitnum;
4830
4831       get_aligned_mem (operands[0], NULL_RTX, &aligned_mem, &bitnum);
4832
4833       emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
4834                                     gen_rtx_REG (SImode, REGNO (operands[2])),
4835                                     gen_rtx_REG (SImode,
4836                                                  REGNO (operands[2]) + 1)));
4837     }
4838   else
4839     {
4840       rtx addr = get_unaligned_address (operands[0], 0);
4841       rtx scratch1 = gen_rtx_REG (DImode, REGNO (operands[2]));
4842       rtx scratch2 = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
4843       rtx scratch3 = scratch1;
4844       rtx seq;
4845
4846       if (GET_CODE (addr) == REG)
4847         scratch1 = addr;
4848
4849       seq = gen_unaligned_storehi (addr, operands[1], scratch1,
4850                                    scratch2, scratch3);
4851       alpha_set_memflags (seq, operands[0]);
4852       emit_insn (seq);
4853     }
4854
4855   DONE;
4856 }")
4857 \f
4858 ;; Bit field extract patterns which use ext[wlq][lh]
4859
4860 (define_expand "extv"
4861   [(set (match_operand:DI 0 "register_operand" "")
4862         (sign_extract:DI (match_operand:QI 1 "memory_operand" "")
4863                          (match_operand:DI 2 "immediate_operand" "")
4864                          (match_operand:DI 3 "immediate_operand" "")))]
4865   ""
4866   "
4867 {
4868   /* We can do 16, 32 and 64 bit fields, if aligned on byte boundaries.  */
4869   if (INTVAL (operands[3]) % 8 != 0
4870       || (INTVAL (operands[2]) != 16
4871           && INTVAL (operands[2]) != 32
4872           && INTVAL (operands[2]) != 64))
4873     FAIL;
4874
4875   /* From mips.md: extract_bit_field doesn't verify that our source
4876      matches the predicate, so we force it to be a MEM here.  */
4877   if (GET_CODE (operands[1]) != MEM)
4878     FAIL;
4879
4880   alpha_expand_unaligned_load (operands[0], operands[1],
4881                                INTVAL (operands[2]) / 8,
4882                                INTVAL (operands[3]) / 8, 1);
4883   DONE;
4884 }")
4885
4886 (define_expand "extzv"
4887   [(set (match_operand:DI 0 "register_operand" "")
4888         (zero_extract:DI (match_operand:DI 1 "general_operand" "")
4889                          (match_operand:DI 2 "immediate_operand" "")
4890                          (match_operand:DI 3 "immediate_operand" "")))]
4891   ""
4892   "
4893 {
4894   /* We can do 8, 16, 32 and 64 bit fields, if aligned on byte boundaries.  */
4895   if (INTVAL (operands[3]) % 8 != 0
4896       || (INTVAL (operands[2]) != 8
4897           && INTVAL (operands[2]) != 16
4898           && INTVAL (operands[2]) != 32
4899           && INTVAL (operands[2]) != 64))
4900     FAIL;
4901
4902   if (GET_CODE (operands[1]) == MEM)
4903     {
4904       /* Fail 8 bit fields, falling back on a simple byte load.  */
4905       if (INTVAL (operands[2]) == 8)
4906         FAIL;
4907
4908       alpha_expand_unaligned_load (operands[0], operands[1],
4909                                    INTVAL (operands[2]) / 8,
4910                                    INTVAL (operands[3]) / 8, 0);
4911       DONE;
4912     }
4913 }")
4914
4915 (define_expand "insv"
4916   [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "")
4917                          (match_operand:DI 1 "immediate_operand" "")
4918                          (match_operand:DI 2 "immediate_operand" ""))
4919         (match_operand:DI 3 "register_operand" ""))]
4920   ""
4921   "
4922 {
4923   /* We can do 16, 32 and 64 bit fields, if aligned on byte boundaries.  */
4924   if (INTVAL (operands[2]) % 8 != 0
4925       || (INTVAL (operands[1]) != 16
4926           && INTVAL (operands[1]) != 32
4927           && INTVAL (operands[1]) != 64))
4928     FAIL;
4929
4930   /* From mips.md: store_bit_field doesn't verify that our source
4931      matches the predicate, so we force it to be a MEM here.  */
4932   if (GET_CODE (operands[0]) != MEM)
4933     FAIL;
4934
4935   alpha_expand_unaligned_store (operands[0], operands[3],
4936                                 INTVAL (operands[1]) / 8,
4937                                 INTVAL (operands[2]) / 8);
4938   DONE;
4939 }")
4940
4941
4942
4943 ;; Block move/clear, see alpha.c for more details.
4944 ;; Argument 0 is the destination
4945 ;; Argument 1 is the source
4946 ;; Argument 2 is the length
4947 ;; Argument 3 is the alignment
4948
4949 (define_expand "movstrqi"
4950   [(parallel [(set (match_operand:BLK 0 "general_operand" "")
4951                    (match_operand:BLK 1 "general_operand" ""))
4952               (use (match_operand:DI 2 "immediate_operand" ""))
4953               (use (match_operand:DI 3 "immediate_operand" ""))])]
4954   ""
4955   "
4956 {
4957   if (alpha_expand_block_move (operands))
4958     DONE;
4959   else
4960     FAIL;
4961 }")
4962
4963 (define_expand "clrstrqi"
4964   [(parallel [(set (match_operand:BLK 0 "general_operand" "")
4965                    (const_int 0))
4966               (use (match_operand:DI 1 "immediate_operand" ""))
4967               (use (match_operand:DI 2 "immediate_operand" ""))])]
4968   ""
4969   "
4970 {
4971   if (alpha_expand_block_clear (operands))
4972     DONE;
4973   else
4974     FAIL;
4975 }")
4976 \f
4977 ;; Subroutine of stack space allocation.  Perform a stack probe.
4978 (define_expand "probe_stack"
4979   [(set (match_dup 1) (match_operand:DI 0 "const_int_operand" ""))]
4980   ""
4981   "
4982 {
4983   operands[1] = gen_rtx_MEM (DImode, plus_constant (stack_pointer_rtx,
4984                                                     INTVAL (operands[0])));
4985   MEM_VOLATILE_P (operands[1]) = 1;
4986
4987   operands[0] = const0_rtx;
4988 }")
4989
4990 ;; This is how we allocate stack space.  If we are allocating a
4991 ;; constant amount of space and we know it is less than 4096
4992 ;; bytes, we need do nothing.
4993 ;;
4994 ;; If it is more than 4096 bytes, we need to probe the stack
4995 ;; periodically. 
4996 (define_expand "allocate_stack"
4997   [(set (reg:DI 30)
4998         (plus:DI (reg:DI 30)
4999                  (match_operand:DI 1 "reg_or_cint_operand" "")))
5000    (set (match_operand:DI 0 "register_operand" "=r")
5001         (match_dup 2))]
5002   ""
5003   "
5004 {
5005   if (GET_CODE (operands[1]) == CONST_INT
5006       && INTVAL (operands[1]) < 32768)
5007     {
5008       if (INTVAL (operands[1]) >= 4096)
5009         {
5010           /* We do this the same way as in the prologue and generate explicit
5011              probes.  Then we update the stack by the constant.  */
5012
5013           int probed = 4096;
5014
5015           emit_insn (gen_probe_stack (GEN_INT (- probed)));
5016           while (probed + 8192 < INTVAL (operands[1]))
5017             emit_insn (gen_probe_stack (GEN_INT (- (probed += 8192))));
5018
5019           if (probed + 4096 < INTVAL (operands[1]))
5020             emit_insn (gen_probe_stack (GEN_INT (- INTVAL(operands[1]))));
5021         }
5022
5023       operands[1] = GEN_INT (- INTVAL (operands[1]));
5024       operands[2] = virtual_stack_dynamic_rtx;
5025     }
5026   else
5027     {
5028       rtx out_label = 0;
5029       rtx loop_label = gen_label_rtx ();
5030       rtx want = gen_reg_rtx (Pmode);
5031       rtx tmp = gen_reg_rtx (Pmode);
5032       rtx memref;
5033
5034       emit_insn (gen_subdi3 (want, stack_pointer_rtx,
5035                              force_reg (Pmode, operands[1])));
5036       emit_insn (gen_adddi3 (tmp, stack_pointer_rtx, GEN_INT (-4096)));
5037
5038       if (GET_CODE (operands[1]) != CONST_INT)
5039         {
5040           out_label = gen_label_rtx ();
5041           emit_insn (gen_cmpdi (want, tmp));
5042           emit_jump_insn (gen_bgeu (out_label));
5043         }
5044
5045       emit_label (loop_label);
5046       memref = gen_rtx_MEM (DImode, tmp);
5047       MEM_VOLATILE_P (memref) = 1;
5048       emit_move_insn (memref, const0_rtx);
5049       emit_insn (gen_adddi3 (tmp, tmp, GEN_INT(-8192)));
5050       emit_insn (gen_cmpdi (tmp, want));
5051       emit_jump_insn (gen_bgtu (loop_label));
5052       if (obey_regdecls)
5053         gen_rtx_USE (VOIDmode, tmp);
5054
5055       memref = gen_rtx_MEM (DImode, want);
5056       MEM_VOLATILE_P (memref) = 1;
5057       emit_move_insn (memref, const0_rtx);
5058
5059       if (out_label)
5060         emit_label (out_label);
5061
5062       emit_move_insn (stack_pointer_rtx, want);
5063       emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
5064       DONE;
5065     }
5066 }")
5067
5068 ;; This is used by alpha_expand_prolog to do the same thing as above,
5069 ;; except we cannot at that time generate new basic blocks, so we hide
5070 ;; the loop in this one insn.
5071
5072 (define_insn "prologue_stack_probe_loop"
5073   [(unspec_volatile [(match_operand 0 "register_operand" "r")
5074                      (match_operand 1 "register_operand" "r")] 5)]
5075   ""
5076   "*
5077 {
5078   operands[2] = gen_label_rtx ();
5079   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
5080                              CODE_LABEL_NUMBER (operands[2]));
5081
5082   return \"stq $31,-8192(%1)\;subq %0,1,%0\;lda %1,-8192(%1)\;bne %0,%l2\";
5083 }"
5084   [(set_attr "length" "16")
5085    (set_attr "type" "multi")])
5086
5087 (define_expand "prologue"
5088   [(clobber (const_int 0))]
5089   ""
5090   "alpha_expand_prologue (); DONE;")
5091
5092 (define_insn "init_fp"
5093   [(set (match_operand:DI 0 "register_operand" "r")
5094         (match_operand:DI 1 "register_operand" "r"))
5095    (clobber (mem:BLK (match_operand:DI 2 "register_operand" "r")))]
5096   ""
5097   "mov %1,%0")
5098
5099 (define_expand "epilogue"
5100   [(clobber (const_int 0))]
5101   ""
5102   "alpha_expand_epilogue (); DONE;")
5103
5104 (define_expand "eh_epilogue"
5105   [(use (match_operand:DI 0 "register_operand" "r"))
5106    (use (match_operand:DI 1 "register_operand" "r"))
5107    (use (match_operand:DI 2 "register_operand" "r"))]
5108   "! TARGET_OPEN_VMS"
5109   "
5110 {
5111   alpha_eh_epilogue_sp_ofs = operands[1];
5112   if (GET_CODE (operands[2]) != REG || REGNO (operands[2]) != 26)
5113     {
5114       rtx ra = gen_rtx_REG (Pmode, 26);
5115       emit_move_insn (ra, operands[2]);
5116       operands[2] = ra;
5117     }
5118 }")
5119
5120 (define_expand "builtin_longjmp"
5121   [(unspec_volatile [(match_operand 0 "register_operand" "r")] 3)]
5122   "! TARGET_OPEN_VMS && ! TARGET_WINDOWS_NT"
5123   "
5124 {
5125   /* The elements of the buffer are, in order:  */
5126   rtx fp = gen_rtx_MEM (Pmode, operands[0]);
5127   rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0], 8));
5128   rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0], 16));
5129   rtx pv = gen_rtx_REG (Pmode, 27);
5130
5131   /* This bit is the same as expand_builtin_longjmp.  */
5132   emit_move_insn (hard_frame_pointer_rtx, fp);
5133   emit_move_insn (pv, lab);
5134   emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
5135   emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
5136   emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
5137
5138   /* Load the label we are jumping through into $27 so that we know
5139      where to look for it when we get back to setjmp's function for
5140      restoring the gp.  */
5141   emit_indirect_jump (pv);
5142   DONE;
5143 }")
5144
5145 (define_insn "builtin_setjmp_receiver"
5146   [(unspec_volatile [(match_operand 0 "" "")] 2)]
5147   "! TARGET_OPEN_VMS && ! TARGET_WINDOWS_NT && TARGET_AS_CAN_SUBTRACT_LABELS"
5148   "\\n$LSJ%=:\;ldgp $29,$LSJ%=-%l0($27)"
5149   [(set_attr "length" "8")
5150    (set_attr "type" "multi")])
5151
5152 (define_insn ""
5153   [(unspec_volatile [(match_operand 0 "" "")] 2)]
5154   "! TARGET_OPEN_VMS && ! TARGET_WINDOWS_NT"
5155   "br $29,$LSJ%=\\n$LSJ%=:\;ldgp $29,0($29)"
5156   [(set_attr "length" "12")
5157    (set_attr "type" "multi")])
5158
5159 (define_insn "exception_receiver"
5160   [(unspec_volatile [(const_int 0)] 7)]
5161   "! TARGET_OPEN_VMS && ! TARGET_WINDOWS_NT"
5162   "br $29,$LSJ%=\\n$LSJ%=:\;ldgp $29,0($29)"
5163   [(set_attr "length" "12")
5164    (set_attr "type" "multi")])
5165
5166 (define_expand "nonlocal_goto_receiver"
5167   [(unspec_volatile [(const_int 0)] 1)
5168    (set (reg:DI 27) (mem:DI (reg:DI 29)))
5169    (unspec_volatile [(const_int 0)] 1)
5170    (use (reg:DI 27))]
5171   "TARGET_OPEN_VMS"
5172   "")
5173
5174 (define_insn "arg_home"
5175   [(unspec [(const_int 0)] 0)
5176    (use (reg:DI 1))
5177    (use (reg:DI 25))
5178    (use (reg:DI 16))
5179    (use (reg:DI 17))
5180    (use (reg:DI 18))
5181    (use (reg:DI 19))
5182    (use (reg:DI 20))
5183    (use (reg:DI 21))
5184    (use (reg:DI 48))
5185    (use (reg:DI 49))
5186    (use (reg:DI 50))
5187    (use (reg:DI 51))
5188    (use (reg:DI 52))
5189    (use (reg:DI 53))
5190    (clobber (mem:BLK (const_int 0)))
5191    (clobber (reg:DI 24))
5192    (clobber (reg:DI 25))
5193    (clobber (reg:DI 0))]
5194   "TARGET_OPEN_VMS"
5195   "lda $0,OTS$HOME_ARGS\;ldq $0,8($0)\;jsr $0,OTS$HOME_ARGS"
5196   [(set_attr "length" "16")
5197    (set_attr "type" "multi")])
5198
5199 ;; Close the trap shadow of preceeding instructions.  This is generated
5200 ;; by alpha_reorg.
5201
5202 (define_insn "trapb"
5203   [(unspec_volatile [(const_int 0)] 4)]
5204   ""
5205   "trapb"
5206   [(set_attr "type" "misc")])
5207
5208 ;; No-op instructions used by machine-dependant reorg to preserve
5209 ;; alignment for instruction issue.
5210
5211 (define_insn "nop"
5212   [(const_int 0)]
5213   ""
5214   "nop"
5215   [(set_attr "type" "ilog")])
5216
5217 (define_insn "fnop"
5218   [(const_int 1)]
5219   "TARGET_FP"
5220   "fnop"
5221   [(set_attr "type" "fcpys")])
5222
5223 (define_insn "unop"
5224   [(const_int 2)]
5225   ""
5226   "unop")
5227
5228 (define_insn "realign"
5229   [(unspec_volatile [(match_operand 0 "immediate_operand" "i")] 6)]
5230   ""
5231   ".align %0 #realign")
5232 \f
5233 ;; Peepholes go at the end.
5234
5235 ;; Optimize sign-extension of SImode loads.  This shows up in the wake of
5236 ;; reload when converting fp->int.
5237 ;;
5238 ;; ??? What to do now that we actually care about the packing and
5239 ;; alignment of instructions?  Perhaps reload can be enlightened, or
5240 ;; the peephole pass moved up after reload but before sched2?
5241 ;
5242 ;(define_peephole
5243 ;  [(set (match_operand:SI 0 "register_operand" "=r")
5244 ;        (match_operand:SI 1 "memory_operand" "m"))
5245 ;   (set (match_operand:DI 2 "register_operand" "=r")
5246 ;        (sign_extend:DI (match_dup 0)))]
5247 ;  "dead_or_set_p (insn, operands[0])"
5248 ;  "ldl %2,%1")
5249 ;
5250 ;(define_peephole
5251 ;  [(set (match_operand:SI 0 "register_operand" "=r")
5252 ;        (match_operand:SI 1 "hard_fp_register_operand" "f"))
5253 ;   (set (match_operand:DI 2 "register_operand" "=r")
5254 ;        (sign_extend:DI (match_dup 0)))]
5255 ;  "TARGET_CIX && dead_or_set_p (insn, operands[0])"
5256 ;  "ftois %1,%2")