1 ;; Machine description for DEC Alpha for GNU C compiler
2 ;; Copyright (C) 1992, 93-98, 1999 Free Software Foundation, Inc.
3 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
5 ;; This file is part of GNU CC.
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)
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.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU CC; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
22 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
24 ;; Uses of UNSPEC in this file:
37 ;; 2 builtin_setjmp_receiver
40 ;; 5 prologue_stack_probe_loop
42 ;; 7 exception_receiver
44 ;; Processor type -- this attribute must exactly match the processor_type
45 ;; enumeration in alpha.h.
47 (define_attr "cpu" "ev4,ev5,ev6"
48 (const (symbol_ref "alpha_cpu")))
50 ;; Define an insn type attribute. This is used in function unit delay
51 ;; computations, among other purposes. For the most part, we use the names
52 ;; defined in the EV4 documentation, but add a few that we have to know about
56 "ild,fld,ldsym,ist,fst,ibr,fbr,jsr,iadd,ilog,shift,icmov,fcmov,icmp,imul,fadd,fmul,fcpys,fdiv,fsqrt,misc,mvi,ftoi,itof,multi"
57 (const_string "iadd"))
59 ;; Describe a user's asm statement.
60 (define_asm_attributes
61 [(set_attr "type" "multi")])
63 ;; Define the operand size an insn operates on. Used primarily by mul
64 ;; and div operations that have size dependant timings.
66 (define_attr "opsize" "si,di,udi" (const_string "di"))
68 ;; The TRAP_TYPE attribute marks instructions that may generate traps
69 ;; (which are imprecise and may need a trapb if software completion
72 (define_attr "trap" "no,yes" (const_string "no"))
74 ;; The length of an instruction sequence in bytes.
76 (define_attr "length" "" (const_int 4))
78 ;; On EV4 there are two classes of resources to consider: resources needed
79 ;; to issue, and resources needed to execute. IBUS[01] are in the first
80 ;; category. ABOX, BBOX, EBOX, FBOX, IMUL & FDIV make up the second.
81 ;; (There are a few other register-like resources, but ...)
83 ; First, describe all of the issue constraints with single cycle delays.
84 ; All insns need a bus, but all except loads require one or the other.
85 (define_function_unit "ev4_ibus0" 1 0
86 (and (eq_attr "cpu" "ev4")
87 (eq_attr "type" "fst,fbr,iadd,imul,ilog,shift,icmov,icmp"))
90 (define_function_unit "ev4_ibus1" 1 0
91 (and (eq_attr "cpu" "ev4")
92 (eq_attr "type" "ist,ibr,jsr,fadd,fcmov,fcpys,fmul,fdiv,misc"))
95 ; Memory delivers its result in three cycles. Actually return one and
96 ; take care of this in adjust_cost, since we want to handle user-defined
98 (define_function_unit "ev4_abox" 1 0
99 (and (eq_attr "cpu" "ev4")
100 (eq_attr "type" "ild,fld,ldsym,ist,fst"))
103 ; Branches have no delay cost, but do tie up the unit for two cycles.
104 (define_function_unit "ev4_bbox" 1 1
105 (and (eq_attr "cpu" "ev4")
106 (eq_attr "type" "ibr,fbr,jsr"))
109 ; Arithmetic insns are normally have their results available after
110 ; two cycles. There are a number of exceptions. They are encoded in
111 ; ADJUST_COST. Some of the other insns have similar exceptions.
112 (define_function_unit "ev4_ebox" 1 0
113 (and (eq_attr "cpu" "ev4")
114 (eq_attr "type" "iadd,ilog,shift,icmov,icmp,misc"))
117 (define_function_unit "imul" 1 0
118 (and (eq_attr "cpu" "ev4")
119 (and (eq_attr "type" "imul")
120 (eq_attr "opsize" "si")))
123 (define_function_unit "imul" 1 0
124 (and (eq_attr "cpu" "ev4")
125 (and (eq_attr "type" "imul")
126 (eq_attr "opsize" "!si")))
129 (define_function_unit "ev4_fbox" 1 0
130 (and (eq_attr "cpu" "ev4")
131 (eq_attr "type" "fadd,fmul,fcpys,fcmov"))
134 (define_function_unit "fdiv" 1 0
135 (and (eq_attr "cpu" "ev4")
136 (and (eq_attr "type" "fdiv")
137 (eq_attr "opsize" "si")))
140 (define_function_unit "fdiv" 1 0
141 (and (eq_attr "cpu" "ev4")
142 (and (eq_attr "type" "fdiv")
143 (eq_attr "opsize" "di")))
146 ;; EV5 scheduling. EV5 can issue 4 insns per clock.
148 ;; EV5 has two asymetric integer units. Model this with E0 & E1 along
149 ;; with the combined resource EBOX.
151 (define_function_unit "ev5_ebox" 2 0
152 (and (eq_attr "cpu" "ev5")
153 (eq_attr "type" "!fbr,fcmov,fadd,fmul,fcpys,fdiv"))
156 ; Memory takes at least 2 clocks. Return one from here and fix up with
157 ; user-defined latencies in adjust_cost.
158 ; ??? How to: "An instruction of class LD cannot be issued in the _second_
159 ; cycle after an instruction of class ST is issued."
160 (define_function_unit "ev5_ebox" 2 0
161 (and (eq_attr "cpu" "ev5")
162 (eq_attr "type" "ild,fld,ldsym"))
165 ; Stores, shifts, multiplies can only issue to E0
166 (define_function_unit "ev5_e0" 1 0
167 (and (eq_attr "cpu" "ev5")
168 (eq_attr "type" "ist,fst,shift,imul"))
171 ; Motion video insns also issue only to E0, and take two ticks.
172 (define_function_unit "ev5_e0" 1 0
173 (and (eq_attr "cpu" "ev5")
174 (eq_attr "type" "mvi"))
177 ; Conditional moves always take 2 ticks.
178 (define_function_unit "ev5_ebox" 2 0
179 (and (eq_attr "cpu" "ev5")
180 (eq_attr "type" "icmov"))
183 ; Branches can only issue to E1
184 (define_function_unit "ev5_e1" 1 0
185 (and (eq_attr "cpu" "ev5")
186 (eq_attr "type" "ibr,jsr"))
189 ; Multiplies also use the integer multiplier.
190 ; ??? How to: "No instruction can be issued to pipe E0 exactly two
191 ; cycles before an integer multiplication completes."
192 (define_function_unit "imul" 1 0
193 (and (eq_attr "cpu" "ev5")
194 (and (eq_attr "type" "imul")
195 (eq_attr "opsize" "si")))
198 (define_function_unit "imul" 1 0
199 (and (eq_attr "cpu" "ev5")
200 (and (eq_attr "type" "imul")
201 (eq_attr "opsize" "di")))
204 (define_function_unit "imul" 1 0
205 (and (eq_attr "cpu" "ev5")
206 (and (eq_attr "type" "imul")
207 (eq_attr "opsize" "udi")))
210 ;; Similarly for the FPU we have two asymetric units. But fcpys can issue
211 ;; on either so we have to play the game again.
213 (define_function_unit "ev5_fbox" 2 0
214 (and (eq_attr "cpu" "ev5")
215 (eq_attr "type" "fadd,fcmov,fmul,fcpys,fbr,fdiv"))
218 (define_function_unit "ev5_fm" 1 0
219 (and (eq_attr "cpu" "ev5")
220 (eq_attr "type" "fmul"))
223 ; Add and cmov as you would expect; fbr never produces a result;
224 ; fdiv issues through fa to the divider,
225 (define_function_unit "ev5_fa" 1 0
226 (and (eq_attr "cpu" "ev5")
227 (eq_attr "type" "fadd,fcmov,fbr,fdiv"))
230 ; ??? How to: "No instruction can be issued to pipe FA exactly five
231 ; cycles before a floating point divide completes."
232 (define_function_unit "fdiv" 1 0
233 (and (eq_attr "cpu" "ev5")
234 (and (eq_attr "type" "fdiv")
235 (eq_attr "opsize" "si")))
236 15 15) ; 15 to 31 data dependant
238 (define_function_unit "fdiv" 1 0
239 (and (eq_attr "cpu" "ev5")
240 (and (eq_attr "type" "fdiv")
241 (eq_attr "opsize" "di")))
242 22 22) ; 22 to 60 data dependant
244 ;; EV6 scheduling. EV6 can issue 4 insns per clock.
246 ;; EV6 has two symmetric pairs ("clusters") of two asymetric integer units
247 ;; ("upper" and "lower"), yielding pipe names U0, U1, L0, L1.
249 ;; Conditional moves decompose into two independant primitives, each
250 ;; taking one cycle. Since ev6 is out-of-order, we can't see anything
252 (define_function_unit "ev6_ebox" 4 0
253 (and (eq_attr "cpu" "ev6")
254 (eq_attr "type" "icmov"))
257 (define_function_unit "ev6_ebox" 4 0
258 (and (eq_attr "cpu" "ev6")
259 (eq_attr "type" "!fbr,fcmov,fadd,fmul,fcpys,fdiv,fsqrt"))
262 ;; Integer loads take at least 3 clocks, and only issue to lower units.
263 ;; Return one from here and fix up with user-defined latencies in adjust_cost.
264 (define_function_unit "ev6_l" 2 0
265 (and (eq_attr "cpu" "ev6")
266 (eq_attr "type" "ild,ldsym,ist,fst"))
269 ;; FP loads take at least 4 clocks. Return two from here...
270 (define_function_unit "ev6_l" 2 0
271 (and (eq_attr "cpu" "ev6")
272 (eq_attr "type" "fld"))
275 ;; Motion video insns also issue only to U0, and take three ticks.
276 (define_function_unit "ev6_u0" 1 0
277 (and (eq_attr "cpu" "ev6")
278 (eq_attr "type" "mvi"))
281 (define_function_unit "ev6_u" 2 0
282 (and (eq_attr "cpu" "ev6")
283 (eq_attr "type" "mvi"))
286 ;; Shifts issue to either upper pipe.
287 (define_function_unit "ev6_u" 2 0
288 (and (eq_attr "cpu" "ev6")
289 (eq_attr "type" "shift"))
292 ;; Multiplies issue only to U1, and all take 7 ticks.
293 ;; Rather than create a new function unit just for U1, reuse IMUL
294 (define_function_unit "imul" 1 0
295 (and (eq_attr "cpu" "ev6")
296 (eq_attr "type" "imul"))
299 (define_function_unit "ev6_u" 2 0
300 (and (eq_attr "cpu" "ev6")
301 (eq_attr "type" "imul"))
304 ;; Branches issue to either upper pipe
305 (define_function_unit "ev6_u" 2 0
306 (and (eq_attr "cpu" "ev6")
307 (eq_attr "type" "ibr"))
310 ;; Calls only issue to L0.
311 (define_function_unit "ev6_l0" 1 0
312 (and (eq_attr "cpu" "ev6")
313 (eq_attr "type" "jsr"))
316 (define_function_unit "ev6_l" 2 0
317 (and (eq_attr "cpu" "ev6")
318 (eq_attr "type" "jsr"))
321 ;; Ftoi/itof only issue to lower pipes
322 (define_function_unit "ev6_l" 2 0
323 (and (eq_attr "cpu" "ev6")
324 (eq_attr "type" "ftoi"))
327 (define_function_unit "ev6_l" 2 0
328 (and (eq_attr "cpu" "ev6")
329 (eq_attr "type" "itof"))
332 ;; For the FPU we are very similar to EV5, except there's no insn that
333 ;; can issue to fm & fa, so we get to leave that out.
335 (define_function_unit "ev6_fm" 1 0
336 (and (eq_attr "cpu" "ev6")
337 (eq_attr "type" "fmul"))
340 (define_function_unit "ev6_fa" 1 0
341 (and (eq_attr "cpu" "ev6")
342 (eq_attr "type" "fadd,fcpys,fbr,fdiv,fsqrt"))
345 (define_function_unit "ev6_fa" 1 0
346 (and (eq_attr "cpu" "ev6")
347 (eq_attr "type" "fcmov"))
350 (define_function_unit "fdiv" 1 0
351 (and (eq_attr "cpu" "ev6")
352 (and (eq_attr "type" "fdiv")
353 (eq_attr "opsize" "si")))
356 (define_function_unit "fdiv" 1 0
357 (and (eq_attr "cpu" "ev6")
358 (and (eq_attr "type" "fdiv")
359 (eq_attr "opsize" "di")))
362 (define_function_unit "fsqrt" 1 0
363 (and (eq_attr "cpu" "ev6")
364 (and (eq_attr "type" "fsqrt")
365 (eq_attr "opsize" "si")))
368 (define_function_unit "fsqrt" 1 0
369 (and (eq_attr "cpu" "ev6")
370 (and (eq_attr "type" "fsqrt")
371 (eq_attr "opsize" "di")))
374 ; ??? The FPU communicates with memory and the integer register file
375 ; via two fp store units. We need a slot in the fst immediately, and
376 ; a slot in LOW after the operand data is ready. At which point the
377 ; data may be moved either to the store queue or the integer register
378 ; file and the insn retired.
381 ;; First define the arithmetic insns. Note that the 32-bit forms also
384 ;; Handle 32-64 bit extension from memory to a floating point register
385 ;; specially, since this ocurrs frequently in int->double conversions.
386 ;; This is done with a define_split after reload converting the plain
387 ;; sign-extension into a load+unspec, which of course results in lds+cvtlq.
389 ;; Note that while we must retain the =f case in the insn for reload's
390 ;; benefit, it should be eliminated after reload, so we should never emit
391 ;; code for that case. But we don't reject the possibility.
393 (define_insn "extendsidi2"
394 [(set (match_operand:DI 0 "register_operand" "=r,r,?f")
395 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "r,m,m")))]
400 lds %0,%1\;cvtlq %0,%0"
401 [(set_attr "type" "iadd,ild,fld")
402 (set_attr "length" "*,*,8")])
404 ;; Due to issues with CLASS_CANNOT_CHANGE_SIZE, we cannot use a subreg here.
406 [(set (match_operand:DI 0 "hard_fp_register_operand" "")
407 (sign_extend:DI (match_operand:SI 1 "memory_operand" "")))]
409 [(set (match_dup 2) (match_dup 1))
410 (set (match_dup 0) (unspec:DI [(match_dup 2)] 4))]
411 "operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]));")
414 [(set (match_operand:DI 0 "register_operand" "=f")
415 (unspec:DI [(match_operand:SI 1 "register_operand" "f")] 4))]
418 [(set_attr "type" "fadd")])
420 ;; Do addsi3 the way expand_binop would do if we didn't have one. This
421 ;; generates better code. We have the anonymous addsi3 pattern below in
422 ;; case combine wants to make it.
423 (define_expand "addsi3"
424 [(set (match_operand:SI 0 "register_operand" "")
425 (plus:SI (match_operand:SI 1 "reg_or_0_operand" "")
426 (match_operand:SI 2 "add_operand" "")))]
432 rtx op1 = gen_lowpart (DImode, operands[1]);
433 rtx op2 = gen_lowpart (DImode, operands[2]);
435 if (! cse_not_expected)
437 rtx tmp = gen_reg_rtx (DImode);
438 emit_insn (gen_adddi3 (tmp, op1, op2));
439 emit_move_insn (gen_lowpart (DImode, operands[0]), tmp);
442 emit_insn (gen_adddi3 (gen_lowpart (DImode, operands[0]), op1, op2));
448 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
449 (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ,rJ,rJ,rJ")
450 (match_operand:SI 2 "add_operand" "rI,O,K,L")))]
459 [(set (match_operand:SI 0 "register_operand" "")
460 (plus:SI (match_operand:SI 1 "register_operand" "")
461 (match_operand:SI 2 "const_int_operand" "")))]
462 "! add_operand (operands[2], SImode)"
463 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
464 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
467 HOST_WIDE_INT val = INTVAL (operands[2]);
468 HOST_WIDE_INT low = (val & 0xffff) - 2 * (val & 0x8000);
469 HOST_WIDE_INT rest = val - low;
471 operands[3] = GEN_INT (rest);
472 operands[4] = GEN_INT (low);
476 [(set (match_operand:DI 0 "register_operand" "=r,r")
478 (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ,rJ")
479 (match_operand:SI 2 "sext_add_operand" "rI,O"))))]
486 [(set (match_operand:DI 0 "register_operand" "")
488 (plus:SI (match_operand:SI 1 "register_operand" "")
489 (match_operand:SI 2 "const_int_operand" ""))))
490 (clobber (match_operand:SI 3 "reg_not_elim_operand" ""))]
491 "! sext_add_operand (operands[2], SImode) && INTVAL (operands[2]) > 0
492 && INTVAL (operands[2]) % 4 == 0"
493 [(set (match_dup 3) (match_dup 4))
494 (set (match_dup 0) (sign_extend:DI (plus:SI (mult:SI (match_dup 3)
499 HOST_WIDE_INT val = INTVAL (operands[2]) / 4;
505 operands[4] = GEN_INT (val);
506 operands[5] = GEN_INT (mult);
510 [(set (match_operand:DI 0 "register_operand" "")
512 (plus:SI (match_operator:SI 1 "comparison_operator"
513 [(match_operand 2 "" "")
514 (match_operand 3 "" "")])
515 (match_operand:SI 4 "add_operand" ""))))
516 (clobber (match_operand:DI 5 "register_operand" ""))]
518 [(set (match_dup 5) (match_dup 6))
519 (set (match_dup 0) (sign_extend:DI (plus:SI (match_dup 7) (match_dup 4))))]
522 operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[1]), DImode,
523 operands[2], operands[3]);
524 operands[7] = gen_lowpart (SImode, operands[5]);
527 (define_insn "adddi3"
528 [(set (match_operand:DI 0 "register_operand" "=r,r,r,r")
529 (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ,rJ,rJ")
530 (match_operand:DI 2 "add_operand" "rI,O,K,L")))]
538 ;; Don't do this if we are adjusting SP since we don't want to do
541 [(set (match_operand:DI 0 "register_operand" "")
542 (plus:DI (match_operand:DI 1 "register_operand" "")
543 (match_operand:DI 2 "const_int_operand" "")))]
544 "! add_operand (operands[2], DImode)
545 && REGNO (operands[0]) != STACK_POINTER_REGNUM"
546 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
547 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
550 HOST_WIDE_INT val = INTVAL (operands[2]);
551 HOST_WIDE_INT low = (val & 0xffff) - 2 * (val & 0x8000);
552 HOST_WIDE_INT rest = val - low;
554 operands[3] = GEN_INT (rest);
555 operands[4] = GEN_INT (low);
559 [(set (match_operand:SI 0 "register_operand" "=r,r")
560 (plus:SI (mult:SI (match_operand:SI 1 "reg_not_elim_operand" "r,r")
561 (match_operand:SI 2 "const48_operand" "I,I"))
562 (match_operand:SI 3 "sext_add_operand" "rI,O")))]
569 [(set (match_operand:DI 0 "register_operand" "=r,r")
571 (plus:SI (mult:SI (match_operand:SI 1 "reg_not_elim_operand" "r,r")
572 (match_operand:SI 2 "const48_operand" "I,I"))
573 (match_operand:SI 3 "sext_add_operand" "rI,O"))))]
580 [(set (match_operand:DI 0 "register_operand" "")
582 (plus:SI (mult:SI (match_operator:SI 1 "comparison_operator"
583 [(match_operand 2 "" "")
584 (match_operand 3 "" "")])
585 (match_operand:SI 4 "const48_operand" ""))
586 (match_operand:SI 5 "add_operand" ""))))
587 (clobber (match_operand:DI 6 "reg_not_elim_operand" ""))]
589 [(set (match_dup 6) (match_dup 7))
591 (sign_extend:DI (plus:SI (mult:SI (match_dup 8) (match_dup 4))
595 operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[1]), DImode,
596 operands[2], operands[3]);
597 operands[8] = gen_lowpart (SImode, operands[6]);
601 [(set (match_operand:DI 0 "register_operand" "=r,r")
602 (plus:DI (mult:DI (match_operand:DI 1 "reg_not_elim_operand" "r,r")
603 (match_operand:DI 2 "const48_operand" "I,I"))
604 (match_operand:DI 3 "sext_add_operand" "rI,O")))]
610 ;; These variants of the above insns can occur if the third operand
611 ;; is the frame pointer. This is a kludge, but there doesn't
612 ;; seem to be a way around it. Only recognize them while reloading.
615 [(set (match_operand:DI 0 "some_operand" "=&r")
616 (plus:DI (plus:DI (match_operand:DI 1 "some_operand" "r")
617 (match_operand:DI 2 "some_operand" "r"))
618 (match_operand:DI 3 "some_operand" "rIOKL")))]
623 [(set (match_operand:DI 0 "register_operand" "")
624 (plus:DI (plus:DI (match_operand:DI 1 "register_operand" "")
625 (match_operand:DI 2 "register_operand" ""))
626 (match_operand:DI 3 "add_operand" "")))]
628 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
629 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
633 [(set (match_operand:SI 0 "some_operand" "=&r")
634 (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "some_operand" "rJ")
635 (match_operand:SI 2 "const48_operand" "I"))
636 (match_operand:SI 3 "some_operand" "r"))
637 (match_operand:SI 4 "some_operand" "rIOKL")))]
642 [(set (match_operand:SI 0 "register_operand" "r")
643 (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "reg_or_0_operand" "")
644 (match_operand:SI 2 "const48_operand" ""))
645 (match_operand:SI 3 "register_operand" ""))
646 (match_operand:SI 4 "add_operand" "rIOKL")))]
649 (plus:SI (mult:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
650 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
654 [(set (match_operand:DI 0 "some_operand" "=&r")
657 (mult:SI (match_operand:SI 1 "some_operand" "rJ")
658 (match_operand:SI 2 "const48_operand" "I"))
659 (match_operand:SI 3 "some_operand" "r"))
660 (match_operand:SI 4 "some_operand" "rIOKL"))))]
665 [(set (match_operand:DI 0 "register_operand" "")
668 (mult:SI (match_operand:SI 1 "reg_or_0_operand" "")
669 (match_operand:SI 2 "const48_operand" ""))
670 (match_operand:SI 3 "register_operand" ""))
671 (match_operand:SI 4 "add_operand" ""))))]
674 (plus:SI (mult:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
675 (set (match_dup 0) (sign_extend:DI (plus:SI (match_dup 5) (match_dup 4))))]
676 "operands[5] = gen_lowpart (SImode, operands[0]);")
679 [(set (match_operand:DI 0 "some_operand" "=&r")
680 (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "some_operand" "rJ")
681 (match_operand:DI 2 "const48_operand" "I"))
682 (match_operand:DI 3 "some_operand" "r"))
683 (match_operand:DI 4 "some_operand" "rIOKL")))]
688 [(set (match_operand:DI 0 "register_operand" "=")
689 (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "reg_or_0_operand" "")
690 (match_operand:DI 2 "const48_operand" ""))
691 (match_operand:DI 3 "register_operand" ""))
692 (match_operand:DI 4 "add_operand" "")))]
695 (plus:DI (mult:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
696 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
699 (define_insn "negsi2"
700 [(set (match_operand:SI 0 "register_operand" "=r")
701 (neg:SI (match_operand:SI 1 "reg_or_8bit_operand" "rI")))]
706 [(set (match_operand:DI 0 "register_operand" "=r")
707 (sign_extend:DI (neg:SI
708 (match_operand:SI 1 "reg_or_8bit_operand" "rI"))))]
712 (define_insn "negdi2"
713 [(set (match_operand:DI 0 "register_operand" "=r")
714 (neg:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI")))]
718 (define_expand "subsi3"
719 [(set (match_operand:SI 0 "register_operand" "")
720 (minus:SI (match_operand:SI 1 "reg_or_0_operand" "")
721 (match_operand:SI 2 "reg_or_8bit_operand" "")))]
727 rtx op1 = gen_lowpart (DImode, operands[1]);
728 rtx op2 = gen_lowpart (DImode, operands[2]);
730 if (! cse_not_expected)
732 rtx tmp = gen_reg_rtx (DImode);
733 emit_insn (gen_subdi3 (tmp, op1, op2));
734 emit_move_insn (gen_lowpart (DImode, operands[0]), tmp);
737 emit_insn (gen_subdi3 (gen_lowpart (DImode, operands[0]), op1, op2));
743 [(set (match_operand:SI 0 "register_operand" "=r")
744 (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
745 (match_operand:SI 2 "reg_or_8bit_operand" "rI")))]
750 [(set (match_operand:DI 0 "register_operand" "=r")
751 (sign_extend:DI (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
752 (match_operand:SI 2 "reg_or_8bit_operand" "rI"))))]
756 (define_insn "subdi3"
757 [(set (match_operand:DI 0 "register_operand" "=r")
758 (minus:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
759 (match_operand:DI 2 "reg_or_8bit_operand" "rI")))]
764 [(set (match_operand:SI 0 "register_operand" "=r")
765 (minus:SI (mult:SI (match_operand:SI 1 "reg_not_elim_operand" "r")
766 (match_operand:SI 2 "const48_operand" "I"))
767 (match_operand:SI 3 "reg_or_8bit_operand" "rI")))]
772 [(set (match_operand:DI 0 "register_operand" "=r")
774 (minus:SI (mult:SI (match_operand:SI 1 "reg_not_elim_operand" "r")
775 (match_operand:SI 2 "const48_operand" "I"))
776 (match_operand:SI 3 "reg_or_8bit_operand" "rI"))))]
781 [(set (match_operand:DI 0 "register_operand" "=r")
782 (minus:DI (mult:DI (match_operand:DI 1 "reg_not_elim_operand" "r")
783 (match_operand:DI 2 "const48_operand" "I"))
784 (match_operand:DI 3 "reg_or_8bit_operand" "rI")))]
788 (define_insn "mulsi3"
789 [(set (match_operand:SI 0 "register_operand" "=r")
790 (mult:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
791 (match_operand:SI 2 "reg_or_8bit_operand" "rI")))]
794 [(set_attr "type" "imul")
795 (set_attr "opsize" "si")])
798 [(set (match_operand:DI 0 "register_operand" "=r")
800 (mult:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
801 (match_operand:SI 2 "reg_or_8bit_operand" "rI"))))]
804 [(set_attr "type" "imul")
805 (set_attr "opsize" "si")])
807 (define_insn "muldi3"
808 [(set (match_operand:DI 0 "register_operand" "=r")
809 (mult:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ")
810 (match_operand:DI 2 "reg_or_8bit_operand" "rI")))]
813 [(set_attr "type" "imul")])
815 (define_insn "umuldi3_highpart"
816 [(set (match_operand:DI 0 "register_operand" "=r")
819 (mult:TI (zero_extend:TI
820 (match_operand:DI 1 "reg_or_0_operand" "%rJ"))
822 (match_operand:DI 2 "reg_or_8bit_operand" "rI")))
826 [(set_attr "type" "imul")
827 (set_attr "opsize" "udi")])
830 [(set (match_operand:DI 0 "register_operand" "=r")
833 (mult:TI (zero_extend:TI (match_operand:DI 1 "register_operand" "r"))
834 (match_operand:TI 2 "cint8_operand" "I"))
838 [(set_attr "type" "imul")
839 (set_attr "opsize" "udi")])
841 ;; The divide and remainder operations always take their inputs from
842 ;; r24 and r25, put their output in r27, and clobber r23 and r28.
844 ;; ??? Force sign-extension here because some versions of OSF/1 don't
845 ;; do the right thing if the inputs are not properly sign-extended.
846 ;; But Linux, for instance, does not have this problem. Is it worth
847 ;; the complication here to eliminate the sign extension?
849 (define_expand "divsi3"
851 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))
853 (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "")))
854 (parallel [(set (reg:DI 27)
855 (sign_extend:DI (div:SI (reg:DI 24) (reg:DI 25))))
856 (clobber (reg:DI 23))
857 (clobber (reg:DI 28))])
858 (set (match_operand:SI 0 "general_operand" "")
859 (subreg:SI (reg:DI 27) 0))]
863 (define_expand "udivsi3"
865 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))
867 (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "")))
868 (parallel [(set (reg:DI 27)
869 (sign_extend:DI (udiv:SI (reg:DI 24) (reg:DI 25))))
870 (clobber (reg:DI 23))
871 (clobber (reg:DI 28))])
872 (set (match_operand:SI 0 "general_operand" "")
873 (subreg:SI (reg:DI 27) 0))]
877 (define_expand "modsi3"
879 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))
881 (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "")))
882 (parallel [(set (reg:DI 27)
883 (sign_extend:DI (mod:SI (reg:DI 24) (reg:DI 25))))
884 (clobber (reg:DI 23))
885 (clobber (reg:DI 28))])
886 (set (match_operand:SI 0 "general_operand" "")
887 (subreg:SI (reg:DI 27) 0))]
891 (define_expand "umodsi3"
893 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))
895 (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "")))
896 (parallel [(set (reg:DI 27)
897 (sign_extend:DI (umod:SI (reg:DI 24) (reg:DI 25))))
898 (clobber (reg:DI 23))
899 (clobber (reg:DI 28))])
900 (set (match_operand:SI 0 "general_operand" "")
901 (subreg:SI (reg:DI 27) 0))]
905 (define_expand "divdi3"
906 [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
907 (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
908 (parallel [(set (reg:DI 27)
911 (clobber (reg:DI 23))
912 (clobber (reg:DI 28))])
913 (set (match_operand:DI 0 "general_operand" "")
918 (define_expand "udivdi3"
919 [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
920 (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
921 (parallel [(set (reg:DI 27)
924 (clobber (reg:DI 23))
925 (clobber (reg:DI 28))])
926 (set (match_operand:DI 0 "general_operand" "")
931 (define_expand "moddi3"
932 [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
933 (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
934 (parallel [(set (reg:DI 27)
937 (clobber (reg:DI 23))
938 (clobber (reg:DI 28))])
939 (set (match_operand:DI 0 "general_operand" "")
944 (define_expand "umoddi3"
945 [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
946 (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
947 (parallel [(set (reg:DI 27)
950 (clobber (reg:DI 23))
951 (clobber (reg:DI 28))])
952 (set (match_operand:DI 0 "general_operand" "")
957 ;; Lengths of 8 for ldq $t12,__divq($gp); jsr $t9,($t12),__divq as
958 ;; expanded by the assembler.
961 (sign_extend:DI (match_operator:SI 1 "divmod_operator"
962 [(reg:DI 24) (reg:DI 25)])))
963 (clobber (reg:DI 23))
964 (clobber (reg:DI 28))]
967 [(set_attr "type" "jsr")
968 (set_attr "length" "8")])
972 (match_operator:DI 1 "divmod_operator"
973 [(reg:DI 24) (reg:DI 25)]))
974 (clobber (reg:DI 23))
975 (clobber (reg:DI 28))]
978 [(set_attr "type" "jsr")
979 (set_attr "length" "8")])
981 ;; Next are the basic logical operations. These only exist in DImode.
983 (define_insn "anddi3"
984 [(set (match_operand:DI 0 "register_operand" "=r,r,r")
985 (and:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ,rJ")
986 (match_operand:DI 2 "and_operand" "rI,N,MH")))]
992 [(set_attr "type" "ilog,ilog,shift")])
994 ;; There are times when we can split an AND into two AND insns. This occurs
995 ;; when we can first clear any bytes and then clear anything else. For
996 ;; example "I & 0xffff07" is "(I & 0xffffff) & 0xffffffffffffff07".
997 ;; Only do this when running on 64-bit host since the computations are
998 ;; too messy otherwise.
1001 [(set (match_operand:DI 0 "register_operand" "")
1002 (and:DI (match_operand:DI 1 "register_operand" "")
1003 (match_operand:DI 2 "const_int_operand" "")))]
1004 "HOST_BITS_PER_WIDE_INT == 64 && ! and_operand (operands[2], DImode)"
1005 [(set (match_dup 0) (and:DI (match_dup 1) (match_dup 3)))
1006 (set (match_dup 0) (and:DI (match_dup 0) (match_dup 4)))]
1009 unsigned HOST_WIDE_INT mask1 = INTVAL (operands[2]);
1010 unsigned HOST_WIDE_INT mask2 = mask1;
1013 /* For each byte that isn't all zeros, make it all ones. */
1014 for (i = 0; i < 64; i += 8)
1015 if ((mask1 & ((HOST_WIDE_INT) 0xff << i)) != 0)
1016 mask1 |= (HOST_WIDE_INT) 0xff << i;
1018 /* Now turn on any bits we've just turned off. */
1021 operands[3] = GEN_INT (mask1);
1022 operands[4] = GEN_INT (mask2);
1025 (define_insn "zero_extendqihi2"
1026 [(set (match_operand:HI 0 "register_operand" "=r")
1027 (zero_extend:HI (match_operand:QI 1 "register_operand" "r")))]
1030 [(set_attr "type" "ilog")])
1033 [(set (match_operand:SI 0 "register_operand" "=r,r")
1034 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
1039 [(set_attr "type" "ilog,ild")])
1042 [(set (match_operand:SI 0 "register_operand" "=r")
1043 (zero_extend:SI (match_operand:QI 1 "register_operand" "r")))]
1046 [(set_attr "type" "ilog")])
1048 (define_expand "zero_extendqisi2"
1049 [(set (match_operand:SI 0 "register_operand" "")
1050 (zero_extend:SI (match_operand:QI 1 "register_operand" "")))]
1055 [(set (match_operand:DI 0 "register_operand" "=r,r")
1056 (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
1061 [(set_attr "type" "ilog,ild")])
1064 [(set (match_operand:DI 0 "register_operand" "=r")
1065 (zero_extend:DI (match_operand:QI 1 "register_operand" "r")))]
1068 [(set_attr "type" "ilog")])
1070 (define_expand "zero_extendqidi2"
1071 [(set (match_operand:DI 0 "register_operand" "")
1072 (zero_extend:DI (match_operand:QI 1 "register_operand" "")))]
1077 [(set (match_operand:SI 0 "register_operand" "=r,r")
1078 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
1083 [(set_attr "type" "shift,ild")])
1086 [(set (match_operand:SI 0 "register_operand" "=r")
1087 (zero_extend:SI (match_operand:HI 1 "register_operand" "r")))]
1090 [(set_attr "type" "shift")])
1092 (define_expand "zero_extendhisi2"
1093 [(set (match_operand:SI 0 "register_operand" "")
1094 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
1099 [(set (match_operand:DI 0 "register_operand" "=r,r")
1100 (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
1105 [(set_attr "type" "shift,ild")])
1108 [(set (match_operand:DI 0 "register_operand" "=r")
1109 (zero_extend:DI (match_operand:HI 1 "register_operand" "r")))]
1112 [(set_attr "type" "shift")])
1114 (define_expand "zero_extendhidi2"
1115 [(set (match_operand:DI 0 "register_operand" "")
1116 (zero_extend:DI (match_operand:HI 1 "register_operand" "")))]
1120 (define_insn "zero_extendsidi2"
1121 [(set (match_operand:DI 0 "register_operand" "=r")
1122 (zero_extend:DI (match_operand:SI 1 "register_operand" "r")))]
1125 [(set_attr "type" "shift")])
1128 [(set (match_operand:DI 0 "register_operand" "=r")
1129 (and:DI (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI"))
1130 (match_operand:DI 2 "reg_or_0_operand" "rJ")))]
1133 [(set_attr "type" "ilog")])
1135 (define_insn "iordi3"
1136 [(set (match_operand:DI 0 "register_operand" "=r,r")
1137 (ior:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ")
1138 (match_operand:DI 2 "or_operand" "rI,N")))]
1143 [(set_attr "type" "ilog")])
1145 (define_insn "one_cmpldi2"
1146 [(set (match_operand:DI 0 "register_operand" "=r")
1147 (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI")))]
1150 [(set_attr "type" "ilog")])
1153 [(set (match_operand:DI 0 "register_operand" "=r")
1154 (ior:DI (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI"))
1155 (match_operand:DI 2 "reg_or_0_operand" "rJ")))]
1158 [(set_attr "type" "ilog")])
1160 (define_insn "xordi3"
1161 [(set (match_operand:DI 0 "register_operand" "=r,r")
1162 (xor:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ")
1163 (match_operand:DI 2 "or_operand" "rI,N")))]
1168 [(set_attr "type" "ilog")])
1171 [(set (match_operand:DI 0 "register_operand" "=r")
1172 (not:DI (xor:DI (match_operand:DI 1 "register_operand" "%rJ")
1173 (match_operand:DI 2 "register_operand" "rI"))))]
1176 [(set_attr "type" "ilog")])
1178 ;; Handle the FFS insn if we support CIX.
1180 (define_expand "ffsdi2"
1182 (unspec [(match_operand:DI 1 "register_operand" "")] 1))
1184 (plus:DI (match_dup 2) (const_int 1)))
1185 (set (match_operand:DI 0 "register_operand" "")
1186 (if_then_else:DI (eq (match_dup 1) (const_int 0))
1187 (const_int 0) (match_dup 3)))]
1191 operands[2] = gen_reg_rtx (DImode);
1192 operands[3] = gen_reg_rtx (DImode);
1196 [(set (match_operand:DI 0 "register_operand" "=r")
1197 (unspec [(match_operand:DI 1 "register_operand" "r")] 1))]
1200 ; ev6 calls all mvi and cttz/ctlz/popc class imisc, so just
1201 ; reuse the existing type name.
1202 [(set_attr "type" "mvi")])
1204 ;; Next come the shifts and the various extract and insert operations.
1206 (define_insn "ashldi3"
1207 [(set (match_operand:DI 0 "register_operand" "=r,r")
1208 (ashift:DI (match_operand:DI 1 "reg_or_0_operand" "rJ,rJ")
1209 (match_operand:DI 2 "reg_or_6bit_operand" "P,rS")))]
1213 switch (which_alternative)
1216 if (operands[2] == const1_rtx)
1217 return \"addq %r1,%r1,%0\";
1219 return \"s%P2addq %r1,0,%0\";
1221 return \"sll %r1,%2,%0\";
1226 [(set_attr "type" "iadd,shift")])
1228 ;; ??? The following pattern is made by combine, but earlier phases
1229 ;; (specifically flow) can't handle it. This occurs in jump.c. Deal
1230 ;; with this in a better way at some point.
1232 ;; [(set (match_operand:DI 0 "register_operand" "=r")
1234 ;; (subreg:SI (ashift:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1235 ;; (match_operand:DI 2 "const_int_operand" "P"))
1237 ;; "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3"
1240 ;; if (operands[2] == const1_rtx)
1241 ;; return \"addl %r1,%r1,%0\";
1243 ;; return \"s%P2addl %r1,0,%0\";
1245 ;; [(set_attr "type" "iadd")])
1247 (define_insn "lshrdi3"
1248 [(set (match_operand:DI 0 "register_operand" "=r")
1249 (lshiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1250 (match_operand:DI 2 "reg_or_6bit_operand" "rS")))]
1253 [(set_attr "type" "shift")])
1255 (define_insn "ashrdi3"
1256 [(set (match_operand:DI 0 "register_operand" "=r")
1257 (ashiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1258 (match_operand:DI 2 "reg_or_6bit_operand" "rS")))]
1261 [(set_attr "type" "shift")])
1263 (define_expand "extendqihi2"
1265 (ashift:DI (match_operand:QI 1 "some_operand" "")
1267 (set (match_operand:HI 0 "register_operand" "")
1268 (ashiftrt:DI (match_dup 2)
1275 emit_insn (gen_extendqihi2x (operands[0],
1276 force_reg (QImode, operands[1])));
1280 /* If we have an unaligned MEM, extend to DImode (which we do
1281 specially) and then copy to the result. */
1282 if (unaligned_memory_operand (operands[1], HImode))
1284 rtx temp = gen_reg_rtx (DImode);
1286 emit_insn (gen_extendqidi2 (temp, operands[1]));
1287 emit_move_insn (operands[0], gen_lowpart (HImode, temp));
1291 operands[0] = gen_lowpart (DImode, operands[0]);
1292 operands[1] = gen_lowpart (DImode, force_reg (QImode, operands[1]));
1293 operands[2] = gen_reg_rtx (DImode);
1296 (define_insn "extendqidi2x"
1297 [(set (match_operand:DI 0 "register_operand" "=r")
1298 (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
1301 [(set_attr "type" "shift")])
1303 (define_insn "extendhidi2x"
1304 [(set (match_operand:DI 0 "register_operand" "=r")
1305 (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
1308 [(set_attr "type" "shift")])
1310 (define_insn "extendqisi2x"
1311 [(set (match_operand:SI 0 "register_operand" "=r")
1312 (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
1315 [(set_attr "type" "shift")])
1317 (define_insn "extendhisi2x"
1318 [(set (match_operand:SI 0 "register_operand" "=r")
1319 (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
1322 [(set_attr "type" "shift")])
1324 (define_insn "extendqihi2x"
1325 [(set (match_operand:HI 0 "register_operand" "=r")
1326 (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
1329 [(set_attr "type" "shift")])
1331 (define_expand "extendqisi2"
1333 (ashift:DI (match_operand:QI 1 "some_operand" "")
1335 (set (match_operand:SI 0 "register_operand" "")
1336 (ashiftrt:DI (match_dup 2)
1343 emit_insn (gen_extendqisi2x (operands[0],
1344 force_reg (QImode, operands[1])));
1348 /* If we have an unaligned MEM, extend to a DImode form of
1349 the result (which we do specially). */
1350 if (unaligned_memory_operand (operands[1], QImode))
1352 rtx temp = gen_reg_rtx (DImode);
1354 emit_insn (gen_extendqidi2 (temp, operands[1]));
1355 emit_move_insn (operands[0], gen_lowpart (SImode, temp));
1359 operands[0] = gen_lowpart (DImode, operands[0]);
1360 operands[1] = gen_lowpart (DImode, force_reg (QImode, operands[1]));
1361 operands[2] = gen_reg_rtx (DImode);
1364 (define_expand "extendqidi2"
1366 (ashift:DI (match_operand:QI 1 "some_operand" "")
1368 (set (match_operand:DI 0 "register_operand" "")
1369 (ashiftrt:DI (match_dup 2)
1376 emit_insn (gen_extendqidi2x (operands[0],
1377 force_reg (QImode, operands[1])));
1381 if (unaligned_memory_operand (operands[1], QImode))
1384 = gen_unaligned_extendqidi (operands[0],
1385 get_unaligned_address (operands[1], 1));
1387 alpha_set_memflags (seq, operands[1]);
1392 operands[1] = gen_lowpart (DImode, force_reg (QImode, operands[1]));
1393 operands[2] = gen_reg_rtx (DImode);
1396 (define_expand "extendhisi2"
1398 (ashift:DI (match_operand:HI 1 "some_operand" "")
1400 (set (match_operand:SI 0 "register_operand" "")
1401 (ashiftrt:DI (match_dup 2)
1408 emit_insn (gen_extendhisi2x (operands[0],
1409 force_reg (HImode, operands[1])));
1413 /* If we have an unaligned MEM, extend to a DImode form of
1414 the result (which we do specially). */
1415 if (unaligned_memory_operand (operands[1], HImode))
1417 rtx temp = gen_reg_rtx (DImode);
1419 emit_insn (gen_extendhidi2 (temp, operands[1]));
1420 emit_move_insn (operands[0], gen_lowpart (SImode, temp));
1424 operands[0] = gen_lowpart (DImode, operands[0]);
1425 operands[1] = gen_lowpart (DImode, force_reg (HImode, operands[1]));
1426 operands[2] = gen_reg_rtx (DImode);
1429 (define_expand "extendhidi2"
1431 (ashift:DI (match_operand:HI 1 "some_operand" "")
1433 (set (match_operand:DI 0 "register_operand" "")
1434 (ashiftrt:DI (match_dup 2)
1441 emit_insn (gen_extendhidi2x (operands[0],
1442 force_reg (HImode, operands[1])));
1446 if (unaligned_memory_operand (operands[1], HImode))
1449 = gen_unaligned_extendhidi (operands[0],
1450 get_unaligned_address (operands[1], 2));
1452 alpha_set_memflags (seq, operands[1]);
1457 operands[1] = gen_lowpart (DImode, force_reg (HImode, operands[1]));
1458 operands[2] = gen_reg_rtx (DImode);
1461 ;; Here's how we sign extend an unaligned byte and halfword. Doing this
1462 ;; as a pattern saves one instruction. The code is similar to that for
1463 ;; the unaligned loads (see below).
1465 ;; Operand 1 is the address + 1 (+2 for HI), operand 0 is the result.
1466 (define_expand "unaligned_extendqidi"
1467 [(set (match_dup 2) (match_operand:DI 1 "address_operand" ""))
1469 (mem:DI (and:DI (plus:DI (match_dup 2) (const_int -1))
1472 (ashift:DI (match_dup 3)
1473 (minus:DI (const_int 56)
1475 (and:DI (plus:DI (match_dup 2) (const_int -1))
1478 (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
1479 (ashiftrt:DI (match_dup 4) (const_int 56)))]
1482 { operands[2] = gen_reg_rtx (DImode);
1483 operands[3] = gen_reg_rtx (DImode);
1484 operands[4] = gen_reg_rtx (DImode);
1487 (define_expand "unaligned_extendhidi"
1488 [(set (match_dup 2) (match_operand:DI 1 "address_operand" ""))
1490 (mem:DI (and:DI (plus:DI (match_dup 2) (const_int -2))
1493 (ashift:DI (match_dup 3)
1494 (minus:DI (const_int 56)
1496 (and:DI (plus:DI (match_dup 2) (const_int -1))
1499 (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
1500 (ashiftrt:DI (match_dup 4) (const_int 48)))]
1503 { operands[2] = gen_reg_rtx (DImode);
1504 operands[3] = gen_reg_rtx (DImode);
1505 operands[4] = gen_reg_rtx (DImode);
1509 [(set (match_operand:DI 0 "register_operand" "=r")
1510 (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1511 (match_operand:DI 2 "mode_width_operand" "n")
1512 (match_operand:DI 3 "mul8_operand" "I")))]
1514 "ext%M2l %r1,%s3,%0"
1515 [(set_attr "type" "shift")])
1517 (define_insn "extxl"
1518 [(set (match_operand:DI 0 "register_operand" "=r")
1519 (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1520 (match_operand:DI 2 "mode_width_operand" "n")
1521 (ashift:DI (match_operand:DI 3 "reg_or_8bit_operand" "rI")
1525 [(set_attr "type" "shift")])
1527 ;; Combine has some strange notion of preserving existing undefined behaviour
1528 ;; in shifts larger than a word size. So capture these patterns that it
1529 ;; should have turned into zero_extracts.
1532 [(set (match_operand:DI 0 "register_operand" "=r")
1533 (and (lshiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1534 (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1536 (match_operand:DI 3 "mode_mask_operand" "n")))]
1539 [(set_attr "type" "shift")])
1542 [(set (match_operand:DI 0 "register_operand" "=r")
1543 (lshiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1544 (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1548 [(set_attr "type" "shift")])
1550 (define_insn "extqh"
1551 [(set (match_operand:DI 0 "register_operand" "=r")
1553 (match_operand:DI 1 "reg_or_0_operand" "rJ")
1554 (minus:DI (const_int 56)
1557 (plus:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1563 [(set_attr "type" "shift")])
1565 (define_insn "extlh"
1566 [(set (match_operand:DI 0 "register_operand" "=r")
1568 (and:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1569 (const_int 2147483647))
1570 (minus:DI (const_int 56)
1573 (plus:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1579 [(set_attr "type" "shift")])
1581 (define_insn "extwh"
1582 [(set (match_operand:DI 0 "register_operand" "=r")
1584 (and:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
1586 (minus:DI (const_int 56)
1589 (plus:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1595 [(set_attr "type" "shift")])
1597 ;; This converts an extXl into an extXh with an appropriate adjustment
1598 ;; to the address calculation.
1601 ;; [(set (match_operand:DI 0 "register_operand" "")
1602 ;; (ashift:DI (zero_extract:DI (match_operand:DI 1 "register_operand" "")
1603 ;; (match_operand:DI 2 "mode_width_operand" "")
1604 ;; (ashift:DI (match_operand:DI 3 "" "")
1606 ;; (match_operand:DI 4 "const_int_operand" "")))
1607 ;; (clobber (match_operand:DI 5 "register_operand" ""))]
1608 ;; "INTVAL (operands[4]) == 64 - INTVAL (operands[2])"
1609 ;; [(set (match_dup 5) (match_dup 6))
1610 ;; (set (match_dup 0)
1611 ;; (ashift:DI (zero_extract:DI (match_dup 1) (match_dup 2)
1612 ;; (ashift:DI (plus:DI (match_dup 5)
1618 ;; operands[6] = plus_constant (operands[3],
1619 ;; INTVAL (operands[2]) / BITS_PER_UNIT);
1620 ;; operands[7] = GEN_INT (- INTVAL (operands[2]) / BITS_PER_UNIT);
1624 [(set (match_operand:DI 0 "register_operand" "=r")
1625 (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" "r"))
1626 (match_operand:DI 2 "mul8_operand" "I")))]
1629 [(set_attr "type" "shift")])
1632 [(set (match_operand:DI 0 "register_operand" "=r")
1633 (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" "r"))
1634 (match_operand:DI 2 "mul8_operand" "I")))]
1637 [(set_attr "type" "shift")])
1640 [(set (match_operand:DI 0 "register_operand" "=r")
1641 (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
1642 (match_operand:DI 2 "mul8_operand" "I")))]
1645 [(set_attr "type" "shift")])
1647 (define_insn "insbl"
1648 [(set (match_operand:DI 0 "register_operand" "=r")
1649 (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" "r"))
1650 (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1654 [(set_attr "type" "shift")])
1656 (define_insn "inswl"
1657 [(set (match_operand:DI 0 "register_operand" "=r")
1658 (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" "r"))
1659 (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1663 [(set_attr "type" "shift")])
1665 (define_insn "insll"
1666 [(set (match_operand:DI 0 "register_operand" "=r")
1667 (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
1668 (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1672 [(set_attr "type" "shift")])
1674 (define_insn "insql"
1675 [(set (match_operand:DI 0 "register_operand" "=r")
1676 (ashift:DI (match_operand:DI 1 "register_operand" "r")
1677 (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
1681 [(set_attr "type" "shift")])
1683 ;; Combine has this sometimes habit of moving the and outside of the
1684 ;; shift, making life more interesting.
1687 [(set (match_operand:DI 0 "register_operand" "=r")
1688 (and:DI (ashift:DI (match_operand:DI 1 "register_operand" "r")
1689 (match_operand:DI 2 "mul8_operand" "I"))
1690 (match_operand:DI 3 "immediate_operand" "i")))]
1691 "HOST_BITS_PER_WIDE_INT == 64
1692 && GET_CODE (operands[3]) == CONST_INT
1693 && (((unsigned HOST_WIDE_INT) 0xff << INTVAL (operands[2])
1694 == INTVAL (operands[3]))
1695 || ((unsigned HOST_WIDE_INT) 0xffff << INTVAL (operands[2])
1696 == INTVAL (operands[3]))
1697 || ((unsigned HOST_WIDE_INT) 0xffffffff << INTVAL (operands[2])
1698 == INTVAL (operands[3])))"
1701 #if HOST_BITS_PER_WIDE_INT == 64
1702 if ((unsigned HOST_WIDE_INT) 0xff << INTVAL (operands[2])
1703 == INTVAL (operands[3]))
1704 return \"insbl %1,%s2,%0\";
1705 if ((unsigned HOST_WIDE_INT) 0xffff << INTVAL (operands[2])
1706 == INTVAL (operands[3]))
1707 return \"inswl %1,%s2,%0\";
1708 if ((unsigned HOST_WIDE_INT) 0xffffffff << INTVAL (operands[2])
1709 == INTVAL (operands[3]))
1710 return \"insll %1,%s2,%0\";
1714 [(set_attr "type" "shift")])
1716 ;; We do not include the insXh insns because they are complex to express
1717 ;; and it does not appear that we would ever want to generate them.
1719 ;; Since we need them for block moves, though, cop out and use unspec.
1721 (define_insn "insxh"
1722 [(set (match_operand:DI 0 "register_operand" "=r")
1723 (unspec [(match_operand:DI 1 "register_operand" "r")
1724 (match_operand:DI 2 "mode_width_operand" "n")
1725 (match_operand:DI 3 "reg_or_8bit_operand" "rI")] 2))]
1728 [(set_attr "type" "shift")])
1730 (define_insn "mskxl"
1731 [(set (match_operand:DI 0 "register_operand" "=r")
1732 (and:DI (not:DI (ashift:DI
1733 (match_operand:DI 2 "mode_mask_operand" "n")
1735 (match_operand:DI 3 "reg_or_8bit_operand" "rI")
1737 (match_operand:DI 1 "reg_or_0_operand" "rJ")))]
1740 [(set_attr "type" "shift")])
1742 ;; We do not include the mskXh insns because it does not appear we would
1743 ;; ever generate one.
1745 ;; Again, we do for block moves and we use unspec again.
1747 (define_insn "mskxh"
1748 [(set (match_operand:DI 0 "register_operand" "=r")
1749 (unspec [(match_operand:DI 1 "register_operand" "r")
1750 (match_operand:DI 2 "mode_width_operand" "n")
1751 (match_operand:DI 3 "reg_or_8bit_operand" "rI")] 3))]
1754 [(set_attr "type" "shift")])
1756 ;; Floating-point operations. All the double-precision insns can extend
1757 ;; from single, so indicate that. The exception are the ones that simply
1758 ;; play with the sign bits; it's not clear what to do there.
1760 (define_insn "abssf2"
1761 [(set (match_operand:SF 0 "register_operand" "=f")
1762 (abs:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")))]
1765 [(set_attr "type" "fcpys")])
1767 (define_insn "absdf2"
1768 [(set (match_operand:DF 0 "register_operand" "=f")
1769 (abs:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
1772 [(set_attr "type" "fcpys")])
1774 (define_insn "negsf2"
1775 [(set (match_operand:SF 0 "register_operand" "=f")
1776 (neg:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")))]
1779 [(set_attr "type" "fadd")])
1781 (define_insn "negdf2"
1782 [(set (match_operand:DF 0 "register_operand" "=f")
1783 (neg:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
1786 [(set_attr "type" "fadd")])
1789 [(set (match_operand:SF 0 "register_operand" "=&f")
1790 (plus:SF (match_operand:SF 1 "reg_or_fp0_operand" "%fG")
1791 (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
1792 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
1793 "add%,%)%& %R1,%R2,%0"
1794 [(set_attr "type" "fadd")
1795 (set_attr "trap" "yes")])
1797 (define_insn "addsf3"
1798 [(set (match_operand:SF 0 "register_operand" "=f")
1799 (plus:SF (match_operand:SF 1 "reg_or_fp0_operand" "%fG")
1800 (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
1802 "add%,%)%& %R1,%R2,%0"
1803 [(set_attr "type" "fadd")
1804 (set_attr "trap" "yes")])
1807 [(set (match_operand:DF 0 "register_operand" "=&f")
1808 (plus:DF (match_operand:DF 1 "reg_or_fp0_operand" "%fG")
1809 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1810 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
1811 "add%-%)%& %R1,%R2,%0"
1812 [(set_attr "type" "fadd")
1813 (set_attr "trap" "yes")])
1815 (define_insn "adddf3"
1816 [(set (match_operand:DF 0 "register_operand" "=f")
1817 (plus:DF (match_operand:DF 1 "reg_or_fp0_operand" "%fG")
1818 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1820 "add%-%)%& %R1,%R2,%0"
1821 [(set_attr "type" "fadd")
1822 (set_attr "trap" "yes")])
1825 [(set (match_operand:DF 0 "register_operand" "=f")
1826 (plus:DF (float_extend:DF
1827 (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
1828 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
1829 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
1830 "add%-%)%& %R1,%R2,%0"
1831 [(set_attr "type" "fadd")
1832 (set_attr "trap" "yes")])
1835 [(set (match_operand:DF 0 "register_operand" "=f")
1836 (plus:DF (float_extend:DF
1837 (match_operand:SF 1 "reg_or_fp0_operand" "%fG"))
1839 (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
1840 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
1841 "add%-%)%& %R1,%R2,%0"
1842 [(set_attr "type" "fadd")
1843 (set_attr "trap" "yes")])
1845 ;; Define conversion operators between DFmode and SImode, using the cvtql
1846 ;; instruction. To allow combine et al to do useful things, we keep the
1847 ;; operation as a unit until after reload, at which point we split the
1850 ;; Note that we (attempt to) only consider this optimization when the
1851 ;; ultimate destination is memory. If we will be doing further integer
1852 ;; processing, it is cheaper to do the truncation in the int regs.
1854 (define_insn "*cvtql"
1855 [(set (match_operand:SI 0 "register_operand" "=f")
1856 (unspec:SI [(match_operand:DI 1 "reg_or_fp0_operand" "fG")] 5))]
1859 [(set_attr "type" "fadd")
1860 (set_attr "trap" "yes")])
1863 [(set (match_operand:SI 0 "memory_operand" "")
1864 (subreg:SI (fix:DI (match_operand:DF 1 "reg_or_fp0_operand" "")) 0))
1865 (clobber (match_scratch:DI 2 ""))
1866 (clobber (match_scratch:SI 3 ""))]
1867 "TARGET_FP && reload_completed"
1868 [(set (match_dup 2) (fix:DI (match_dup 1)))
1869 (set (match_dup 3) (unspec:SI [(match_dup 2)] 5))
1870 (set (match_dup 0) (match_dup 3))]
1874 [(set (match_operand:SI 0 "memory_operand" "")
1875 (subreg:SI (fix:DI (match_operand:DF 1 "reg_or_fp0_operand" "")) 0))
1876 (clobber (match_scratch:DI 2 ""))]
1877 "TARGET_FP && reload_completed"
1878 [(set (match_dup 2) (fix:DI (match_dup 1)))
1879 (set (match_dup 3) (unspec:SI [(match_dup 2)] 5))
1880 (set (match_dup 0) (match_dup 3))]
1881 ;; Due to REG_CANNOT_CHANGE_SIZE issues, we cannot simply use SUBREG.
1882 "operands[3] = gen_rtx_REG (SImode, REGNO (operands[2]));")
1885 [(set (match_operand:SI 0 "memory_operand" "=m")
1886 (subreg:SI (fix:DI (match_operand:DF 1 "reg_or_fp0_operand" "fG")) 0))
1887 (clobber (match_scratch:DI 2 "=&f"))
1888 (clobber (match_scratch:SI 3 "=&f"))]
1889 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
1891 [(set_attr "type" "fadd")
1892 (set_attr "trap" "yes")])
1895 [(set (match_operand:SI 0 "memory_operand" "=m")
1896 (subreg:SI (fix:DI (match_operand:DF 1 "reg_or_fp0_operand" "fG")) 0))
1897 (clobber (match_scratch:DI 2 "=f"))]
1898 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
1900 [(set_attr "type" "fadd")
1901 (set_attr "trap" "yes")])
1904 [(set (match_operand:DI 0 "register_operand" "=&f")
1905 (fix:DI (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
1906 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
1908 [(set_attr "type" "fadd")
1909 (set_attr "trap" "yes")])
1911 (define_insn "fix_truncdfdi2"
1912 [(set (match_operand:DI 0 "register_operand" "=f")
1913 (fix:DI (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
1916 [(set_attr "type" "fadd")
1917 (set_attr "trap" "yes")])
1919 ;; Likewise between SFmode and SImode.
1922 [(set (match_operand:SI 0 "memory_operand" "")
1923 (subreg:SI (fix:DI (float_extend:DF
1924 (match_operand:SF 1 "reg_or_fp0_operand" ""))) 0))
1925 (clobber (match_scratch:DI 2 ""))
1926 (clobber (match_scratch:SI 3 ""))]
1927 "TARGET_FP && reload_completed"
1928 [(set (match_dup 2) (fix:DI (float_extend:DF (match_dup 1))))
1929 (set (match_dup 3) (unspec:SI [(match_dup 2)] 5))
1930 (set (match_dup 0) (match_dup 3))]
1934 [(set (match_operand:SI 0 "memory_operand" "")
1935 (subreg:SI (fix:DI (float_extend:DF
1936 (match_operand:SF 1 "reg_or_fp0_operand" ""))) 0))
1937 (clobber (match_scratch:DI 2 ""))]
1938 "TARGET_FP && reload_completed"
1939 [(set (match_dup 2) (fix:DI (float_extend:DF (match_dup 1))))
1940 (set (match_dup 3) (unspec:SI [(match_dup 2)] 5))
1941 (set (match_dup 0) (match_dup 3))]
1942 ;; Due to REG_CANNOT_CHANGE_SIZE issues, we cannot simply use SUBREG.
1943 "operands[3] = gen_rtx_REG (SImode, REGNO (operands[2]));")
1946 [(set (match_operand:SI 0 "memory_operand" "=m")
1947 (subreg:SI (fix:DI (float_extend:DF
1948 (match_operand:SF 1 "reg_or_fp0_operand" "fG"))) 0))
1949 (clobber (match_scratch:DI 2 "=&f"))
1950 (clobber (match_scratch:SI 3 "=&f"))]
1951 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
1953 [(set_attr "type" "fadd")
1954 (set_attr "trap" "yes")])
1957 [(set (match_operand:SI 0 "memory_operand" "=m")
1958 (subreg:SI (fix:DI (float_extend:DF
1959 (match_operand:SF 1 "reg_or_fp0_operand" "fG"))) 0))
1960 (clobber (match_scratch:DI 2 "=f"))]
1961 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
1963 [(set_attr "type" "fadd")
1964 (set_attr "trap" "yes")])
1967 [(set (match_operand:DI 0 "register_operand" "=&f")
1968 (fix:DI (float_extend:DF
1969 (match_operand:SF 1 "reg_or_fp0_operand" "fG"))))]
1970 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
1972 [(set_attr "type" "fadd")
1973 (set_attr "trap" "yes")])
1975 (define_insn "fix_truncsfdi2"
1976 [(set (match_operand:DI 0 "register_operand" "=f")
1977 (fix:DI (float_extend:DF
1978 (match_operand:SF 1 "reg_or_fp0_operand" "fG"))))]
1981 [(set_attr "type" "fadd")
1982 (set_attr "trap" "yes")])
1985 [(set (match_operand:SF 0 "register_operand" "=&f")
1986 (float:SF (match_operand:DI 1 "register_operand" "f")))]
1987 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
1989 [(set_attr "type" "fadd")
1990 (set_attr "trap" "yes")])
1992 (define_insn "floatdisf2"
1993 [(set (match_operand:SF 0 "register_operand" "=f")
1994 (float:SF (match_operand:DI 1 "register_operand" "f")))]
1997 [(set_attr "type" "fadd")
1998 (set_attr "trap" "yes")])
2001 [(set (match_operand:DF 0 "register_operand" "=&f")
2002 (float:DF (match_operand:DI 1 "register_operand" "f")))]
2003 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2005 [(set_attr "type" "fadd")
2006 (set_attr "trap" "yes")])
2008 (define_insn "floatdidf2"
2009 [(set (match_operand:DF 0 "register_operand" "=f")
2010 (float:DF (match_operand:DI 1 "register_operand" "f")))]
2013 [(set_attr "type" "fadd")
2014 (set_attr "trap" "yes")])
2016 (define_expand "extendsfdf2"
2017 [(use (match_operand:DF 0 "register_operand" ""))
2018 (use (match_operand:SF 1 "nonimmediate_operand" ""))]
2022 if (alpha_tp == ALPHA_TP_INSN)
2023 emit_insn (gen_extendsfdf2_tp (operands[0],
2024 force_reg (SFmode, operands[1])));
2026 emit_insn (gen_extendsfdf2_no_tp (operands[0], operands[1]));
2031 (define_insn "extendsfdf2_tp"
2032 [(set (match_operand:DF 0 "register_operand" "=&f")
2033 (float_extend:DF (match_operand:SF 1 "register_operand" "f")))]
2034 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2036 [(set_attr "type" "fadd")
2037 (set_attr "trap" "yes")])
2039 (define_insn "extendsfdf2_no_tp"
2040 [(set (match_operand:DF 0 "register_operand" "=f,f,m")
2041 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,m,f")))]
2042 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2047 [(set_attr "type" "fcpys,fld,fst")
2048 (set_attr "trap" "yes")])
2051 [(set (match_operand:SF 0 "register_operand" "=&f")
2052 (float_truncate:SF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
2053 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2054 "cvt%-%,%)%& %R1,%0"
2055 [(set_attr "type" "fadd")
2056 (set_attr "trap" "yes")])
2058 (define_insn "truncdfsf2"
2059 [(set (match_operand:SF 0 "register_operand" "=f")
2060 (float_truncate:SF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
2062 "cvt%-%,%)%& %R1,%0"
2063 [(set_attr "type" "fadd")
2064 (set_attr "trap" "yes")])
2067 [(set (match_operand:SF 0 "register_operand" "=&f")
2068 (div:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")
2069 (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
2070 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2071 "div%,%)%& %R1,%R2,%0"
2072 [(set_attr "type" "fdiv")
2073 (set_attr "opsize" "si")
2074 (set_attr "trap" "yes")])
2076 (define_insn "divsf3"
2077 [(set (match_operand:SF 0 "register_operand" "=f")
2078 (div:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")
2079 (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
2081 "div%,%)%& %R1,%R2,%0"
2082 [(set_attr "type" "fdiv")
2083 (set_attr "opsize" "si")
2084 (set_attr "trap" "yes")])
2087 [(set (match_operand:DF 0 "register_operand" "=&f")
2088 (div:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
2089 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2090 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2091 "div%-%)%& %R1,%R2,%0"
2092 [(set_attr "type" "fdiv")
2093 (set_attr "trap" "yes")])
2095 (define_insn "divdf3"
2096 [(set (match_operand:DF 0 "register_operand" "=f")
2097 (div:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
2098 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2100 "div%-%)%& %R1,%R2,%0"
2101 [(set_attr "type" "fdiv")
2102 (set_attr "trap" "yes")])
2105 [(set (match_operand:DF 0 "register_operand" "=f")
2106 (div:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
2107 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2108 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2109 "div%-%)%& %R1,%R2,%0"
2110 [(set_attr "type" "fdiv")
2111 (set_attr "trap" "yes")])
2114 [(set (match_operand:DF 0 "register_operand" "=f")
2115 (div:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
2117 (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
2118 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2119 "div%-%)%& %R1,%R2,%0"
2120 [(set_attr "type" "fdiv")
2121 (set_attr "trap" "yes")])
2124 [(set (match_operand:DF 0 "register_operand" "=f")
2125 (div:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
2126 (float_extend:DF (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
2127 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2128 "div%-%)%& %R1,%R2,%0"
2129 [(set_attr "type" "fdiv")
2130 (set_attr "trap" "yes")])
2133 [(set (match_operand:SF 0 "register_operand" "=&f")
2134 (mult:SF (match_operand:SF 1 "reg_or_fp0_operand" "%fG")
2135 (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
2136 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2137 "mul%,%)%& %R1,%R2,%0"
2138 [(set_attr "type" "fmul")
2139 (set_attr "trap" "yes")])
2141 (define_insn "mulsf3"
2142 [(set (match_operand:SF 0 "register_operand" "=f")
2143 (mult:SF (match_operand:SF 1 "reg_or_fp0_operand" "%fG")
2144 (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
2146 "mul%,%)%& %R1,%R2,%0"
2147 [(set_attr "type" "fmul")
2148 (set_attr "trap" "yes")])
2151 [(set (match_operand:DF 0 "register_operand" "=&f")
2152 (mult:DF (match_operand:DF 1 "reg_or_fp0_operand" "%fG")
2153 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2154 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2155 "mul%-%)%& %R1,%R2,%0"
2156 [(set_attr "type" "fmul")
2157 (set_attr "trap" "yes")])
2159 (define_insn "muldf3"
2160 [(set (match_operand:DF 0 "register_operand" "=f")
2161 (mult:DF (match_operand:DF 1 "reg_or_fp0_operand" "%fG")
2162 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2164 "mul%-%)%& %R1,%R2,%0"
2165 [(set_attr "type" "fmul")
2166 (set_attr "trap" "yes")])
2169 [(set (match_operand:DF 0 "register_operand" "=f")
2170 (mult:DF (float_extend:DF
2171 (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
2172 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2173 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2174 "mul%-%)%& %R1,%R2,%0"
2175 [(set_attr "type" "fmul")
2176 (set_attr "trap" "yes")])
2179 [(set (match_operand:DF 0 "register_operand" "=f")
2180 (mult:DF (float_extend:DF
2181 (match_operand:SF 1 "reg_or_fp0_operand" "%fG"))
2183 (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
2184 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2185 "mul%-%)%& %R1,%R2,%0"
2186 [(set_attr "type" "fmul")
2187 (set_attr "trap" "yes")])
2190 [(set (match_operand:SF 0 "register_operand" "=&f")
2191 (minus:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")
2192 (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
2193 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2194 "sub%,%)%& %R1,%R2,%0"
2195 [(set_attr "type" "fadd")
2196 (set_attr "trap" "yes")])
2198 (define_insn "subsf3"
2199 [(set (match_operand:SF 0 "register_operand" "=f")
2200 (minus:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")
2201 (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
2203 "sub%,%)%& %R1,%R2,%0"
2204 [(set_attr "type" "fadd")
2205 (set_attr "trap" "yes")])
2208 [(set (match_operand:DF 0 "register_operand" "=&f")
2209 (minus:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
2210 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2211 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2212 "sub%-%)%& %R1,%R2,%0"
2213 [(set_attr "type" "fadd")
2214 (set_attr "trap" "yes")])
2216 (define_insn "subdf3"
2217 [(set (match_operand:DF 0 "register_operand" "=f")
2218 (minus:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
2219 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2221 "sub%-%)%& %R1,%R2,%0"
2222 [(set_attr "type" "fadd")
2223 (set_attr "trap" "yes")])
2226 [(set (match_operand:DF 0 "register_operand" "=f")
2227 (minus:DF (float_extend:DF
2228 (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
2229 (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
2230 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2231 "sub%-%)%& %R1,%R2,%0"
2232 [(set_attr "type" "fadd")
2233 (set_attr "trap" "yes")])
2236 [(set (match_operand:DF 0 "register_operand" "=f")
2237 (minus:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
2239 (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
2240 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2241 "sub%-%)%& %R1,%R2,%0"
2242 [(set_attr "type" "fadd")
2243 (set_attr "trap" "yes")])
2246 [(set (match_operand:DF 0 "register_operand" "=f")
2247 (minus:DF (float_extend:DF
2248 (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
2250 (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
2251 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2252 "sub%-%)%& %R1,%R2,%0"
2253 [(set_attr "type" "fadd")
2254 (set_attr "trap" "yes")])
2257 [(set (match_operand:SF 0 "register_operand" "=&f")
2258 (sqrt:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")))]
2259 "TARGET_FP && TARGET_CIX && alpha_tp == ALPHA_TP_INSN"
2261 [(set_attr "type" "fsqrt")
2262 (set_attr "opsize" "si")
2263 (set_attr "trap" "yes")])
2265 (define_insn "sqrtsf2"
2266 [(set (match_operand:SF 0 "register_operand" "=f")
2267 (sqrt:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")))]
2268 "TARGET_FP && TARGET_CIX"
2270 [(set_attr "type" "fsqrt")
2271 (set_attr "opsize" "si")
2272 (set_attr "trap" "yes")])
2275 [(set (match_operand:DF 0 "register_operand" "=&f")
2276 (sqrt:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
2277 "TARGET_FP && TARGET_CIX && alpha_tp == ALPHA_TP_INSN"
2279 [(set_attr "type" "fsqrt")
2280 (set_attr "trap" "yes")])
2282 (define_insn "sqrtdf2"
2283 [(set (match_operand:DF 0 "register_operand" "=f")
2284 (sqrt:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
2285 "TARGET_FP && TARGET_CIX"
2287 [(set_attr "type" "fsqrt")
2288 (set_attr "trap" "yes")])
2290 ;; Next are all the integer comparisons, and conditional moves and branches
2291 ;; and some of the related define_expand's and define_split's.
2294 [(set (match_operand:DI 0 "register_operand" "=r")
2295 (match_operator:DI 1 "alpha_comparison_operator"
2296 [(match_operand:DI 2 "reg_or_0_operand" "rJ")
2297 (match_operand:DI 3 "reg_or_8bit_operand" "rI")]))]
2300 [(set_attr "type" "icmp")])
2303 [(set (match_operand:DI 0 "register_operand" "=r")
2304 (match_operator:DI 1 "alpha_swapped_comparison_operator"
2305 [(match_operand:DI 2 "reg_or_8bit_operand" "rI")
2306 (match_operand:DI 3 "reg_or_0_operand" "rJ")]))]
2309 [(set_attr "type" "icmp")])
2311 ;; This pattern exists so conditional moves of SImode values are handled.
2312 ;; Comparisons are still done in DImode though.
2315 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
2317 (match_operator 2 "signed_comparison_operator"
2318 [(match_operand:DI 3 "reg_or_0_operand" "rJ,rJ,J,J")
2319 (match_operand:DI 4 "reg_or_0_operand" "J,J,rJ,rJ")])
2320 (match_operand:SI 1 "reg_or_8bit_operand" "rI,0,rI,0")
2321 (match_operand:SI 5 "reg_or_8bit_operand" "0,rI,0,rI")))]
2322 "operands[3] == const0_rtx || operands[4] == const0_rtx"
2328 [(set_attr "type" "icmov")])
2331 [(set (match_operand:DI 0 "register_operand" "=r,r,r,r")
2333 (match_operator 2 "signed_comparison_operator"
2334 [(match_operand:DI 3 "reg_or_0_operand" "rJ,rJ,J,J")
2335 (match_operand:DI 4 "reg_or_0_operand" "J,J,rJ,rJ")])
2336 (match_operand:DI 1 "reg_or_8bit_operand" "rI,0,rI,0")
2337 (match_operand:DI 5 "reg_or_8bit_operand" "0,rI,0,rI")))]
2338 "operands[3] == const0_rtx || operands[4] == const0_rtx"
2344 [(set_attr "type" "icmov")])
2347 [(set (match_operand:DI 0 "register_operand" "=r,r")
2349 (eq (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
2353 (match_operand:DI 1 "reg_or_8bit_operand" "rI,0")
2354 (match_operand:DI 3 "reg_or_8bit_operand" "0,rI")))]
2359 [(set_attr "type" "icmov")])
2362 [(set (match_operand:DI 0 "register_operand" "=r,r")
2364 (ne (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
2368 (match_operand:DI 1 "reg_or_8bit_operand" "rI,0")
2369 (match_operand:DI 3 "reg_or_8bit_operand" "0,rI")))]
2374 [(set_attr "type" "icmov")])
2376 ;; This form is added since combine thinks that an IF_THEN_ELSE with both
2377 ;; arms constant is a single insn, so it won't try to form it if combine
2378 ;; knows they are really two insns. This occurs in divides by powers
2382 [(set (match_operand:DI 0 "register_operand" "=r")
2384 (match_operator 2 "signed_comparison_operator"
2385 [(match_operand:DI 3 "reg_or_0_operand" "rJ")
2387 (plus:DI (match_dup 0)
2388 (match_operand:DI 1 "reg_or_8bit_operand" "rI"))
2390 (clobber (match_scratch:DI 4 "=&r"))]
2392 "addq %0,%1,%4\;cmov%C2 %r3,%4,%0"
2393 [(set_attr "type" "icmov")
2394 (set_attr "length" "8")])
2397 [(set (match_operand:DI 0 "register_operand" "")
2399 (match_operator 2 "signed_comparison_operator"
2400 [(match_operand:DI 3 "reg_or_0_operand" "")
2402 (plus:DI (match_dup 0)
2403 (match_operand:DI 1 "reg_or_8bit_operand" ""))
2405 (clobber (match_operand:DI 4 "register_operand" ""))]
2407 [(set (match_dup 4) (plus:DI (match_dup 0) (match_dup 1)))
2408 (set (match_dup 0) (if_then_else:DI (match_op_dup 2
2411 (match_dup 4) (match_dup 0)))]
2416 [(set (match_operand:DI 0 "register_operand" "")
2418 (match_operator 1 "comparison_operator"
2419 [(zero_extract:DI (match_operand:DI 2 "register_operand" "")
2421 (match_operand:DI 3 "const_int_operand" ""))
2423 (match_operand:DI 4 "reg_or_8bit_operand" "")
2424 (match_operand:DI 5 "reg_or_8bit_operand" "")))
2425 (clobber (match_operand:DI 6 "register_operand" ""))])]
2426 "INTVAL (operands[3]) != 0"
2428 (lshiftrt:DI (match_dup 2) (match_dup 3)))
2430 (if_then_else:DI (match_op_dup 1
2431 [(zero_extract:DI (match_dup 6)
2439 ;; For ABS, we have two choices, depending on whether the input and output
2440 ;; registers are the same or not.
2441 (define_expand "absdi2"
2442 [(set (match_operand:DI 0 "register_operand" "")
2443 (abs:DI (match_operand:DI 1 "register_operand" "")))]
2446 { if (rtx_equal_p (operands[0], operands[1]))
2447 emit_insn (gen_absdi2_same (operands[0], gen_reg_rtx (DImode)));
2449 emit_insn (gen_absdi2_diff (operands[0], operands[1]));
2454 (define_expand "absdi2_same"
2455 [(set (match_operand:DI 1 "register_operand" "")
2456 (neg:DI (match_operand:DI 0 "register_operand" "")))
2458 (if_then_else:DI (ge (match_dup 0) (const_int 0))
2464 (define_expand "absdi2_diff"
2465 [(set (match_operand:DI 0 "register_operand" "")
2466 (neg:DI (match_operand:DI 1 "register_operand" "")))
2468 (if_then_else:DI (lt (match_dup 1) (const_int 0))
2475 [(set (match_operand:DI 0 "register_operand" "")
2476 (abs:DI (match_dup 0)))
2477 (clobber (match_operand:DI 2 "register_operand" ""))]
2479 [(set (match_dup 1) (neg:DI (match_dup 0)))
2480 (set (match_dup 0) (if_then_else:DI (ge (match_dup 0) (const_int 0))
2481 (match_dup 0) (match_dup 1)))]
2485 [(set (match_operand:DI 0 "register_operand" "")
2486 (abs:DI (match_operand:DI 1 "register_operand" "")))]
2487 "! rtx_equal_p (operands[0], operands[1])"
2488 [(set (match_dup 0) (neg:DI (match_dup 1)))
2489 (set (match_dup 0) (if_then_else:DI (lt (match_dup 1) (const_int 0))
2490 (match_dup 0) (match_dup 1)))]
2494 [(set (match_operand:DI 0 "register_operand" "")
2495 (neg:DI (abs:DI (match_dup 0))))
2496 (clobber (match_operand:DI 2 "register_operand" ""))]
2498 [(set (match_dup 1) (neg:DI (match_dup 0)))
2499 (set (match_dup 0) (if_then_else:DI (le (match_dup 0) (const_int 0))
2500 (match_dup 0) (match_dup 1)))]
2504 [(set (match_operand:DI 0 "register_operand" "")
2505 (neg:DI (abs:DI (match_operand:DI 1 "register_operand" ""))))]
2506 "! rtx_equal_p (operands[0], operands[1])"
2507 [(set (match_dup 0) (neg:DI (match_dup 1)))
2508 (set (match_dup 0) (if_then_else:DI (gt (match_dup 1) (const_int 0))
2509 (match_dup 0) (match_dup 1)))]
2512 (define_insn "sminqi3"
2513 [(set (match_operand:QI 0 "register_operand" "=r")
2514 (smin:QI (match_operand:QI 1 "reg_or_0_operand" "%rJ")
2515 (match_operand:QI 2 "reg_or_8bit_operand" "rI")))]
2518 [(set_attr "type" "mvi")])
2520 (define_insn "uminqi3"
2521 [(set (match_operand:QI 0 "register_operand" "=r")
2522 (umin:QI (match_operand:QI 1 "reg_or_0_operand" "%rJ")
2523 (match_operand:QI 2 "reg_or_8bit_operand" "rI")))]
2526 [(set_attr "type" "mvi")])
2528 (define_insn "smaxqi3"
2529 [(set (match_operand:QI 0 "register_operand" "=r")
2530 (smax:QI (match_operand:QI 1 "reg_or_0_operand" "%rJ")
2531 (match_operand:QI 2 "reg_or_8bit_operand" "rI")))]
2534 [(set_attr "type" "mvi")])
2536 (define_insn "umaxqi3"
2537 [(set (match_operand:QI 0 "register_operand" "=r")
2538 (umax:QI (match_operand:QI 1 "reg_or_0_operand" "%rJ")
2539 (match_operand:QI 2 "reg_or_8bit_operand" "rI")))]
2542 [(set_attr "type" "mvi")])
2544 (define_insn "sminhi3"
2545 [(set (match_operand:HI 0 "register_operand" "=r")
2546 (smin:HI (match_operand:HI 1 "reg_or_0_operand" "%rJ")
2547 (match_operand:HI 2 "reg_or_8bit_operand" "rI")))]
2550 [(set_attr "type" "mvi")])
2552 (define_insn "uminhi3"
2553 [(set (match_operand:HI 0 "register_operand" "=r")
2554 (umin:HI (match_operand:HI 1 "reg_or_0_operand" "%rJ")
2555 (match_operand:HI 2 "reg_or_8bit_operand" "rI")))]
2558 [(set_attr "type" "mvi")])
2560 (define_insn "smaxhi3"
2561 [(set (match_operand:HI 0 "register_operand" "=r")
2562 (smax:HI (match_operand:HI 1 "reg_or_0_operand" "%rJ")
2563 (match_operand:HI 2 "reg_or_8bit_operand" "rI")))]
2566 [(set_attr "type" "mvi")])
2568 (define_insn "umaxhi3"
2569 [(set (match_operand:HI 0 "register_operand" "=r")
2570 (umax:HI (match_operand:HI 1 "reg_or_0_operand" "%rJ")
2571 (match_operand:HI 2 "reg_or_8bit_operand" "rI")))]
2574 [(set_attr "type" "shift")])
2576 (define_expand "smaxdi3"
2578 (le:DI (match_operand:DI 1 "reg_or_0_operand" "")
2579 (match_operand:DI 2 "reg_or_8bit_operand" "")))
2580 (set (match_operand:DI 0 "register_operand" "")
2581 (if_then_else:DI (eq (match_dup 3) (const_int 0))
2582 (match_dup 1) (match_dup 2)))]
2585 { operands[3] = gen_reg_rtx (DImode);
2589 [(set (match_operand:DI 0 "register_operand" "")
2590 (smax:DI (match_operand:DI 1 "reg_or_0_operand" "")
2591 (match_operand:DI 2 "reg_or_8bit_operand" "")))
2592 (clobber (match_operand:DI 3 "register_operand" ""))]
2593 "operands[2] != const0_rtx"
2594 [(set (match_dup 3) (le:DI (match_dup 1) (match_dup 2)))
2595 (set (match_dup 0) (if_then_else:DI (eq (match_dup 3) (const_int 0))
2596 (match_dup 1) (match_dup 2)))]
2600 [(set (match_operand:DI 0 "register_operand" "=r")
2601 (smax:DI (match_operand:DI 1 "register_operand" "0")
2605 [(set_attr "type" "icmov")])
2607 (define_expand "smindi3"
2609 (lt:DI (match_operand:DI 1 "reg_or_0_operand" "")
2610 (match_operand:DI 2 "reg_or_8bit_operand" "")))
2611 (set (match_operand:DI 0 "register_operand" "")
2612 (if_then_else:DI (ne (match_dup 3) (const_int 0))
2613 (match_dup 1) (match_dup 2)))]
2616 { operands[3] = gen_reg_rtx (DImode);
2620 [(set (match_operand:DI 0 "register_operand" "")
2621 (smin:DI (match_operand:DI 1 "reg_or_0_operand" "")
2622 (match_operand:DI 2 "reg_or_8bit_operand" "")))
2623 (clobber (match_operand:DI 3 "register_operand" ""))]
2624 "operands[2] != const0_rtx"
2625 [(set (match_dup 3) (lt:DI (match_dup 1) (match_dup 2)))
2626 (set (match_dup 0) (if_then_else:DI (ne (match_dup 3) (const_int 0))
2627 (match_dup 1) (match_dup 2)))]
2631 [(set (match_operand:DI 0 "register_operand" "=r")
2632 (smin:DI (match_operand:DI 1 "register_operand" "0")
2636 [(set_attr "type" "icmov")])
2638 (define_expand "umaxdi3"
2640 (leu:DI (match_operand:DI 1 "reg_or_0_operand" "")
2641 (match_operand:DI 2 "reg_or_8bit_operand" "")))
2642 (set (match_operand:DI 0 "register_operand" "")
2643 (if_then_else:DI (eq (match_dup 3) (const_int 0))
2644 (match_dup 1) (match_dup 2)))]
2647 { operands[3] = gen_reg_rtx (DImode);
2651 [(set (match_operand:DI 0 "register_operand" "")
2652 (umax:DI (match_operand:DI 1 "reg_or_0_operand" "")
2653 (match_operand:DI 2 "reg_or_8bit_operand" "")))
2654 (clobber (match_operand:DI 3 "register_operand" ""))]
2655 "operands[2] != const0_rtx"
2656 [(set (match_dup 3) (leu:DI (match_dup 1) (match_dup 2)))
2657 (set (match_dup 0) (if_then_else:DI (eq (match_dup 3) (const_int 0))
2658 (match_dup 1) (match_dup 2)))]
2661 (define_expand "umindi3"
2663 (ltu:DI (match_operand:DI 1 "reg_or_0_operand" "")
2664 (match_operand:DI 2 "reg_or_8bit_operand" "")))
2665 (set (match_operand:DI 0 "register_operand" "")
2666 (if_then_else:DI (ne (match_dup 3) (const_int 0))
2667 (match_dup 1) (match_dup 2)))]
2670 { operands[3] = gen_reg_rtx (DImode);
2674 [(set (match_operand:DI 0 "register_operand" "")
2675 (umin:DI (match_operand:DI 1 "reg_or_0_operand" "")
2676 (match_operand:DI 2 "reg_or_8bit_operand" "")))
2677 (clobber (match_operand:DI 3 "register_operand" ""))]
2678 "operands[2] != const0_rtx"
2679 [(set (match_dup 3) (ltu:DI (match_dup 1) (match_dup 2)))
2680 (set (match_dup 0) (if_then_else:DI (ne (match_dup 3) (const_int 0))
2681 (match_dup 1) (match_dup 2)))]
2687 (match_operator 1 "signed_comparison_operator"
2688 [(match_operand:DI 2 "reg_or_0_operand" "rJ")
2690 (label_ref (match_operand 0 "" ""))
2694 [(set_attr "type" "ibr")])
2699 (match_operator 1 "signed_comparison_operator"
2701 (match_operand:DI 2 "register_operand" "r")])
2702 (label_ref (match_operand 0 "" ""))
2706 [(set_attr "type" "ibr")])
2711 (ne (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
2715 (label_ref (match_operand 0 "" ""))
2719 [(set_attr "type" "ibr")])
2724 (eq (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
2728 (label_ref (match_operand 0 "" ""))
2732 [(set_attr "type" "ibr")])
2738 (match_operator 1 "comparison_operator"
2739 [(zero_extract:DI (match_operand:DI 2 "register_operand" "")
2741 (match_operand:DI 3 "const_int_operand" ""))
2743 (label_ref (match_operand 0 "" ""))
2745 (clobber (match_operand:DI 4 "register_operand" ""))])]
2746 "INTVAL (operands[3]) != 0"
2748 (lshiftrt:DI (match_dup 2) (match_dup 3)))
2750 (if_then_else (match_op_dup 1
2751 [(zero_extract:DI (match_dup 4)
2755 (label_ref (match_dup 0))
2759 ;; The following are the corresponding floating-point insns. Recall
2760 ;; we need to have variants that expand the arguments from SF mode
2764 [(set (match_operand:DF 0 "register_operand" "=&f")
2765 (match_operator:DF 1 "alpha_comparison_operator"
2766 [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2767 (match_operand:DF 3 "reg_or_fp0_operand" "fG")]))]
2768 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2769 "cmp%-%C1%' %R2,%R3,%0"
2770 [(set_attr "type" "fadd")
2771 (set_attr "trap" "yes")])
2774 [(set (match_operand:DF 0 "register_operand" "=f")
2775 (match_operator:DF 1 "alpha_comparison_operator"
2776 [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2777 (match_operand:DF 3 "reg_or_fp0_operand" "fG")]))]
2778 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2779 "cmp%-%C1%' %R2,%R3,%0"
2780 [(set_attr "type" "fadd")
2781 (set_attr "trap" "yes")])
2784 [(set (match_operand:DF 0 "register_operand" "=&f")
2785 (match_operator:DF 1 "alpha_comparison_operator"
2787 (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
2788 (match_operand:DF 3 "reg_or_fp0_operand" "fG")]))]
2789 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2790 "cmp%-%C1%' %R2,%R3,%0"
2791 [(set_attr "type" "fadd")
2792 (set_attr "trap" "yes")])
2795 [(set (match_operand:DF 0 "register_operand" "=f")
2796 (match_operator:DF 1 "alpha_comparison_operator"
2798 (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
2799 (match_operand:DF 3 "reg_or_fp0_operand" "fG")]))]
2800 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2801 "cmp%-%C1%' %R2,%R3,%0"
2802 [(set_attr "type" "fadd")
2803 (set_attr "trap" "yes")])
2806 [(set (match_operand:DF 0 "register_operand" "=&f")
2807 (match_operator:DF 1 "alpha_comparison_operator"
2808 [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2810 (match_operand:SF 3 "reg_or_fp0_operand" "fG"))]))]
2811 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2812 "cmp%-%C1%' %R2,%R3,%0"
2813 [(set_attr "type" "fadd")
2814 (set_attr "trap" "yes")])
2817 [(set (match_operand:DF 0 "register_operand" "=f")
2818 (match_operator:DF 1 "alpha_comparison_operator"
2819 [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2821 (match_operand:SF 3 "reg_or_fp0_operand" "fG"))]))]
2822 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2823 "cmp%-%C1%' %R2,%R3,%0"
2824 [(set_attr "type" "fadd")
2825 (set_attr "trap" "yes")])
2828 [(set (match_operand:DF 0 "register_operand" "=&f")
2829 (match_operator:DF 1 "alpha_comparison_operator"
2831 (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
2833 (match_operand:SF 3 "reg_or_fp0_operand" "fG"))]))]
2834 "TARGET_FP && alpha_tp == ALPHA_TP_INSN"
2835 "cmp%-%C1%' %R2,%R3,%0"
2836 [(set_attr "type" "fadd")
2837 (set_attr "trap" "yes")])
2840 [(set (match_operand:DF 0 "register_operand" "=f")
2841 (match_operator:DF 1 "alpha_comparison_operator"
2843 (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
2845 (match_operand:SF 3 "reg_or_fp0_operand" "fG"))]))]
2846 "TARGET_FP && alpha_tp != ALPHA_TP_INSN"
2847 "cmp%-%C1%' %R2,%R3,%0"
2848 [(set_attr "type" "fadd")
2849 (set_attr "trap" "yes")])
2852 [(set (match_operand:DF 0 "register_operand" "=f,f")
2854 (match_operator 3 "signed_comparison_operator"
2855 [(match_operand:DF 4 "reg_or_fp0_operand" "fG,fG")
2856 (match_operand:DF 2 "fp0_operand" "G,G")])
2857 (match_operand:DF 1 "reg_or_fp0_operand" "fG,0")
2858 (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2862 fcmov%D3 %R4,%R5,%0"
2863 [(set_attr "type" "fcmov")])
2866 [(set (match_operand:SF 0 "register_operand" "=f,f")
2868 (match_operator 3 "signed_comparison_operator"
2869 [(match_operand:DF 4 "reg_or_fp0_operand" "fG,fG")
2870 (match_operand:DF 2 "fp0_operand" "G,G")])
2871 (match_operand:SF 1 "reg_or_fp0_operand" "fG,0")
2872 (match_operand:SF 5 "reg_or_fp0_operand" "0,fG")))]
2876 fcmov%D3 %R4,%R5,%0"
2877 [(set_attr "type" "fcmov")])
2880 [(set (match_operand:DF 0 "register_operand" "=f,f")
2882 (match_operator 3 "signed_comparison_operator"
2883 [(match_operand:DF 4 "reg_or_fp0_operand" "fG,fG")
2884 (match_operand:DF 2 "fp0_operand" "G,G")])
2885 (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG,0"))
2886 (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2890 fcmov%D3 %R4,%R5,%0"
2891 [(set_attr "type" "fcmov")])
2894 [(set (match_operand:DF 0 "register_operand" "=f,f")
2896 (match_operator 3 "signed_comparison_operator"
2898 (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
2899 (match_operand:DF 2 "fp0_operand" "G,G")])
2900 (match_operand:DF 1 "reg_or_fp0_operand" "fG,0")
2901 (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2905 fcmov%D3 %R4,%R5,%0"
2906 [(set_attr "type" "fcmov")])
2909 [(set (match_operand:SF 0 "register_operand" "=f,f")
2911 (match_operator 3 "signed_comparison_operator"
2913 (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
2914 (match_operand:DF 2 "fp0_operand" "G,G")])
2915 (match_operand:SF 1 "reg_or_fp0_operand" "fG,0")
2916 (match_operand:SF 5 "reg_or_fp0_operand" "0,fG")))]
2920 fcmov%D3 %R4,%R5,%0"
2921 [(set_attr "type" "fcmov")])
2924 [(set (match_operand:DF 0 "register_operand" "=f,f")
2926 (match_operator 3 "signed_comparison_operator"
2928 (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
2929 (match_operand:DF 2 "fp0_operand" "G,G")])
2930 (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG,0"))
2931 (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
2935 fcmov%D3 %R4,%R5,%0"
2936 [(set_attr "type" "fcmov")])
2938 (define_expand "maxdf3"
2940 (le:DF (match_operand:DF 1 "reg_or_fp0_operand" "")
2941 (match_operand:DF 2 "reg_or_fp0_operand" "")))
2942 (set (match_operand:DF 0 "register_operand" "")
2943 (if_then_else:DF (eq (match_dup 3) (match_dup 4))
2944 (match_dup 1) (match_dup 2)))]
2947 { operands[3] = gen_reg_rtx (DFmode);
2948 operands[4] = CONST0_RTX (DFmode);
2951 (define_expand "mindf3"
2953 (lt:DF (match_operand:DF 1 "reg_or_fp0_operand" "")
2954 (match_operand:DF 2 "reg_or_fp0_operand" "")))
2955 (set (match_operand:DF 0 "register_operand" "")
2956 (if_then_else:DF (ne (match_dup 3) (match_dup 4))
2957 (match_dup 1) (match_dup 2)))]
2960 { operands[3] = gen_reg_rtx (DFmode);
2961 operands[4] = CONST0_RTX (DFmode);
2964 (define_expand "maxsf3"
2966 (le:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" ""))
2967 (float_extend:DF (match_operand:SF 2 "reg_or_fp0_operand" ""))))
2968 (set (match_operand:SF 0 "register_operand" "")
2969 (if_then_else:SF (eq (match_dup 3) (match_dup 4))
2970 (match_dup 1) (match_dup 2)))]
2973 { operands[3] = gen_reg_rtx (DFmode);
2974 operands[4] = CONST0_RTX (DFmode);
2977 (define_expand "minsf3"
2979 (lt:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" ""))
2980 (float_extend:DF (match_operand:SF 2 "reg_or_fp0_operand" ""))))
2981 (set (match_operand:SF 0 "register_operand" "")
2982 (if_then_else:SF (ne (match_dup 3) (match_dup 4))
2983 (match_dup 1) (match_dup 2)))]
2986 { operands[3] = gen_reg_rtx (DFmode);
2987 operands[4] = CONST0_RTX (DFmode);
2993 (match_operator 1 "signed_comparison_operator"
2994 [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
2995 (match_operand:DF 3 "fp0_operand" "G")])
2996 (label_ref (match_operand 0 "" ""))
3000 [(set_attr "type" "fbr")])
3005 (match_operator 1 "signed_comparison_operator"
3007 (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
3008 (match_operand:DF 3 "fp0_operand" "G")])
3009 (label_ref (match_operand 0 "" ""))
3013 [(set_attr "type" "fbr")])
3015 ;; These are the main define_expand's used to make conditional branches
3018 (define_expand "cmpdf"
3019 [(set (cc0) (compare (match_operand:DF 0 "reg_or_fp0_operand" "")
3020 (match_operand:DF 1 "reg_or_fp0_operand" "")))]
3024 alpha_compare_op0 = operands[0];
3025 alpha_compare_op1 = operands[1];
3026 alpha_compare_fp_p = 1;
3030 (define_expand "cmpdi"
3031 [(set (cc0) (compare (match_operand:DI 0 "reg_or_0_operand" "")
3032 (match_operand:DI 1 "reg_or_8bit_operand" "")))]
3036 alpha_compare_op0 = operands[0];
3037 alpha_compare_op1 = operands[1];
3038 alpha_compare_fp_p = 0;
3042 (define_expand "beq"
3044 (if_then_else (match_dup 1)
3045 (label_ref (match_operand 0 "" ""))
3048 "{ operands[1] = alpha_emit_conditional_branch (EQ); }")
3050 (define_expand "bne"
3052 (if_then_else (match_dup 1)
3053 (label_ref (match_operand 0 "" ""))
3056 "{ operands[1] = alpha_emit_conditional_branch (NE); }")
3058 (define_expand "blt"
3060 (if_then_else (match_dup 1)
3061 (label_ref (match_operand 0 "" ""))
3064 "{ operands[1] = alpha_emit_conditional_branch (LT); }")
3066 (define_expand "ble"
3068 (if_then_else (match_dup 1)
3069 (label_ref (match_operand 0 "" ""))
3072 "{ operands[1] = alpha_emit_conditional_branch (LE); }")
3074 (define_expand "bgt"
3076 (if_then_else (match_dup 1)
3077 (label_ref (match_operand 0 "" ""))
3080 "{ operands[1] = alpha_emit_conditional_branch (GT); }")
3082 (define_expand "bge"
3084 (if_then_else (match_dup 1)
3085 (label_ref (match_operand 0 "" ""))
3088 "{ operands[1] = alpha_emit_conditional_branch (GE); }")
3090 (define_expand "bltu"
3092 (if_then_else (match_dup 1)
3093 (label_ref (match_operand 0 "" ""))
3096 "{ operands[1] = alpha_emit_conditional_branch (LTU); }")
3098 (define_expand "bleu"
3100 (if_then_else (match_dup 1)
3101 (label_ref (match_operand 0 "" ""))
3104 "{ operands[1] = alpha_emit_conditional_branch (LEU); }")
3106 (define_expand "bgtu"
3108 (if_then_else (match_dup 1)
3109 (label_ref (match_operand 0 "" ""))
3112 "{ operands[1] = alpha_emit_conditional_branch (GTU); }")
3114 (define_expand "bgeu"
3116 (if_then_else (match_dup 1)
3117 (label_ref (match_operand 0 "" ""))
3120 "{ operands[1] = alpha_emit_conditional_branch (GEU); }")
3122 (define_expand "seq"
3123 [(set (match_operand:DI 0 "register_operand" "")
3128 if (alpha_compare_fp_p)
3131 operands[1] = gen_rtx_EQ (DImode, alpha_compare_op0, alpha_compare_op1);
3134 (define_expand "sne"
3135 [(set (match_operand:DI 0 "register_operand" "")
3137 (set (match_dup 0) (xor:DI (match_dup 0) (const_int 1)))]
3141 if (alpha_compare_fp_p)
3144 operands[1] = gen_rtx_EQ (DImode, alpha_compare_op0, alpha_compare_op1);
3147 (define_expand "slt"
3148 [(set (match_operand:DI 0 "register_operand" "")
3153 if (alpha_compare_fp_p)
3156 operands[1] = gen_rtx_LT (DImode, alpha_compare_op0, alpha_compare_op1);
3159 (define_expand "sle"
3160 [(set (match_operand:DI 0 "register_operand" "")
3165 if (alpha_compare_fp_p)
3168 operands[1] = gen_rtx_LE (DImode, alpha_compare_op0, alpha_compare_op1);
3171 (define_expand "sgt"
3172 [(set (match_operand:DI 0 "register_operand" "")
3177 if (alpha_compare_fp_p)
3180 operands[1] = gen_rtx_LT (DImode, force_reg (DImode, alpha_compare_op1),
3184 (define_expand "sge"
3185 [(set (match_operand:DI 0 "register_operand" "")
3190 if (alpha_compare_fp_p)
3193 operands[1] = gen_rtx_LE (DImode, force_reg (DImode, alpha_compare_op1),
3197 (define_expand "sltu"
3198 [(set (match_operand:DI 0 "register_operand" "")
3203 if (alpha_compare_fp_p)
3206 operands[1] = gen_rtx_LTU (DImode, alpha_compare_op0, alpha_compare_op1);
3209 (define_expand "sleu"
3210 [(set (match_operand:DI 0 "register_operand" "")
3215 if (alpha_compare_fp_p)
3218 operands[1] = gen_rtx_LEU (DImode, alpha_compare_op0, alpha_compare_op1);
3221 (define_expand "sgtu"
3222 [(set (match_operand:DI 0 "register_operand" "")
3227 if (alpha_compare_fp_p)
3230 operands[1] = gen_rtx_LTU (DImode, force_reg (DImode, alpha_compare_op1),
3234 (define_expand "sgeu"
3235 [(set (match_operand:DI 0 "register_operand" "")
3240 if (alpha_compare_fp_p)
3243 operands[1] = gen_rtx_LEU (DImode, force_reg (DImode, alpha_compare_op1),
3247 ;; These are the main define_expand's used to make conditional moves.
3249 (define_expand "movsicc"
3250 [(set (match_operand:SI 0 "register_operand" "")
3251 (if_then_else:SI (match_operand 1 "comparison_operator" "")
3252 (match_operand:SI 2 "reg_or_8bit_operand" "")
3253 (match_operand:SI 3 "reg_or_8bit_operand" "")))]
3257 if ((operands[1] = alpha_emit_conditional_move (operands[1], SImode)) == 0)
3261 (define_expand "movdicc"
3262 [(set (match_operand:DI 0 "register_operand" "")
3263 (if_then_else:DI (match_operand 1 "comparison_operator" "")
3264 (match_operand:DI 2 "reg_or_8bit_operand" "")
3265 (match_operand:DI 3 "reg_or_8bit_operand" "")))]
3269 if ((operands[1] = alpha_emit_conditional_move (operands[1], DImode)) == 0)
3273 (define_expand "movsfcc"
3274 [(set (match_operand:SF 0 "register_operand" "")
3275 (if_then_else:SF (match_operand 1 "comparison_operator" "")
3276 (match_operand:SF 2 "reg_or_8bit_operand" "")
3277 (match_operand:SF 3 "reg_or_8bit_operand" "")))]
3281 if ((operands[1] = alpha_emit_conditional_move (operands[1], SFmode)) == 0)
3285 (define_expand "movdfcc"
3286 [(set (match_operand:DF 0 "register_operand" "")
3287 (if_then_else:DF (match_operand 1 "comparison_operator" "")
3288 (match_operand:DF 2 "reg_or_8bit_operand" "")
3289 (match_operand:DF 3 "reg_or_8bit_operand" "")))]
3293 if ((operands[1] = alpha_emit_conditional_move (operands[1], DFmode)) == 0)
3297 ;; These define_split definitions are used in cases when comparisons have
3298 ;; not be stated in the correct way and we need to reverse the second
3299 ;; comparison. For example, x >= 7 has to be done as x < 6 with the
3300 ;; comparison that tests the result being reversed. We have one define_split
3301 ;; for each use of a comparison. They do not match valid insns and need
3302 ;; not generate valid insns.
3304 ;; We can also handle equality comparisons (and inequality comparisons in
3305 ;; cases where the resulting add cannot overflow) by doing an add followed by
3306 ;; a comparison with zero. This is faster since the addition takes one
3307 ;; less cycle than a compare when feeding into a conditional move.
3308 ;; For this case, we also have an SImode pattern since we can merge the add
3309 ;; and sign extend and the order doesn't matter.
3311 ;; We do not do this for floating-point, since it isn't clear how the "wrong"
3312 ;; operation could have been generated.
3315 [(set (match_operand:DI 0 "register_operand" "")
3317 (match_operator 1 "comparison_operator"
3318 [(match_operand:DI 2 "reg_or_0_operand" "")
3319 (match_operand:DI 3 "reg_or_cint_operand" "")])
3320 (match_operand:DI 4 "reg_or_cint_operand" "")
3321 (match_operand:DI 5 "reg_or_cint_operand" "")))
3322 (clobber (match_operand:DI 6 "register_operand" ""))]
3323 "operands[3] != const0_rtx"
3324 [(set (match_dup 6) (match_dup 7))
3326 (if_then_else:DI (match_dup 8) (match_dup 4) (match_dup 5)))]
3328 { enum rtx_code code = GET_CODE (operands[1]);
3329 int unsignedp = (code == GEU || code == LEU || code == GTU || code == LTU);
3331 /* If we are comparing for equality with a constant and that constant
3332 appears in the arm when the register equals the constant, use the
3333 register since that is more likely to match (and to produce better code
3336 if (code == EQ && GET_CODE (operands[3]) == CONST_INT
3337 && rtx_equal_p (operands[4], operands[3]))
3338 operands[4] = operands[2];
3340 else if (code == NE && GET_CODE (operands[3]) == CONST_INT
3341 && rtx_equal_p (operands[5], operands[3]))
3342 operands[5] = operands[2];
3344 if (code == NE || code == EQ
3345 || (extended_count (operands[2], DImode, unsignedp) >= 1
3346 && extended_count (operands[3], DImode, unsignedp) >= 1))
3348 if (GET_CODE (operands[3]) == CONST_INT)
3349 operands[7] = gen_rtx_PLUS (DImode, operands[2],
3350 GEN_INT (- INTVAL (operands[3])));
3352 operands[7] = gen_rtx_MINUS (DImode, operands[2], operands[3]);
3354 operands[8] = gen_rtx_fmt_ee (code, VOIDmode, operands[6], const0_rtx);
3357 else if (code == EQ || code == LE || code == LT
3358 || code == LEU || code == LTU)
3360 operands[7] = gen_rtx_fmt_ee (code, DImode, operands[2], operands[3]);
3361 operands[8] = gen_rtx_NE (VOIDmode, operands[6], const0_rtx);
3365 operands[7] = gen_rtx_fmt_ee (reverse_condition (code), DImode,
3366 operands[2], operands[3]);
3367 operands[8] = gen_rtx_EQ (VOIDmode, operands[6], const0_rtx);
3372 [(set (match_operand:DI 0 "register_operand" "")
3374 (match_operator 1 "comparison_operator"
3375 [(match_operand:SI 2 "reg_or_0_operand" "")
3376 (match_operand:SI 3 "reg_or_cint_operand" "")])
3377 (match_operand:DI 4 "reg_or_8bit_operand" "")
3378 (match_operand:DI 5 "reg_or_8bit_operand" "")))
3379 (clobber (match_operand:DI 6 "register_operand" ""))]
3380 "operands[3] != const0_rtx
3381 && (GET_CODE (operands[1]) == EQ || GET_CODE (operands[1]) == NE)"
3382 [(set (match_dup 6) (match_dup 7))
3384 (if_then_else:DI (match_dup 8) (match_dup 4) (match_dup 5)))]
3386 { enum rtx_code code = GET_CODE (operands[1]);
3387 int unsignedp = (code == GEU || code == LEU || code == GTU || code == LTU);
3390 if ((code != NE && code != EQ
3391 && ! (extended_count (operands[2], DImode, unsignedp) >= 1
3392 && extended_count (operands[3], DImode, unsignedp) >= 1)))
3395 if (GET_CODE (operands[3]) == CONST_INT)
3396 tem = gen_rtx_PLUS (SImode, operands[2],
3397 GEN_INT (- INTVAL (operands[3])));
3399 tem = gen_rtx_MINUS (SImode, operands[2], operands[3]);
3401 operands[7] = gen_rtx_SIGN_EXTEND (DImode, tem);
3402 operands[8] = gen_rtx_fmt_ee (GET_CODE (operands[1]), VOIDmode,
3403 operands[6], const0_rtx);
3409 (match_operator 1 "comparison_operator"
3410 [(match_operand:DI 2 "reg_or_0_operand" "")
3411 (match_operand:DI 3 "reg_or_cint_operand" "")])
3412 (label_ref (match_operand 0 "" ""))
3414 (clobber (match_operand:DI 4 "register_operand" ""))]
3415 "operands[3] != const0_rtx"
3416 [(set (match_dup 4) (match_dup 5))
3417 (set (pc) (if_then_else (match_dup 6) (label_ref (match_dup 0)) (pc)))]
3419 { enum rtx_code code = GET_CODE (operands[1]);
3420 int unsignedp = (code == GEU || code == LEU || code == GTU || code == LTU);
3422 if (code == NE || code == EQ
3423 || (extended_count (operands[2], DImode, unsignedp) >= 1
3424 && extended_count (operands[3], DImode, unsignedp) >= 1))
3426 if (GET_CODE (operands[3]) == CONST_INT)
3427 operands[5] = gen_rtx_PLUS (DImode, operands[2],
3428 GEN_INT (- INTVAL (operands[3])));
3430 operands[5] = gen_rtx_MINUS (DImode, operands[2], operands[3]);
3432 operands[6] = gen_rtx_fmt_ee (code, VOIDmode, operands[4], const0_rtx);
3435 else if (code == EQ || code == LE || code == LT
3436 || code == LEU || code == LTU)
3438 operands[5] = gen_rtx_fmt_ee (code, DImode, operands[2], operands[3]);
3439 operands[6] = gen_rtx_NE (VOIDmode, operands[4], const0_rtx);
3443 operands[5] = gen_rtx_fmt_ee (reverse_condition (code), DImode,
3444 operands[2], operands[3]);
3445 operands[6] = gen_rtx_EQ (VOIDmode, operands[4], const0_rtx);
3452 (match_operator 1 "comparison_operator"
3453 [(match_operand:SI 2 "reg_or_0_operand" "")
3454 (match_operand:SI 3 "const_int_operand" "")])
3455 (label_ref (match_operand 0 "" ""))
3457 (clobber (match_operand:DI 4 "register_operand" ""))]
3458 "operands[3] != const0_rtx
3459 && (GET_CODE (operands[1]) == EQ || GET_CODE (operands[1]) == NE)"
3460 [(set (match_dup 4) (match_dup 5))
3461 (set (pc) (if_then_else (match_dup 6) (label_ref (match_dup 0)) (pc)))]
3465 if (GET_CODE (operands[3]) == CONST_INT)
3466 tem = gen_rtx_PLUS (SImode, operands[2],
3467 GEN_INT (- INTVAL (operands[3])));
3469 tem = gen_rtx_MINUS (SImode, operands[2], operands[3]);
3471 operands[5] = gen_rtx_SIGN_EXTEND (DImode, tem);
3472 operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[1]), VOIDmode,
3473 operands[4], const0_rtx);
3476 ;; We can convert such things as "a > 0xffff" to "t = a & ~ 0xffff; t != 0".
3477 ;; This eliminates one, and sometimes two, insns when the AND can be done
3480 [(set (match_operand:DI 0 "register_operand" "")
3481 (match_operator 1 "comparison_operator"
3482 [(match_operand:DI 2 "register_operand" "")
3483 (match_operand:DI 3 "const_int_operand" "")]))
3484 (clobber (match_operand:DI 4 "register_operand" ""))]
3485 "exact_log2 (INTVAL (operands[3]) + 1) >= 0
3486 && (GET_CODE (operands[1]) == GTU
3487 || GET_CODE (operands[1]) == LEU
3488 || ((GET_CODE (operands[1]) == GT || GET_CODE (operands[1]) == LE)
3489 && extended_count (operands[2], DImode, 1) > 0))"
3490 [(set (match_dup 4) (and:DI (match_dup 2) (match_dup 5)))
3491 (set (match_dup 0) (match_dup 6))]
3494 operands[5] = GEN_INT (~ INTVAL (operands[3]));
3495 operands[6] = gen_rtx_fmt_ee (((GET_CODE (operands[1]) == GTU
3496 || GET_CODE (operands[1]) == GT)
3498 DImode, operands[4], const0_rtx);
3501 ;; Here are the CALL and unconditional branch insns. Calls on NT and OSF
3502 ;; work differently, so we have different patterns for each.
3504 (define_expand "call"
3505 [(use (match_operand:DI 0 "" ""))
3506 (use (match_operand 1 "" ""))
3507 (use (match_operand 2 "" ""))
3508 (use (match_operand 3 "" ""))]
3511 { if (TARGET_WINDOWS_NT)
3512 emit_call_insn (gen_call_nt (operands[0], operands[1]));
3513 else if (TARGET_OPEN_VMS)
3514 emit_call_insn (gen_call_vms (operands[0], operands[2]));
3516 emit_call_insn (gen_call_osf (operands[0], operands[1]));
3521 (define_expand "call_osf"
3522 [(parallel [(call (mem:DI (match_operand 0 "" ""))
3523 (match_operand 1 "" ""))
3524 (clobber (reg:DI 27))
3525 (clobber (reg:DI 26))])]
3528 { if (GET_CODE (operands[0]) != MEM)
3531 operands[0] = XEXP (operands[0], 0);
3533 if (GET_CODE (operands[0]) != SYMBOL_REF
3534 && ! (GET_CODE (operands[0]) == REG && REGNO (operands[0]) == 27))
3536 rtx tem = gen_rtx_REG (DImode, 27);
3537 emit_move_insn (tem, operands[0]);
3542 (define_expand "call_nt"
3543 [(parallel [(call (mem:DI (match_operand 0 "" ""))
3544 (match_operand 1 "" ""))
3545 (clobber (reg:DI 26))])]
3548 { if (GET_CODE (operands[0]) != MEM)
3551 operands[0] = XEXP (operands[0], 0);
3552 if (GET_CODE (operands[0]) != SYMBOL_REF && GET_CODE (operands[0]) != REG)
3553 operands[0] = force_reg (DImode, operands[0]);
3557 ;; call openvms/alpha
3558 ;; op 0: symbol ref for called function
3559 ;; op 1: next_arg_reg (argument information value for R25)
3561 (define_expand "call_vms"
3562 [(parallel [(call (mem:DI (match_operand 0 "" ""))
3563 (match_operand 1 "" ""))
3567 (clobber (reg:DI 27))])]
3570 { if (GET_CODE (operands[0]) != MEM)
3573 operands[0] = XEXP (operands[0], 0);
3575 /* Always load AI with argument information, then handle symbolic and
3576 indirect call differently. Load RA and set operands[2] to PV in
3579 emit_move_insn (gen_rtx_REG (DImode, 25), operands[1]);
3580 if (GET_CODE (operands[0]) == SYMBOL_REF)
3582 extern char *savealloc ();
3583 char *linksym, *symbol = XSTR (operands[0], 0);
3588 linksym = savealloc (strlen (symbol) + 6);
3590 alpha_need_linkage (symbol, 0);
3593 strcpy (linksym+1, symbol);
3594 strcat (linksym, \"..lk\");
3595 linkage = gen_rtx_SYMBOL_REF (Pmode, linksym);
3597 emit_move_insn (gen_rtx_REG (Pmode, 26), gen_rtx_MEM (Pmode, linkage));
3600 = validize_mem (gen_rtx_MEM (Pmode, plus_constant (linkage, 8)));
3604 emit_move_insn (gen_rtx_REG (Pmode, 26),
3605 gen_rtx_MEM (Pmode, plus_constant (operands[0], 8)));
3607 operands[2] = operands[0];
3612 (define_expand "call_value"
3613 [(use (match_operand 0 "" ""))
3614 (use (match_operand:DI 1 "" ""))
3615 (use (match_operand 2 "" ""))
3616 (use (match_operand 3 "" ""))
3617 (use (match_operand 4 "" ""))]
3620 { if (TARGET_WINDOWS_NT)
3621 emit_call_insn (gen_call_value_nt (operands[0], operands[1], operands[2]));
3622 else if (TARGET_OPEN_VMS)
3623 emit_call_insn (gen_call_value_vms (operands[0], operands[1],
3626 emit_call_insn (gen_call_value_osf (operands[0], operands[1],
3631 (define_expand "call_value_osf"
3632 [(parallel [(set (match_operand 0 "" "")
3633 (call (mem:DI (match_operand 1 "" ""))
3634 (match_operand 2 "" "")))
3635 (clobber (reg:DI 27))
3636 (clobber (reg:DI 26))])]
3639 { if (GET_CODE (operands[1]) != MEM)
3642 operands[1] = XEXP (operands[1], 0);
3644 if (GET_CODE (operands[1]) != SYMBOL_REF
3645 && ! (GET_CODE (operands[1]) == REG && REGNO (operands[1]) == 27))
3647 rtx tem = gen_rtx_REG (DImode, 27);
3648 emit_move_insn (tem, operands[1]);
3653 (define_expand "call_value_nt"
3654 [(parallel [(set (match_operand 0 "" "")
3655 (call (mem:DI (match_operand 1 "" ""))
3656 (match_operand 2 "" "")))
3657 (clobber (reg:DI 26))])]
3660 { if (GET_CODE (operands[1]) != MEM)
3663 operands[1] = XEXP (operands[1], 0);
3664 if (GET_CODE (operands[0]) != SYMBOL_REF && GET_CODE (operands[0]) != REG)
3665 operands[1] = force_reg (DImode, operands[1]);
3668 (define_expand "call_value_vms"
3669 [(parallel [(set (match_operand 0 "" "")
3670 (call (mem:DI (match_operand:DI 1 "" ""))
3671 (match_operand 2 "" "")))
3675 (clobber (reg:DI 27))])]
3678 { if (GET_CODE (operands[1]) != MEM)
3681 operands[1] = XEXP (operands[1], 0);
3683 /* Always load AI with argument information, then handle symbolic and
3684 indirect call differently. Load RA and set operands[3] to PV in
3687 emit_move_insn (gen_rtx_REG (DImode, 25), operands[2]);
3688 if (GET_CODE (operands[1]) == SYMBOL_REF)
3690 extern char *savealloc ();
3691 char *linksym, *symbol = XSTR (operands[1], 0);
3696 linksym = savealloc (strlen (symbol) + 6);
3698 alpha_need_linkage (symbol, 0);
3700 strcpy (linksym+1, symbol);
3701 strcat (linksym, \"..lk\");
3702 linkage = gen_rtx_SYMBOL_REF (Pmode, linksym);
3704 emit_move_insn (gen_rtx_REG (Pmode, 26), gen_rtx_MEM (Pmode, linkage));
3707 = validize_mem (gen_rtx_MEM (Pmode, plus_constant (linkage, 8)));
3711 emit_move_insn (gen_rtx_REG (Pmode, 26),
3712 gen_rtx_MEM (Pmode, plus_constant (operands[1], 8)));
3714 operands[3] = operands[1];
3719 [(call (mem:DI (match_operand:DI 0 "call_operand" "r,R,i"))
3720 (match_operand 1 "" ""))
3721 (clobber (reg:DI 27))
3722 (clobber (reg:DI 26))]
3723 "! TARGET_WINDOWS_NT && ! TARGET_OPEN_VMS"
3725 jsr $26,($27),0\;ldgp $29,0($26)
3727 jsr $26,%0\;ldgp $29,0($26)"
3728 [(set_attr "type" "jsr")
3729 (set_attr "length" "12,*,16")])
3732 [(call (mem:DI (match_operand:DI 0 "call_operand" "r,R,i"))
3733 (match_operand 1 "" ""))
3734 (clobber (reg:DI 26))]
3740 [(set_attr "type" "jsr")
3741 (set_attr "length" "*,*,12")])
3744 [(call (mem:DI (match_operand:DI 0 "call_operand" "r,i"))
3745 (match_operand 1 "" ""))
3746 (use (match_operand:DI 2 "general_operand" "r,m"))
3749 (clobber (reg:DI 27))]
3752 mov %2,$27\;jsr $26,0\;ldq $27,0($29)
3753 ldq $27,%2\;jsr $26,%0\;ldq $27,0($29)"
3754 [(set_attr "type" "jsr")
3755 (set_attr "length" "12,16")])
3758 [(set (match_operand 0 "register_operand" "=rf,rf,rf")
3759 (call (mem:DI (match_operand:DI 1 "call_operand" "r,R,i"))
3760 (match_operand 2 "" "")))
3761 (clobber (reg:DI 27))
3762 (clobber (reg:DI 26))]
3763 "! TARGET_WINDOWS_NT && ! TARGET_OPEN_VMS"
3765 jsr $26,($27),0\;ldgp $29,0($26)
3767 jsr $26,%1\;ldgp $29,0($26)"
3768 [(set_attr "type" "jsr")
3769 (set_attr "length" "12,*,16")])
3772 [(set (match_operand 0 "register_operand" "=rf,rf,rf")
3773 (call (mem:DI (match_operand:DI 1 "call_operand" "r,R,i"))
3774 (match_operand 2 "" "")))
3775 (clobber (reg:DI 26))]
3781 [(set_attr "type" "jsr")
3782 (set_attr "length" "*,*,12")])
3785 [(set (match_operand 0 "register_operand" "")
3786 (call (mem:DI (match_operand:DI 1 "call_operand" "r,i"))
3787 (match_operand 2 "" "")))
3788 (use (match_operand:DI 3 "general_operand" "r,m"))
3791 (clobber (reg:DI 27))]
3794 mov %3,$27\;jsr $26,0\;ldq $27,0($29)
3795 ldq $27,%3\;jsr $26,%1\;ldq $27,0($29)"
3796 [(set_attr "type" "jsr")
3797 (set_attr "length" "12,16")])
3799 ;; Call subroutine returning any type.
3801 (define_expand "untyped_call"
3802 [(parallel [(call (match_operand 0 "" "")
3804 (match_operand 1 "" "")
3805 (match_operand 2 "" "")])]
3811 emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx));
3813 for (i = 0; i < XVECLEN (operands[2], 0); i++)
3815 rtx set = XVECEXP (operands[2], 0, i);
3816 emit_move_insn (SET_DEST (set), SET_SRC (set));
3819 /* The optimizer does not know that the call sets the function value
3820 registers we stored in the result block. We avoid problems by
3821 claiming that all hard registers are used and clobbered at this
3823 emit_insn (gen_blockage ());
3828 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
3829 ;; all of memory. This blocks insns from being moved across this point.
3831 (define_insn "blockage"
3832 [(unspec_volatile [(const_int 0)] 1)]
3835 [(set_attr "length" "0")])
3839 (label_ref (match_operand 0 "" "")))]
3842 [(set_attr "type" "ibr")])
3844 (define_insn "return"
3848 [(set_attr "type" "ibr")])
3850 ;; Use a different pattern for functions which have non-trivial
3851 ;; epilogues so as not to confuse jump and reorg.
3852 (define_insn "return_internal"
3857 [(set_attr "type" "ibr")])
3859 (define_insn "indirect_jump"
3860 [(set (pc) (match_operand:DI 0 "register_operand" "r"))]
3863 [(set_attr "type" "ibr")])
3865 (define_expand "tablejump"
3866 [(use (match_operand:SI 0 "register_operand" ""))
3867 (use (match_operand:SI 1 "" ""))]
3871 if (TARGET_WINDOWS_NT)
3872 emit_jump_insn (gen_tablejump_nt (operands[0], operands[1]));
3873 else if (TARGET_OPEN_VMS)
3874 emit_jump_insn (gen_tablejump_vms (operands[0], operands[1]));
3876 emit_jump_insn (gen_tablejump_osf (operands[0], operands[1]));
3881 (define_expand "tablejump_osf"
3883 (sign_extend:DI (match_operand:SI 0 "register_operand" "")))
3884 (parallel [(set (pc)
3885 (plus:DI (match_dup 3)
3886 (label_ref:DI (match_operand 1 "" ""))))
3887 (clobber (match_scratch:DI 2 "=r"))])]
3890 { operands[3] = gen_reg_rtx (DImode); }")
3892 (define_expand "tablejump_nt"
3894 (sign_extend:DI (match_operand:SI 0 "register_operand" "")))
3895 (parallel [(set (pc)
3897 (use (label_ref (match_operand 1 "" "")))])]
3900 { operands[3] = gen_reg_rtx (DImode); }")
3903 ;; tablejump, openVMS way
3905 ;; op 1: label preceding jump-table
3907 (define_expand "tablejump_vms"
3909 (match_operand:DI 0 "register_operand" ""))
3911 (plus:DI (match_dup 2)
3912 (label_ref:DI (match_operand 1 "" ""))))]
3915 { operands[2] = gen_reg_rtx (DImode); }")
3919 (plus:DI (match_operand:DI 0 "register_operand" "r")
3920 (label_ref:DI (match_operand 1 "" ""))))
3921 (clobber (match_scratch:DI 2 "=r"))]
3922 "! TARGET_WINDOWS_NT && ! TARGET_OPEN_VMS && next_active_insn (insn) != 0
3923 && GET_CODE (PATTERN (next_active_insn (insn))) == ADDR_DIFF_VEC
3924 && PREV_INSN (next_active_insn (insn)) == operands[1]"
3926 { rtx best_label = 0;
3927 rtx jump_table_insn = next_active_insn (operands[1]);
3929 if (GET_CODE (jump_table_insn) == JUMP_INSN
3930 && GET_CODE (PATTERN (jump_table_insn)) == ADDR_DIFF_VEC)
3932 rtx jump_table = PATTERN (jump_table_insn);
3933 int n_labels = XVECLEN (jump_table, 1);
3934 int best_count = -1;
3937 for (i = 0; i < n_labels; i++)
3941 for (j = i + 1; j < n_labels; j++)
3942 if (XEXP (XVECEXP (jump_table, 1, i), 0)
3943 == XEXP (XVECEXP (jump_table, 1, j), 0))
3946 if (count > best_count)
3947 best_count = count, best_label = XVECEXP (jump_table, 1, i);
3953 operands[3] = best_label;
3954 return \"addq %0,$29,%2\;jmp $31,(%2),%3\";
3957 return \"addq %0,$29,%2\;jmp $31,(%2),0\";
3959 [(set_attr "type" "ibr")
3960 (set_attr "length" "8")])
3964 (match_operand:DI 0 "register_operand" "r"))
3965 (use (label_ref (match_operand 1 "" "")))]
3966 "TARGET_WINDOWS_NT && next_active_insn (insn) != 0
3967 && GET_CODE (PATTERN (next_active_insn (insn))) == ADDR_DIFF_VEC
3968 && PREV_INSN (next_active_insn (insn)) == operands[1]"
3970 { rtx best_label = 0;
3971 rtx jump_table_insn = next_active_insn (operands[1]);
3973 if (GET_CODE (jump_table_insn) == JUMP_INSN
3974 && GET_CODE (PATTERN (jump_table_insn)) == ADDR_DIFF_VEC)
3976 rtx jump_table = PATTERN (jump_table_insn);
3977 int n_labels = XVECLEN (jump_table, 1);
3978 int best_count = -1;
3981 for (i = 0; i < n_labels; i++)
3985 for (j = i + 1; j < n_labels; j++)
3986 if (XEXP (XVECEXP (jump_table, 1, i), 0)
3987 == XEXP (XVECEXP (jump_table, 1, j), 0))
3990 if (count > best_count)
3991 best_count = count, best_label = XVECEXP (jump_table, 1, i);
3997 operands[2] = best_label;
3998 return \"jmp $31,(%0),%2\";
4001 return \"jmp $31,(%0),0\";
4003 [(set_attr "type" "ibr")])
4006 ;; op 0 is table offset
4007 ;; op 1 is table label
4012 (plus:DI (match_operand 0 "register_operand" "r")
4013 (label_ref (match_operand 1 "" ""))))]
4016 [(set_attr "type" "ibr")])
4018 ;; Cache flush. Used by INITIALIZE_TRAMPOLINE. 0x86 is PAL_imb, but we don't
4019 ;; want to have to include pal.h in our .s file.
4021 ;; Technically the type for call_pal is jsr, but we use that for determining
4022 ;; if we need a GP. Use ibr instead since it has the same EV5 scheduling
4025 [(unspec_volatile [(const_int 0)] 0)]
4028 [(set_attr "type" "ibr")])
4030 ;; Finally, we have the basic data motion insns. The byte and word insns
4031 ;; are done via define_expand. Start with the floating-point insns, since
4032 ;; they are simpler.
4035 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m,f,f,m")
4036 (match_operand:SF 1 "input_operand" "rG,m,r,fG,m,fG"))]
4038 && (register_operand (operands[0], SFmode)
4039 || reg_or_fp0_operand (operands[1], SFmode))"
4047 [(set_attr "type" "ilog,ild,ist,fcpys,fld,fst")])
4050 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m,f,f,m,f,*r")
4051 (match_operand:SF 1 "input_operand" "rG,m,r,fG,m,fG,r,*f"))]
4053 && (register_operand (operands[0], SFmode)
4054 || reg_or_fp0_operand (operands[1], SFmode))"
4064 [(set_attr "type" "ilog,ild,ist,fcpys,fld,fst,itof,ftoi")])
4067 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,f,f,m")
4068 (match_operand:DF 1 "input_operand" "rG,m,r,fG,m,fG"))]
4070 && (register_operand (operands[0], DFmode)
4071 || reg_or_fp0_operand (operands[1], DFmode))"
4079 [(set_attr "type" "ilog,ild,ist,fcpys,fld,fst")])
4082 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,f,f,m,f,*r")
4083 (match_operand:DF 1 "input_operand" "rG,m,r,fG,m,fG,r,*f"))]
4085 && (register_operand (operands[0], DFmode)
4086 || reg_or_fp0_operand (operands[1], DFmode))"
4096 [(set_attr "type" "ilog,ild,ist,fcpys,fld,fst,itof,ftoi")])
4098 (define_expand "movsf"
4099 [(set (match_operand:SF 0 "nonimmediate_operand" "")
4100 (match_operand:SF 1 "general_operand" ""))]
4104 if (GET_CODE (operands[0]) == MEM
4105 && ! reg_or_fp0_operand (operands[1], SFmode))
4106 operands[1] = force_reg (SFmode, operands[1]);
4109 (define_expand "movdf"
4110 [(set (match_operand:DF 0 "nonimmediate_operand" "")
4111 (match_operand:DF 1 "general_operand" ""))]
4115 if (GET_CODE (operands[0]) == MEM
4116 && ! reg_or_fp0_operand (operands[1], DFmode))
4117 operands[1] = force_reg (DFmode, operands[1]);
4121 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,m,f,f,m")
4122 (match_operand:SI 1 "input_operand" "rJ,K,L,m,rJ,fJ,m,f"))]
4123 "! TARGET_WINDOWS_NT && ! TARGET_OPEN_VMS && ! TARGET_CIX
4124 && (register_operand (operands[0], SImode)
4125 || reg_or_0_operand (operands[1], SImode))"
4135 [(set_attr "type" "ilog,iadd,iadd,ild,ist,fcpys,fld,fst")])
4138 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,m,f,f,m,r,*f")
4139 (match_operand:SI 1 "input_operand" "rJ,K,L,m,rJ,fJ,m,f,f,*r"))]
4140 "! TARGET_WINDOWS_NT && ! TARGET_OPEN_VMS && TARGET_CIX
4141 && (register_operand (operands[0], SImode)
4142 || reg_or_0_operand (operands[1], SImode))"
4154 [(set_attr "type" "ilog,iadd,iadd,ild,ist,fcpys,fld,fst,ftoi,itof")])
4157 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,r,m,f,f,m")
4158 (match_operand:SI 1 "input_operand" "rJ,K,L,s,m,rJ,fJ,m,f"))]
4159 "(TARGET_WINDOWS_NT || TARGET_OPEN_VMS)
4160 && (register_operand (operands[0], SImode)
4161 || reg_or_0_operand (operands[1], SImode))"
4172 [(set_attr "type" "ilog,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst")])
4175 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,f")
4176 (match_operand:HI 1 "input_operand" "rJ,n,fJ"))]
4178 && (register_operand (operands[0], HImode)
4179 || register_operand (operands[1], HImode))"
4184 [(set_attr "type" "ilog,iadd,fcpys")])
4187 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m,f")
4188 (match_operand:HI 1 "input_operand" "rJ,n,m,rJ,fJ"))]
4190 && (register_operand (operands[0], HImode)
4191 || reg_or_0_operand (operands[1], HImode))"
4198 [(set_attr "type" "ilog,iadd,ild,ist,fcpys")])
4201 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,f")
4202 (match_operand:QI 1 "input_operand" "rJ,n,fJ"))]
4204 && (register_operand (operands[0], QImode)
4205 || register_operand (operands[1], QImode))"
4210 [(set_attr "type" "ilog,iadd,fcpys")])
4213 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,r,m,f")
4214 (match_operand:QI 1 "input_operand" "rJ,n,m,rJ,fJ"))]
4216 && (register_operand (operands[0], QImode)
4217 || reg_or_0_operand (operands[1], QImode))"
4224 [(set_attr "type" "ilog,iadd,ild,ist,fcpys")])
4226 ;; We do two major things here: handle mem->mem and construct long
4229 (define_expand "movsi"
4230 [(set (match_operand:SI 0 "general_operand" "")
4231 (match_operand:SI 1 "general_operand" ""))]
4235 if (GET_CODE (operands[0]) == MEM
4236 && ! reg_or_0_operand (operands[1], SImode))
4237 operands[1] = force_reg (SImode, operands[1]);
4239 if (! CONSTANT_P (operands[1]) || input_operand (operands[1], SImode))
4241 else if (GET_CODE (operands[1]) == CONST_INT)
4244 = alpha_emit_set_const (operands[0], SImode, INTVAL (operands[1]), 3);
4245 if (rtx_equal_p (operands[0], operands[1]))
4250 ;; Split a load of a large constant into the appropriate two-insn
4254 [(set (match_operand:SI 0 "register_operand" "")
4255 (match_operand:SI 1 "const_int_operand" ""))]
4256 "! add_operand (operands[1], SImode)"
4257 [(set (match_dup 0) (match_dup 2))
4258 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
4261 = alpha_emit_set_const (operands[0], SImode, INTVAL (operands[1]), 2);
4263 if (tem == operands[0])
4270 [(set (match_operand:DI 0 "general_operand" "=r,r,r,r,r,m,f,f,Q")
4271 (match_operand:DI 1 "input_operand" "rJ,K,L,s,m,rJ,fJ,Q,f"))]
4273 && (register_operand (operands[0], DImode)
4274 || reg_or_0_operand (operands[1], DImode))"
4285 [(set_attr "type" "ilog,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst")])
4288 [(set (match_operand:DI 0 "general_operand" "=r,r,r,r,r,m,f,f,Q,r,*f")
4289 (match_operand:DI 1 "input_operand" "rJ,K,L,s,m,rJ,fJ,Q,f,f,*r"))]
4291 && (register_operand (operands[0], DImode)
4292 || reg_or_0_operand (operands[1], DImode))"
4305 [(set_attr "type" "ilog,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst,ftoi,itof")])
4307 ;; We do three major things here: handle mem->mem, put 64-bit constants in
4308 ;; memory, and construct long 32-bit constants.
4310 (define_expand "movdi"
4311 [(set (match_operand:DI 0 "general_operand" "")
4312 (match_operand:DI 1 "general_operand" ""))]
4318 if (GET_CODE (operands[0]) == MEM
4319 && ! reg_or_0_operand (operands[1], DImode))
4320 operands[1] = force_reg (DImode, operands[1]);
4322 if (! CONSTANT_P (operands[1]) || input_operand (operands[1], DImode))
4324 else if (GET_CODE (operands[1]) == CONST_INT
4325 && (tem = alpha_emit_set_const (operands[0], DImode,
4326 INTVAL (operands[1]), 3)) != 0)
4328 if (rtx_equal_p (tem, operands[0]))
4333 else if (CONSTANT_P (operands[1]))
4335 if (TARGET_BUILD_CONSTANTS)
4337 HOST_WIDE_INT i0, i1;
4339 if (GET_CODE (operands[1]) == CONST_INT)
4341 i0 = INTVAL (operands[1]);
4344 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
4346 #if HOST_BITS_PER_WIDE_INT >= 64
4347 i0 = CONST_DOUBLE_LOW (operands[1]);
4350 i0 = CONST_DOUBLE_LOW (operands[1]);
4351 i1 = CONST_DOUBLE_HIGH (operands[1]);
4357 tem = alpha_emit_set_long_const (operands[0], i0, i1);
4358 if (rtx_equal_p (tem, operands[0]))
4365 operands[1] = force_const_mem (DImode, operands[1]);
4366 if (reload_in_progress)
4368 emit_move_insn (operands[0], XEXP (operands[1], 0));
4369 operands[1] = copy_rtx (operands[1]);
4370 XEXP (operands[1], 0) = operands[0];
4373 operands[1] = validize_mem (operands[1]);
4380 ;; Split a load of a large constant into the appropriate two-insn
4384 [(set (match_operand:DI 0 "register_operand" "")
4385 (match_operand:DI 1 "const_int_operand" ""))]
4386 "! add_operand (operands[1], DImode)"
4387 [(set (match_dup 0) (match_dup 2))
4388 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
4391 = alpha_emit_set_const (operands[0], DImode, INTVAL (operands[1]), 2);
4393 if (tem == operands[0])
4399 ;; These are the partial-word cases.
4401 ;; First we have the code to load an aligned word. Operand 0 is the register
4402 ;; in which to place the result. It's mode is QImode or HImode. Operand 1
4403 ;; is an SImode MEM at the low-order byte of the proper word. Operand 2 is the
4404 ;; number of bits within the word that the value is. Operand 3 is an SImode
4405 ;; scratch register. If operand 0 is a hard register, operand 3 may be the
4406 ;; same register. It is allowed to conflict with operand 1 as well.
4408 (define_expand "aligned_loadqi"
4409 [(set (match_operand:SI 3 "register_operand" "")
4410 (match_operand:SI 1 "memory_operand" ""))
4411 (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
4412 (zero_extract:DI (subreg:DI (match_dup 3) 0)
4414 (match_operand:DI 2 "const_int_operand" "")))]
4419 (define_expand "aligned_loadhi"
4420 [(set (match_operand:SI 3 "register_operand" "")
4421 (match_operand:SI 1 "memory_operand" ""))
4422 (set (subreg:DI (match_operand:HI 0 "register_operand" "") 0)
4423 (zero_extract:DI (subreg:DI (match_dup 3) 0)
4425 (match_operand:DI 2 "const_int_operand" "")))]
4430 ;; Similar for unaligned loads, where we use the sequence from the
4431 ;; Alpha Architecture manual.
4433 ;; Operand 1 is the address. Operands 2 and 3 are temporaries, where
4434 ;; operand 3 can overlap the input and output registers.
4436 (define_expand "unaligned_loadqi"
4437 [(set (match_operand:DI 2 "register_operand" "")
4438 (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
4440 (set (match_operand:DI 3 "register_operand" "")
4442 (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
4443 (zero_extract:DI (match_dup 2)
4445 (ashift:DI (match_dup 3) (const_int 3))))]
4449 (define_expand "unaligned_loadhi"
4450 [(set (match_operand:DI 2 "register_operand" "")
4451 (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
4453 (set (match_operand:DI 3 "register_operand" "")
4455 (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
4456 (zero_extract:DI (match_dup 2)
4458 (ashift:DI (match_dup 3) (const_int 3))))]
4462 ;; Storing an aligned byte or word requires two temporaries. Operand 0 is the
4463 ;; aligned SImode MEM. Operand 1 is the register containing the
4464 ;; byte or word to store. Operand 2 is the number of bits within the word that
4465 ;; the value should be placed. Operands 3 and 4 are SImode temporaries.
4467 (define_expand "aligned_store"
4468 [(set (match_operand:SI 3 "register_operand" "")
4469 (match_operand:SI 0 "memory_operand" ""))
4470 (set (subreg:DI (match_dup 3) 0)
4471 (and:DI (subreg:DI (match_dup 3) 0) (match_dup 5)))
4472 (set (subreg:DI (match_operand:SI 4 "register_operand" "") 0)
4473 (ashift:DI (zero_extend:DI (match_operand 1 "register_operand" ""))
4474 (match_operand:DI 2 "const_int_operand" "")))
4475 (set (subreg:DI (match_dup 4) 0)
4476 (ior:DI (subreg:DI (match_dup 4) 0) (subreg:DI (match_dup 3) 0)))
4477 (set (match_dup 0) (match_dup 4))]
4480 { operands[5] = GEN_INT (~ (GET_MODE_MASK (GET_MODE (operands[1]))
4481 << INTVAL (operands[2])));
4484 ;; For the unaligned byte and halfword cases, we use code similar to that
4485 ;; in the ;; Architecture book, but reordered to lower the number of registers
4486 ;; required. Operand 0 is the address. Operand 1 is the data to store.
4487 ;; Operands 2, 3, and 4 are DImode temporaries, where operands 2 and 4 may
4488 ;; be the same temporary, if desired. If the address is in a register,
4489 ;; operand 2 can be that register.
4491 (define_expand "unaligned_storeqi"
4492 [(set (match_operand:DI 3 "register_operand" "")
4493 (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
4495 (set (match_operand:DI 2 "register_operand" "")
4498 (and:DI (not:DI (ashift:DI (const_int 255)
4499 (ashift:DI (match_dup 2) (const_int 3))))
4501 (set (match_operand:DI 4 "register_operand" "")
4502 (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" ""))
4503 (ashift:DI (match_dup 2) (const_int 3))))
4504 (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
4505 (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
4510 (define_expand "unaligned_storehi"
4511 [(set (match_operand:DI 3 "register_operand" "")
4512 (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
4514 (set (match_operand:DI 2 "register_operand" "")
4517 (and:DI (not:DI (ashift:DI (const_int 65535)
4518 (ashift:DI (match_dup 2) (const_int 3))))
4520 (set (match_operand:DI 4 "register_operand" "")
4521 (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" ""))
4522 (ashift:DI (match_dup 2) (const_int 3))))
4523 (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
4524 (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
4529 ;; Here are the define_expand's for QI and HI moves that use the above
4530 ;; patterns. We have the normal sets, plus the ones that need scratch
4531 ;; registers for reload.
4533 (define_expand "movqi"
4534 [(set (match_operand:QI 0 "general_operand" "")
4535 (match_operand:QI 1 "general_operand" ""))]
4541 if (GET_CODE (operands[0]) == MEM
4542 && ! reg_or_0_operand (operands[1], QImode))
4543 operands[1] = force_reg (QImode, operands[1]);
4545 if (GET_CODE (operands[1]) == CONST_INT
4546 && ! input_operand (operands[1], QImode))
4548 operands[1] = alpha_emit_set_const (operands[0], QImode,
4549 INTVAL (operands[1]), 3);
4551 if (rtx_equal_p (operands[0], operands[1]))
4558 /* If the output is not a register, the input must be. */
4559 if (GET_CODE (operands[0]) == MEM)
4560 operands[1] = force_reg (QImode, operands[1]);
4562 /* Handle four memory cases, unaligned and aligned for either the input
4563 or the output. The only case where we can be called during reload is
4564 for aligned loads; all other cases require temporaries. */
4566 if (GET_CODE (operands[1]) == MEM
4567 || (GET_CODE (operands[1]) == SUBREG
4568 && GET_CODE (SUBREG_REG (operands[1])) == MEM)
4569 || (reload_in_progress && GET_CODE (operands[1]) == REG
4570 && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER)
4571 || (reload_in_progress && GET_CODE (operands[1]) == SUBREG
4572 && GET_CODE (SUBREG_REG (operands[1])) == REG
4573 && REGNO (SUBREG_REG (operands[1])) >= FIRST_PSEUDO_REGISTER))
4575 if (aligned_memory_operand (operands[1], QImode))
4577 rtx aligned_mem, bitnum;
4578 rtx scratch = (reload_in_progress
4579 ? gen_rtx_REG (SImode, REGNO (operands[0]))
4580 : gen_reg_rtx (SImode));
4582 get_aligned_mem (operands[1], &aligned_mem, &bitnum);
4584 emit_insn (gen_aligned_loadqi (operands[0], aligned_mem, bitnum,
4589 /* Don't pass these as parameters since that makes the generated
4590 code depend on parameter evaluation order which will cause
4591 bootstrap failures. */
4593 rtx temp1 = gen_reg_rtx (DImode);
4594 rtx temp2 = gen_reg_rtx (DImode);
4596 = gen_unaligned_loadqi (operands[0],
4597 get_unaligned_address (operands[1], 0),
4600 alpha_set_memflags (seq, operands[1]);
4607 else if (GET_CODE (operands[0]) == MEM
4608 || (GET_CODE (operands[0]) == SUBREG
4609 && GET_CODE (SUBREG_REG (operands[0])) == MEM)
4610 || (reload_in_progress && GET_CODE (operands[0]) == REG
4611 && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER)
4612 || (reload_in_progress && GET_CODE (operands[0]) == SUBREG
4613 && GET_CODE (SUBREG_REG (operands[0])) == REG
4614 && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER))
4616 if (aligned_memory_operand (operands[0], QImode))
4618 rtx aligned_mem, bitnum;
4619 rtx temp1 = gen_reg_rtx (SImode);
4620 rtx temp2 = gen_reg_rtx (SImode);
4622 get_aligned_mem (operands[0], &aligned_mem, &bitnum);
4624 emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
4629 rtx temp1 = gen_reg_rtx (DImode);
4630 rtx temp2 = gen_reg_rtx (DImode);
4631 rtx temp3 = gen_reg_rtx (DImode);
4633 = gen_unaligned_storeqi (get_unaligned_address (operands[0], 0),
4634 operands[1], temp1, temp2, temp3);
4636 alpha_set_memflags (seq, operands[0]);
4644 (define_expand "movhi"
4645 [(set (match_operand:HI 0 "general_operand" "")
4646 (match_operand:HI 1 "general_operand" ""))]
4652 if (GET_CODE (operands[0]) == MEM
4653 && ! reg_or_0_operand (operands[1], HImode))
4654 operands[1] = force_reg (HImode, operands[1]);
4656 if (GET_CODE (operands[1]) == CONST_INT
4657 && ! input_operand (operands[1], HImode))
4659 operands[1] = alpha_emit_set_const (operands[0], HImode,
4660 INTVAL (operands[1]), 3);
4662 if (rtx_equal_p (operands[0], operands[1]))
4669 /* If the output is not a register, the input must be. */
4670 if (GET_CODE (operands[0]) == MEM)
4671 operands[1] = force_reg (HImode, operands[1]);
4673 /* Handle four memory cases, unaligned and aligned for either the input
4674 or the output. The only case where we can be called during reload is
4675 for aligned loads; all other cases require temporaries. */
4677 if (GET_CODE (operands[1]) == MEM
4678 || (GET_CODE (operands[1]) == SUBREG
4679 && GET_CODE (SUBREG_REG (operands[1])) == MEM)
4680 || (reload_in_progress && GET_CODE (operands[1]) == REG
4681 && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER)
4682 || (reload_in_progress && GET_CODE (operands[1]) == SUBREG
4683 && GET_CODE (SUBREG_REG (operands[1])) == REG
4684 && REGNO (SUBREG_REG (operands[1])) >= FIRST_PSEUDO_REGISTER))
4686 if (aligned_memory_operand (operands[1], HImode))
4688 rtx aligned_mem, bitnum;
4689 rtx scratch = (reload_in_progress
4690 ? gen_rtx_REG (SImode, REGNO (operands[0]))
4691 : gen_reg_rtx (SImode));
4693 get_aligned_mem (operands[1], &aligned_mem, &bitnum);
4695 emit_insn (gen_aligned_loadhi (operands[0], aligned_mem, bitnum,
4700 /* Don't pass these as parameters since that makes the generated
4701 code depend on parameter evaluation order which will cause
4702 bootstrap failures. */
4704 rtx temp1 = gen_reg_rtx (DImode);
4705 rtx temp2 = gen_reg_rtx (DImode);
4707 = gen_unaligned_loadhi (operands[0],
4708 get_unaligned_address (operands[1], 0),
4711 alpha_set_memflags (seq, operands[1]);
4718 else if (GET_CODE (operands[0]) == MEM
4719 || (GET_CODE (operands[0]) == SUBREG
4720 && GET_CODE (SUBREG_REG (operands[0])) == MEM)
4721 || (reload_in_progress && GET_CODE (operands[0]) == REG
4722 && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER)
4723 || (reload_in_progress && GET_CODE (operands[0]) == SUBREG
4724 && GET_CODE (SUBREG_REG (operands[0])) == REG
4725 && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER))
4727 if (aligned_memory_operand (operands[0], HImode))
4729 rtx aligned_mem, bitnum;
4730 rtx temp1 = gen_reg_rtx (SImode);
4731 rtx temp2 = gen_reg_rtx (SImode);
4733 get_aligned_mem (operands[0], &aligned_mem, &bitnum);
4735 emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
4740 rtx temp1 = gen_reg_rtx (DImode);
4741 rtx temp2 = gen_reg_rtx (DImode);
4742 rtx temp3 = gen_reg_rtx (DImode);
4744 = gen_unaligned_storehi (get_unaligned_address (operands[0], 0),
4745 operands[1], temp1, temp2, temp3);
4747 alpha_set_memflags (seq, operands[0]);
4756 ;; Here are the versions for reload. Note that in the unaligned cases
4757 ;; we know that the operand must not be a pseudo-register because stack
4758 ;; slots are always aligned references.
4760 (define_expand "reload_inqi"
4761 [(parallel [(match_operand:QI 0 "register_operand" "=r")
4762 (match_operand:QI 1 "unaligned_memory_operand" "m")
4763 (match_operand:TI 2 "register_operand" "=&r")])]
4767 rtx addr = get_unaligned_address (operands[1], 0);
4769 /* It is possible that one of the registers we got for operands[2]
4770 might coincide with that of operands[0] (which is why we made
4771 it TImode). Pick the other one to use as our scratch. */
4772 rtx scratch = gen_rtx_REG (DImode,
4773 REGNO (operands[0]) == REGNO (operands[2])
4774 ? REGNO (operands[2]) + 1 : REGNO (operands[2]));
4776 rtx seq = gen_unaligned_loadqi (operands[0], addr, scratch,
4777 gen_rtx_REG (DImode, REGNO (operands[0])));
4779 alpha_set_memflags (seq, operands[1]);
4784 (define_expand "reload_inhi"
4785 [(parallel [(match_operand:HI 0 "register_operand" "=r")
4786 (match_operand:HI 1 "unaligned_memory_operand" "m")
4787 (match_operand:TI 2 "register_operand" "=&r")])]
4791 rtx addr = get_unaligned_address (operands[1], 0);
4793 /* It is possible that one of the registers we got for operands[2]
4794 might coincide with that of operands[0] (which is why we made
4795 it TImode). Pick the other one to use as our scratch. */
4796 rtx scratch = gen_rtx_REG (DImode,
4797 REGNO (operands[0]) == REGNO (operands[2])
4798 ? REGNO (operands[2]) + 1 : REGNO (operands[2]));
4800 rtx seq = gen_unaligned_loadhi (operands[0], addr, scratch,
4801 gen_rtx_REG (DImode, REGNO (operands[0])));
4803 alpha_set_memflags (seq, operands[1]);
4808 (define_expand "reload_outqi"
4809 [(parallel [(match_operand:QI 0 "any_memory_operand" "=m")
4810 (match_operand:QI 1 "register_operand" "r")
4811 (match_operand:TI 2 "register_operand" "=&r")])]
4815 if (aligned_memory_operand (operands[0], QImode))
4817 rtx aligned_mem, bitnum;
4819 get_aligned_mem (operands[0], &aligned_mem, &bitnum);
4821 emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
4822 gen_rtx_REG (SImode, REGNO (operands[2])),
4823 gen_rtx_REG (SImode,
4824 REGNO (operands[2]) + 1)));
4828 rtx addr = get_unaligned_address (operands[0], 0);
4829 rtx scratch1 = gen_rtx_REG (DImode, REGNO (operands[2]));
4830 rtx scratch2 = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
4831 rtx scratch3 = scratch1;
4834 if (GET_CODE (addr) == REG)
4837 seq = gen_unaligned_storeqi (addr, operands[1], scratch1,
4838 scratch2, scratch3);
4839 alpha_set_memflags (seq, operands[0]);
4846 (define_expand "reload_outhi"
4847 [(parallel [(match_operand:HI 0 "any_memory_operand" "=m")
4848 (match_operand:HI 1 "register_operand" "r")
4849 (match_operand:TI 2 "register_operand" "=&r")])]
4853 if (aligned_memory_operand (operands[0], HImode))
4855 rtx aligned_mem, bitnum;
4857 get_aligned_mem (operands[0], &aligned_mem, &bitnum);
4859 emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
4860 gen_rtx_REG (SImode, REGNO (operands[2])),
4861 gen_rtx_REG (SImode,
4862 REGNO (operands[2]) + 1)));
4866 rtx addr = get_unaligned_address (operands[0], 0);
4867 rtx scratch1 = gen_rtx_REG (DImode, REGNO (operands[2]));
4868 rtx scratch2 = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
4869 rtx scratch3 = scratch1;
4872 if (GET_CODE (addr) == REG)
4875 seq = gen_unaligned_storehi (addr, operands[1], scratch1,
4876 scratch2, scratch3);
4877 alpha_set_memflags (seq, operands[0]);
4884 ;; Bit field extract patterns which use ext[wlq][lh]
4886 (define_expand "extv"
4887 [(set (match_operand:DI 0 "register_operand" "")
4888 (sign_extract:DI (match_operand:QI 1 "memory_operand" "")
4889 (match_operand:DI 2 "immediate_operand" "")
4890 (match_operand:DI 3 "immediate_operand" "")))]
4894 /* We can do 16, 32 and 64 bit fields, if aligned on byte boundaries. */
4895 if (INTVAL (operands[3]) % 8 != 0
4896 || (INTVAL (operands[2]) != 16
4897 && INTVAL (operands[2]) != 32
4898 && INTVAL (operands[2]) != 64))
4901 /* From mips.md: extract_bit_field doesn't verify that our source
4902 matches the predicate, so we force it to be a MEM here. */
4903 if (GET_CODE (operands[1]) != MEM)
4906 alpha_expand_unaligned_load (operands[0], operands[1],
4907 INTVAL (operands[2]) / 8,
4908 INTVAL (operands[3]) / 8, 1);
4912 (define_expand "extzv"
4913 [(set (match_operand:DI 0 "register_operand" "")
4914 (zero_extract:DI (match_operand:DI 1 "general_operand" "")
4915 (match_operand:DI 2 "immediate_operand" "")
4916 (match_operand:DI 3 "immediate_operand" "")))]
4920 /* We can do 8, 16, 32 and 64 bit fields, if aligned on byte boundaries. */
4921 if (INTVAL (operands[3]) % 8 != 0
4922 || (INTVAL (operands[2]) != 8
4923 && INTVAL (operands[2]) != 16
4924 && INTVAL (operands[2]) != 32
4925 && INTVAL (operands[2]) != 64))
4928 if (GET_CODE (operands[1]) == MEM)
4930 /* Fail 8 bit fields, falling back on a simple byte load. */
4931 if (INTVAL (operands[2]) == 8)
4934 alpha_expand_unaligned_load (operands[0], operands[1],
4935 INTVAL (operands[2]) / 8,
4936 INTVAL (operands[3]) / 8, 0);
4941 (define_expand "insv"
4942 [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "")
4943 (match_operand:DI 1 "immediate_operand" "")
4944 (match_operand:DI 2 "immediate_operand" ""))
4945 (match_operand:DI 3 "register_operand" ""))]
4949 /* We can do 16, 32 and 64 bit fields, if aligned on byte boundaries. */
4950 if (INTVAL (operands[2]) % 8 != 0
4951 || (INTVAL (operands[1]) != 16
4952 && INTVAL (operands[1]) != 32
4953 && INTVAL (operands[1]) != 64))
4956 /* From mips.md: store_bit_field doesn't verify that our source
4957 matches the predicate, so we force it to be a MEM here. */
4958 if (GET_CODE (operands[0]) != MEM)
4961 alpha_expand_unaligned_store (operands[0], operands[3],
4962 INTVAL (operands[1]) / 8,
4963 INTVAL (operands[2]) / 8);
4969 ;; Block move/clear, see alpha.c for more details.
4970 ;; Argument 0 is the destination
4971 ;; Argument 1 is the source
4972 ;; Argument 2 is the length
4973 ;; Argument 3 is the alignment
4975 (define_expand "movstrqi"
4976 [(parallel [(set (match_operand:BLK 0 "general_operand" "")
4977 (match_operand:BLK 1 "general_operand" ""))
4978 (use (match_operand:DI 2 "immediate_operand" ""))
4979 (use (match_operand:DI 3 "immediate_operand" ""))])]
4983 if (alpha_expand_block_move (operands))
4989 (define_expand "clrstrqi"
4990 [(parallel [(set (match_operand:BLK 0 "general_operand" "")
4992 (use (match_operand:DI 1 "immediate_operand" ""))
4993 (use (match_operand:DI 2 "immediate_operand" ""))])]
4997 if (alpha_expand_block_clear (operands))
5003 ;; Subroutine of stack space allocation. Perform a stack probe.
5004 (define_expand "probe_stack"
5005 [(set (match_dup 1) (match_operand:DI 0 "const_int_operand" ""))]
5009 operands[1] = gen_rtx_MEM (DImode, plus_constant (stack_pointer_rtx,
5010 INTVAL (operands[0])));
5011 MEM_VOLATILE_P (operands[1]) = 1;
5013 operands[0] = const0_rtx;
5016 ;; This is how we allocate stack space. If we are allocating a
5017 ;; constant amount of space and we know it is less than 4096
5018 ;; bytes, we need do nothing.
5020 ;; If it is more than 4096 bytes, we need to probe the stack
5022 (define_expand "allocate_stack"
5024 (plus:DI (reg:DI 30)
5025 (match_operand:DI 1 "reg_or_cint_operand" "")))
5026 (set (match_operand:DI 0 "register_operand" "=r")
5031 if (GET_CODE (operands[1]) == CONST_INT
5032 && INTVAL (operands[1]) < 32768)
5034 if (INTVAL (operands[1]) >= 4096)
5036 /* We do this the same way as in the prologue and generate explicit
5037 probes. Then we update the stack by the constant. */
5041 emit_insn (gen_probe_stack (GEN_INT (- probed)));
5042 while (probed + 8192 < INTVAL (operands[1]))
5043 emit_insn (gen_probe_stack (GEN_INT (- (probed += 8192))));
5045 if (probed + 4096 < INTVAL (operands[1]))
5046 emit_insn (gen_probe_stack (GEN_INT (- INTVAL(operands[1]))));
5049 operands[1] = GEN_INT (- INTVAL (operands[1]));
5050 operands[2] = virtual_stack_dynamic_rtx;
5055 rtx loop_label = gen_label_rtx ();
5056 rtx want = gen_reg_rtx (Pmode);
5057 rtx tmp = gen_reg_rtx (Pmode);
5060 emit_insn (gen_subdi3 (want, stack_pointer_rtx,
5061 force_reg (Pmode, operands[1])));
5062 emit_insn (gen_adddi3 (tmp, stack_pointer_rtx, GEN_INT (-4096)));
5064 if (GET_CODE (operands[1]) != CONST_INT)
5066 out_label = gen_label_rtx ();
5067 emit_insn (gen_cmpdi (want, tmp));
5068 emit_jump_insn (gen_bgeu (out_label));
5071 emit_label (loop_label);
5072 memref = gen_rtx_MEM (DImode, tmp);
5073 MEM_VOLATILE_P (memref) = 1;
5074 emit_move_insn (memref, const0_rtx);
5075 emit_insn (gen_adddi3 (tmp, tmp, GEN_INT(-8192)));
5076 emit_insn (gen_cmpdi (tmp, want));
5077 emit_jump_insn (gen_bgtu (loop_label));
5079 gen_rtx_USE (VOIDmode, tmp);
5081 memref = gen_rtx_MEM (DImode, want);
5082 MEM_VOLATILE_P (memref) = 1;
5083 emit_move_insn (memref, const0_rtx);
5086 emit_label (out_label);
5088 emit_move_insn (stack_pointer_rtx, want);
5089 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
5094 ;; This is used by alpha_expand_prolog to do the same thing as above,
5095 ;; except we cannot at that time generate new basic blocks, so we hide
5096 ;; the loop in this one insn.
5098 (define_insn "prologue_stack_probe_loop"
5099 [(unspec_volatile [(match_operand 0 "register_operand" "r")
5100 (match_operand 1 "register_operand" "r")] 5)]
5104 operands[2] = gen_label_rtx ();
5105 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
5106 CODE_LABEL_NUMBER (operands[2]));
5108 return \"stq $31,-8192(%1)\;subq %0,1,%0\;lda %1,-8192(%1)\;bne %0,%l2\";
5110 [(set_attr "length" "16")
5111 (set_attr "type" "multi")])
5113 (define_expand "prologue"
5114 [(clobber (const_int 0))]
5116 "alpha_expand_prologue (); DONE;")
5118 (define_insn "init_fp"
5119 [(set (match_operand:DI 0 "register_operand" "r")
5120 (match_operand:DI 1 "register_operand" "r"))
5121 (clobber (mem:BLK (match_operand:DI 2 "register_operand" "r")))]
5125 (define_expand "epilogue"
5126 [(clobber (const_int 0))]
5128 "alpha_expand_epilogue (); DONE;")
5130 (define_expand "eh_epilogue"
5131 [(use (match_operand:DI 0 "register_operand" "r"))
5132 (use (match_operand:DI 1 "register_operand" "r"))
5133 (use (match_operand:DI 2 "register_operand" "r"))]
5137 alpha_eh_epilogue_sp_ofs = operands[1];
5138 if (GET_CODE (operands[2]) != REG || REGNO (operands[2]) != 26)
5140 rtx ra = gen_rtx_REG (Pmode, 26);
5141 emit_move_insn (ra, operands[2]);
5146 (define_expand "builtin_longjmp"
5147 [(unspec_volatile [(match_operand 0 "register_operand" "r")] 3)]
5148 "! TARGET_OPEN_VMS && ! TARGET_WINDOWS_NT"
5151 /* The elements of the buffer are, in order: */
5152 rtx fp = gen_rtx_MEM (Pmode, operands[0]);
5153 rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0], 8));
5154 rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0], 16));
5155 rtx pv = gen_rtx_REG (Pmode, 27);
5157 /* This bit is the same as expand_builtin_longjmp. */
5158 emit_move_insn (hard_frame_pointer_rtx, fp);
5159 emit_move_insn (pv, lab);
5160 emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
5161 emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
5162 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
5164 /* Load the label we are jumping through into $27 so that we know
5165 where to look for it when we get back to setjmp's function for
5166 restoring the gp. */
5167 emit_indirect_jump (pv);
5171 (define_insn "builtin_setjmp_receiver"
5172 [(unspec_volatile [(match_operand 0 "" "")] 2)]
5173 "! TARGET_OPEN_VMS && ! TARGET_WINDOWS_NT && TARGET_AS_CAN_SUBTRACT_LABELS"
5174 "\\n$LSJ%=:\;ldgp $29,$LSJ%=-%l0($27)"
5175 [(set_attr "length" "8")
5176 (set_attr "type" "multi")])
5179 [(unspec_volatile [(match_operand 0 "" "")] 2)]
5180 "! TARGET_OPEN_VMS && ! TARGET_WINDOWS_NT"
5181 "br $29,$LSJ%=\\n$LSJ%=:\;ldgp $29,0($29)"
5182 [(set_attr "length" "12")
5183 (set_attr "type" "multi")])
5185 (define_insn "exception_receiver"
5186 [(unspec_volatile [(const_int 0)] 7)]
5187 "! TARGET_OPEN_VMS && ! TARGET_WINDOWS_NT"
5188 "br $29,$LSJ%=\\n$LSJ%=:\;ldgp $29,0($29)"
5189 [(set_attr "length" "12")
5190 (set_attr "type" "multi")])
5192 (define_expand "nonlocal_goto_receiver"
5193 [(unspec_volatile [(const_int 0)] 1)
5194 (set (reg:DI 27) (mem:DI (reg:DI 29)))
5195 (unspec_volatile [(const_int 0)] 1)
5200 (define_insn "arg_home"
5201 [(unspec [(const_int 0)] 0)
5216 (clobber (mem:BLK (const_int 0)))
5217 (clobber (reg:DI 24))
5218 (clobber (reg:DI 25))
5219 (clobber (reg:DI 0))]
5221 "lda $0,OTS$HOME_ARGS\;ldq $0,8($0)\;jsr $0,OTS$HOME_ARGS"
5222 [(set_attr "length" "16")
5223 (set_attr "type" "multi")])
5225 ;; Close the trap shadow of preceeding instructions. This is generated
5228 (define_insn "trapb"
5229 [(unspec_volatile [(const_int 0)] 4)]
5232 [(set_attr "type" "misc")])
5234 ;; No-op instructions used by machine-dependant reorg to preserve
5235 ;; alignment for instruction issue.
5241 [(set_attr "type" "ilog")])
5247 [(set_attr "type" "fcpys")])
5254 (define_insn "realign"
5255 [(unspec_volatile [(match_operand 0 "immediate_operand" "i")] 6)]
5257 ".align %0 #realign")
5259 ;; Peepholes go at the end.
5261 ;; Optimize sign-extension of SImode loads. This shows up in the wake of
5262 ;; reload when converting fp->int.
5264 ;; ??? What to do now that we actually care about the packing and
5265 ;; alignment of instructions? Perhaps reload can be enlightened, or
5266 ;; the peephole pass moved up after reload but before sched2?
5269 ; [(set (match_operand:SI 0 "register_operand" "=r")
5270 ; (match_operand:SI 1 "memory_operand" "m"))
5271 ; (set (match_operand:DI 2 "register_operand" "=r")
5272 ; (sign_extend:DI (match_dup 0)))]
5273 ; "dead_or_set_p (insn, operands[0])"
5277 ; [(set (match_operand:SI 0 "register_operand" "=r")
5278 ; (match_operand:SI 1 "hard_fp_register_operand" "f"))
5279 ; (set (match_operand:DI 2 "register_operand" "=r")
5280 ; (sign_extend:DI (match_dup 0)))]
5281 ; "TARGET_CIX && dead_or_set_p (insn, operands[0])"