OSDN Git Service

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