OSDN Git Service

(trap): New attribute.
[pf3gnuchains/gcc-fork.git] / gcc / config / alpha / alpha.md
1 ;; Machine description for DEC Alpha for GNU C compiler
2 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996 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 \f
24 ;; Define an insn type attribute.  This is used in function unit delay
25 ;; computations, among other purposes.  For the most part, we use the names
26 ;; defined in the EV4 documentation, but add a few that we have to know about
27 ;; separately.
28
29 (define_attr "type"
30   "ld,st,ibr,fbr,jsr,iaddlog,shiftcm,icmp,imull,imulq,fpop,fdivs,fdivt,ldsym,isubr"
31   (const_string "shiftcm"))
32
33 ;; The TRAP_TYPE attribute marks instructions that may generate traps
34 ;; (which are imprecise and may need a trapb if software complention
35 ;; is desired).
36 (define_attr "trap" "yes,no" (const_string "no"))
37
38 ;; We include four function units: ABOX, which computes the address,
39 ;; BBOX, used for branches, EBOX, used for integer operations, and FBOX,
40 ;; used for FP operations.
41 ;;
42 ;; We assume that we have been successful in getting double issues and
43 ;; hence multiply all costs by two insns per cycle.  The minimum time in
44 ;; a function unit is 2 cycle, which will tend to produce the double
45 ;; issues.
46
47 ;; Memory delivers its result in three cycles.
48 (define_function_unit "abox" 1 0 (eq_attr "type" "ld,ldsym,st") 6 2)
49
50 ;; Branches have no delay cost, but do tie up the unit for two cycles.
51 (define_function_unit "bbox" 1 1 (eq_attr "type" "ibr,fbr,jsr") 4 4)
52
53 ;; Arithmetic insns are normally have their results available after two
54 ;; cycles.  There are a number of exceptions.  They are encoded in
55 ;; ADJUST_COST.  Some of the other insns have similar exceptions.
56
57 (define_function_unit "ebox" 1 0 (eq_attr "type" "iaddlog,shiftcm,icmp") 4 2)
58
59 ;; These really don't take up the integer pipeline, but they do occupy
60 ;; IBOX1; we approximate here.
61
62 (define_function_unit "ebox" 1 0 (eq_attr "type" "imull") 42 2)
63 (define_function_unit "ebox" 1 0 (eq_attr "type" "imulq") 46 2)
64
65 (define_function_unit "imult" 1 0 (eq_attr "type" "imull") 42 38)
66 (define_function_unit "imult" 1 0 (eq_attr "type" "imulq") 46 42)
67
68 (define_function_unit "fbox" 1 0 (eq_attr "type" "fpop") 12 2)
69
70 (define_function_unit "fbox" 1 0 (eq_attr "type" "fdivs") 68 0)
71 (define_function_unit "fbox" 1 0 (eq_attr "type" "fdivt") 126 0)
72
73 (define_function_unit "divider" 1 0 (eq_attr "type" "fdivs") 68 60)
74 (define_function_unit "divider" 1 0 (eq_attr "type" "fdivt") 126 118)
75 \f
76 ;; First define the arithmetic insns.  Note that the 32-bit forms also
77 ;; sign-extend.
78
79 ;; Note that we can do sign extensions in both FP and integer registers.
80 ;; However, the result must be in the same type of register as the input.
81 ;; The register preferencing code can't handle this case very well, so, for
82 ;; now, don't let the FP case show up here for preferencing.  Also,
83 ;; sign-extends in FP registers take two instructions.
84 (define_insn "extendsidi2"
85   [(set (match_operand:DI 0 "register_operand" "=r,r,*f")
86         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "r,m,*f")))]
87   ""
88   "@
89    addl %1,$31,%0
90    ldl %0,%1
91    cvtql %1,%0\;cvtlq %0,%0"
92   [(set_attr "type" "iaddlog,ld,fpop")])
93
94 ;; Do addsi3 the way expand_binop would do if we didn't have one.  This
95 ;; generates better code.  We have the anonymous addsi3 pattern below in
96 ;; case combine wants to make it.
97 (define_expand "addsi3"
98   [(set (match_operand:SI 0 "register_operand" "")
99         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "")
100                  (match_operand:SI 2 "add_operand" "")))]
101   ""
102   "
103 { emit_insn (gen_rtx (SET, VOIDmode, gen_lowpart (DImode, operands[0]),
104                       gen_rtx (PLUS, DImode,
105                                gen_lowpart (DImode, operands[1]),
106                                gen_lowpart (DImode, operands[2]))));
107   DONE;
108 } ")
109
110 (define_insn ""
111   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
112         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ,rJ,rJ,rJ")
113                  (match_operand:SI 2 "add_operand" "rI,O,K,L")))]
114   ""
115   "@
116    addl %r1,%2,%0
117    subl %r1,%n2,%0
118    lda %0,%2(%r1)
119    ldah %0,%h2(%r1)"
120   [(set_attr "type" "iaddlog")])
121
122 (define_split
123   [(set (match_operand:SI 0 "register_operand" "")
124         (plus:SI (match_operand:SI 1 "register_operand" "")
125                  (match_operand:SI 2 "const_int_operand" "")))]
126   "! add_operand (operands[2], SImode)"
127   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
128    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
129   "
130 {
131   HOST_WIDE_INT val = INTVAL (operands[2]);
132   HOST_WIDE_INT low = (val & 0xffff) - 2 * (val & 0x8000);
133   HOST_WIDE_INT rest = val - low;
134
135   operands[3] = GEN_INT (rest);
136   operands[4] = GEN_INT (low);
137 }")
138
139 (define_insn ""
140   [(set (match_operand:DI 0 "register_operand" "=r,r")
141         (sign_extend:DI
142          (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ,rJ")
143                   (match_operand:SI 2 "sext_add_operand" "rI,O"))))]
144   ""
145   "@
146    addl %r1,%2,%0
147    subl %r1,%n2,%0"
148   [(set_attr "type" "iaddlog")])
149
150 (define_split
151   [(set (match_operand:DI 0 "register_operand" "")
152         (sign_extend:DI
153          (plus:SI (match_operand:SI 1 "register_operand" "")
154                   (match_operand:SI 2 "const_int_operand" ""))))
155    (clobber (match_operand:SI 3 "register_operand" ""))]
156   "! sext_add_operand (operands[2], SImode) && INTVAL (operands[2]) > 0
157    && INTVAL (operands[2]) % 4 == 0"
158   [(set (match_dup 3) (match_dup 4))
159    (set (match_dup 0) (sign_extend:DI (plus:SI (mult:SI (match_dup 3)
160                                                         (match_dup 5))
161                                                (match_dup 1))))]
162   "
163 {
164   HOST_WIDE_INT val = INTVAL (operands[2]) / 4;
165   int mult = 4;
166
167   if (val % 2 == 0)
168     val /= 2, mult = 8;
169
170   operands[4] = GEN_INT (val);
171   operands[5] = GEN_INT (mult);
172 }")
173
174 (define_split
175   [(set (match_operand:DI 0 "register_operand" "")
176         (sign_extend:DI
177          (plus:SI (match_operator:SI 1 "comparison_operator"
178                                      [(match_operand 2 "" "")
179                                       (match_operand 3 "" "")])
180                   (match_operand:SI 4 "add_operand" ""))))
181    (clobber (match_operand:DI 5 "register_operand" ""))]
182   ""
183   [(set (match_dup 5) (match_dup 6))
184    (set (match_dup 0) (sign_extend:DI (plus:SI (match_dup 7) (match_dup 4))))]
185   "
186 {
187   operands[6] = gen_rtx (GET_CODE (operands[1]), DImode,
188                          operands[2], operands[3]);
189   operands[7] = gen_lowpart (SImode, operands[5]);
190 }")
191
192 (define_insn "adddi3"
193   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r")
194         (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ,rJ,rJ")
195                  (match_operand:DI 2 "add_operand" "rI,O,K,L")))]
196   ""
197   "@
198    addq %r1,%2,%0
199    subq %r1,%n2,%0
200    lda %0,%2(%r1)
201    ldah %0,%h2(%r1)"
202   [(set_attr "type" "iaddlog")])
203
204 ;; Don't do this if we are adjusting SP since we don't want to do
205 ;; it in two steps. 
206 (define_split
207   [(set (match_operand:DI 0 "register_operand" "")
208         (plus:DI (match_operand:DI 1 "register_operand" "")
209                  (match_operand:DI 2 "const_int_operand" "")))]
210   "! add_operand (operands[2], DImode)
211    && REGNO (operands[0]) != STACK_POINTER_REGNUM"
212   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
213    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
214   "
215 {
216   HOST_WIDE_INT val = INTVAL (operands[2]);
217   HOST_WIDE_INT low = (val & 0xffff) - 2 * (val & 0x8000);
218   HOST_WIDE_INT rest = val - low;
219
220   operands[3] = GEN_INT (rest);
221   operands[4] = GEN_INT (low);
222 }")
223
224 (define_insn ""
225   [(set (match_operand:SI 0 "register_operand" "=r,r")
226         (plus:SI (mult:SI (match_operand:SI 1 "reg_or_0_operand" "rJ,rJ")
227                           (match_operand:SI 2 "const48_operand" "I,I"))
228                  (match_operand:SI 3 "sext_add_operand" "rI,O")))]
229   ""
230   "@
231    s%2addl %r1,%3,%0
232    s%2subl %r1,%n3,%0"
233   [(set_attr "type" "iaddlog")])
234
235 (define_insn ""
236   [(set (match_operand:DI 0 "register_operand" "=r,r")
237         (sign_extend:DI
238          (plus:SI (mult:SI (match_operand:SI 1 "reg_or_0_operand" "rJ,rJ")
239                            (match_operand:SI 2 "const48_operand" "I,I"))
240                   (match_operand:SI 3 "sext_add_operand" "rI,O"))))]
241   ""
242   "@
243    s%2addl %r1,%3,%0
244    s%2subl %r1,%n3,%0"
245   [(set_attr "type" "iaddlog")])
246
247 (define_split
248   [(set (match_operand:DI 0 "register_operand" "")
249         (sign_extend:DI
250          (plus:SI (mult:SI (match_operator:SI 1 "comparison_operator"
251                                               [(match_operand 2 "" "")
252                                                (match_operand 3 "" "")])
253                            (match_operand:SI 4 "const48_operand" ""))
254                   (match_operand:SI 5 "add_operand" ""))))
255    (clobber (match_operand:DI 6 "register_operand" ""))]
256   ""
257   [(set (match_dup 6) (match_dup 7))
258    (set (match_dup 0)
259         (sign_extend:DI (plus:SI (mult:SI (match_dup 8) (match_dup 4))
260                                  (match_dup 5))))]
261   "
262 {
263   operands[7] = gen_rtx (GET_CODE (operands[1]), DImode,
264                          operands[2], operands[3]);
265   operands[8] = gen_lowpart (SImode, operands[6]);
266 }")
267
268 (define_insn ""
269   [(set (match_operand:DI 0 "register_operand" "=r,r")
270         (plus:DI (mult:DI (match_operand:DI 1 "reg_or_0_operand" "rJ,rJ")
271                           (match_operand:DI 2 "const48_operand" "I,I"))
272                  (match_operand:DI 3 "reg_or_8bit_operand" "rI,O")))]
273   ""
274   "@
275    s%2addq %r1,%3,%0
276    s%2subq %1,%n3,%0"
277   [(set_attr "type" "iaddlog")])
278
279 ;; These variants of the above insns can occur if the third operand
280 ;; is the frame pointer.  This is a kludge, but there doesn't
281 ;; seem to be a way around it.  Only recognize them while reloading.
282
283 (define_insn ""
284   [(set (match_operand:DI 0 "some_operand" "=&r")
285         (plus:DI (plus:DI (match_operand:DI 1 "some_operand" "r")
286                           (match_operand:DI 2 "some_operand" "r"))
287                  (match_operand:DI 3 "some_operand" "rIOKL")))]
288   "reload_in_progress"
289   "#"
290   [(set_attr "type" "iaddlog")])
291
292 (define_split
293   [(set (match_operand:DI 0 "register_operand" "")
294         (plus:DI (plus:DI (match_operand:DI 1 "register_operand" "")
295                           (match_operand:DI 2 "register_operand" ""))
296                  (match_operand:DI 3 "add_operand" "")))]
297   "reload_completed"
298   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
299    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
300   "")
301                                            
302 (define_insn ""
303   [(set (match_operand:SI 0 "some_operand" "=&r")
304         (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "some_operand" "rJ")
305                                    (match_operand:SI 2 "const48_operand" "I"))
306                           (match_operand:SI 3 "some_operand" "r"))
307                  (match_operand:SI 4 "some_operand" "rIOKL")))]
308   "reload_in_progress"
309   "#"
310   [(set_attr "type" "iaddlog")])
311
312 (define_split
313   [(set (match_operand:SI 0 "register_operand" "r")
314         (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "reg_or_0_operand" "")
315                                    (match_operand:SI 2 "const48_operand" ""))
316                           (match_operand:SI 3 "register_operand" ""))
317                  (match_operand:SI 4 "add_operand" "rIOKL")))]
318   "reload_completed"
319   [(set (match_dup 0)
320         (plus:SI (mult:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
321    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
322   "")
323
324 (define_insn ""
325   [(set (match_operand:DI 0 "some_operand" "=&r")
326         (sign_extend:DI
327          (plus:SI (plus:SI
328                    (mult:SI (match_operand:SI 1 "some_operand" "rJ")
329                             (match_operand:SI 2 "const48_operand" "I"))
330                    (match_operand:SI 3 "some_operand" "r"))
331                   (match_operand:SI 4 "some_operand" "rIOKL"))))]
332   "reload_in_progress"
333   "#"
334   [(set_attr "type" "iaddlog")])
335
336 (define_split
337   [(set (match_operand:DI 0 "register_operand" "")
338         (sign_extend:DI
339          (plus:SI (plus:SI
340                    (mult:SI (match_operand:SI 1 "reg_or_0_operand" "")
341                             (match_operand:SI 2 "const48_operand" ""))
342                    (match_operand:SI 3 "register_operand" ""))
343                   (match_operand:SI 4 "add_operand" ""))))]
344   "reload_completed"
345   [(set (match_dup 5)
346         (plus:SI (mult:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
347    (set (match_dup 0) (sign_extend:DI (plus:SI (match_dup 5) (match_dup 4))))]
348   "
349 { operands[5] = gen_lowpart (SImode, operands[0]);
350 }")
351
352 (define_insn ""
353   [(set (match_operand:DI 0 "some_operand" "=&r")
354         (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "some_operand" "rJ")
355                                    (match_operand:DI 2 "const48_operand" "I"))
356                           (match_operand:DI 3 "some_operand" "r"))
357                  (match_operand:DI 4 "some_operand" "rIOKL")))]
358   "reload_in_progress"
359   "#"
360   [(set_attr "type" "iaddlog")])
361
362 (define_split
363   [(set (match_operand:DI 0 "register_operand" "=")
364         (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "reg_or_0_operand" "")
365                                    (match_operand:DI 2 "const48_operand" ""))
366                           (match_operand:DI 3 "register_operand" ""))
367                  (match_operand:DI 4 "add_operand" "")))]
368   "reload_completed"
369   [(set (match_dup 0)
370         (plus:DI (mult:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
371    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
372   "")
373
374 (define_insn "negsi2"
375   [(set (match_operand:SI 0 "register_operand" "=r")
376         (neg:SI (match_operand:SI 1 "reg_or_8bit_operand" "rI")))]
377   ""
378   "subl $31,%1,%0"
379   [(set_attr "type" "iaddlog")])
380
381 (define_insn ""
382   [(set (match_operand:DI 0 "register_operand" "=r")
383         (sign_extend:DI (neg:SI
384                          (match_operand:SI 1 "reg_or_8bit_operand" "rI"))))]
385   ""
386   "subl $31,%1,%0"
387   [(set_attr "type" "iaddlog")])
388
389 (define_insn "negdi2"
390   [(set (match_operand:DI 0 "register_operand" "=r")
391         (neg:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI")))]
392   ""
393   "subq $31,%1,%0"
394   [(set_attr "type" "iaddlog")])
395
396 (define_expand "subsi3"
397   [(set (match_operand:SI 0 "register_operand" "")
398         (minus:SI (match_operand:SI 1 "reg_or_0_operand" "")
399                   (match_operand:SI 2 "reg_or_8bit_operand" "")))]
400   ""
401   "
402 { emit_insn (gen_rtx (SET, VOIDmode, gen_lowpart (DImode, operands[0]),
403                       gen_rtx (MINUS, DImode,
404                                gen_lowpart (DImode, operands[1]),
405                                gen_lowpart (DImode, operands[2]))));
406   DONE;
407
408 } ")
409
410 (define_insn ""
411   [(set (match_operand:SI 0 "register_operand" "=r")
412         (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
413                   (match_operand:SI 2 "reg_or_8bit_operand" "rI")))]
414   ""
415   "subl %r1,%2,%0"
416   [(set_attr "type" "iaddlog")])
417
418 (define_insn ""
419   [(set (match_operand:DI 0 "register_operand" "=r")
420         (sign_extend:DI (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
421                                   (match_operand:SI 2 "reg_or_8bit_operand" "rI"))))]
422   ""
423   "subl %r1,%2,%0"
424   [(set_attr "type" "iaddlog")])
425
426 (define_insn "subdi3"
427   [(set (match_operand:DI 0 "register_operand" "=r")
428         (minus:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
429                   (match_operand:DI 2 "reg_or_8bit_operand" "rI")))]
430   ""
431   "subq %r1,%2,%0"
432   [(set_attr "type" "iaddlog")])
433
434 (define_insn ""
435   [(set (match_operand:SI 0 "register_operand" "=r")
436         (minus:SI (mult:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
437                            (match_operand:SI 2 "const48_operand" "I"))
438                   (match_operand:SI 3 "reg_or_8bit_operand" "rI")))]
439   ""
440   "s%2subl %r1,%3,%0"
441   [(set_attr "type" "iaddlog")])
442
443 (define_insn ""
444   [(set (match_operand:DI 0 "register_operand" "=r")
445         (sign_extend:DI
446          (minus:SI (mult:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
447                             (match_operand:SI 2 "const48_operand" "I"))
448                    (match_operand:SI 3 "reg_or_8bit_operand" "rI"))))]
449   ""
450   "s%2subl %r1,%3,%0"
451   [(set_attr "type" "iaddlog")])
452
453 (define_insn ""
454   [(set (match_operand:DI 0 "register_operand" "=r")
455         (minus:DI (mult:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
456                            (match_operand:DI 2 "const48_operand" "I"))
457                   (match_operand:DI 3 "reg_or_8bit_operand" "rI")))]
458   ""
459   "s%2subq %r1,%3,%0"
460   [(set_attr "type" "iaddlog")])
461
462 (define_insn "mulsi3"
463   [(set (match_operand:SI 0 "register_operand" "=r")
464         (mult:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
465                  (match_operand:SI 2 "reg_or_0_operand" "rJ")))]
466   ""
467   "mull %r1,%r2,%0"
468   [(set_attr "type" "imull")])
469
470 (define_insn ""
471   [(set (match_operand:DI 0 "register_operand" "=r")
472         (sign_extend:DI (mult:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
473                                  (match_operand:SI 2 "reg_or_0_operand" "rJ"))))]
474   ""
475   "mull %r1,%r2,%0"
476   [(set_attr "type" "imull")])
477
478 (define_insn "muldi3"
479   [(set (match_operand:DI 0 "register_operand" "=r")
480         (mult:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ")
481                  (match_operand:DI 2 "reg_or_0_operand" "rJ")))]
482   ""
483   "mulq %r1,%r2,%0"
484   [(set_attr "type" "imulq")])
485
486 (define_insn "umuldi3_highpart"
487   [(set (match_operand:DI 0 "register_operand" "=r")
488         (truncate:DI
489          (lshiftrt:TI
490           (mult:TI (zero_extend:TI (match_operand:DI 1 "register_operand" "r"))
491                    (zero_extend:TI (match_operand:DI 2 "register_operand" "r")))
492           (const_int 64))))]
493   ""
494   "umulh %1,%2,%0"
495   [(set_attr "type" "imulq")])
496
497 (define_insn ""
498   [(set (match_operand:DI 0 "register_operand" "=r")
499         (truncate:DI
500          (lshiftrt:TI
501           (mult:TI (zero_extend:TI (match_operand:DI 1 "register_operand" "r"))
502                    (match_operand:TI 2 "cint8_operand" "I"))
503           (const_int 64))))]
504   ""
505   "umulh %1,%2,%0"
506   [(set_attr "type" "imulq")])
507 \f
508 ;; The divide and remainder operations always take their inputs from
509 ;; r24 and r25, put their output in r27, and clobber r23 and r28.
510
511 (define_expand "divsi3"
512   [(set (reg:SI 24) (match_operand:SI 1 "input_operand" ""))
513    (set (reg:SI 25) (match_operand:SI 2 "input_operand" ""))
514    (parallel [(set (reg:SI 27)
515                    (div:SI (reg:SI 24)
516                            (reg:SI 25)))
517               (clobber (reg:DI 23))
518               (clobber (reg:DI 28))])
519    (set (match_operand:SI 0 "general_operand" "")
520         (reg:SI 27))]
521   ""
522   "")
523
524 (define_expand "udivsi3"
525   [(set (reg:SI 24) (match_operand:SI 1 "input_operand" ""))
526    (set (reg:SI 25) (match_operand:SI 2 "input_operand" ""))
527    (parallel [(set (reg:SI 27)
528                    (udiv:SI (reg:SI 24)
529                             (reg:SI 25)))
530               (clobber (reg:DI 23))
531               (clobber (reg:DI 28))])
532    (set (match_operand:SI 0 "general_operand" "")
533         (reg:SI 27))]
534   ""
535   "")
536
537 (define_expand "modsi3"
538   [(set (reg:SI 24) (match_operand:SI 1 "input_operand" ""))
539    (set (reg:SI 25) (match_operand:SI 2 "input_operand" ""))
540    (parallel [(set (reg:SI 27)
541                    (mod:SI (reg:SI 24)
542                            (reg:SI 25)))
543               (clobber (reg:DI 23))
544               (clobber (reg:DI 28))])
545    (set (match_operand:SI 0 "general_operand" "")
546         (reg:SI 27))]
547   ""
548   "")
549
550 (define_expand "umodsi3"
551   [(set (reg:SI 24) (match_operand:SI 1 "input_operand" ""))
552    (set (reg:SI 25) (match_operand:SI 2 "input_operand" ""))
553    (parallel [(set (reg:SI 27)
554                    (umod:SI (reg:SI 24)
555                             (reg:SI 25)))
556               (clobber (reg:DI 23))
557               (clobber (reg:DI 28))])
558    (set (match_operand:SI 0 "general_operand" "")
559         (reg:SI 27))]
560   ""
561   "")
562
563 (define_expand "divdi3"
564   [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
565    (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
566    (parallel [(set (reg:DI 27)
567                    (div:DI (reg:DI 24)
568                            (reg:DI 25)))
569               (clobber (reg:DI 23))
570               (clobber (reg:DI 28))])
571    (set (match_operand:DI 0 "general_operand" "")
572         (reg:DI 27))]
573   ""
574   "")
575
576 (define_expand "udivdi3"
577   [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
578    (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
579    (parallel [(set (reg:DI 27)
580                    (udiv:DI (reg:DI 24)
581                             (reg:DI 25)))
582               (clobber (reg:DI 23))
583               (clobber (reg:DI 28))])
584    (set (match_operand:DI 0 "general_operand" "")
585         (reg:DI 27))]
586   ""
587   "")
588
589 (define_expand "moddi3"
590   [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
591    (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
592    (parallel [(set (reg:DI 27)
593                    (mod:DI (reg:DI 24)
594                            (reg:DI 25)))
595               (clobber (reg:DI 23))
596               (clobber (reg:DI 28))])
597    (set (match_operand:DI 0 "general_operand" "")
598         (reg:DI 27))]
599   ""
600   "")
601
602 (define_expand "umoddi3"
603   [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
604    (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
605    (parallel [(set (reg:DI 27)
606                    (umod:DI (reg:DI 24)
607                             (reg:DI 25)))
608               (clobber (reg:DI 23))
609               (clobber (reg:DI 28))])
610    (set (match_operand:DI 0 "general_operand" "")
611         (reg:DI 27))]
612   ""
613   "")
614
615 (define_insn ""
616   [(set (reg:SI 27)
617         (match_operator:SI 1 "divmod_operator"
618                         [(reg:SI 24) (reg:SI 25)]))
619    (clobber (reg:DI 23))
620    (clobber (reg:DI 28))]
621   ""
622   "%E1 $24,$25,$27"
623   [(set_attr "type" "isubr")])
624
625 (define_insn ""
626   [(set (reg:DI 27)
627         (match_operator:DI 1 "divmod_operator"
628                         [(reg:DI 24) (reg:DI 25)]))
629    (clobber (reg:DI 23))
630    (clobber (reg:DI 28))]
631   ""
632   "%E1 $24,$25,$27"
633   [(set_attr "type" "isubr")])
634 \f
635 ;; Next are the basic logical operations.  These only exist in DImode.
636
637 (define_insn "anddi3"
638   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
639         (and:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ,rJ")
640                 (match_operand:DI 2 "and_operand" "rI,N,MH")))]
641   ""
642   "@
643    and %r1,%2,%0
644    bic %r1,%N2,%0
645    zapnot %r1,%m2,%0"
646   [(set_attr "type" "iaddlog,iaddlog,shiftcm")])
647
648 ;; There are times when we can split an AND into two AND insns.  This occurs
649 ;; when we can first clear any bytes and then clear anything else.  For
650 ;; example "I & 0xffff07" is "(I & 0xffffff) & 0xffffffffffffff07".
651 ;; Only do this when running on 64-bit host since the computations are
652 ;; too messy otherwise.
653
654 (define_split
655   [(set (match_operand:DI 0 "register_operand" "")
656         (and:DI (match_operand:DI 1 "register_operand" "")
657                 (match_operand:DI 2 "const_int_operand" "")))]
658   "HOST_BITS_PER_WIDE_INT == 64 && ! and_operand (operands[2], DImode)"
659   [(set (match_dup 0) (and:DI (match_dup 1) (match_dup 3)))
660    (set (match_dup 0) (and:DI (match_dup 0) (match_dup 4)))]
661   "
662 {
663   unsigned HOST_WIDE_INT mask1 = INTVAL (operands[2]);
664   unsigned HOST_WIDE_INT mask2 = mask1;
665   int i;
666
667   /* For each byte that isn't all zeros, make it all ones.  */
668   for (i = 0; i < 64; i += 8)
669     if ((mask1 & ((HOST_WIDE_INT) 0xff << i)) != 0)
670       mask1 |= (HOST_WIDE_INT) 0xff << i;
671
672   /* Now turn on any bits we've just turned off.  */
673   mask2 |= ~ mask1;
674
675   operands[3] = GEN_INT (mask1);
676   operands[4] = GEN_INT (mask2);
677 }")
678
679 (define_insn "zero_extendqihi2"
680   [(set (match_operand:HI 0 "register_operand" "=r")
681         (zero_extend:HI (match_operand:QI 1 "register_operand" "r")))]
682   ""
683   "zapnot %1,1,%0"
684   [(set_attr "type" "iaddlog")])
685
686 (define_insn "zero_extendqisi2"
687   [(set (match_operand:SI 0 "register_operand" "=r")
688         (zero_extend:SI (match_operand:QI 1 "register_operand" "r")))]
689   ""
690   "zapnot %1,1,%0"
691   [(set_attr "type" "iaddlog")])
692
693 (define_insn "zero_extendqidi2"
694   [(set (match_operand:DI 0 "register_operand" "=r")
695         (zero_extend:DI (match_operand:QI 1 "register_operand" "r")))]
696   ""
697   "zapnot %1,1,%0"
698   [(set_attr "type" "iaddlog")])
699
700 (define_insn "zero_extendhisi2"
701   [(set (match_operand:SI 0 "register_operand" "=r")
702         (zero_extend:SI (match_operand:HI 1 "register_operand" "r")))]
703   ""
704   "zapnot %1,3,%0"
705   [(set_attr "type" "iaddlog")])
706
707 (define_insn "zero_extendhidi2"
708   [(set (match_operand:DI 0 "register_operand" "=r")
709         (zero_extend:DI (match_operand:HI 1 "register_operand" "r")))]
710   ""
711   "zapnot %1,3,%0"
712   [(set_attr "type" "iaddlog")])
713
714 (define_insn "zero_extendsidi2"
715   [(set (match_operand:DI 0 "register_operand" "=r")
716         (zero_extend:DI (match_operand:SI 1 "register_operand" "r")))]
717   ""
718   "zapnot %1,15,%0"
719   [(set_attr "type" "iaddlog")])
720
721 (define_insn  ""
722   [(set (match_operand:DI 0 "register_operand" "=r")
723         (and:DI (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI"))
724                 (match_operand:DI 2 "reg_or_0_operand" "rJ")))]
725   ""
726   "bic %r2,%1,%0"
727   [(set_attr "type" "iaddlog")])
728
729 (define_insn "iordi3"
730   [(set (match_operand:DI 0 "register_operand" "=r,r")
731         (ior:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ")
732                 (match_operand:DI 2 "or_operand" "rI,N")))]
733   ""
734   "@
735    bis %r1,%2,%0
736    ornot %r1,%N2,%0"
737   [(set_attr "type" "iaddlog")])
738
739 (define_insn "one_cmpldi2"
740   [(set (match_operand:DI 0 "register_operand" "=r")
741         (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI")))]
742   ""
743   "ornot $31,%1,%0"
744   [(set_attr "type" "iaddlog")])
745
746 (define_insn ""
747   [(set (match_operand:DI 0 "register_operand" "=r")
748         (ior:DI (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI"))
749                 (match_operand:DI 2 "reg_or_0_operand" "rJ")))]
750   ""
751   "ornot %r2,%1,%0"
752   [(set_attr "type" "iaddlog")])
753
754 (define_insn "xordi3"
755   [(set (match_operand:DI 0 "register_operand" "=r,r")
756         (xor:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ")
757                 (match_operand:DI 2 "or_operand" "rI,N")))]
758   ""
759   "@
760    xor %r1,%2,%0
761    eqv %r1,%N2,%0"
762   [(set_attr "type" "iaddlog")])
763
764 (define_insn ""
765   [(set (match_operand:DI 0 "register_operand" "=r")
766         (not:DI (xor:DI (match_operand:DI 1 "register_operand" "%rJ")
767                         (match_operand:DI 2 "register_operand" "rI"))))]
768   ""
769   "eqv %r1,%2,%0"
770   [(set_attr "type" "iaddlog")])
771 \f
772 ;; Next come the shifts and the various extract and insert operations.
773
774 (define_insn "ashldi3"
775   [(set (match_operand:DI 0 "register_operand" "=r,r")
776         (ashift:DI (match_operand:DI 1 "reg_or_0_operand" "rJ,rJ")
777                    (match_operand:DI 2 "reg_or_6bit_operand" "P,rI")))]
778   ""
779   "*
780 {
781   switch (which_alternative)
782     {
783     case 0:
784       if (operands[2] == const1_rtx)
785         return \"addq %r1,%r1,%0\";
786       else
787         return \"s%P2addq %r1,0,%0\";
788     case 1:
789       return \"sll %r1,%2,%0\";
790     }
791 }"
792   [(set_attr "type" "iaddlog,shiftcm")])
793
794 ;; ??? The following pattern is made by combine, but earlier phases
795 ;; (specifically flow) can't handle it.  This occurs in jump.c.  Deal
796 ;; with this in a better way at some point.
797 ;;(define_insn ""
798 ;;  [(set (match_operand:DI 0 "register_operand" "=r")
799 ;;      (sign_extend:DI
800 ;;       (subreg:SI (ashift:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
801 ;;                             (match_operand:DI 2 "const_int_operand" "P"))
802 ;;                  0)))]
803 ;;  "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3"
804 ;;  "*
805 ;;{
806 ;;  if (operands[2] == const1_rtx)
807 ;;    return \"addl %r1,%r1,%0\";
808 ;;  else
809 ;;    return \"s%P2addl %r1,0,%0\";
810 ;; }"
811 ;;  [(set_attr "type" "iaddlog")])
812                           
813 (define_insn "lshrdi3"
814   [(set (match_operand:DI 0 "register_operand" "=r")
815         (lshiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
816                      (match_operand:DI 2 "reg_or_6bit_operand" "rI")))]
817   ""
818   "srl %r1,%2,%0")
819
820 (define_insn "ashrdi3"
821   [(set (match_operand:DI 0 "register_operand" "=r")
822         (ashiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
823                      (match_operand:DI 2 "reg_or_6bit_operand" "rI")))]
824   ""
825   "sra %r1,%2,%0")
826
827 (define_expand "extendqihi2"
828   [(set (match_dup 2)
829         (ashift:DI (match_operand:QI 1 "reg_or_unaligned_mem_operand" "")
830                    (const_int 56)))
831    (set (match_operand:HI 0 "register_operand" "")
832         (ashiftrt:DI (match_dup 2)
833                      (const_int 56)))]
834   ""
835   "
836 {
837   /* If we have a MEM (must be unaligned), extend to DImode (which we do
838         specially) and then copy to the result.  */
839   if (GET_CODE (operands[1]) == MEM)
840     {
841       rtx temp = gen_reg_rtx (DImode);
842
843       emit_insn (gen_extendqidi2 (temp, operands[1]));
844       emit_move_insn (operands[0], gen_lowpart (HImode, temp));
845       DONE;
846     }
847
848   operands[0] = gen_lowpart (DImode, operands[0]);
849   operands[1] = gen_lowpart (DImode, operands[1]);
850   operands[2] = gen_reg_rtx (DImode);
851 }")
852
853 (define_expand "extendqisi2"
854   [(set (match_dup 2)
855         (ashift:DI (match_operand:QI 1 "reg_or_unaligned_mem_operand" "")
856                    (const_int 56)))
857    (set (match_operand:SI 0 "register_operand" "")
858         (ashiftrt:DI (match_dup 2)
859                      (const_int 56)))]
860   ""
861   "
862 {
863   /* If we have a MEM (must be unaligned), extend to a DImode form of
864      the result (which we do specially).  */
865   if (GET_CODE (operands[1]) == MEM)
866     {
867       rtx temp = gen_reg_rtx (DImode);
868
869       emit_insn (gen_extendqidi2 (temp, operands[1]));
870       emit_move_insn (operands[0], gen_lowpart (SImode, temp));
871       DONE;
872     }
873
874   operands[0] = gen_lowpart (DImode, operands[0]);
875   operands[1] = gen_lowpart (DImode, operands[1]);
876   operands[2] = gen_reg_rtx (DImode);
877 }")
878
879 (define_expand "extendqidi2"
880   [(set (match_dup 2)
881         (ashift:DI (match_operand:QI 1 "reg_or_unaligned_mem_operand" "")
882                    (const_int 56)))
883    (set (match_operand:DI 0 "register_operand" "")
884         (ashiftrt:DI (match_dup 2)
885                      (const_int 56)))]
886   ""
887   "
888 { extern rtx get_unaligned_address ();
889   if (GET_CODE (operands[1]) == MEM)
890     {
891       rtx seq
892         = gen_unaligned_extendqidi (operands[0],
893                                     get_unaligned_address (operands[1], 1));
894
895       alpha_set_memflags (seq, operands[1]);
896       emit_insn (seq);
897       DONE;
898     }
899
900   operands[1] = gen_lowpart (DImode, operands[1]);
901   operands[2] = gen_reg_rtx (DImode);
902 }")
903
904 (define_expand "extendhisi2"
905   [(set (match_dup 2)
906         (ashift:DI (match_operand:HI 1 "reg_or_unaligned_mem_operand" "")
907                    (const_int 48)))
908    (set (match_operand:SI 0 "register_operand" "")
909         (ashiftrt:DI (match_dup 2)
910                      (const_int 48)))]
911   ""
912   "
913 {
914   /* If we have a MEM (must be unaligned), extend to a DImode form of
915      the result (which we do specially).  */
916   if (GET_CODE (operands[1]) == MEM)
917     {
918       rtx temp = gen_reg_rtx (DImode);
919
920       emit_insn (gen_extendhidi2 (temp, operands[1]));
921       emit_move_insn (operands[0], gen_lowpart (SImode, temp));
922       DONE;
923     }
924
925   operands[0] = gen_lowpart (DImode, operands[0]);
926   operands[1] = gen_lowpart (DImode, operands[1]);
927   operands[2] = gen_reg_rtx (DImode);
928 }")
929
930 (define_expand "extendhidi2"
931   [(set (match_dup 2)
932         (ashift:DI (match_operand:HI 1 "reg_or_unaligned_mem_operand" "")
933                    (const_int 48)))
934    (set (match_operand:DI 0 "register_operand" "")
935         (ashiftrt:DI (match_dup 2)
936                      (const_int 48)))]
937   ""
938   "
939 { extern rtx get_unaligned_address ();
940   if (GET_CODE (operands[1]) == MEM)
941     {
942       rtx seq
943         = gen_unaligned_extendhidi (operands[0],
944                                     get_unaligned_address (operands[1], 2));
945
946       alpha_set_memflags (seq, operands[1]);
947       emit_insn (seq);
948       DONE;
949     }
950
951   operands[1] = gen_lowpart (DImode, operands[1]);
952   operands[2] = gen_reg_rtx (DImode);
953 }")
954
955 ;; Here's how we sign extend an unaligned byte and halfword.  Doing this
956 ;; as a pattern saves one instruction.  The code is similar to that for
957 ;; the unaligned loads (see below).
958 ;;
959 ;; Operand 1 is the address + 1 (+2 for HI), operand 0 is the result.
960 (define_expand "unaligned_extendqidi"
961   [(set (match_dup 2) (match_operand:DI 1 "address_operand" ""))
962    (set (match_dup 3)
963         (mem:DI (and:DI (plus:DI (match_dup 2) (const_int -1))
964                         (const_int -8))))
965    (set (match_dup 4)
966         (ashift:DI (match_dup 3)
967                    (minus:DI (const_int 56)
968                              (ashift:DI
969                               (and:DI (plus:DI (match_dup 2) (const_int -1))
970                                       (const_int 7))
971                               (const_int 3)))))
972    (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
973         (ashiftrt:DI (match_dup 4) (const_int 56)))]
974   ""
975   "
976 { operands[2] = gen_reg_rtx (DImode);
977   operands[3] = gen_reg_rtx (DImode);
978   operands[4] = gen_reg_rtx (DImode);
979 }")
980
981 (define_expand "unaligned_extendhidi"
982   [(set (match_dup 2) (match_operand:DI 1 "address_operand" ""))
983    (set (match_dup 3)
984         (mem:DI (and:DI (plus:DI (match_dup 2) (const_int -2))
985                         (const_int -8))))
986    (set (match_dup 4)
987         (ashift:DI (match_dup 3)
988                    (minus:DI (const_int 56)
989                              (ashift:DI
990                               (and:DI (plus:DI (match_dup 2) (const_int -1))
991                                       (const_int 7))
992                               (const_int 3)))))
993    (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
994         (ashiftrt:DI (match_dup 4) (const_int 48)))]
995   ""
996   "
997 { operands[2] = gen_reg_rtx (DImode);
998   operands[3] = gen_reg_rtx (DImode);
999   operands[4] = gen_reg_rtx (DImode);
1000 }")
1001
1002 (define_insn ""
1003   [(set (match_operand:DI 0 "register_operand" "=r")
1004         (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1005                          (match_operand:DI 2 "mode_width_operand" "n")
1006                          (match_operand:DI 3 "mul8_operand" "I")))]
1007   ""
1008   "ext%M2l %r1,%s3,%0")
1009
1010 (define_insn ""
1011   [(set (match_operand:DI 0 "register_operand" "=r")
1012         (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1013                          (match_operand:DI 2 "mode_width_operand" "n")
1014                          (ashift:DI (match_operand:DI 3 "reg_or_8bit_operand" "rI")
1015                                     (const_int 3))))]
1016   ""
1017   "ext%M2l %r1,%3,%0")
1018
1019 (define_insn ""
1020   [(set (match_operand:DI 0 "register_operand" "=r")
1021         (ashift:DI
1022          (match_operand:DI 1 "reg_or_0_operand" "rJ")
1023           (minus:DI (const_int 56)
1024                     (ashift:DI
1025                      (and:DI
1026                       (plus:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1027                                (const_int -1))
1028                       (const_int 7))
1029                      (const_int 3)))))]
1030   ""
1031   "extqh %r1,%2,%0")
1032
1033 (define_insn ""
1034   [(set (match_operand:DI 0 "register_operand" "=r")
1035         (ashift:DI
1036          (and:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1037                  (const_int 2147483647))
1038          (minus:DI (const_int 56)
1039                     (ashift:DI
1040                      (and:DI
1041                       (plus:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1042                                (const_int -1))
1043                       (const_int 7))
1044                      (const_int 3)))))]
1045   ""
1046   "extlh %r1,%2,%0")
1047
1048 (define_insn ""
1049   [(set (match_operand:DI 0 "register_operand" "=r")
1050         (ashift:DI
1051          (and:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1052                  (const_int 65535))
1053          (minus:DI (const_int 56)
1054                     (ashift:DI
1055                      (and:DI
1056                       (plus:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1057                                (const_int -1))
1058                       (const_int 7))
1059                      (const_int 3)))))]
1060   ""
1061   "extwh %r1,%2,%0")
1062
1063 ;; This converts an extXl into an extXh with an appropriate adjustment
1064 ;; to the address calculation.
1065
1066 ;;(define_split
1067 ;;  [(set (match_operand:DI 0 "register_operand" "")
1068 ;;      (ashift:DI (zero_extract:DI (match_operand:DI 1 "register_operand" "")
1069 ;;                                  (match_operand:DI 2 "mode_width_operand" "")
1070 ;;                                  (ashift:DI (match_operand:DI 3 "" "")
1071 ;;                                             (const_int 3)))
1072 ;;                 (match_operand:DI 4 "const_int_operand" "")))
1073 ;;   (clobber (match_operand:DI 5 "register_operand" ""))]
1074 ;;  "INTVAL (operands[4]) == 64 - INTVAL (operands[2])"
1075 ;;  [(set (match_dup 5) (match_dup 6))
1076 ;;   (set (match_dup 0)
1077 ;;      (ashift:DI (zero_extract:DI (match_dup 1) (match_dup 2)
1078 ;;                                  (ashift:DI (plus:DI (match_dup 5)
1079 ;;                                                      (match_dup 7))
1080 ;;                                             (const_int 3)))
1081 ;;                 (match_dup 4)))]
1082 ;;  "
1083 ;;{
1084 ;;  operands[6] = plus_constant (operands[3], 
1085 ;;                             INTVAL (operands[2]) / BITS_PER_UNIT);
1086 ;;  operands[7] = GEN_INT (- INTVAL (operands[2]) / BITS_PER_UNIT);
1087 ;;}")
1088   
1089 (define_insn ""
1090   [(set (match_operand:DI 0 "register_operand" "=r")
1091         (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" "r"))
1092                    (match_operand:DI 2 "mul8_operand" "I")))]
1093   ""
1094   "insbl %1,%s2,%0")
1095
1096 (define_insn ""
1097   [(set (match_operand:DI 0 "register_operand" "=r")
1098         (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" "r"))
1099                    (match_operand:DI 2 "mul8_operand" "I")))]
1100   ""
1101   "inswl %1,%s2,%0")
1102
1103 (define_insn ""
1104   [(set (match_operand:DI 0 "register_operand" "=r")
1105         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
1106                    (match_operand:DI 2 "mul8_operand" "I")))]
1107   ""
1108   "insll %1,%s2,%0")
1109
1110 (define_insn ""
1111   [(set (match_operand:DI 0 "register_operand" "=r")
1112         (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" "r"))
1113                    (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1114                               (const_int 3))))]
1115   ""
1116   "insbl %1,%2,%0")
1117
1118 (define_insn ""
1119   [(set (match_operand:DI 0 "register_operand" "=r")
1120         (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" "r"))
1121                    (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1122                               (const_int 3))))]
1123   ""
1124   "inswl %1,%2,%0")
1125
1126 (define_insn ""
1127   [(set (match_operand:DI 0 "register_operand" "=r")
1128         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
1129                    (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1130                               (const_int 3))))]
1131   ""
1132   "insll %1,%2,%0")
1133
1134 ;; We do not include the insXh insns because they are complex to express
1135 ;; and it does not appear that we would ever want to generate them.
1136
1137 (define_insn ""
1138   [(set (match_operand:DI 0 "register_operand" "=r")
1139         (and:DI (not:DI (ashift:DI
1140                          (match_operand:DI 2 "mode_mask_operand" "n")
1141                          (ashift:DI
1142                           (match_operand:DI 3 "reg_or_8bit_operand" "rI")
1143                           (const_int 3))))
1144                 (match_operand:DI 1 "reg_or_0_operand" "rJ")))]
1145   ""
1146   "msk%U2l %r1,%3,%0")
1147
1148 ;; We do not include the mskXh insns because it does not appear we would ever
1149 ;; generate one.
1150 \f
1151 ;; Floating-point operations.  All the double-precision insns can extend
1152 ;; from single, so indicate that.  The exception are the ones that simply
1153 ;; play with the sign bits; it's not clear what to do there.
1154
1155 (define_insn "abssf2"
1156   [(set (match_operand:SF 0 "register_operand" "=f")
1157         (abs:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")))]
1158   "TARGET_FP"
1159   "cpys $f31,%R1,%0"
1160   [(set_attr "type" "fpop")])
1161
1162 (define_insn "absdf2"
1163   [(set (match_operand:DF 0 "register_operand" "=f")
1164         (abs:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
1165   "TARGET_FP"
1166   "cpys $f31,%R1,%0"
1167   [(set_attr "type" "fpop")])
1168
1169 (define_insn "negsf2"
1170   [(set (match_operand:SF 0 "register_operand" "=f")
1171         (neg:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")))]
1172   "TARGET_FP"
1173   "cpysn %R1,%R1,%0"
1174   [(set_attr "type" "fpop")])
1175
1176 (define_insn "negdf2"
1177   [(set (match_operand:DF 0 "register_operand" "=f")
1178         (neg:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
1179   "TARGET_FP"
1180   "cpysn %R1,%R1,%0"
1181   [(set_attr "type" "fpop")])
1182
1183 (define_insn ""
1184   [(set (match_operand:SF 0 "register_operand" "=&f")
1185         (plus:SF (match_operand:SF 1 "reg_or_fp0_operand" "%fG")
1186                  (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
1187   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1188   "adds%)%& %R1,%R2,%0"
1189   [(set_attr "type" "fpop")
1190    (set_attr "trap" "yes")])
1191
1192 (define_insn "addsf3"
1193   [(set (match_operand:SF 0 "register_operand" "=f")
1194         (plus:SF (match_operand:SF 1 "reg_or_fp0_operand" "%fG")
1195                  (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
1196   "TARGET_FP"
1197   "adds%)%& %R1,%R2,%0"
1198   [(set_attr "type" "fpop")
1199    (set_attr "trap" "yes")])
1200
1201 (define_insn ""
1202   [(set (match_operand:DF 0 "register_operand" "=&f")
1203         (plus:DF (match_operand:DF 1 "reg_or_fp0_operand" "%fG")
1204                  (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1205   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1206   "addt%)%& %R1,%R2,%0"
1207   [(set_attr "type" "fpop")
1208    (set_attr "trap" "yes")])
1209
1210 (define_insn "adddf3"
1211   [(set (match_operand:DF 0 "register_operand" "=f")
1212         (plus:DF (match_operand:DF 1 "reg_or_fp0_operand" "%fG")
1213                  (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1214   "TARGET_FP"
1215   "addt%)%& %R1,%R2,%0"
1216   [(set_attr "type" "fpop")
1217    (set_attr "trap" "yes")])
1218
1219 (define_insn ""
1220   [(set (match_operand:DF 0 "register_operand" "=&f")
1221         (plus:DF (float_extend:DF
1222                   (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
1223                  (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1224   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1225   "addt%)%& %R1,%R2,%0"
1226   [(set_attr "type" "fpop")
1227    (set_attr "trap" "yes")])
1228
1229 (define_insn ""
1230   [(set (match_operand:DF 0 "register_operand" "=f")
1231         (plus:DF (float_extend:DF
1232                   (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
1233                  (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1234   "TARGET_FP"
1235   "addt%)%& %R1,%R2,%0"
1236   [(set_attr "type" "fpop")
1237    (set_attr "trap" "yes")])
1238
1239 (define_insn ""
1240   [(set (match_operand:DF 0 "register_operand" "=&f")
1241         (plus:DF (float_extend:DF
1242                   (match_operand:SF 1 "reg_or_fp0_operand" "%fG"))
1243                  (float_extend:DF
1244                   (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
1245   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1246   "addt%)%& %R1,%R2,%0"
1247   [(set_attr "type" "fpop")
1248    (set_attr "trap" "yes")])
1249
1250 (define_insn ""
1251   [(set (match_operand:DF 0 "register_operand" "=f")
1252         (plus:DF (float_extend:DF
1253                   (match_operand:SF 1 "reg_or_fp0_operand" "%fG"))
1254                  (float_extend:DF
1255                   (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
1256   "TARGET_FP"
1257   "addt%)%& %R1,%R2,%0"
1258   [(set_attr "type" "fpop")
1259    (set_attr "trap" "yes")])
1260
1261 (define_insn "fix_truncdfdi2"
1262   [(set (match_operand:DI 0 "register_operand" "=f")
1263         (fix:DI (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
1264   "TARGET_FP"
1265   "cvttqc %R1,%0"
1266   [(set_attr "type" "fpop")])
1267
1268 (define_insn "fix_truncsfdi2"
1269   [(set (match_operand:DI 0 "register_operand" "=f")
1270         (fix:DI (float_extend:DF
1271                  (match_operand:SF 1 "reg_or_fp0_operand" "fG"))))]
1272   "TARGET_FP"
1273   "cvttqc %R1,%0"
1274   [(set_attr "type" "fpop")])
1275
1276 (define_insn ""
1277   [(set (match_operand:SF 0 "register_operand" "=&f")
1278         (float:SF (match_operand:DI 1 "register_operand" "f")))]
1279   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1280   "cvtqs%+%& %1,%0"
1281   [(set_attr "type" "fpop")
1282    (set_attr "trap" "yes")])
1283
1284 (define_insn "floatdisf2"
1285   [(set (match_operand:SF 0 "register_operand" "=f")
1286         (float:SF (match_operand:DI 1 "register_operand" "f")))]
1287   "TARGET_FP"
1288   "cvtqs%+%& %1,%0"
1289   [(set_attr "type" "fpop")
1290    (set_attr "trap" "yes")])
1291
1292 (define_insn ""
1293   [(set (match_operand:DF 0 "register_operand" "=&f")
1294         (float:DF (match_operand:DI 1 "register_operand" "f")))]
1295   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1296   "cvtqt%+%& %1,%0"
1297   [(set_attr "type" "fpop")
1298    (set_attr "trap" "yes")])
1299
1300 (define_insn "floatdidf2"
1301   [(set (match_operand:DF 0 "register_operand" "=f")
1302         (float:DF (match_operand:DI 1 "register_operand" "f")))]
1303   "TARGET_FP"
1304   "cvtqt%+%& %1,%0"
1305   [(set_attr "type" "fpop")
1306    (set_attr "trap" "yes")])
1307
1308 (define_insn ""
1309   [(set (match_operand:DF 0 "register_operand" "=&f,f")
1310         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,m")))]
1311   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1312   "@
1313    addt%)%& $f31,%1,%0
1314    lds %0,%1"
1315   [(set_attr "type" "fpop,ld")
1316    (set_attr "trap" "yes")])
1317
1318 (define_insn "extendsfdf2"
1319   [(set (match_operand:DF 0 "register_operand" "=f,f")
1320         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,m")))]
1321   "TARGET_FP"
1322   "@
1323    addt%)%& $f31,%1,%0
1324    lds %0,%1"
1325   [(set_attr "type" "fpop,ld")
1326    (set_attr "trap" "yes")])
1327
1328 (define_insn ""
1329   [(set (match_operand:SF 0 "register_operand" "=&f")
1330         (float_truncate:SF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
1331   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1332   "cvtts%)%& %R1,%0"
1333   [(set_attr "type" "fpop")
1334    (set_attr "trap" "yes")])
1335
1336 (define_insn "truncdfsf2"
1337   [(set (match_operand:SF 0 "register_operand" "=f")
1338         (float_truncate:SF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
1339   "TARGET_FP"
1340   "cvtts%)%& %R1,%0"
1341   [(set_attr "type" "fpop")
1342    (set_attr "trap" "yes")])
1343
1344 (define_insn ""
1345   [(set (match_operand:SF 0 "register_operand" "=&f")
1346         (div:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")
1347                 (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
1348   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1349   "divs%)%& %R1,%R2,%0"
1350   [(set_attr "type" "fdivs")
1351    (set_attr "trap" "yes")])
1352
1353 (define_insn "divsf3"
1354   [(set (match_operand:SF 0 "register_operand" "=f")
1355         (div:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")
1356                 (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
1357   "TARGET_FP"
1358   "divs%)%& %R1,%R2,%0"
1359   [(set_attr "type" "fdivs")
1360    (set_attr "trap" "yes")])
1361
1362 (define_insn ""
1363   [(set (match_operand:DF 0 "register_operand" "=&f")
1364         (div:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
1365                 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1366   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1367   "divt%)%& %R1,%R2,%0"
1368   [(set_attr "type" "fdivt")
1369    (set_attr "trap" "yes")])
1370
1371 (define_insn "divdf3"
1372   [(set (match_operand:DF 0 "register_operand" "=f")
1373         (div:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
1374                 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1375   "TARGET_FP"
1376   "divt%)%& %R1,%R2,%0"
1377   [(set_attr "type" "fdivt")
1378    (set_attr "trap" "yes")])
1379
1380 (define_insn ""
1381   [(set (match_operand:DF 0 "register_operand" "=&f")
1382         (div:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
1383                 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1384   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1385   "divt%)%& %R1,%R2,%0"
1386   [(set_attr "type" "fdivt")
1387    (set_attr "trap" "yes")])
1388
1389 (define_insn ""
1390   [(set (match_operand:DF 0 "register_operand" "=f")
1391         (div:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
1392                 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1393   "TARGET_FP"
1394   "divt%)%& %R1,%R2,%0"
1395   [(set_attr "type" "fdivt")
1396    (set_attr "trap" "yes")])
1397
1398 (define_insn ""
1399   [(set (match_operand:DF 0 "register_operand" "=&f")
1400         (div:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
1401                 (float_extend:DF
1402                  (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
1403   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1404   "divt%)%& %R1,%R2,%0"
1405   [(set_attr "type" "fdivt")
1406    (set_attr "trap" "yes")])
1407
1408 (define_insn ""
1409   [(set (match_operand:DF 0 "register_operand" "=f")
1410         (div:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
1411                 (float_extend:DF
1412                  (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
1413   "TARGET_FP"
1414   "divt%)%& %R1,%R2,%0"
1415   [(set_attr "type" "fdivt")
1416    (set_attr "trap" "yes")])
1417
1418 (define_insn ""
1419   [(set (match_operand:DF 0 "register_operand" "=&f")
1420         (div:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
1421                 (float_extend:DF (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
1422   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1423   "divt%)%& %R1,%R2,%0"
1424   [(set_attr "type" "fdivt")
1425    (set_attr "trap" "yes")])
1426
1427 (define_insn ""
1428   [(set (match_operand:DF 0 "register_operand" "=f")
1429         (div:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
1430                 (float_extend:DF (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
1431   "TARGET_FP"
1432   "divt%)%& %R1,%R2,%0"
1433   [(set_attr "type" "fdivt")
1434    (set_attr "trap" "yes")])
1435
1436 (define_insn ""
1437   [(set (match_operand:SF 0 "register_operand" "=&f")
1438         (mult:SF (match_operand:SF 1 "reg_or_fp0_operand" "%fG")
1439                  (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
1440   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1441   "muls%)%& %R1,%R2,%0"
1442   [(set_attr "type" "fpop")
1443    (set_attr "trap" "yes")])
1444
1445 (define_insn "mulsf3"
1446   [(set (match_operand:SF 0 "register_operand" "=f")
1447         (mult:SF (match_operand:SF 1 "reg_or_fp0_operand" "%fG")
1448                  (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
1449   "TARGET_FP"
1450   "muls%)%& %R1,%R2,%0"
1451   [(set_attr "type" "fpop")
1452    (set_attr "trap" "yes")])
1453
1454 (define_insn ""
1455   [(set (match_operand:DF 0 "register_operand" "=&f")
1456         (mult:DF (match_operand:DF 1 "reg_or_fp0_operand" "%fG")
1457                  (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1458   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1459   "mult%)%& %R1,%R2,%0"
1460   [(set_attr "type" "fpop")
1461    (set_attr "trap" "yes")])
1462
1463 (define_insn "muldf3"
1464   [(set (match_operand:DF 0 "register_operand" "=f")
1465         (mult:DF (match_operand:DF 1 "reg_or_fp0_operand" "%fG")
1466                  (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1467   "TARGET_FP"
1468   "mult%)%& %R1,%R2,%0"
1469   [(set_attr "type" "fpop")
1470    (set_attr "trap" "yes")])
1471
1472 (define_insn ""
1473   [(set (match_operand:DF 0 "register_operand" "=&f")
1474         (mult:DF (float_extend:DF
1475                   (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
1476                  (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1477   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1478   "mult%)%& %R1,%R2,%0"
1479   [(set_attr "type" "fpop")
1480    (set_attr "trap" "yes")])
1481
1482 (define_insn ""
1483   [(set (match_operand:DF 0 "register_operand" "=f")
1484         (mult:DF (float_extend:DF
1485                   (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
1486                  (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1487   "TARGET_FP"
1488   "mult%)%& %R1,%R2,%0"
1489   [(set_attr "type" "fpop")
1490    (set_attr "trap" "yes")])
1491
1492 (define_insn ""
1493   [(set (match_operand:DF 0 "register_operand" "=&f")
1494         (mult:DF (float_extend:DF
1495                   (match_operand:SF 1 "reg_or_fp0_operand" "%fG"))
1496                  (float_extend:DF
1497                   (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
1498   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1499   "mult%)%& %R1,%R2,%0"
1500   [(set_attr "type" "fpop")
1501    (set_attr "trap" "yes")])
1502
1503 (define_insn ""
1504   [(set (match_operand:DF 0 "register_operand" "=f")
1505         (mult:DF (float_extend:DF
1506                   (match_operand:SF 1 "reg_or_fp0_operand" "%fG"))
1507                  (float_extend:DF
1508                   (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
1509   "TARGET_FP"
1510   "mult%)%& %R1,%R2,%0"
1511   [(set_attr "type" "fpop")
1512    (set_attr "trap" "yes")])
1513
1514 (define_insn ""
1515   [(set (match_operand:SF 0 "register_operand" "=&f")
1516         (minus:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")
1517                   (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
1518   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1519   "subs%)%& %R1,%R2,%0"
1520   [(set_attr "type" "fpop")
1521    (set_attr "trap" "yes")])
1522
1523 (define_insn "subsf3"
1524   [(set (match_operand:SF 0 "register_operand" "=f")
1525         (minus:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")
1526                   (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
1527   "TARGET_FP"
1528   "subs%)%& %R1,%R2,%0"
1529   [(set_attr "type" "fpop")
1530    (set_attr "trap" "yes")])
1531
1532 (define_insn ""
1533   [(set (match_operand:DF 0 "register_operand" "=&f")
1534         (minus:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
1535                   (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1536   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1537   "subt%)%& %R1,%R2,%0"
1538   [(set_attr "type" "fpop")
1539    (set_attr "trap" "yes")])
1540
1541 (define_insn "subdf3"
1542   [(set (match_operand:DF 0 "register_operand" "=f")
1543         (minus:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
1544                   (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1545   "TARGET_FP"
1546   "subt%)%& %R1,%R2,%0"
1547   [(set_attr "type" "fpop")
1548    (set_attr "trap" "yes")])
1549
1550 (define_insn ""
1551   [(set (match_operand:DF 0 "register_operand" "=&f")
1552         (minus:DF (float_extend:DF
1553                    (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
1554                   (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1555   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1556   "subt%)%& %R1,%R2,%0"
1557   [(set_attr "type" "fpop")
1558    (set_attr "trap" "yes")])
1559
1560 (define_insn ""
1561   [(set (match_operand:DF 0 "register_operand" "=f")
1562         (minus:DF (float_extend:DF
1563                    (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
1564                   (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1565   "TARGET_FP"
1566   "subt%)%& %R1,%R2,%0"
1567   [(set_attr "type" "fpop")
1568    (set_attr "trap" "yes")])
1569
1570 (define_insn ""
1571   [(set (match_operand:DF 0 "register_operand" "=&f")
1572         (minus:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
1573                   (float_extend:DF
1574                    (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
1575   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1576   "subt%)%& %R1,%R2,%0"
1577   [(set_attr "type" "fpop")
1578    (set_attr "trap" "yes")])
1579
1580 (define_insn ""
1581   [(set (match_operand:DF 0 "register_operand" "=f")
1582         (minus:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
1583                   (float_extend:DF
1584                    (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
1585   "TARGET_FP"
1586   "subt%)%& %R1,%R2,%0"
1587   [(set_attr "type" "fpop")
1588    (set_attr "trap" "yes")])
1589
1590 (define_insn ""
1591   [(set (match_operand:DF 0 "register_operand" "=&f")
1592         (minus:DF (float_extend:DF
1593                    (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
1594                   (float_extend:DF
1595                    (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
1596   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
1597   "subt%)%& %R1,%R2,%0"
1598   [(set_attr "type" "fpop")
1599    (set_attr "trap" "yes")])
1600
1601 (define_insn ""
1602   [(set (match_operand:DF 0 "register_operand" "=f")
1603         (minus:DF (float_extend:DF
1604                    (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
1605                   (float_extend:DF
1606                    (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
1607   "TARGET_FP"
1608   "subt%)%& %R1,%R2,%0"
1609   [(set_attr "type" "fpop")
1610    (set_attr "trap" "yes")])
1611 \f
1612 ;; Next are all the integer comparisons, and conditional moves and branches
1613 ;; and some of the related define_expand's and define_split's.
1614
1615 (define_insn ""
1616   [(set (match_operand:DI 0 "register_operand" "=r")
1617         (match_operator:DI 1 "alpha_comparison_operator"
1618                            [(match_operand:DI 2 "reg_or_0_operand" "rJ")
1619                             (match_operand:DI 3 "reg_or_8bit_operand" "rI")]))]
1620   ""
1621   "cmp%C1 %r2,%3,%0"
1622   [(set_attr "type" "icmp")])
1623
1624 ;; There are three important special-case that don't fit the above pattern
1625 ;; but which we want to handle here.
1626
1627 (define_insn ""
1628   [(set (match_operand:DI 0 "register_operand" "=r")
1629         (ne:DI (match_operand:DI 1 "register_operand" "r")
1630                (const_int 0)))]
1631   ""
1632   "cmpult $31,%1,%0"
1633   [(set_attr "type" "icmp")])
1634
1635 (define_insn ""
1636   [(set (match_operand:DI 0 "register_operand" "=r")
1637         (gt:DI (match_operand:DI 1 "register_operand" "r")
1638                (const_int 0)))]
1639   ""
1640   "cmplt $31,%1,%0"
1641   [(set_attr "type" "icmp")])
1642
1643 (define_insn ""
1644   [(set (match_operand:DI 0 "register_operand" "=r")
1645         (ge:DI (match_operand:DI 1 "register_operand" "r")
1646                (const_int 0)))]
1647   ""
1648   "cmple $31,%1,%0"
1649   [(set_attr "type" "icmp")])
1650
1651 ;; This pattern exists so conditional moves of SImode values are handled.
1652 ;; Comparisons are still done in DImode though.
1653
1654 (define_insn ""
1655   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1656         (if_then_else:DI
1657          (match_operator 2 "signed_comparison_operator"
1658                          [(match_operand:DI 3 "reg_or_0_operand" "rJ,rJ,J,J")
1659                           (match_operand:DI 4 "reg_or_0_operand" "J,J,rJ,rJ")])
1660          (match_operand:SI 1 "reg_or_8bit_operand" "rI,0,rI,0")
1661          (match_operand:SI 5 "reg_or_8bit_operand" "0,rI,0,rI")))]
1662   "operands[3] == const0_rtx || operands[4] == const0_rtx"
1663   "@
1664    cmov%C2 %r3,%1,%0
1665    cmov%D2 %r3,%5,%0
1666    cmov%c2 %r4,%1,%0
1667    cmov%d2 %r4,%5,%0")
1668
1669 (define_insn ""
1670   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r")
1671         (if_then_else:DI
1672          (match_operator 2 "signed_comparison_operator"
1673                          [(match_operand:DI 3 "reg_or_0_operand" "rJ,rJ,J,J")
1674                           (match_operand:DI 4 "reg_or_0_operand" "J,J,rJ,rJ")])
1675          (match_operand:DI 1 "reg_or_8bit_operand" "rI,0,rI,0")
1676          (match_operand:DI 5 "reg_or_8bit_operand" "0,rI,0,rI")))]
1677   "operands[3] == const0_rtx || operands[4] == const0_rtx"
1678   "@
1679    cmov%C2 %r3,%1,%0
1680    cmov%D2 %r3,%5,%0
1681    cmov%c2 %r4,%1,%0
1682    cmov%d2 %r4,%5,%0")
1683
1684 (define_insn ""
1685   [(set (match_operand:DI 0 "register_operand" "=r,r")
1686         (if_then_else:DI
1687          (eq (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
1688                               (const_int 1)
1689                               (const_int 0))
1690              (const_int 0))
1691          (match_operand:DI 1 "reg_or_8bit_operand" "rI,0")
1692          (match_operand:DI 3 "reg_or_8bit_operand" "0,rI")))]
1693   ""
1694   "@
1695    cmovlbc %r2,%1,%0
1696    cmovlbs %r2,%3,%0")
1697
1698 (define_insn ""
1699   [(set (match_operand:DI 0 "register_operand" "=r,r")
1700         (if_then_else:DI
1701          (ne (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
1702                               (const_int 1)
1703                               (const_int 0))
1704              (const_int 0))
1705          (match_operand:DI 1 "reg_or_8bit_operand" "rI,0")
1706          (match_operand:DI 3 "reg_or_8bit_operand" "0,rI")))]
1707   ""
1708   "@
1709    cmovlbs %r2,%1,%0
1710    cmovlbc %r2,%3,%0")
1711
1712 ;; This form is added since combine thinks that an IF_THEN_ELSE with both
1713 ;; arms constant is a single insn, so it won't try to form it if combine
1714 ;; knows they are really two insns.  This occurs in divides by powers
1715 ;; of two.
1716
1717 (define_insn ""
1718   [(set (match_operand:DI 0 "register_operand" "=r")
1719         (if_then_else:DI
1720          (match_operator 2 "signed_comparison_operator"
1721                          [(match_operand:DI 3 "reg_or_0_operand" "rJ")
1722                           (const_int 0)])
1723          (plus:DI (match_dup 0)
1724                   (match_operand:DI 1 "reg_or_8bit_operand" "rI"))
1725          (match_dup 0)))
1726    (clobber (match_scratch:DI 4 "=&r"))]
1727   ""
1728   "addq %0,%1,%4\;cmov%C2 %r3,%4,%0")
1729
1730 (define_split
1731   [(set (match_operand:DI 0 "register_operand" "")
1732         (if_then_else:DI
1733          (match_operator 2 "signed_comparison_operator"
1734                          [(match_operand:DI 3 "reg_or_0_operand" "")
1735                           (const_int 0)])
1736          (plus:DI (match_dup 0)
1737                   (match_operand:DI 1 "reg_or_8bit_operand" ""))
1738          (match_dup 0)))
1739    (clobber (match_operand:DI 4 "register_operand" ""))]
1740   ""
1741   [(set (match_dup 4) (plus:DI (match_dup 0) (match_dup 1)))
1742    (set (match_dup 0) (if_then_else:DI (match_op_dup 2
1743                                                      [(match_dup 3)
1744                                                       (const_int 0)])
1745                                        (match_dup 4) (match_dup 0)))]
1746   "")
1747
1748 (define_split
1749   [(parallel
1750     [(set (match_operand:DI 0 "register_operand" "")
1751           (if_then_else:DI
1752            (match_operator 1 "comparison_operator"
1753                            [(zero_extract:DI (match_operand:DI 2 "register_operand" "")
1754                                              (const_int 1)
1755                                              (match_operand:DI 3 "const_int_operand" ""))
1756                             (const_int 0)])
1757            (match_operand:DI 4 "reg_or_8bit_operand" "")
1758            (match_operand:DI 5 "reg_or_8bit_operand" "")))
1759      (clobber (match_operand:DI 6 "register_operand" ""))])]
1760   "INTVAL (operands[3]) != 0"
1761   [(set (match_dup 6)
1762         (lshiftrt:DI (match_dup 2) (match_dup 3)))
1763    (set (match_dup 0)
1764         (if_then_else:DI (match_op_dup 1
1765                                        [(zero_extract:DI (match_dup 6)
1766                                                          (const_int 1)
1767                                                          (const_int 0))
1768                                         (const_int 0)])
1769                          (match_dup 4)
1770                          (match_dup 5)))]
1771   "")
1772
1773 ;; For ABS, we have two choices, depending on whether the input and output
1774 ;; registers are the same or not.
1775 (define_expand "absdi2"
1776   [(set (match_operand:DI 0 "register_operand" "")
1777         (abs:DI (match_operand:DI 1 "register_operand" "")))]
1778   ""
1779   "
1780 { if (rtx_equal_p (operands[0], operands[1]))
1781     emit_insn (gen_absdi2_same (operands[0], gen_reg_rtx (DImode)));
1782   else
1783     emit_insn (gen_absdi2_diff (operands[0], operands[1]));
1784
1785   DONE;
1786 }")
1787
1788 (define_expand "absdi2_same"
1789   [(set (match_operand:DI 1 "register_operand" "")
1790         (neg:DI (match_operand:DI 0 "register_operand" "")))
1791    (set (match_dup 0)
1792         (if_then_else:DI (ge (match_dup 0) (const_int 0))
1793                          (match_dup 0)
1794                          (match_dup 1)))]
1795   ""
1796   "")
1797
1798 (define_expand "absdi2_diff"
1799   [(set (match_operand:DI 0 "register_operand" "")
1800         (neg:DI (match_operand:DI 1 "register_operand" "")))
1801    (set (match_dup 0)
1802         (if_then_else:DI (lt (match_dup 1) (const_int 0))
1803                          (match_dup 0)
1804                          (match_dup 1)))]
1805   ""
1806   "")
1807
1808 (define_split
1809   [(set (match_operand:DI 0 "register_operand" "")
1810         (abs:DI (match_dup 0)))
1811    (clobber (match_operand:DI 2 "register_operand" ""))]
1812   ""
1813   [(set (match_dup 1) (neg:DI (match_dup 0)))
1814    (set (match_dup 0) (if_then_else:DI (ge (match_dup 0) (const_int 0))
1815                                        (match_dup 0) (match_dup 1)))]
1816   "")
1817
1818 (define_split
1819   [(set (match_operand:DI 0 "register_operand" "")
1820         (abs:DI (match_operand:DI 1 "register_operand" "")))]
1821   "! rtx_equal_p (operands[0], operands[1])"
1822   [(set (match_dup 0) (neg:DI (match_dup 1)))
1823    (set (match_dup 0) (if_then_else:DI (lt (match_dup 1) (const_int 0))
1824                                        (match_dup 0) (match_dup 1)))]
1825   "")
1826
1827 (define_split
1828   [(set (match_operand:DI 0 "register_operand" "")
1829         (neg:DI (abs:DI (match_dup 0))))
1830    (clobber (match_operand:DI 2 "register_operand" ""))]
1831   ""
1832   [(set (match_dup 1) (neg:DI (match_dup 0)))
1833    (set (match_dup 0) (if_then_else:DI (le (match_dup 0) (const_int 0))
1834                                        (match_dup 0) (match_dup 1)))]
1835   "")
1836
1837 (define_split
1838   [(set (match_operand:DI 0 "register_operand" "")
1839         (neg:DI (abs:DI (match_operand:DI 1 "register_operand" ""))))]
1840   "! rtx_equal_p (operands[0], operands[1])"
1841   [(set (match_dup 0) (neg:DI (match_dup 1)))
1842    (set (match_dup 0) (if_then_else:DI (gt (match_dup 1) (const_int 0))
1843                                        (match_dup 0) (match_dup 1)))]
1844   "")
1845
1846 (define_expand "smaxdi3"
1847   [(set (match_dup 3)
1848         (le:DI (match_operand:DI 1 "reg_or_0_operand" "")
1849                (match_operand:DI 2 "reg_or_8bit_operand" "")))
1850    (set (match_operand:DI 0 "register_operand" "")
1851         (if_then_else:DI (eq (match_dup 3) (const_int 0))
1852                          (match_dup 1) (match_dup 2)))]
1853   ""
1854   "
1855 { operands[3] = gen_reg_rtx (DImode);
1856 }")
1857
1858 (define_split
1859   [(set (match_operand:DI 0 "register_operand" "")
1860         (smax:DI (match_operand:DI 1 "reg_or_0_operand" "")
1861                  (match_operand:DI 2 "reg_or_8bit_operand" "")))
1862    (clobber (match_operand:DI 3 "register_operand" ""))]
1863   "operands[2] != const0_rtx"
1864   [(set (match_dup 3) (le:DI (match_dup 1) (match_dup 2)))
1865    (set (match_dup 0) (if_then_else:DI (eq (match_dup 3) (const_int 0))
1866                                        (match_dup 1) (match_dup 2)))]
1867   "")
1868
1869 (define_insn ""
1870   [(set (match_operand:DI 0 "register_operand" "=r")
1871         (smax:DI (match_operand:DI 1 "register_operand" "0")
1872                  (const_int 0)))]
1873   ""
1874   "cmovlt %0,0,%0")
1875
1876 (define_expand "smindi3"
1877   [(set (match_dup 3)
1878         (lt:DI (match_operand:DI 1 "reg_or_0_operand" "")
1879                (match_operand:DI 2 "reg_or_8bit_operand" "")))
1880    (set (match_operand:DI 0 "register_operand" "")
1881         (if_then_else:DI (ne (match_dup 3) (const_int 0))
1882                          (match_dup 1) (match_dup 2)))]
1883   ""
1884   "
1885 { operands[3] = gen_reg_rtx (DImode);
1886 }")
1887
1888 (define_split
1889   [(set (match_operand:DI 0 "register_operand" "")
1890         (smin:DI (match_operand:DI 1 "reg_or_0_operand" "")
1891                  (match_operand:DI 2 "reg_or_8bit_operand" "")))
1892    (clobber (match_operand:DI 3 "register_operand" ""))]
1893   "operands[2] != const0_rtx"
1894   [(set (match_dup 3) (lt:DI (match_dup 1) (match_dup 2)))
1895    (set (match_dup 0) (if_then_else:DI (ne (match_dup 3) (const_int 0))
1896                                        (match_dup 1) (match_dup 2)))]
1897   "")
1898
1899 (define_insn ""
1900   [(set (match_operand:DI 0 "register_operand" "=r")
1901         (smin:DI (match_operand:DI 1 "register_operand" "0")
1902                  (const_int 0)))]
1903   ""
1904   "cmovgt %0,0,%0")
1905
1906 (define_expand "umaxdi3"
1907   [(set (match_dup 3) 
1908         (leu:DI (match_operand:DI 1 "reg_or_0_operand" "")
1909                 (match_operand:DI 2 "reg_or_8bit_operand" "")))
1910    (set (match_operand:DI 0 "register_operand" "")
1911         (if_then_else:DI (eq (match_dup 3) (const_int 0))
1912                          (match_dup 1) (match_dup 2)))]
1913   ""
1914   "
1915 { operands[3] = gen_reg_rtx (DImode);
1916 }")
1917
1918 (define_split
1919   [(set (match_operand:DI 0 "register_operand" "")
1920         (umax:DI (match_operand:DI 1 "reg_or_0_operand" "")
1921                  (match_operand:DI 2 "reg_or_8bit_operand" "")))
1922    (clobber (match_operand:DI 3 "register_operand" ""))]
1923   "operands[2] != const0_rtx"
1924   [(set (match_dup 3) (leu:DI (match_dup 1) (match_dup 2)))
1925    (set (match_dup 0) (if_then_else:DI (eq (match_dup 3) (const_int 0))
1926                                        (match_dup 1) (match_dup 2)))]
1927   "")
1928
1929 (define_expand "umindi3"
1930   [(set (match_dup 3)
1931         (ltu:DI (match_operand:DI 1 "reg_or_0_operand" "")
1932                 (match_operand:DI 2 "reg_or_8bit_operand" "")))
1933    (set (match_operand:DI 0 "register_operand" "")
1934         (if_then_else:DI (ne (match_dup 3) (const_int 0))
1935                          (match_dup 1) (match_dup 2)))]
1936   ""
1937   "
1938 { operands[3] = gen_reg_rtx (DImode);
1939 }")
1940
1941 (define_split
1942   [(set (match_operand:DI 0 "register_operand" "")
1943         (umin:DI (match_operand:DI 1 "reg_or_0_operand" "")
1944                  (match_operand:DI 2 "reg_or_8bit_operand" "")))
1945    (clobber (match_operand:DI 3 "register_operand" ""))]
1946   "operands[2] != const0_rtx"
1947   [(set (match_dup 3) (ltu:DI (match_dup 1) (match_dup 2)))
1948    (set (match_dup 0) (if_then_else:DI (ne (match_dup 3) (const_int 0))
1949                                        (match_dup 1) (match_dup 2)))]
1950   "")
1951
1952 (define_insn ""
1953   [(set (pc)
1954         (if_then_else
1955          (match_operator 1 "signed_comparison_operator"
1956                          [(match_operand:DI 2 "reg_or_0_operand" "rJ")
1957                           (const_int 0)])
1958          (label_ref (match_operand 0 "" ""))
1959          (pc)))]
1960   ""
1961   "b%C1 %r2,%0"
1962   [(set_attr "type" "ibr")])
1963
1964 (define_insn ""
1965   [(set (pc)
1966         (if_then_else
1967          (ne (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1968                               (const_int 1)
1969                               (const_int 0))
1970              (const_int 0))
1971          (label_ref (match_operand 0 "" ""))
1972          (pc)))]
1973   ""
1974   "blbs %r1,%0"
1975   [(set_attr "type" "ibr")])
1976
1977 (define_insn ""
1978   [(set (pc)
1979         (if_then_else
1980          (eq (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1981                               (const_int 1)
1982                               (const_int 0))
1983              (const_int 0))
1984          (label_ref (match_operand 0 "" ""))
1985          (pc)))]
1986   ""
1987   "blbc %r1,%0"
1988   [(set_attr "type" "ibr")])
1989
1990 (define_split
1991   [(parallel
1992     [(set (pc)
1993           (if_then_else
1994            (match_operator 1 "comparison_operator"
1995                            [(zero_extract:DI (match_operand:DI 2 "register_operand" "")
1996                                              (const_int 1)
1997                                              (match_operand:DI 3 "const_int_operand" ""))
1998                             (const_int 0)])
1999            (label_ref (match_operand 0 "" ""))
2000            (pc)))
2001      (clobber (match_operand:DI 4 "register_operand" ""))])]
2002   "INTVAL (operands[3]) != 0"
2003   [(set (match_dup 4)
2004         (lshiftrt:DI (match_dup 2) (match_dup 3)))
2005    (set (pc)
2006         (if_then_else (match_op_dup 1
2007                                     [(zero_extract:DI (match_dup 4)
2008                                                       (const_int 1)
2009                                                       (const_int 0))
2010                                      (const_int 0)])
2011                       (label_ref (match_dup 0))
2012                       (pc)))]
2013   "")
2014 \f
2015 ;; The following are the corresponding floating-point insns.  Recall
2016 ;; we need to have variants that expand the arguments from SF mode
2017 ;; to DFmode.
2018
2019 (define_insn ""
2020   [(set (match_operand:DF 0 "register_operand" "=&f")
2021         (match_operator:DF 1 "alpha_comparison_operator"
2022                            [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2023                             (match_operand:DF 3 "reg_or_fp0_operand" "fG")]))]
2024   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
2025   "cmpt%C1%' %R2,%R3,%0"
2026   [(set_attr "type" "fpop")
2027    (set_attr "trap" "yes")])
2028
2029 (define_insn ""
2030   [(set (match_operand:DF 0 "register_operand" "=f")
2031         (match_operator:DF 1 "alpha_comparison_operator"
2032                            [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2033                             (match_operand:DF 3 "reg_or_fp0_operand" "fG")]))]
2034   "TARGET_FP"
2035   "cmpt%C1%' %R2,%R3,%0"
2036   [(set_attr "type" "fpop")
2037    (set_attr "trap" "yes")])
2038
2039 (define_insn ""
2040   [(set (match_operand:DF 0 "register_operand" "=&f")
2041         (match_operator:DF 1 "alpha_comparison_operator"
2042                            [(float_extend:DF
2043                              (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
2044                             (match_operand:DF 3 "reg_or_fp0_operand" "fG")]))]
2045   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
2046   "cmpt%C1%' %R2,%R3,%0"
2047   [(set_attr "type" "fpop")
2048    (set_attr "trap" "yes")])
2049
2050 (define_insn ""
2051   [(set (match_operand:DF 0 "register_operand" "=f")
2052         (match_operator:DF 1 "alpha_comparison_operator"
2053                            [(float_extend:DF
2054                              (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
2055                             (match_operand:DF 3 "reg_or_fp0_operand" "fG")]))]
2056   "TARGET_FP"
2057   "cmpt%C1%' %R2,%R3,%0"
2058   [(set_attr "type" "fpop")
2059    (set_attr "trap" "yes")])
2060
2061 (define_insn ""
2062   [(set (match_operand:DF 0 "register_operand" "=&f")
2063         (match_operator:DF 1 "alpha_comparison_operator"
2064                            [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2065                             (float_extend:DF
2066                              (match_operand:SF 3 "reg_or_fp0_operand" "fG"))]))]
2067   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
2068   "cmpt%C1%' %R2,%R3,%0"
2069   [(set_attr "type" "fpop")
2070    (set_attr "trap" "yes")])
2071
2072 (define_insn ""
2073   [(set (match_operand:DF 0 "register_operand" "=f")
2074         (match_operator:DF 1 "alpha_comparison_operator"
2075                            [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2076                             (float_extend:DF
2077                              (match_operand:SF 3 "reg_or_fp0_operand" "fG"))]))]
2078   "TARGET_FP"
2079   "cmpt%C1%' %R2,%R3,%0"
2080   [(set_attr "type" "fpop")
2081    (set_attr "trap" "yes")])
2082
2083 (define_insn ""
2084   [(set (match_operand:DF 0 "register_operand" "=&f")
2085         (match_operator:DF 1 "alpha_comparison_operator"
2086                            [(float_extend:DF
2087                              (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
2088                             (float_extend:DF
2089                              (match_operand:SF 3 "reg_or_fp0_operand" "fG"))]))]
2090   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
2091   "cmpt%C1%' %R2,%R3,%0"
2092   [(set_attr "type" "fpop")
2093    (set_attr "trap" "yes")])
2094
2095 (define_insn ""
2096   [(set (match_operand:DF 0 "register_operand" "=f")
2097         (match_operator:DF 1 "alpha_comparison_operator"
2098                            [(float_extend:DF
2099                              (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
2100                             (float_extend:DF
2101                              (match_operand:SF 3 "reg_or_fp0_operand" "fG"))]))]
2102   "TARGET_FP"
2103   "cmpt%C1%' %R2,%R3,%0"
2104   [(set_attr "type" "fpop")
2105    (set_attr "trap" "yes")])
2106
2107 (define_insn ""
2108   [(set (match_operand:DF 0 "register_operand" "=&f,f")
2109         (if_then_else:DF 
2110          (match_operator 3 "signed_comparison_operator"
2111                          [(match_operand:DF 4 "reg_or_fp0_operand" "fG,fG")
2112                           (match_operand:DF 2 "fp0_operand" "G,G")])
2113          (match_operand:DF 1 "reg_or_fp0_operand" "fG,0")
2114          (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2115   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
2116   "@
2117    fcmov%C3 %R4,%R1,%0
2118    fcmov%D3 %R4,%R5,%0"
2119   [(set_attr "type" "fpop")])
2120
2121 (define_insn ""
2122   [(set (match_operand:DF 0 "register_operand" "=f,f")
2123         (if_then_else:DF 
2124          (match_operator 3 "signed_comparison_operator"
2125                          [(match_operand:DF 4 "reg_or_fp0_operand" "fG,fG")
2126                           (match_operand:DF 2 "fp0_operand" "G,G")])
2127          (match_operand:DF 1 "reg_or_fp0_operand" "fG,0")
2128          (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2129   "TARGET_FP"
2130   "@
2131    fcmov%C3 %R4,%R1,%0
2132    fcmov%D3 %R4,%R5,%0"
2133   [(set_attr "type" "fpop")])
2134
2135 (define_insn ""
2136   [(set (match_operand:SF 0 "register_operand" "=&f,f")
2137         (if_then_else:SF 
2138          (match_operator 3 "signed_comparison_operator"
2139                          [(match_operand:DF 4 "reg_or_fp0_operand" "fG,fG")
2140                           (match_operand:DF 2 "fp0_operand" "G,G")])
2141          (match_operand:SF 1 "reg_or_fp0_operand" "fG,0")
2142          (match_operand:SF 5 "reg_or_fp0_operand" "0,fG")))]
2143   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
2144   "@
2145    fcmov%C3 %R4,%R1,%0
2146    fcmov%D3 %R4,%R5,%0"
2147   [(set_attr "type" "fpop")])
2148
2149 (define_insn ""
2150   [(set (match_operand:SF 0 "register_operand" "=f,f")
2151         (if_then_else:SF 
2152          (match_operator 3 "signed_comparison_operator"
2153                          [(match_operand:DF 4 "reg_or_fp0_operand" "fG,fG")
2154                           (match_operand:DF 2 "fp0_operand" "G,G")])
2155          (match_operand:SF 1 "reg_or_fp0_operand" "fG,0")
2156          (match_operand:SF 5 "reg_or_fp0_operand" "0,fG")))]
2157   "TARGET_FP"
2158   "@
2159    fcmov%C3 %R4,%R1,%0
2160    fcmov%D3 %R4,%R5,%0"
2161   [(set_attr "type" "fpop")])
2162
2163 (define_insn ""
2164   [(set (match_operand:DF 0 "register_operand" "=&f,f")
2165         (if_then_else:DF 
2166          (match_operator 3 "signed_comparison_operator"
2167                          [(match_operand:DF 1 "reg_or_fp0_operand" "fG,fG")
2168                           (match_operand:DF 2 "fp0_operand" "G,G")])
2169          (float_extend:DF (match_operand:SF 4 "reg_or_fp0_operand" "fG,0"))
2170          (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2171   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
2172   "@
2173    fcmov%C3 %R4,%R1,%0
2174    fcmov%D3 %R4,%R5,%0"
2175   [(set_attr "type" "fpop")])
2176
2177 (define_insn ""
2178   [(set (match_operand:DF 0 "register_operand" "=&f,f")
2179         (if_then_else:DF 
2180          (match_operator 3 "signed_comparison_operator"
2181                          [(float_extend:DF 
2182                            (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
2183                           (match_operand:DF 2 "fp0_operand" "G,G")])
2184          (match_operand:DF 1 "reg_or_fp0_operand" "fG,0")
2185          (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2186   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
2187   "@
2188    fcmov%C3 %R4,%R1,%0
2189    fcmov%D3 %R4,%R5,%0"
2190   [(set_attr "type" "fpop")])
2191
2192 (define_insn ""
2193   [(set (match_operand:DF 0 "register_operand" "=f,f")
2194         (if_then_else:DF 
2195          (match_operator 3 "signed_comparison_operator"
2196                          [(match_operand:DF 1 "reg_or_fp0_operand" "fG,fG")
2197                           (match_operand:DF 2 "fp0_operand" "G,G")])
2198          (float_extend:DF (match_operand:SF 4 "reg_or_fp0_operand" "fG,0"))
2199          (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2200   "TARGET_FP"
2201   "@
2202    fcmov%C3 %R4,%R1,%0
2203    fcmov%D3 %R4,%R5,%0"
2204   [(set_attr "type" "fpop")])
2205
2206 (define_insn ""
2207   [(set (match_operand:DF 0 "register_operand" "=f,f")
2208         (if_then_else:DF 
2209          (match_operator 3 "signed_comparison_operator"
2210                          [(float_extend:DF 
2211                            (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
2212                           (match_operand:DF 2 "fp0_operand" "G,G")])
2213          (match_operand:DF 1 "reg_or_fp0_operand" "fG,0")
2214          (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2215   "TARGET_FP"
2216   "@
2217    fcmov%C3 %R4,%R1,%0
2218    fcmov%D3 %R4,%R5,%0"
2219   [(set_attr "type" "fpop")])
2220
2221 (define_insn ""
2222   [(set (match_operand:SF 0 "register_operand" "=&f,f")
2223         (if_then_else:SF 
2224          (match_operator 3 "signed_comparison_operator"
2225                          [(float_extend:DF
2226                            (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
2227                           (match_operand:DF 2 "fp0_operand" "G,G")])
2228          (match_operand:SF 1 "reg_or_fp0_operand" "fG,0")
2229          (match_operand:SF 5 "reg_or_fp0_operand" "0,fG")))]
2230   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
2231   "@
2232    fcmov%C3 %R4,%R1,%0
2233    fcmov%D3 %R4,%R5,%0"
2234   [(set_attr "type" "fpop")])
2235
2236 (define_insn ""
2237   [(set (match_operand:SF 0 "register_operand" "=f,f")
2238         (if_then_else:SF 
2239          (match_operator 3 "signed_comparison_operator"
2240                          [(float_extend:DF
2241                            (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
2242                           (match_operand:DF 2 "fp0_operand" "G,G")])
2243          (match_operand:SF 1 "reg_or_fp0_operand" "fG,0")
2244          (match_operand:SF 5 "reg_or_fp0_operand" "0,fG")))]
2245   "TARGET_FP"
2246   "@
2247    fcmov%C3 %R4,%R1,%0
2248    fcmov%D3 %R4,%R5,%0"
2249   [(set_attr "type" "fpop")])
2250
2251 (define_insn ""
2252   [(set (match_operand:DF 0 "register_operand" "=&f,f")
2253         (if_then_else:DF 
2254          (match_operator 3 "signed_comparison_operator"
2255                          [(float_extend:DF
2256                            (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
2257                           (match_operand:DF 2 "fp0_operand" "G,G")])
2258          (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG,0"))
2259          (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2260   "TARGET_FP && (alpha_tp == ALPHA_TP_INSN)"
2261   "@
2262    fcmov%C3 %R4,%R1,%0
2263    fcmov%D3 %R4,%R5,%0"
2264   [(set_attr "type" "fpop")])
2265
2266 (define_insn ""
2267   [(set (match_operand:DF 0 "register_operand" "=f,f")
2268         (if_then_else:DF 
2269          (match_operator 3 "signed_comparison_operator"
2270                          [(float_extend:DF
2271                            (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
2272                           (match_operand:DF 2 "fp0_operand" "G,G")])
2273          (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG,0"))
2274          (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2275   "TARGET_FP"
2276   "@
2277    fcmov%C3 %R4,%R1,%0
2278    fcmov%D3 %R4,%R5,%0"
2279   [(set_attr "type" "fpop")])
2280
2281 (define_expand "maxdf3"
2282   [(set (match_dup 3)
2283         (le:DF (match_operand:DF 1 "reg_or_fp0_operand" "")
2284                (match_operand:DF 2 "reg_or_fp0_operand" "")))
2285    (set (match_operand:DF 0 "register_operand" "")
2286         (if_then_else:DF (eq (match_dup 3) (match_dup 4))
2287                          (match_dup 1) (match_dup 2)))]
2288   "TARGET_FP"
2289   "
2290 { operands[3] = gen_reg_rtx (DFmode);
2291   operands[4] = CONST0_RTX (DFmode);
2292 }")
2293
2294 (define_expand "mindf3"
2295   [(set (match_dup 3)
2296         (lt:DF (match_operand:DF 1 "reg_or_fp0_operand" "")
2297                (match_operand:DF 2 "reg_or_fp0_operand" "")))
2298    (set (match_operand:DF 0 "register_operand" "")
2299         (if_then_else:DF (ne (match_dup 3) (match_dup 4))
2300                          (match_dup 1) (match_dup 2)))]
2301   "TARGET_FP"
2302   "
2303 { operands[3] = gen_reg_rtx (DFmode);
2304   operands[4] = CONST0_RTX (DFmode);
2305 }")
2306
2307 (define_expand "maxsf3"
2308   [(set (match_dup 3)
2309         (le:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" ""))
2310                (float_extend:DF (match_operand:SF 2 "reg_or_fp0_operand" ""))))
2311    (set (match_operand:SF 0 "register_operand" "")
2312         (if_then_else:SF (eq (match_dup 3) (match_dup 4))
2313                          (match_dup 1) (match_dup 2)))]
2314   "TARGET_FP"
2315   "
2316 { operands[3] = gen_reg_rtx (DFmode);
2317   operands[4] = CONST0_RTX (DFmode);
2318 }")
2319
2320 (define_expand "minsf3"
2321   [(set (match_dup 3)
2322         (lt:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" ""))
2323                (float_extend:DF (match_operand:SF 2 "reg_or_fp0_operand" ""))))
2324    (set (match_operand:SF 0 "register_operand" "")
2325         (if_then_else:SF (ne (match_dup 3) (match_dup 4))
2326                       (match_dup 1) (match_dup 2)))]
2327   "TARGET_FP"
2328   "
2329 { operands[3] = gen_reg_rtx (DFmode);
2330   operands[4] = CONST0_RTX (DFmode);
2331 }")
2332
2333 (define_insn ""
2334   [(set (pc)
2335         (if_then_else
2336          (match_operator 1 "signed_comparison_operator"
2337                          [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2338                           (match_operand:DF 3 "fp0_operand" "G")])
2339          (label_ref (match_operand 0 "" ""))
2340          (pc)))]
2341   "TARGET_FP"
2342   "fb%C1 %R2,%0"
2343   [(set_attr "type" "fbr")])
2344
2345 (define_insn ""
2346   [(set (pc)
2347         (if_then_else
2348          (match_operator 1 "signed_comparison_operator"
2349                          [(float_extend:DF
2350                            (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
2351                           (match_operand:DF 3 "fp0_operand" "G")])
2352          (label_ref (match_operand 0 "" ""))
2353          (pc)))]
2354   "TARGET_FP"
2355   "fb%C1 %R2,%0"
2356   [(set_attr "type" "fbr")])
2357 \f
2358 ;; These are the main define_expand's used to make conditional branches
2359 ;; and compares.
2360
2361 (define_expand "cmpdf"
2362   [(set (cc0) (compare (match_operand:DF 0 "reg_or_fp0_operand" "")
2363                        (match_operand:DF 1 "reg_or_fp0_operand" "")))]
2364   "TARGET_FP"
2365   "
2366 {
2367   alpha_compare_op0 = operands[0];
2368   alpha_compare_op1 = operands[1];
2369   alpha_compare_fp_p = 1;
2370   DONE;
2371 }")
2372
2373 (define_expand "cmpdi"
2374   [(set (cc0) (compare (match_operand:DI 0 "reg_or_0_operand" "")
2375                        (match_operand:DI 1 "reg_or_8bit_operand" "")))]
2376   ""
2377   "
2378 {
2379   alpha_compare_op0 = operands[0];
2380   alpha_compare_op1 = operands[1];
2381   alpha_compare_fp_p = 0;
2382   DONE;
2383 }")
2384
2385 (define_expand "beq"
2386   [(set (match_dup 1) (match_dup 2))
2387    (set (pc)
2388         (if_then_else (match_dup 3)
2389                       (label_ref (match_operand 0 "" ""))
2390                       (pc)))]
2391   ""
2392   "
2393 {
2394   enum machine_mode mode;
2395   enum rtx_code compare_code, branch_code;
2396
2397   if (alpha_compare_fp_p)
2398     mode = DFmode, compare_code = EQ, branch_code = NE;
2399   else
2400     {
2401       mode = DImode, compare_code = MINUS, branch_code = EQ;
2402       if (GET_CODE (alpha_compare_op1) == CONST_INT)
2403         {
2404           compare_code = PLUS;
2405           alpha_compare_op1 = GEN_INT (- INTVAL (alpha_compare_op1));
2406         }
2407     }
2408
2409   operands[1] = gen_reg_rtx (mode);
2410   operands[2] = gen_rtx (compare_code, mode,
2411                          alpha_compare_op0, alpha_compare_op1);
2412   operands[3] = gen_rtx (branch_code, VOIDmode,
2413                          operands[1], CONST0_RTX (mode));
2414 }")
2415
2416 (define_expand "bne"
2417   [(set (match_dup 1) (match_dup 2))
2418    (set (pc)
2419         (if_then_else (match_dup 3)
2420                       (label_ref (match_operand 0 "" ""))
2421                       (pc)))]
2422   ""
2423   "
2424 {
2425   enum machine_mode mode;
2426   enum rtx_code compare_code, branch_code;
2427
2428   if (alpha_compare_fp_p)
2429     mode = DFmode, compare_code = EQ, branch_code = EQ;
2430   else
2431     {
2432       mode = DImode, compare_code = MINUS, branch_code = NE;
2433       if (GET_CODE (alpha_compare_op1) == CONST_INT)
2434         {
2435           compare_code = PLUS;
2436           alpha_compare_op1 = GEN_INT (- INTVAL (alpha_compare_op1));
2437         }
2438     }
2439
2440   operands[1] = gen_reg_rtx (mode);
2441   operands[2] = gen_rtx (compare_code, mode,
2442                          alpha_compare_op0, alpha_compare_op1);
2443   operands[3] = gen_rtx (branch_code, VOIDmode,
2444                          operands[1], CONST0_RTX (mode));
2445 }")
2446
2447 (define_expand "blt"
2448   [(set (match_dup 1) (match_dup 2))
2449    (set (pc)
2450         (if_then_else (match_dup 3)
2451                       (label_ref (match_operand 0 "" ""))
2452                       (pc)))]
2453   ""
2454   "
2455 {
2456   enum machine_mode mode = alpha_compare_fp_p ? DFmode : DImode;
2457   operands[1] = gen_reg_rtx (mode);
2458   operands[2] = gen_rtx (LT, mode, alpha_compare_op0, alpha_compare_op1);
2459   operands[3] = gen_rtx (NE, VOIDmode, operands[1], CONST0_RTX (mode));
2460 }")
2461
2462 (define_expand "ble"
2463   [(set (match_dup 1) (match_dup 2))
2464    (set (pc)
2465         (if_then_else (match_dup 3)
2466                       (label_ref (match_operand 0 "" ""))
2467                       (pc)))]
2468   ""
2469   "
2470 {
2471   enum machine_mode mode = alpha_compare_fp_p ? DFmode : DImode;
2472   operands[1] = gen_reg_rtx (mode);
2473   operands[2] = gen_rtx (LE, mode, alpha_compare_op0, alpha_compare_op1);
2474   operands[3] = gen_rtx (NE, VOIDmode, operands[1], CONST0_RTX (mode));
2475 }")
2476
2477 (define_expand "bgt"
2478   [(set (match_dup 1) (match_dup 2))
2479    (set (pc)
2480         (if_then_else (match_dup 3)
2481                       (label_ref (match_operand 0 "" ""))
2482                       (pc)))]
2483   ""
2484   "
2485 {
2486   if (alpha_compare_fp_p)
2487     {
2488       operands[1] = gen_reg_rtx (DFmode);
2489       operands[2] = gen_rtx (LT, DFmode, alpha_compare_op1, alpha_compare_op0);
2490       operands[3] = gen_rtx (NE, VOIDmode, operands[1], CONST0_RTX (DFmode));
2491     }
2492   else
2493     {
2494       operands[1] = gen_reg_rtx (DImode);
2495       operands[2] = gen_rtx (LE, DImode, alpha_compare_op0, alpha_compare_op1);
2496       operands[3] = gen_rtx (EQ, VOIDmode, operands[1], const0_rtx);
2497     }
2498 }")
2499
2500 (define_expand "bge"
2501   [(set (match_dup 1) (match_dup 2))
2502    (set (pc)
2503         (if_then_else (match_dup 3)
2504                       (label_ref (match_operand 0 "" ""))
2505                       (pc)))]
2506   ""
2507   "
2508 {
2509   if (alpha_compare_fp_p)
2510     {
2511       operands[1] = gen_reg_rtx (DFmode);
2512       operands[2] = gen_rtx (LE, DFmode, alpha_compare_op1, alpha_compare_op0);
2513       operands[3] = gen_rtx (NE, VOIDmode, operands[1], CONST0_RTX (DFmode));
2514     }
2515   else
2516     {
2517       operands[1] = gen_reg_rtx (DImode);
2518       operands[2] = gen_rtx (LT, DImode, alpha_compare_op0, alpha_compare_op1);
2519       operands[3] = gen_rtx (EQ, VOIDmode, operands[1], const0_rtx);
2520     }
2521 }")
2522
2523 (define_expand "bltu"
2524   [(set (match_dup 1) (match_dup 2))
2525    (set (pc)
2526         (if_then_else (match_dup 3)
2527                       (label_ref (match_operand 0 "" ""))
2528                       (pc)))]
2529   ""
2530   "
2531 {
2532   operands[1] = gen_reg_rtx (DImode);
2533   operands[2] = gen_rtx (LTU, DImode, alpha_compare_op0, alpha_compare_op1);
2534   operands[3] = gen_rtx (NE, VOIDmode, operands[1], const0_rtx);
2535 }")
2536
2537 (define_expand "bleu"
2538   [(set (match_dup 1) (match_dup 2))
2539    (set (pc)
2540         (if_then_else (match_dup 3)
2541                       (label_ref (match_operand 0 "" ""))
2542                       (pc)))]
2543   ""
2544   "
2545 {
2546   operands[1] = gen_reg_rtx (DImode);
2547   operands[2] = gen_rtx (LEU, DImode, alpha_compare_op0, alpha_compare_op1);
2548   operands[3] = gen_rtx (NE, VOIDmode, operands[1], const0_rtx);
2549 }")
2550
2551 (define_expand "bgtu"
2552   [(set (match_dup 1) (match_dup 2))
2553    (set (pc)
2554         (if_then_else (match_dup 3)
2555                       (label_ref (match_operand 0 "" ""))
2556                       (pc)))]
2557   ""
2558   "
2559 {
2560   operands[1] = gen_reg_rtx (DImode);
2561   operands[2] = gen_rtx (LEU, DImode, alpha_compare_op0, alpha_compare_op1);
2562   operands[3] = gen_rtx (EQ, VOIDmode, operands[1], const0_rtx);
2563 }")
2564
2565 (define_expand "bgeu"
2566   [(set (match_dup 1) (match_dup 2))
2567    (set (pc)
2568         (if_then_else (match_dup 3)
2569                       (label_ref (match_operand 0 "" ""))
2570                       (pc)))]
2571   ""
2572   "
2573 {
2574   operands[1] = gen_reg_rtx (DImode);
2575   operands[2] = gen_rtx (LTU, DImode, alpha_compare_op0, alpha_compare_op1);
2576   operands[3] = gen_rtx (EQ, VOIDmode, operands[1], const0_rtx);
2577 }")
2578
2579 (define_expand "seq"
2580   [(set (match_operand:DI 0 "register_operand" "")
2581         (match_dup 1))]
2582   ""
2583   "
2584 {
2585   if (alpha_compare_fp_p)
2586     FAIL;
2587
2588   operands[1] = gen_rtx (EQ, DImode, alpha_compare_op0, alpha_compare_op1);
2589 }")
2590
2591 (define_expand "sne"
2592   [(set (match_operand:DI 0 "register_operand" "")
2593         (match_dup 1))
2594    (set (match_dup 0) (xor:DI (match_dup 0) (const_int 1)))]
2595   ""
2596   "
2597 {
2598   if (alpha_compare_fp_p)
2599     FAIL;
2600
2601   operands[1] = gen_rtx (EQ, DImode, alpha_compare_op0, alpha_compare_op1);
2602 }")
2603
2604 (define_expand "slt"
2605   [(set (match_operand:DI 0 "register_operand" "")
2606         (match_dup 1))]
2607   ""
2608   "
2609 {
2610   if (alpha_compare_fp_p)
2611     FAIL;
2612
2613   operands[1] = gen_rtx (LT, DImode, alpha_compare_op0, alpha_compare_op1);
2614 }")
2615
2616 (define_expand "sle"
2617   [(set (match_operand:DI 0 "register_operand" "")
2618         (match_dup 1))]
2619   ""
2620   "
2621 {
2622   if (alpha_compare_fp_p)
2623     FAIL;
2624
2625   operands[1] = gen_rtx (LE, DImode, alpha_compare_op0, alpha_compare_op1);
2626 }")
2627
2628 (define_expand "sgt"
2629   [(set (match_operand:DI 0 "register_operand" "")
2630         (match_dup 1))]
2631   ""
2632   "
2633 {
2634   if (alpha_compare_fp_p)
2635     FAIL;
2636
2637   operands[1] = gen_rtx (LT, DImode, force_reg (DImode, alpha_compare_op1),
2638                          alpha_compare_op0);
2639 }")
2640
2641 (define_expand "sge"
2642   [(set (match_operand:DI 0 "register_operand" "")
2643         (match_dup 1))]
2644   ""
2645   "
2646 {
2647   if (alpha_compare_fp_p)
2648     FAIL;
2649
2650   operands[1] = gen_rtx (LE, DImode, force_reg (DImode, alpha_compare_op1),
2651                          alpha_compare_op0);
2652 }")
2653
2654 (define_expand "sltu"
2655   [(set (match_operand:DI 0 "register_operand" "")
2656         (match_dup 1))]
2657   ""
2658   "
2659 {
2660   if (alpha_compare_fp_p)
2661     FAIL;
2662
2663   operands[1] = gen_rtx (LTU, DImode, alpha_compare_op0, alpha_compare_op1);
2664 }")
2665
2666 (define_expand "sleu"
2667   [(set (match_operand:DI 0 "register_operand" "")
2668         (match_dup 1))]
2669   ""
2670   "
2671 {
2672   if (alpha_compare_fp_p)
2673     FAIL;
2674
2675   operands[1] = gen_rtx (LEU, DImode, alpha_compare_op0, alpha_compare_op1);
2676 }")
2677
2678 (define_expand "sgtu"
2679   [(set (match_operand:DI 0 "register_operand" "")
2680         (match_dup 1))]
2681   ""
2682   "
2683 {
2684   if (alpha_compare_fp_p)
2685     FAIL;
2686
2687   operands[1] = gen_rtx (LTU, DImode, force_reg (DImode, alpha_compare_op1),
2688                          alpha_compare_op0);
2689 }")
2690
2691 (define_expand "sgeu"
2692   [(set (match_operand:DI 0 "register_operand" "")
2693         (match_dup 1))]
2694   ""
2695   "
2696 {
2697   if (alpha_compare_fp_p)
2698     FAIL;
2699
2700   operands[1] = gen_rtx (LEU, DImode, force_reg (DImode, alpha_compare_op1),
2701                          alpha_compare_op0);
2702 }")
2703 \f
2704 ;; These are the main define_expand's used to make conditional moves.
2705
2706 (define_expand "movsicc"
2707   [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
2708    (set (match_operand:SI 0 "register_operand" "")
2709         (if_then_else:DI (match_dup 5)
2710                          (match_operand:SI 2 "reg_or_8bit_operand" "")
2711                          (match_operand:SI 3 "reg_or_8bit_operand" "")))]
2712   ""
2713   "
2714 {
2715   rtx op0,op1;
2716   enum rtx_code code = GET_CODE (operands[1]), code2 = NE;
2717
2718   if (alpha_compare_fp_p)
2719     FAIL;
2720   switch (code)
2721     {
2722     case EQ: case LE: case LT:
2723       op0 = alpha_compare_op0;
2724       op1 = alpha_compare_op1;
2725       break;
2726     case NE:
2727       code = code2 = EQ;
2728       op0 = alpha_compare_op0;
2729       op1 = alpha_compare_op1;
2730       break;
2731     case GE:
2732       code = LE;
2733       op0 = force_reg (DImode, alpha_compare_op1);
2734       op1 = alpha_compare_op0;
2735       break;
2736     case GT:
2737       code = LT;
2738       op0 = force_reg (DImode, alpha_compare_op1);
2739       op1 = alpha_compare_op0;
2740       break;
2741     default:
2742       FAIL;
2743     }
2744   operands[1] = gen_rtx (code, DImode, op0, op1);
2745   operands[4] = gen_reg_rtx (DImode);
2746   operands[5] = gen_rtx (code2, VOIDmode, operands[4], CONST0_RTX (DImode));
2747 }")
2748
2749 (define_expand "movdicc"
2750   [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
2751    (set (match_operand:DI 0 "register_operand" "")
2752         (if_then_else:DI (match_dup 5)
2753                          (match_operand:DI 2 "reg_or_8bit_operand" "")
2754                          (match_operand:DI 3 "reg_or_8bit_operand" "")))]
2755   ""
2756   "
2757 {
2758   rtx op0,op1;
2759   enum rtx_code code = GET_CODE (operands[1]), code2 = NE;
2760
2761   if (alpha_compare_fp_p)
2762     FAIL;
2763   switch (code)
2764     {
2765     case EQ: case LE: case LT:
2766       op0 = alpha_compare_op0;
2767       op1 = alpha_compare_op1;
2768       break;
2769     case NE:
2770       code = code2 = EQ;
2771       op0 = alpha_compare_op0;
2772       op1 = alpha_compare_op1;
2773       break;
2774     case GE:
2775       code = LE;
2776       op0 = force_reg (DImode, alpha_compare_op1);
2777       op1 = alpha_compare_op0;
2778       break;
2779     case GT:
2780       code = LT;
2781       op0 = force_reg (DImode, alpha_compare_op1);
2782       op1 = alpha_compare_op0;
2783       break;
2784     default:
2785       FAIL;
2786     }
2787   operands[1] = gen_rtx (code, DImode, op0, op1);
2788   operands[4] = gen_reg_rtx (DImode);
2789   operands[5] = gen_rtx (code2, VOIDmode, operands[4], CONST0_RTX (DImode));
2790 }")
2791
2792 (define_expand "movsfcc"
2793   [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
2794    (set (match_operand:SF 0 "register_operand" "")
2795         (if_then_else:SF (match_dup 5)
2796                          (match_operand:SF 2 "reg_or_fp0_operand" "")
2797                          (match_operand:SF 3 "reg_or_fp0_operand" "")))]
2798   ""
2799   "
2800 {
2801   rtx op0,op1;
2802   enum rtx_code code = GET_CODE (operands[1]), code2 = NE;
2803
2804   if (!alpha_compare_fp_p)
2805     FAIL;
2806   switch (code)
2807     {
2808     case EQ: case LE: case LT:
2809       op0 = alpha_compare_op0;
2810       op1 = alpha_compare_op1;
2811       break;
2812     case NE:
2813       /* There isn't a cmptne insn.  */
2814       code = code2 = EQ;
2815       op0 = alpha_compare_op0;
2816       op1 = alpha_compare_op1;
2817       break;
2818     case GE:
2819       code = LE;
2820       op0 = force_reg (DFmode, alpha_compare_op1);
2821       op1 = alpha_compare_op0;
2822       break;
2823     case GT:
2824       code = LT;
2825       op0 = force_reg (DFmode, alpha_compare_op1);
2826       op1 = alpha_compare_op0;
2827       break;
2828     default:
2829       FAIL;
2830     }
2831   operands[1] = gen_rtx (code, DFmode, op0, op1);
2832   operands[4] = gen_reg_rtx (DFmode);
2833   operands[5] = gen_rtx (code2, VOIDmode, operands[4], CONST0_RTX (DFmode));
2834 }")
2835
2836 (define_expand "movdfcc"
2837   [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
2838    (set (match_operand:DF 0 "register_operand" "")
2839         (if_then_else:DF (match_dup 5)
2840                          (match_operand:DF 2 "reg_or_fp0_operand" "")
2841                          (match_operand:DF 3 "reg_or_fp0_operand" "")))]
2842   ""
2843   "
2844 {
2845   rtx op0,op1;
2846   enum rtx_code code = GET_CODE (operands[1]), code2 = NE;
2847
2848   if (!alpha_compare_fp_p)
2849     FAIL;
2850   switch (code)
2851     {
2852     case EQ: case LE: case LT:
2853       op0 = alpha_compare_op0;
2854       op1 = alpha_compare_op1;
2855       break;
2856     case NE:
2857       /* There isn't a cmptne insn.  */
2858       code = code2 = EQ;
2859       op0 = alpha_compare_op0;
2860       op1 = alpha_compare_op1;
2861       break;
2862     case GE:
2863       code = LE;
2864       op0 = force_reg (DFmode, alpha_compare_op1);
2865       op1 = alpha_compare_op0;
2866       break;
2867     case GT:
2868       code = LT;
2869       op0 = force_reg (DFmode, alpha_compare_op1);
2870       op1 = alpha_compare_op0;
2871       break;
2872     default:
2873       FAIL;
2874     }
2875   operands[1] = gen_rtx (code, DFmode, op0, op1);
2876   operands[4] = gen_reg_rtx (DFmode);
2877   operands[5] = gen_rtx (code2, VOIDmode, operands[4], CONST0_RTX (DFmode));
2878 }")
2879 \f
2880 ;; These define_split definitions are used in cases when comparisons have
2881 ;; not be stated in the correct way and we need to reverse the second
2882 ;; comparison.  For example, x >= 7 has to be done as x < 6 with the
2883 ;; comparison that tests the result being reversed.  We have one define_split
2884 ;; for each use of a comparison.  They do not match valid insns and need
2885 ;; not generate valid insns.
2886 ;;
2887 ;; We can also handle equality comparisons (and inequality comparisons in
2888 ;; cases where the resulting add cannot overflow) by doing an add followed by
2889 ;; a comparison with zero.  This is faster since the addition takes one
2890 ;; less cycle than a compare when feeding into a conditional move.
2891 ;; For this case, we also have an SImode pattern since we can merge the add
2892 ;; and sign extend and the order doesn't matter.
2893 ;;
2894 ;; We do not do this for floating-point, since it isn't clear how the "wrong"
2895 ;; operation could have been generated.
2896
2897 (define_split
2898   [(set (match_operand:DI 0 "register_operand" "")
2899         (if_then_else:DI
2900          (match_operator 1 "comparison_operator"
2901                          [(match_operand:DI 2 "reg_or_0_operand" "")
2902                           (match_operand:DI 3 "reg_or_cint_operand" "")])
2903          (match_operand:DI 4 "reg_or_cint_operand" "")
2904          (match_operand:DI 5 "reg_or_cint_operand" "")))
2905    (clobber (match_operand:DI 6 "register_operand" ""))]
2906   "operands[3] != const0_rtx"
2907   [(set (match_dup 6) (match_dup 7))
2908    (set (match_dup 0)
2909         (if_then_else:DI (match_dup 8) (match_dup 4) (match_dup 5)))]
2910   "
2911 { enum rtx_code code = GET_CODE (operands[1]);
2912   int unsignedp = (code == GEU || code == LEU || code == GTU || code == LTU);
2913
2914   /* If we are comparing for equality with a constant and that constant
2915      appears in the arm when the register equals the constant, use the
2916      register since that is more likely to match (and to produce better code
2917      if both would).  */
2918
2919   if (code == EQ && GET_CODE (operands[3]) == CONST_INT
2920       && rtx_equal_p (operands[4], operands[3]))
2921     operands[4] = operands[2];
2922
2923   else if (code == NE && GET_CODE (operands[3]) == CONST_INT
2924            && rtx_equal_p (operands[5], operands[3]))
2925     operands[5] = operands[2];
2926
2927   if (code == NE || code == EQ
2928       || (extended_count (operands[2], DImode, unsignedp) >= 1
2929           && extended_count (operands[3], DImode, unsignedp) >= 1))
2930     {
2931       if (GET_CODE (operands[3]) == CONST_INT)
2932         operands[7] = gen_rtx (PLUS, DImode, operands[2],
2933                                GEN_INT (- INTVAL (operands[3])));
2934       else
2935         operands[7] = gen_rtx (MINUS, DImode, operands[2], operands[3]);
2936
2937       operands[8] = gen_rtx (code, VOIDmode, operands[6], const0_rtx);
2938     }
2939
2940   else if (code == EQ || code == LE || code == LT
2941            || code == LEU || code == LTU)
2942     {
2943       operands[7] = gen_rtx (code, DImode, operands[2], operands[3]);
2944       operands[8] = gen_rtx (NE, VOIDmode, operands[6], const0_rtx);
2945     }
2946   else
2947     {
2948       operands[7] = gen_rtx (reverse_condition (code), DImode, operands[2],
2949                              operands[3]);
2950       operands[8] = gen_rtx (EQ, VOIDmode, operands[6], const0_rtx);
2951     }
2952 }")
2953
2954 (define_split
2955   [(set (match_operand:DI 0 "register_operand" "")
2956         (if_then_else:DI
2957          (match_operator 1 "comparison_operator"
2958                          [(match_operand:SI 2 "reg_or_0_operand" "")
2959                           (match_operand:SI 3 "reg_or_cint_operand" "")])
2960          (match_operand:DI 4 "reg_or_8bit_operand" "")
2961          (match_operand:DI 5 "reg_or_8bit_operand" "")))
2962    (clobber (match_operand:DI 6 "register_operand" ""))]
2963   "operands[3] != const0_rtx
2964    && (GET_CODE (operands[1]) == EQ || GET_CODE (operands[1]) == NE)"
2965   [(set (match_dup 6) (match_dup 7))
2966    (set (match_dup 0)
2967         (if_then_else:DI (match_dup 8) (match_dup 4) (match_dup 5)))]
2968   "
2969 { enum rtx_code code = GET_CODE (operands[1]);
2970   int unsignedp = (code == GEU || code == LEU || code == GTU || code == LTU);
2971   rtx tem;
2972
2973   if ((code != NE && code != EQ
2974        && ! (extended_count (operands[2], DImode, unsignedp) >= 1
2975              && extended_count (operands[3], DImode, unsignedp) >= 1)))
2976     FAIL;
2977  
2978   if (GET_CODE (operands[3]) == CONST_INT)
2979     tem = gen_rtx (PLUS, SImode, operands[2],
2980                    GEN_INT (- INTVAL (operands[3])));
2981   else
2982     tem = gen_rtx (MINUS, SImode, operands[2], operands[3]);
2983
2984   operands[7] = gen_rtx (SIGN_EXTEND, DImode, tem);
2985   operands[8] = gen_rtx (GET_CODE (operands[1]), VOIDmode, operands[6],
2986                          const0_rtx);
2987 }")
2988
2989 (define_split
2990   [(set (pc)
2991         (if_then_else
2992          (match_operator 1 "comparison_operator"
2993                          [(match_operand:DI 2 "reg_or_0_operand" "")
2994                           (match_operand:DI 3 "reg_or_cint_operand" "")])
2995          (label_ref (match_operand 0 "" ""))
2996          (pc)))
2997    (clobber (match_operand:DI 4 "register_operand" ""))]
2998   "operands[3] != const0_rtx"
2999   [(set (match_dup 4) (match_dup 5))
3000    (set (pc) (if_then_else (match_dup 6) (label_ref (match_dup 0)) (pc)))]
3001   "
3002 { enum rtx_code code = GET_CODE (operands[1]);
3003   int unsignedp = (code == GEU || code == LEU || code == GTU || code == LTU);
3004
3005   if (code == NE || code == EQ
3006       || (extended_count (operands[2], DImode, unsignedp) >= 1
3007           && extended_count (operands[3], DImode, unsignedp) >= 1))
3008     {
3009       if (GET_CODE (operands[3]) == CONST_INT)
3010         operands[5] = gen_rtx (PLUS, DImode, operands[2],
3011                                GEN_INT (- INTVAL (operands[3])));
3012       else
3013         operands[5] = gen_rtx (MINUS, DImode, operands[2], operands[3]);
3014
3015       operands[6] = gen_rtx (code, VOIDmode, operands[4], const0_rtx);
3016     }
3017
3018   else if (code == EQ || code == LE || code == LT
3019            || code == LEU || code == LTU)
3020     {
3021       operands[5] = gen_rtx (code, DImode, operands[2], operands[3]);
3022       operands[6] = gen_rtx (NE, VOIDmode, operands[4], const0_rtx);
3023     }
3024   else
3025     {
3026       operands[5] = gen_rtx (reverse_condition (code), DImode, operands[2],
3027                              operands[3]);
3028       operands[6] = gen_rtx (EQ, VOIDmode, operands[4], const0_rtx);
3029     }
3030 }")
3031
3032 (define_split
3033   [(set (pc)
3034         (if_then_else
3035          (match_operator 1 "comparison_operator"
3036                          [(match_operand:SI 2 "reg_or_0_operand" "")
3037                           (match_operand:SI 3 "const_int_operand" "")])
3038          (label_ref (match_operand 0 "" ""))
3039          (pc)))
3040    (clobber (match_operand:DI 4 "register_operand" ""))]
3041   "operands[3] != const0_rtx
3042    && (GET_CODE (operands[1]) == EQ || GET_CODE (operands[1]) == NE)"
3043   [(set (match_dup 4) (match_dup 5))
3044    (set (pc) (if_then_else (match_dup 6) (label_ref (match_dup 0)) (pc)))]
3045   "
3046 { rtx tem;
3047
3048   if (GET_CODE (operands[3]) == CONST_INT)
3049     tem = gen_rtx (PLUS, SImode, operands[2],
3050                    GEN_INT (- INTVAL (operands[3])));
3051   else
3052     tem = gen_rtx (MINUS, SImode, operands[2], operands[3]);
3053   
3054   operands[5] = gen_rtx (SIGN_EXTEND, DImode, tem);
3055   operands[6] = gen_rtx (GET_CODE (operands[1]), VOIDmode,
3056                          operands[4], const0_rtx);
3057 }")
3058
3059 ;; We can convert such things as "a > 0xffff" to "t = a & ~ 0xffff; t != 0".
3060 ;; This eliminates one, and sometimes two, insns when the AND can be done
3061 ;; with a ZAP.
3062 (define_split
3063   [(set (match_operand:DI 0 "register_operand" "")
3064         (match_operator 1 "comparison_operator"
3065                         [(match_operand:DI 2 "register_operand" "")
3066                          (match_operand:DI 3 "const_int_operand" "")]))
3067    (clobber (match_operand:DI 4 "register_operand" ""))]
3068   "exact_log2 (INTVAL (operands[3]) + 1) >= 0
3069    && (GET_CODE (operands[1]) == GTU
3070        || GET_CODE (operands[1]) == LEU
3071        || ((GET_CODE (operands[1]) == GT || GET_CODE (operands[1]) == LE)
3072            && extended_count (operands[2], DImode, 1) > 0))"
3073   [(set (match_dup 4) (and:DI (match_dup 2) (match_dup 5)))
3074    (set (match_dup 0) (match_dup 6))]
3075   "
3076 {
3077   operands[5] = GEN_INT (~ INTVAL (operands[3]));
3078   operands[6] = gen_rtx (((GET_CODE (operands[1]) == GTU
3079                            || GET_CODE (operands[1]) == GT)
3080                           ? NE : EQ),
3081                          DImode, operands[4], const0_rtx);
3082 }")
3083 \f
3084 ;; Here are the CALL and unconditional branch insns.  Calls on NT and OSF
3085 ;; work differently, so we have different patterns for each.
3086
3087 (define_expand "call"
3088   [(use (match_operand:DI 0 "" ""))
3089    (use (match_operand 1 "" ""))]
3090   ""
3091   "
3092 { if (WINDOWS_NT)
3093     emit_call_insn (gen_call_nt (operands[0], operands[1]));
3094   else
3095     emit_call_insn (gen_call_osf (operands[0], operands[1]));
3096
3097   DONE;
3098 }")
3099
3100 (define_expand "call_osf"
3101   [(parallel [(call (mem:DI (match_operand 0 "" ""))
3102                     (match_operand 1 "" ""))
3103               (clobber (reg:DI 27))
3104               (clobber (reg:DI 26))])]
3105   ""
3106   "
3107 { if (GET_CODE (operands[0]) != MEM)
3108     abort ();
3109
3110   operands[0] = XEXP (operands[0], 0);
3111
3112   if (GET_CODE (operands[0]) != SYMBOL_REF
3113       && ! (GET_CODE (operands[0]) == REG && REGNO (operands[0]) == 27))
3114     {
3115       rtx tem = gen_rtx (REG, DImode, 27);
3116       emit_move_insn (tem, operands[0]);
3117       operands[0] = tem;
3118     }
3119 }")
3120
3121 (define_expand "call_nt"
3122   [(parallel [(call (mem:DI (match_operand:DI 0 "" ""))
3123                     (match_operand 1 "" ""))
3124               (clobber (reg:DI 26))])]
3125   ""
3126   "
3127 { if (GET_CODE (operands[0]) != MEM)
3128     abort ();
3129   operands[0] = XEXP (operands[0], 0);
3130
3131   if (GET_CODE (operands[1]) != SYMBOL_REF
3132       && ! (GET_CODE (operands[1]) == REG && REGNO (operands[1]) == 27))
3133     {
3134       rtx tem = gen_rtx (REG, DImode, 27);
3135       emit_move_insn (tem, operands[1]);
3136       operands[1] = tem;
3137     }
3138 }")
3139
3140 (define_expand "call_value"
3141   [(use (match_operand 0 "" ""))
3142    (use (match_operand:DI 1 "" ""))
3143    (use (match_operand 2 "" ""))]
3144   ""
3145   "
3146 { if (WINDOWS_NT)
3147     emit_call_insn (gen_call_value_nt (operands[0], operands[1], operands[2]));
3148   else
3149     emit_call_insn (gen_call_value_osf (operands[0], operands[1],
3150                                         operands[2]));
3151   DONE;
3152 }")
3153
3154 (define_expand "call_value_osf"
3155   [(parallel [(set (match_operand 0 "" "")
3156                    (call (mem:DI (match_operand 1 "" ""))
3157                          (match_operand 2 "" "")))
3158               (clobber (reg:DI 27))
3159               (clobber (reg:DI 26))])]
3160   ""
3161   "
3162 { if (GET_CODE (operands[1]) != MEM)
3163     abort ();
3164
3165   operands[1] = XEXP (operands[1], 0);
3166
3167   if (GET_CODE (operands[1]) != SYMBOL_REF
3168       && ! (GET_CODE (operands[1]) == REG && REGNO (operands[1]) == 27))
3169     {
3170       rtx tem = gen_rtx (REG, DImode, 27);
3171       emit_move_insn (tem, operands[1]);
3172       operands[1] = tem;
3173     }
3174 }")
3175
3176 (define_expand "call_value_nt"
3177   [(parallel [(set (match_operand 0 "" "")
3178                    (call (mem:DI (match_operand:DI 1 "" ""))
3179                          (match_operand 2 "" "")))
3180               (clobber (reg:DI 26))])]
3181   ""
3182   "
3183 { if (GET_CODE (operands[1]) != MEM)
3184     abort ();
3185
3186   operands[1] = XEXP (operands[1], 0);
3187   if (GET_CODE (operands[1]) != SYMBOL_REF
3188       && ! (GET_CODE (operands[1]) == REG && REGNO (operands[1]) == 27))
3189     {
3190       rtx tem = gen_rtx (REG, DImode, 27);
3191       emit_move_insn (tem, operands[1]);
3192       operands[1] = tem;
3193     }
3194 }")
3195
3196 (define_insn ""
3197   [(call (mem:DI (match_operand:DI 0 "call_operand" "r,R,i"))
3198          (match_operand 1 "" ""))
3199    (clobber (reg:DI 27))
3200    (clobber (reg:DI 26))]
3201   "! WINDOWS_NT && alpha_tp == ALPHA_TP_INSN"
3202   "@
3203    jsr $26,($27),0\;trapb\;ldgp $29,4($26)
3204    bsr $26,%0..ng\;trapb
3205    jsr $26,%0\;trapb\;ldgp $29,4($26)"
3206   [(set_attr "type" "jsr,jsr,ibr")])
3207       
3208 (define_insn ""
3209   [(call (mem:DI (match_operand:DI 0 "call_operand" "r,R,i"))
3210          (match_operand 1 "" ""))
3211    (clobber (reg:DI 27))
3212    (clobber (reg:DI 26))]
3213   "! WINDOWS_NT"
3214   "@
3215    jsr $26,($27),0\;ldgp $29,0($26)
3216    bsr $26,%0..ng
3217    jsr $26,%0\;ldgp $29,0($26)"
3218   [(set_attr "type" "jsr,jsr,ibr")])
3219       
3220 (define_insn ""
3221   [(call (mem:DI (match_operand:DI 0 "call_operand" "r,i"))
3222          (match_operand 1 "" ""))
3223    (clobber (reg:DI 26))]
3224   "WINDOWS_NT"
3225   "@
3226    jsr $26,(%0)
3227    bsr $26,%0"
3228   [(set_attr "type" "jsr")])
3229       
3230 (define_insn ""
3231   [(set (match_operand 0 "register_operand" "=rf,rf,rf")
3232         (call (mem:DI (match_operand:DI 1 "call_operand" "r,R,i"))
3233               (match_operand 2 "" "")))
3234    (clobber (reg:DI 27))
3235    (clobber (reg:DI 26))]
3236   "! WINDOWS_NT && alpha_tp == ALPHA_TP_INSN"
3237   "@
3238    jsr $26,($27),0\;trapb\;ldgp $29,4($26)
3239    bsr $26,%1..ng\;trapb
3240    jsr $26,%1\;trapb\;ldgp $29,4($26)"
3241   [(set_attr "type" "jsr,jsr,ibr")])
3242
3243 (define_insn ""
3244   [(set (match_operand 0 "register_operand" "=rf,rf,rf")
3245         (call (mem:DI (match_operand:DI 1 "call_operand" "r,R,i"))
3246               (match_operand 2 "" "")))
3247    (clobber (reg:DI 27))
3248    (clobber (reg:DI 26))]
3249   "! WINDOWS_NT"
3250   "@
3251    jsr $26,($27),0\;ldgp $29,0($26)
3252    bsr $26,%1..ng
3253    jsr $26,%1\;ldgp $29,0($26)"
3254   [(set_attr "type" "jsr,jsr,ibr")])
3255
3256 (define_insn ""
3257   [(set (match_operand 0 "register_operand" "=rf,rf")
3258         (call (mem:DI (match_operand:DI 1 "call_operand" "r,i"))
3259               (match_operand 2 "" "")))
3260    (clobber (reg:DI 26))]
3261   "WINDOWS_NT"
3262   "@
3263    jsr $26,(%1)
3264    bsr $26,%1"
3265   [(set_attr "type" "jsr")])
3266
3267 ;; Call subroutine returning any type.
3268
3269 (define_expand "untyped_call"
3270   [(parallel [(call (match_operand 0 "" "")
3271                     (const_int 0))
3272               (match_operand 1 "" "")
3273               (match_operand 2 "" "")])]
3274   ""
3275   "
3276 {
3277   int i;
3278
3279   emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx));
3280
3281   for (i = 0; i < XVECLEN (operands[2], 0); i++)
3282     {
3283       rtx set = XVECEXP (operands[2], 0, i);
3284       emit_move_insn (SET_DEST (set), SET_SRC (set));
3285     }
3286
3287   /* The optimizer does not know that the call sets the function value
3288      registers we stored in the result block.  We avoid problems by
3289      claiming that all hard registers are used and clobbered at this
3290      point.  */
3291   emit_insn (gen_blockage ());
3292
3293   DONE;
3294 }")
3295
3296 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
3297 ;; all of memory.  This blocks insns from being moved across this point.
3298
3299 (define_insn "blockage"
3300   [(unspec_volatile [(const_int 0)] 1)]
3301   ""
3302   "")
3303
3304 (define_insn "jump"
3305   [(set (pc)
3306         (label_ref (match_operand 0 "" "")))]
3307   ""
3308   "br $31,%l0"
3309   [(set_attr "type" "ibr")])
3310
3311 (define_insn "return"
3312   [(return)]
3313   "direct_return ()"
3314   "ret $31,($26),1"
3315   [(set_attr "type" "ibr")])
3316
3317 (define_insn "indirect_jump"
3318   [(set (pc) (match_operand:DI 0 "register_operand" "r"))]
3319   ""
3320   "jmp $31,(%0),0"
3321   [(set_attr "type" "ibr")])
3322
3323 (define_insn "nop"
3324   [(const_int 0)]
3325   ""
3326   "bis $31,$31,$31"
3327   [(set_attr "type" "iaddlog")])
3328
3329 (define_expand "tablejump"
3330   [(use (match_operand:SI 0 "register_operand" ""))
3331    (use (match_operand:SI 1 "" ""))]
3332   ""
3333   "
3334 {
3335   if (WINDOWS_NT)
3336     emit_jump_insn (gen_tablejump_nt (operands[0], operands[1]));
3337   else
3338     emit_jump_insn (gen_tablejump_osf (operands[0], operands[1]));
3339
3340   DONE;
3341 }")
3342
3343 (define_expand "tablejump_osf"
3344   [(set (match_dup 3)
3345         (sign_extend:DI (match_operand:SI 0 "register_operand" "")))
3346    (parallel [(set (pc)
3347                    (plus:DI (match_dup 3)
3348                             (label_ref:DI (match_operand 1 "" ""))))
3349               (clobber (match_scratch:DI 2 "=r"))])]
3350   ""
3351   "
3352 { operands[3] = gen_reg_rtx (DImode); }")
3353
3354 (define_expand "tablejump_nt"
3355   [(set (match_dup 3)
3356         (sign_extend:DI (match_operand:SI 0 "register_operand" "")))
3357    (parallel [(set (pc)
3358                    (match_dup 3))
3359               (use (label_ref (match_operand 1 "" "")))])]
3360   ""
3361   "
3362 { operands[3] = gen_reg_rtx (DImode); }")
3363
3364 (define_insn ""
3365   [(set (pc)
3366         (plus:DI (match_operand:DI 0 "register_operand" "r")
3367                  (label_ref:DI (match_operand 1 "" ""))))
3368    (clobber (match_scratch:DI 2 "=r"))]
3369   "! WINDOWS_NT && next_active_insn (insn) != 0
3370    && GET_CODE (PATTERN (next_active_insn (insn))) == ADDR_DIFF_VEC
3371    && PREV_INSN (next_active_insn (insn)) == operands[1]"
3372   "*
3373 { rtx best_label = 0;
3374   rtx jump_table_insn = next_active_insn (operands[1]);
3375
3376   if (GET_CODE (jump_table_insn) == JUMP_INSN
3377       && GET_CODE (PATTERN (jump_table_insn)) == ADDR_DIFF_VEC)
3378     {
3379       rtx jump_table = PATTERN (jump_table_insn);
3380       int n_labels = XVECLEN (jump_table, 1);
3381       int best_count = -1;
3382       int i, j;
3383
3384       for (i = 0; i < n_labels; i++)
3385         {
3386           int count = 1;
3387
3388           for (j = i + 1; j < n_labels; j++)
3389             if (XEXP (XVECEXP (jump_table, 1, i), 0)
3390                 == XEXP (XVECEXP (jump_table, 1, j), 0))
3391               count++;
3392
3393           if (count > best_count)
3394             best_count = count, best_label = XVECEXP (jump_table, 1, i);
3395         }
3396     }
3397
3398   if (best_label)
3399     {
3400       operands[3] = best_label;
3401       return \"addq %0,$29,%2\;jmp $31,(%2),%3\";
3402     }
3403   else
3404     return \"addq %0,$29,%2\;jmp $31,(%2),0\";
3405 }"
3406   [(set_attr "type" "ibr")])
3407
3408 (define_insn ""
3409   [(set (pc)
3410         (match_operand:DI 0 "register_operand" "r"))
3411    (use (label_ref (match_operand 1 "" "")))]
3412   "WINDOWS_NT && next_active_insn (insn) != 0
3413    && GET_CODE (PATTERN (next_active_insn (insn))) == ADDR_DIFF_VEC
3414    && PREV_INSN (next_active_insn (insn)) == operands[1]"
3415   "*
3416 { rtx best_label = 0;
3417   rtx jump_table_insn = next_active_insn (operands[1]);
3418
3419   if (GET_CODE (jump_table_insn) == JUMP_INSN
3420       && GET_CODE (PATTERN (jump_table_insn)) == ADDR_DIFF_VEC)
3421     {
3422       rtx jump_table = PATTERN (jump_table_insn);
3423       int n_labels = XVECLEN (jump_table, 1);
3424       int best_count = -1;
3425       int i, j;
3426
3427       for (i = 0; i < n_labels; i++)
3428         {
3429           int count = 1;
3430
3431           for (j = i + 1; j < n_labels; j++)
3432             if (XEXP (XVECEXP (jump_table, 1, i), 0)
3433                 == XEXP (XVECEXP (jump_table, 1, j), 0))
3434               count++;
3435
3436           if (count > best_count)
3437             best_count = count, best_label = XVECEXP (jump_table, 1, i);
3438         }
3439     }
3440
3441   if (best_label)
3442     {
3443       operands[2] = best_label;
3444       return \"jmp $31,(%0),%2\";
3445     }
3446   else
3447     return \"jmp $31,(%0),0\";
3448 }"
3449   [(set_attr "type" "ibr")])
3450
3451 ;; Cache flush.  Used by INITIALIZE_TRAMPOLINE.  0x86 is PAL_imb, but we don't
3452 ;; want to have to include pal.h in our .s file.
3453 (define_insn ""
3454   [(unspec_volatile [(const_int 0)] 0)]
3455   ""
3456   "call_pal 0x86")
3457 \f
3458 ;; Finally, we have the basic data motion insns.  The byte and word insns
3459 ;; are done via define_expand.  Start with the floating-point insns, since
3460 ;; they are simpler.
3461
3462 (define_insn ""
3463   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m,f,f,f,m")
3464         (match_operand:SF 1 "input_operand" "rG,m,rG,f,G,m,fG"))]
3465   "register_operand (operands[0], SFmode)
3466    || reg_or_fp0_operand (operands[1], SFmode)"
3467   "@
3468    bis %r1,%r1,%0
3469    ldl %0,%1
3470    stl %r1,%0
3471    cpys %1,%1,%0
3472    cpys $f31,$f31,%0
3473    lds %0,%1
3474    sts %R1,%0"
3475   [(set_attr "type" "iaddlog,ld,st,fpop,fpop,ld,st")])
3476
3477 (define_insn ""
3478   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,f,f,f,m")
3479         (match_operand:DF 1 "input_operand" "rG,m,rG,f,G,m,fG"))]
3480   "register_operand (operands[0], DFmode)
3481    || reg_or_fp0_operand (operands[1], DFmode)"
3482   "@
3483    bis %r1,%r1,%0
3484    ldq %0,%1
3485    stq %r1,%0
3486    cpys %1,%1,%0
3487    cpys $f31,$f31,%0
3488    ldt %0,%1
3489    stt %R1,%0"
3490   [(set_attr "type" "iaddlog,ld,st,fpop,fpop,ld,st")])
3491
3492 (define_expand "movsf"
3493   [(set (match_operand:SF 0 "nonimmediate_operand" "")
3494         (match_operand:SF 1 "general_operand" ""))]
3495   ""
3496   "
3497 {
3498   if (GET_CODE (operands[0]) == MEM
3499       && ! reg_or_fp0_operand (operands[1], SFmode))
3500     operands[1] = force_reg (SFmode, operands[1]);
3501 }")
3502
3503 (define_expand "movdf"
3504   [(set (match_operand:DF 0 "nonimmediate_operand" "")
3505         (match_operand:DF 1 "general_operand" ""))]
3506   ""
3507   "
3508 {
3509   if (GET_CODE (operands[0]) == MEM
3510       && ! reg_or_fp0_operand (operands[1], DFmode))
3511     operands[1] = force_reg (DFmode, operands[1]);
3512 }")
3513
3514 (define_insn ""
3515   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,r,r,m,f,f,f,m")
3516         (match_operand:SI 1 "input_operand" "r,J,I,K,L,m,rJ,f,J,m,fG"))]
3517   "! WINDOWS_NT && (register_operand (operands[0], SImode)
3518                     || reg_or_0_operand (operands[1], SImode))"
3519   "@
3520    bis %1,%1,%0
3521    bis $31,$31,%0
3522    bis $31,%1,%0
3523    lda %0,%1
3524    ldah %0,%h1
3525    ldl %0,%1
3526    stl %r1,%0
3527    cpys %1,%1,%0
3528    cpys $f31,$f31,%0
3529    lds %0,%1
3530    sts %R1,%0"
3531   [(set_attr "type" "iaddlog,iaddlog,iaddlog,iaddlog,iaddlog,ld,st,fpop,fpop,ld,st")])
3532
3533 (define_insn ""
3534   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,r,r,r,m,f,f,f,m")
3535         (match_operand:SI 1 "input_operand" "r,J,I,K,L,s,m,rJ,f,J,m,fG"))]
3536   "WINDOWS_NT && (register_operand (operands[0], SImode)
3537                   || reg_or_0_operand (operands[1], SImode))"
3538   "@
3539    bis %1,%1,%0
3540    bis $31,$31,%0
3541    bis $31,%1,%0
3542    lda %0,%1
3543    ldah %0,%h1
3544    lda %0,%1
3545    ldl %0,%1
3546    stl %r1,%0
3547    cpys %1,%1,%0
3548    cpys $f31,$f31,%0
3549    lds %0,%1
3550    sts %R1,%0"
3551   [(set_attr "type" "iaddlog,iaddlog,iaddlog,iaddlog,iaddlog,ldsym,ld,st,fpop,fpop,ld,st")])
3552
3553 (define_insn ""
3554   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,r,f,f")
3555         (match_operand:HI 1 "input_operand" "r,J,I,n,f,J"))]
3556   "register_operand (operands[0], HImode)
3557    || register_operand (operands[1], HImode)"
3558   "@
3559    bis %1,%1,%0
3560    bis $31,$31,%0
3561    bis $31,%1,%0
3562    lda %0,%L1
3563    cpys %1,%1,%0
3564    cpys $f31,$f31,%0"
3565   [(set_attr "type" "iaddlog,iaddlog,iaddlog,iaddlog,fpop,fpop")])
3566
3567 (define_insn ""
3568   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,r,r,f,f")
3569         (match_operand:QI 1 "input_operand" "r,J,I,n,f,J"))]
3570   "register_operand (operands[0], QImode)
3571    || register_operand (operands[1], QImode)"
3572   "@
3573    bis %1,%1,%0
3574    bis $31,$31,%0
3575    bis $31,%1,%0
3576    lda %0,%L1
3577    cpys %1,%1,%0
3578    cpys $f31,$f31,%0"
3579   [(set_attr "type" "iaddlog,iaddlog,iaddlog,iaddlog,fpop,fpop")])
3580
3581 ;; We do two major things here: handle mem->mem and construct long
3582 ;; constants.
3583
3584 (define_expand "movsi"
3585   [(set (match_operand:SI 0 "general_operand" "")
3586         (match_operand:SI 1 "general_operand" ""))]
3587   ""
3588   "
3589 {
3590   if (GET_CODE (operands[0]) == MEM
3591       && ! reg_or_0_operand (operands[1], SImode))
3592     operands[1] = force_reg (SImode, operands[1]);
3593
3594   if (! CONSTANT_P (operands[1]) || input_operand (operands[1], SImode))
3595     ;
3596   else if (GET_CODE (operands[1]) == CONST_INT)
3597     {
3598       operands[1]
3599         = alpha_emit_set_const (operands[0], SImode, INTVAL (operands[1]), 3);
3600       if (rtx_equal_p (operands[0], operands[1]))
3601         DONE;
3602     }
3603 }")
3604
3605 ;; Split a load of a large constant into the appropriate two-insn
3606 ;; sequence.
3607
3608 (define_split
3609   [(set (match_operand:SI 0 "register_operand" "")
3610         (match_operand:SI 1 "const_int_operand" ""))]
3611   "! add_operand (operands[1], SImode)"
3612   [(set (match_dup 0) (match_dup 2))
3613    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
3614   "
3615 { rtx tem
3616     = alpha_emit_set_const (operands[0], SImode, INTVAL (operands[1]), 2);
3617
3618   if (tem == operands[0])
3619     DONE;
3620   else
3621     FAIL;
3622 }")
3623
3624 (define_insn ""
3625   [(set (match_operand:DI 0 "general_operand" "=r,r,r,r,r,r,r,m,f,f,f,Q")
3626         (match_operand:DI 1 "input_operand" "r,J,I,K,L,s,m,rJ,f,J,Q,fG"))]
3627   "register_operand (operands[0], DImode)
3628    || reg_or_0_operand (operands[1], DImode)"
3629   "@
3630    bis %1,%1,%0
3631    bis $31,$31,%0
3632    bis $31,%1,%0
3633    lda %0,%1
3634    ldah %0,%h1
3635    lda %0,%1
3636    ldq%A1 %0,%1
3637    stq%A0 %r1,%0
3638    cpys %1,%1,%0
3639    cpys $f31,$f31,%0
3640    ldt %0,%1
3641    stt %R1,%0"
3642   [(set_attr "type" "iaddlog,iaddlog,iaddlog,iaddlog,iaddlog,ldsym,ld,st,fpop,fpop,ld,st")])
3643
3644 ;; We do three major things here: handle mem->mem, put 64-bit constants in
3645 ;; memory, and construct long 32-bit constants.
3646
3647 (define_expand "movdi"
3648   [(set (match_operand:DI 0 "general_operand" "")
3649         (match_operand:DI 1 "general_operand" ""))]
3650   ""
3651   "
3652 {
3653   rtx tem;
3654
3655   if (GET_CODE (operands[0]) == MEM
3656       && ! reg_or_0_operand (operands[1], DImode))
3657     operands[1] = force_reg (DImode, operands[1]);
3658
3659   if (! CONSTANT_P (operands[1]) || input_operand (operands[1], DImode))
3660     ;
3661   else if (GET_CODE (operands[1]) == CONST_INT
3662            && (tem = alpha_emit_set_const (operands[0], DImode,
3663                                            INTVAL (operands[1]), 3)) != 0)
3664     {
3665       if (rtx_equal_p (tem, operands[0]))
3666         DONE;
3667       else
3668         operands[1] = tem;
3669     }
3670   else if (CONSTANT_P (operands[1]))
3671     {
3672       operands[1] = force_const_mem (DImode, operands[1]);
3673       if (reload_in_progress)
3674         {
3675           emit_move_insn (operands[0], XEXP (operands[1], 0));
3676           operands[1] = copy_rtx (operands[1]);
3677           XEXP (operands[1], 0) = operands[0];
3678         }
3679       else
3680         operands[1] = validize_mem (operands[1]);
3681     }
3682   else
3683     abort ();
3684 }")
3685
3686 ;; Split a load of a large constant into the appropriate two-insn
3687 ;; sequence.
3688
3689 (define_split
3690   [(set (match_operand:DI 0 "register_operand" "")
3691         (match_operand:DI 1 "const_int_operand" ""))]
3692   "! add_operand (operands[1], DImode)"
3693   [(set (match_dup 0) (match_dup 2))
3694    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
3695   "
3696 { rtx tem
3697     = alpha_emit_set_const (operands[0], DImode, INTVAL (operands[1]), 2);
3698
3699   if (tem == operands[0])
3700     DONE;
3701   else
3702     FAIL;
3703 }")
3704
3705 ;; These are the partial-word cases.
3706 ;;
3707 ;; First we have the code to load an aligned word.  Operand 0 is the register
3708 ;; in which to place the result.  It's mode is QImode or HImode.  Operand 1
3709 ;; is an SImode MEM at the low-order byte of the proper word.  Operand 2 is the
3710 ;; number of bits within the word that the value is.  Operand 3 is an SImode
3711 ;; scratch register.  If operand 0 is a hard register, operand 3 may be the
3712 ;; same register.  It is allowed to conflict with operand 1 as well.
3713
3714 (define_expand "aligned_loadqi"
3715   [(set (match_operand:SI 3 "register_operand" "")
3716         (match_operand:SI 1 "memory_operand" ""))
3717    (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
3718         (zero_extract:DI (subreg:DI (match_dup 3) 0)
3719                          (const_int 8)
3720                          (match_operand:DI 2 "const_int_operand" "")))]
3721          
3722   ""
3723   "")
3724   
3725 (define_expand "aligned_loadhi"
3726   [(set (match_operand:SI 3 "register_operand" "")
3727         (match_operand:SI 1 "memory_operand" ""))
3728    (set (subreg:DI (match_operand:HI 0 "register_operand" "") 0)
3729         (zero_extract:DI (subreg:DI (match_dup 3) 0)
3730                          (const_int 16)
3731                          (match_operand:DI 2 "const_int_operand" "")))]
3732          
3733   ""
3734   "")
3735   
3736 ;; Similar for unaligned loads, where we use the sequence from the
3737 ;; Alpha Architecture manual.
3738 ;;
3739 ;; Operand 1 is the address.  Operands 2 and 3 are temporaries, where
3740 ;; operand 3 can overlap the input and output registers.
3741
3742 (define_expand "unaligned_loadqi"
3743   [(set (match_operand:DI 2 "register_operand" "")
3744         (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
3745                         (const_int -8))))
3746    (set (match_operand:DI 3 "register_operand" "")
3747         (match_dup 1))
3748    (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
3749         (zero_extract:DI (match_dup 2)
3750                          (const_int 8)
3751                          (ashift:DI (match_dup 3) (const_int 3))))]
3752   ""
3753   "")
3754
3755 (define_expand "unaligned_loadhi"
3756   [(set (match_operand:DI 2 "register_operand" "")
3757         (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
3758                         (const_int -8))))
3759    (set (match_operand:DI 3 "register_operand" "")
3760         (match_dup 1))
3761    (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
3762         (zero_extract:DI (match_dup 2)
3763                          (const_int 16)
3764                          (ashift:DI (match_dup 3) (const_int 3))))]
3765   ""
3766   "")
3767
3768 ;; Storing an aligned byte or word requires two temporaries.  Operand 0 is the
3769 ;; aligned SImode MEM.  Operand 1 is the register containing the 
3770 ;; byte or word to store.  Operand 2 is the number of bits within the word that
3771 ;; the value should be placed.  Operands 3 and 4 are SImode temporaries.
3772
3773 (define_expand "aligned_store"
3774   [(set (match_operand:SI 3 "register_operand" "")
3775         (match_operand:SI 0 "memory_operand" ""))
3776    (set (subreg:DI (match_dup 3) 0)
3777         (and:DI (subreg:DI (match_dup 3) 0) (match_dup 5)))
3778    (set (subreg:DI (match_operand:SI 4 "register_operand" "") 0)
3779         (ashift:DI (zero_extend:DI (match_operand 1 "register_operand" ""))
3780                    (match_operand:DI 2 "const_int_operand" "")))
3781    (set (subreg:DI (match_dup 4) 0)
3782         (ior:DI (subreg:DI (match_dup 4) 0) (subreg:DI (match_dup 3) 0)))
3783    (set (match_dup 0) (match_dup 4))]
3784   ""
3785   "
3786 { operands[5] = GEN_INT (~ (GET_MODE_MASK (GET_MODE (operands[1]))
3787                             << INTVAL (operands[2])));
3788 }")
3789
3790 ;; For the unaligned byte and halfword cases, we use code similar to that
3791 ;; in the ;; Architecture book, but reordered to lower the number of registers
3792 ;; required.  Operand 0 is the address.  Operand 1 is the data to store.
3793 ;; Operands 2, 3, and 4 are DImode temporaries, where operands 2 and 4 may
3794 ;; be the same temporary, if desired.  If the address is in a register,
3795 ;; operand 2 can be that register.
3796
3797 (define_expand "unaligned_storeqi"
3798   [(set (match_operand:DI 3 "register_operand" "")
3799         (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
3800                         (const_int -8))))
3801    (set (match_operand:DI 2 "register_operand" "")
3802         (match_dup 0))
3803    (set (match_dup 3)
3804         (and:DI (not:DI (ashift:DI (const_int 255)
3805                                    (ashift:DI (match_dup 2) (const_int 3))))
3806                 (match_dup 3)))
3807    (set (match_operand:DI 4 "register_operand" "")
3808         (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" ""))
3809                    (ashift:DI (match_dup 2) (const_int 3))))
3810    (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
3811    (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
3812         (match_dup 4))]
3813   ""
3814   "")
3815
3816 (define_expand "unaligned_storehi"
3817   [(set (match_operand:DI 3 "register_operand" "")
3818         (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
3819                         (const_int -8))))
3820    (set (match_operand:DI 2 "register_operand" "")
3821         (match_dup 0))
3822    (set (match_dup 3)
3823         (and:DI (not:DI (ashift:DI (const_int 65535)
3824                                    (ashift:DI (match_dup 2) (const_int 3))))
3825                 (match_dup 3)))
3826    (set (match_operand:DI 4 "register_operand" "")
3827         (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" ""))
3828                    (ashift:DI (match_dup 2) (const_int 3))))
3829    (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
3830    (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
3831         (match_dup 4))]
3832   ""
3833   "")
3834 \f
3835 ;; Here are the define_expand's for QI and HI moves that use the above
3836 ;; patterns.  We have the normal sets, plus the ones that need scratch
3837 ;; registers for reload.
3838
3839 (define_expand "movqi"
3840   [(set (match_operand:QI 0 "general_operand" "")
3841         (match_operand:QI 1 "general_operand" ""))]
3842   ""
3843   "
3844 { extern rtx get_unaligned_address ();
3845
3846   /* If the output is not a register, the input must be.  */
3847   if (GET_CODE (operands[0]) == MEM)
3848     operands[1] = force_reg (QImode, operands[1]);
3849
3850   /* Handle four memory cases, unaligned and aligned for either the input
3851      or the output.  The only case where we can be called during reload is
3852      for aligned loads; all other cases require temporaries.  */
3853
3854   if (GET_CODE (operands[1]) == MEM
3855       || (GET_CODE (operands[1]) == SUBREG
3856           && GET_CODE (SUBREG_REG (operands[1])) == MEM)
3857       || (reload_in_progress && GET_CODE (operands[1]) == REG
3858           && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER)
3859       || (reload_in_progress && GET_CODE (operands[1]) == SUBREG
3860           && GET_CODE (SUBREG_REG (operands[1])) == REG
3861           && REGNO (SUBREG_REG (operands[1])) >= FIRST_PSEUDO_REGISTER))
3862     {
3863       if (aligned_memory_operand (operands[1], QImode))
3864         {
3865           rtx aligned_mem, bitnum;
3866           rtx scratch = (reload_in_progress
3867                          ? gen_rtx (REG, SImode, REGNO (operands[0]))
3868                          : gen_reg_rtx (SImode));
3869
3870           get_aligned_mem (operands[1], &aligned_mem, &bitnum);
3871
3872           emit_insn (gen_aligned_loadqi (operands[0], aligned_mem, bitnum,
3873                                          scratch));
3874         }
3875       else
3876         {
3877           /* Don't pass these as parameters since that makes the generated
3878              code depend on parameter evaluation order which will cause
3879              bootstrap failures.  */
3880
3881           rtx temp1 = gen_reg_rtx (DImode);
3882           rtx temp2 = gen_reg_rtx (DImode);
3883           rtx seq
3884             = gen_unaligned_loadqi (operands[0],
3885                                     get_unaligned_address (operands[1], 0),
3886                                     temp1, temp2);
3887
3888           alpha_set_memflags (seq, operands[1]);
3889           emit_insn (seq);
3890         }
3891
3892       DONE;
3893     }
3894
3895   else if (GET_CODE (operands[0]) == MEM
3896            || (GET_CODE (operands[0]) == SUBREG 
3897                && GET_CODE (SUBREG_REG (operands[0])) == MEM)
3898            || (reload_in_progress && GET_CODE (operands[0]) == REG
3899                && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER)
3900            || (reload_in_progress && GET_CODE (operands[0]) == SUBREG
3901                && GET_CODE (SUBREG_REG (operands[0])) == REG
3902                && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER))
3903     {
3904       if (aligned_memory_operand (operands[0], QImode))
3905         {
3906           rtx aligned_mem, bitnum;
3907           rtx temp1 = gen_reg_rtx (SImode);
3908           rtx temp2 = gen_reg_rtx (SImode);
3909
3910           get_aligned_mem (operands[0], &aligned_mem, &bitnum);
3911
3912           emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
3913                                         temp1, temp2));
3914         }
3915       else
3916         {
3917           rtx temp1 = gen_reg_rtx (DImode);
3918           rtx temp2 = gen_reg_rtx (DImode);
3919           rtx temp3 = gen_reg_rtx (DImode);
3920           rtx seq
3921             = gen_unaligned_storeqi (get_unaligned_address (operands[0], 0),
3922                                            operands[1], temp1, temp2, temp3);
3923
3924           alpha_set_memflags (seq, operands[0]);
3925           emit_insn (seq);
3926         }
3927       DONE;
3928     }
3929 }")
3930
3931 (define_expand "movhi"
3932   [(set (match_operand:HI 0 "general_operand" "")
3933         (match_operand:HI 1 "general_operand" ""))]
3934   ""
3935   "
3936 { extern rtx get_unaligned_address ();
3937
3938   /* If the output is not a register, the input must be.  */
3939   if (GET_CODE (operands[0]) == MEM)
3940     operands[1] = force_reg (HImode, operands[1]);
3941
3942   /* Handle four memory cases, unaligned and aligned for either the input
3943      or the output.  The only case where we can be called during reload is
3944      for aligned loads; all other cases require temporaries.  */
3945
3946   if (GET_CODE (operands[1]) == MEM
3947       || (GET_CODE (operands[1]) == SUBREG
3948           && GET_CODE (SUBREG_REG (operands[1])) == MEM)
3949       || (reload_in_progress && GET_CODE (operands[1]) == REG
3950           && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER)
3951       || (reload_in_progress && GET_CODE (operands[1]) == SUBREG
3952           && GET_CODE (SUBREG_REG (operands[1])) == REG
3953           && REGNO (SUBREG_REG (operands[1])) >= FIRST_PSEUDO_REGISTER))
3954     {
3955       if (aligned_memory_operand (operands[1], HImode))
3956         {
3957           rtx aligned_mem, bitnum;
3958           rtx scratch = (reload_in_progress
3959                          ? gen_rtx (REG, SImode, REGNO (operands[0]))
3960                          : gen_reg_rtx (SImode));
3961
3962           get_aligned_mem (operands[1], &aligned_mem, &bitnum);
3963
3964           emit_insn (gen_aligned_loadhi (operands[0], aligned_mem, bitnum,
3965                                          scratch));
3966         }
3967       else
3968         {
3969           /* Don't pass these as parameters since that makes the generated
3970              code depend on parameter evaluation order which will cause
3971              bootstrap failures.  */
3972
3973           rtx temp1 = gen_reg_rtx (DImode);
3974           rtx temp2 = gen_reg_rtx (DImode);
3975           rtx seq
3976             = gen_unaligned_loadhi (operands[0],
3977                                     get_unaligned_address (operands[1], 0),
3978                                     temp1, temp2);
3979
3980           alpha_set_memflags (seq, operands[1]);
3981           emit_insn (seq);
3982         }
3983
3984       DONE;
3985     }
3986
3987   else if (GET_CODE (operands[0]) == MEM
3988            || (GET_CODE (operands[0]) == SUBREG 
3989                && GET_CODE (SUBREG_REG (operands[0])) == MEM)
3990            || (reload_in_progress && GET_CODE (operands[0]) == REG
3991                && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER)
3992            || (reload_in_progress && GET_CODE (operands[0]) == SUBREG
3993                && GET_CODE (SUBREG_REG (operands[0])) == REG
3994                && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER))
3995     {
3996       if (aligned_memory_operand (operands[0], HImode))
3997         {
3998           rtx aligned_mem, bitnum;
3999           rtx temp1 = gen_reg_rtx (SImode);
4000           rtx temp2 = gen_reg_rtx (SImode);
4001
4002           get_aligned_mem (operands[0], &aligned_mem, &bitnum);
4003
4004           emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
4005                                         temp1, temp2));
4006         }
4007       else
4008         {
4009           rtx temp1 = gen_reg_rtx (DImode);
4010           rtx temp2 = gen_reg_rtx (DImode);
4011           rtx temp3 = gen_reg_rtx (DImode);
4012           rtx seq
4013             = gen_unaligned_storehi (get_unaligned_address (operands[0], 0),
4014                                      operands[1], temp1, temp2, temp3);
4015
4016           alpha_set_memflags (seq, operands[0]);
4017           emit_insn (seq);
4018         }
4019
4020       DONE;
4021     }
4022 }")
4023
4024 ;; Here are the versions for reload.  Note that in the unaligned cases
4025 ;; we know that the operand must not be a pseudo-register because stack
4026 ;; slots are always aligned references.
4027
4028 (define_expand "reload_inqi"
4029   [(parallel [(match_operand:QI 0 "register_operand" "=r")
4030               (match_operand:QI 1 "unaligned_memory_operand" "m")
4031               (match_operand:TI 2 "register_operand" "=&r")])]
4032   ""
4033   "
4034 { extern rtx get_unaligned_address ();
4035   rtx addr = get_unaligned_address (operands[1], 0);
4036   /* It is possible that one of the registers we got for operands[2]
4037      might coincide with that of operands[0] (which is why we made
4038      it TImode).  Pick the other one to use as our scratch.  */
4039   rtx scratch = gen_rtx (REG, DImode,
4040                          REGNO (operands[0]) == REGNO (operands[2]) 
4041                          ? REGNO (operands[2]) + 1 : REGNO (operands[2]));
4042   rtx seq = gen_unaligned_loadqi (operands[0], addr, scratch,
4043                                   gen_rtx (REG, DImode, REGNO (operands[0])));
4044
4045   alpha_set_memflags (seq, operands[1]);
4046   emit_insn (seq);
4047   DONE;
4048 }")
4049
4050 (define_expand "reload_inhi"
4051   [(parallel [(match_operand:HI 0 "register_operand" "=r")
4052               (match_operand:HI 1 "unaligned_memory_operand" "m")
4053               (match_operand:TI 2 "register_operand" "=&r")])]
4054   ""
4055   "
4056 { extern rtx get_unaligned_address ();
4057   rtx addr = get_unaligned_address (operands[1], 0);
4058   /* It is possible that one of the registers we got for operands[2]
4059      might coincide with that of operands[0] (which is why we made
4060      it TImode).  Pick the other one to use as our scratch.  */
4061   rtx scratch = gen_rtx (REG, DImode,
4062                          REGNO (operands[0]) == REGNO (operands[2]) 
4063                          ? REGNO (operands[2]) + 1 : REGNO (operands[2]));
4064   rtx seq = gen_unaligned_loadhi (operands[0], addr, scratch,
4065                                   gen_rtx (REG, DImode, REGNO (operands[0])));
4066
4067   alpha_set_memflags (seq, operands[1]);
4068   emit_insn (seq);
4069   DONE;
4070 }")
4071
4072 (define_expand "reload_outqi"
4073   [(parallel [(match_operand:QI 0 "any_memory_operand" "=m")
4074               (match_operand:QI 1 "register_operand" "r")
4075               (match_operand:TI 2 "register_operand" "=&r")])]
4076   ""
4077   "
4078 { extern rtx get_unaligned_address ();
4079
4080   if (aligned_memory_operand (operands[0], QImode))
4081     {
4082       rtx aligned_mem, bitnum;
4083
4084       get_aligned_mem (operands[0], &aligned_mem, &bitnum);
4085
4086       emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
4087                                     gen_rtx (REG, SImode, REGNO (operands[2])),
4088                                     gen_rtx (REG, SImode,
4089                                              REGNO (operands[2]) + 1)));
4090     }
4091   else
4092     {
4093       rtx addr = get_unaligned_address (operands[0], 0);
4094       rtx scratch1 = gen_rtx (REG, DImode, REGNO (operands[2]));
4095       rtx scratch2 = gen_rtx (REG, DImode, REGNO (operands[2]) + 1);
4096       rtx scratch3 = scratch1;
4097       rtx seq;
4098
4099       if (GET_CODE (addr) == REG)
4100         scratch1 = addr;
4101
4102       seq = gen_unaligned_storeqi (addr, operands[1], scratch1,
4103                                    scratch2, scratch3);
4104       alpha_set_memflags (seq, operands[0]);
4105       emit_insn (seq);
4106     }
4107
4108   DONE;
4109 }")
4110
4111 (define_expand "reload_outhi"
4112   [(parallel [(match_operand:HI 0 "any_memory_operand" "=m")
4113               (match_operand:HI 1 "register_operand" "r")
4114               (match_operand:TI 2 "register_operand" "=&r")])]
4115   ""
4116   "
4117 { extern rtx get_unaligned_address ();
4118
4119   if (aligned_memory_operand (operands[0], HImode))
4120     {
4121       rtx aligned_mem, bitnum;
4122
4123       get_aligned_mem (operands[0], &aligned_mem, &bitnum);
4124
4125       emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
4126                                     gen_rtx (REG, SImode, REGNO (operands[2])),
4127                                     gen_rtx (REG, SImode,
4128                                              REGNO (operands[2]) + 1)));
4129     }
4130   else
4131     {
4132       rtx addr = get_unaligned_address (operands[0], 0);
4133       rtx scratch1 = gen_rtx (REG, DImode, REGNO (operands[2]));
4134       rtx scratch2 = gen_rtx (REG, DImode, REGNO (operands[2]) + 1);
4135       rtx scratch3 = scratch1;
4136       rtx seq;
4137
4138       if (GET_CODE (addr) == REG)
4139         scratch1 = addr;
4140
4141       seq = gen_unaligned_storehi (addr, operands[1], scratch1,
4142                                    scratch2, scratch3);
4143       alpha_set_memflags (seq, operands[0]);
4144       emit_insn (seq);
4145     }
4146
4147   DONE;
4148 }")
4149 \f
4150 ;; Subroutine of stack space allocation.  Perform a stack probe.
4151 (define_expand "probe_stack"
4152   [(set (match_dup 1) (match_operand:DI 0 "const_int_operand" ""))]
4153   ""
4154   "
4155 {
4156   operands[1] = gen_rtx (MEM, DImode, plus_constant (stack_pointer_rtx,
4157                                                      INTVAL (operands[0])));
4158   MEM_VOLATILE_P (operands[1]) = 1;
4159
4160   operands[0] = const0_rtx;
4161 }")
4162
4163 ;; This is how we allocate stack space.  If we are allocating a
4164 ;; constant amount of space and we know it is less than 4096
4165 ;; bytes, we need do nothing.
4166 ;;
4167 ;; If it is more than 4096 bytes, we need to probe the stack
4168 ;; periodically. 
4169 (define_expand "allocate_stack"
4170   [(set (reg:DI 30)
4171         (plus:DI (reg:DI 30)
4172                  (match_operand:DI 0 "reg_or_cint_operand" "")))]
4173   ""
4174   "
4175 {
4176   if (GET_CODE (operands[0]) == CONST_INT
4177            && INTVAL (operands[0]) < 32768)
4178     {
4179       if (INTVAL (operands[0]) >= 4096)
4180         {
4181           /* We do this the same way as in the prologue and generate explicit
4182              probes.  Then we update the stack by the constant.  */
4183
4184           int probed = 4096;
4185
4186           emit_insn (gen_probe_stack (GEN_INT (- probed)));
4187           while (probed + 8192 < INTVAL (operands[0]))
4188             emit_insn (gen_probe_stack (GEN_INT (- (probed += 8192))));
4189
4190           if (probed + 4096 < INTVAL (operands[0]))
4191             emit_insn (gen_probe_stack (GEN_INT (- INTVAL(operands[0]))));
4192         }
4193
4194       operands[0] = GEN_INT (- INTVAL (operands[0]));
4195     }
4196   else
4197     {
4198       rtx out_label = 0;
4199       rtx loop_label = gen_label_rtx ();
4200       rtx want = gen_reg_rtx (Pmode);
4201       rtx tmp = gen_reg_rtx (Pmode);
4202       rtx memref;
4203
4204       emit_insn (gen_subdi3 (want, stack_pointer_rtx,
4205                              force_reg (Pmode, operands[0])));
4206       emit_insn (gen_adddi3 (tmp, stack_pointer_rtx, GEN_INT (-4096)));
4207
4208       if (GET_CODE (operands[0]) != CONST_INT)
4209         {
4210           out_label = gen_label_rtx ();
4211           emit_insn (gen_cmpdi (want, tmp));
4212           emit_jump_insn (gen_bgeu (out_label));
4213         }
4214
4215       emit_label (loop_label);
4216       memref = gen_rtx (MEM, DImode, tmp);
4217       MEM_VOLATILE_P (memref) = 1;
4218       emit_move_insn (memref, const0_rtx);
4219       emit_insn (gen_adddi3 (tmp, tmp, GEN_INT(-8192)));
4220       emit_insn (gen_cmpdi (tmp, want));
4221       emit_jump_insn (gen_bgtu (loop_label));
4222       memref = gen_rtx (MEM, DImode, want);
4223       MEM_VOLATILE_P (memref) = 1;
4224       emit_move_insn (memref, const0_rtx);
4225
4226       if (out_label)
4227         emit_label (out_label);
4228
4229       emit_move_insn (stack_pointer_rtx, want);
4230
4231       DONE;
4232     }
4233 }")