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