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