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