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