alpha.c (call_operand): Accept pseudos.
[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 operands[0] = copy_to_mode_reg (Pmode, operands[0]);
4606 })
4607
4608 (define_expand "call_nt"
4609 [(parallel [(call (mem:DI (match_operand 0 "" ""))
4610 (match_operand 1 "" ""))
4611 (clobber (reg:DI 26))])]
4612 ""
4613 {
4614 if (GET_CODE (operands[0]) != MEM)
4615 abort ();
4616
4617 operands[0] = XEXP (operands[0], 0);
4618 if (GET_CODE (operands[0]) != SYMBOL_REF && GET_CODE (operands[0]) != REG)
4619 operands[0] = force_reg (DImode, operands[0]);
4620 })
4621
4622 ;; Calls on Unicos/Mk are always indirect.
4623 ;; op 0: symbol ref for called function
4624 ;; op 1: CIW for $25 represented by an unspec
4625
4626 (define_expand "call_umk"
4627 [(parallel [(call (mem:DI (match_operand 0 "" ""))
4628 (match_operand 1 "" ""))
4629 (use (reg:DI 25))
4630 (clobber (reg:DI 26))])]
4631 ""
4632 {
4633 if (GET_CODE (operands[0]) != MEM)
4634 abort ();
4635
4636 /* Always load the address of the called function into a register;
4637 load the CIW in $25. */
4638
4639 operands[0] = XEXP (operands[0], 0);
4640 if (GET_CODE (operands[0]) != REG)
4641 operands[0] = force_reg (DImode, operands[0]);
4642
4643 emit_move_insn (gen_rtx_REG (DImode, 25), operands[1]);
4644 })
4645
4646 ;;
4647 ;; call openvms/alpha
4648 ;; op 0: symbol ref for called function
4649 ;; op 1: next_arg_reg (argument information value for R25)
4650 ;;
4651 (define_expand "call_vms"
4652 [(parallel [(call (mem:DI (match_operand 0 "" ""))
4653 (match_operand 1 "" ""))
4654 (use (match_dup 2))
4655 (use (reg:DI 25))
4656 (use (reg:DI 26))
4657 (clobber (reg:DI 27))])]
4658 ""
4659 {
4660 if (GET_CODE (operands[0]) != MEM)
4661 abort ();
4662
4663 operands[0] = XEXP (operands[0], 0);
4664
4665 /* Always load AI with argument information, then handle symbolic and
4666 indirect call differently. Load RA and set operands[2] to PV in
4667 both cases. */
4668
4669 emit_move_insn (gen_rtx_REG (DImode, 25), operands[1]);
4670 if (GET_CODE (operands[0]) == SYMBOL_REF)
4671 {
4672 rtx linkage = alpha_need_linkage (XSTR (operands[0], 0), 0);
4673
4674 emit_move_insn (gen_rtx_REG (Pmode, 26), gen_rtx_MEM (Pmode, linkage));
4675 operands[2]
4676 = validize_mem (gen_rtx_MEM (Pmode, plus_constant (linkage, 8)));
4677 }
4678 else
4679 {
4680 emit_move_insn (gen_rtx_REG (Pmode, 26),
4681 gen_rtx_MEM (Pmode, plus_constant (operands[0], 8)));
4682 operands[2] = operands[0];
4683 }
4684
4685 })
4686
4687 (define_expand "call_value"
4688 [(use (match_operand 0 "" ""))
4689 (use (match_operand:DI 1 "" ""))
4690 (use (match_operand 2 "" ""))
4691 (use (match_operand 3 "" ""))
4692 (use (match_operand 4 "" ""))]
4693 ""
4694 {
4695 if (TARGET_ABI_WINDOWS_NT)
4696 emit_call_insn (gen_call_value_nt (operands[0], operands[1], operands[2]));
4697 else if (TARGET_ABI_OPEN_VMS)
4698 emit_call_insn (gen_call_value_vms (operands[0], operands[1],
4699 operands[3]));
4700 else if (TARGET_ABI_UNICOSMK)
4701 emit_call_insn (gen_call_value_umk (operands[0], operands[1],
4702 operands[3]));
4703 else
4704 emit_call_insn (gen_call_value_osf (operands[0], operands[1],
4705 operands[2]));
4706 DONE;
4707 })
4708
4709 (define_expand "sibcall_value"
4710 [(parallel [(set (match_operand 0 "" "")
4711 (call (mem:DI (match_operand 1 "" ""))
4712 (match_operand 2 "" "")))
4713 (use (reg:DI 29))])]
4714 "TARGET_ABI_OSF"
4715 {
4716 if (GET_CODE (operands[1]) != MEM)
4717 abort ();
4718 operands[1] = XEXP (operands[1], 0);
4719 })
4720
4721 (define_expand "call_value_osf"
4722 [(parallel [(set (match_operand 0 "" "")
4723 (call (mem:DI (match_operand 1 "" ""))
4724 (match_operand 2 "" "")))
4725 (use (reg:DI 29))
4726 (clobber (reg:DI 26))])]
4727 ""
4728 {
4729 if (GET_CODE (operands[1]) != MEM)
4730 abort ();
4731
4732 operands[1] = XEXP (operands[1], 0);
4733 if (! call_operand (operands[1], Pmode))
4734 operands[1] = copy_to_mode_reg (Pmode, operands[1]);
4735 })
4736
4737 (define_expand "call_value_nt"
4738 [(parallel [(set (match_operand 0 "" "")
4739 (call (mem:DI (match_operand 1 "" ""))
4740 (match_operand 2 "" "")))
4741 (clobber (reg:DI 26))])]
4742 ""
4743 {
4744 if (GET_CODE (operands[1]) != MEM)
4745 abort ();
4746
4747 operands[1] = XEXP (operands[1], 0);
4748 if (GET_CODE (operands[1]) != SYMBOL_REF && GET_CODE (operands[1]) != REG)
4749 operands[1] = force_reg (DImode, operands[1]);
4750 })
4751
4752 (define_expand "call_value_vms"
4753 [(parallel [(set (match_operand 0 "" "")
4754 (call (mem:DI (match_operand:DI 1 "" ""))
4755 (match_operand 2 "" "")))
4756 (use (match_dup 3))
4757 (use (reg:DI 25))
4758 (use (reg:DI 26))
4759 (clobber (reg:DI 27))])]
4760 ""
4761 {
4762 if (GET_CODE (operands[1]) != MEM)
4763 abort ();
4764
4765 operands[1] = XEXP (operands[1], 0);
4766
4767 /* Always load AI with argument information, then handle symbolic and
4768 indirect call differently. Load RA and set operands[3] to PV in
4769 both cases. */
4770
4771 emit_move_insn (gen_rtx_REG (DImode, 25), operands[2]);
4772 if (GET_CODE (operands[1]) == SYMBOL_REF)
4773 {
4774 rtx linkage = alpha_need_linkage (XSTR (operands[1], 0), 0);
4775
4776 emit_move_insn (gen_rtx_REG (Pmode, 26), gen_rtx_MEM (Pmode, linkage));
4777 operands[3]
4778 = validize_mem (gen_rtx_MEM (Pmode, plus_constant (linkage, 8)));
4779 }
4780 else
4781 {
4782 emit_move_insn (gen_rtx_REG (Pmode, 26),
4783 gen_rtx_MEM (Pmode, plus_constant (operands[1], 8)));
4784 operands[3] = operands[1];
4785 }
4786 })
4787
4788 (define_expand "call_value_umk"
4789 [(parallel [(set (match_operand 0 "" "")
4790 (call (mem:DI (match_operand 1 "" ""))
4791 (match_operand 2 "" "")))
4792 (use (reg:DI 25))
4793 (clobber (reg:DI 26))])]
4794 ""
4795 {
4796 if (GET_CODE (operands[1]) != MEM)
4797 abort ();
4798
4799 operands[1] = XEXP (operands[1], 0);
4800 if (GET_CODE (operands[1]) != REG)
4801 operands[1] = force_reg (DImode, operands[1]);
4802
4803 emit_move_insn (gen_rtx_REG (DImode, 25), operands[2]);
4804 })
4805
4806 (define_insn "*call_osf_1_er"
4807 [(call (mem:DI (match_operand:DI 0 "call_operand" "c,R,s"))
4808 (match_operand 1 "" ""))
4809 (use (reg:DI 29))
4810 (clobber (reg:DI 26))]
4811 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
4812 "@
4813 jsr $26,(%0),0\;ldah $29,0($26)\t\t!gpdisp!%*\;lda $29,0($29)\t\t!gpdisp!%*
4814 bsr $26,$%0..ng
4815 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!%*"
4816 [(set_attr "type" "jsr")
4817 (set_attr "length" "12,*,16")])
4818
4819 ;; We must use peep2 instead of a split because we need accurate life
4820 ;; information for $gp. Consider the case of { bar(); while (1); }.
4821 (define_peephole2
4822 [(parallel [(call (mem:DI (match_operand:DI 0 "call_operand" ""))
4823 (match_operand 1 "" ""))
4824 (use (reg:DI 29))
4825 (clobber (reg:DI 26))])]
4826 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF && reload_completed
4827 && ! current_file_function_operand (operands[0], Pmode)
4828 && peep2_regno_dead_p (1, 29)"
4829 [(parallel [(call (mem:DI (match_dup 2))
4830 (match_dup 1))
4831 (set (reg:DI 26) (plus:DI (pc) (const_int 4)))
4832 (unspec_volatile [(reg:DI 29)] UNSPECV_BLOCKAGE)
4833 (use (match_dup 0))])]
4834 {
4835 if (CONSTANT_P (operands[0]))
4836 {
4837 operands[2] = gen_rtx_REG (Pmode, 27);
4838 emit_move_insn (operands[2], operands[0]);
4839 }
4840 else
4841 {
4842 operands[2] = operands[0];
4843 operands[0] = const0_rtx;
4844 }
4845 })
4846
4847 (define_peephole2
4848 [(parallel [(call (mem:DI (match_operand:DI 0 "call_operand" ""))
4849 (match_operand 1 "" ""))
4850 (use (reg:DI 29))
4851 (clobber (reg:DI 26))])]
4852 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF && reload_completed
4853 && ! current_file_function_operand (operands[0], Pmode)
4854 && ! peep2_regno_dead_p (1, 29)"
4855 [(parallel [(call (mem:DI (match_dup 2))
4856 (match_dup 1))
4857 (set (reg:DI 26) (plus:DI (pc) (const_int 4)))
4858 (unspec_volatile [(reg:DI 29)] UNSPECV_BLOCKAGE)
4859 (use (match_dup 0))])
4860 (set (reg:DI 29)
4861 (unspec_volatile:DI [(reg:DI 26) (match_dup 3)] UNSPECV_LDGP1))
4862 (set (reg:DI 29)
4863 (unspec:DI [(reg:DI 29) (match_dup 3)] UNSPEC_LDGP2))]
4864 {
4865 if (CONSTANT_P (operands[0]))
4866 {
4867 operands[2] = gen_rtx_REG (Pmode, 27);
4868 emit_move_insn (operands[2], operands[0]);
4869 }
4870 else
4871 {
4872 operands[2] = operands[0];
4873 operands[0] = const0_rtx;
4874 }
4875 operands[3] = GEN_INT (alpha_next_sequence_number++);
4876 })
4877
4878 ;; We add a blockage unspec_volatile to prevent insns from moving down
4879 ;; from above the call to in between the call and the ldah gpdisp.
4880
4881 (define_insn "*call_osf_2_er"
4882 [(call (mem:DI (match_operand:DI 0 "register_operand" "c"))
4883 (match_operand 1 "" ""))
4884 (set (reg:DI 26) (plus:DI (pc) (const_int 4)))
4885 (unspec_volatile [(reg:DI 29)] UNSPECV_BLOCKAGE)
4886 (use (match_operand 2 "" ""))]
4887 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
4888 "jsr $26,(%0),%2"
4889 [(set_attr "type" "jsr")])
4890
4891 (define_insn "*call_osf_1_noreturn"
4892 [(call (mem:DI (match_operand:DI 0 "call_operand" "c,R,s"))
4893 (match_operand 1 "" ""))
4894 (use (reg:DI 29))
4895 (clobber (reg:DI 26))]
4896 "! TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF
4897 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
4898 "@
4899 jsr $26,($27),0
4900 bsr $26,$%0..ng
4901 jsr $26,%0"
4902 [(set_attr "type" "jsr")
4903 (set_attr "length" "*,*,8")])
4904
4905 (define_insn "*call_osf_1"
4906 [(call (mem:DI (match_operand:DI 0 "call_operand" "c,R,s"))
4907 (match_operand 1 "" ""))
4908 (use (reg:DI 29))
4909 (clobber (reg:DI 26))]
4910 "! TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
4911 "@
4912 jsr $26,($27),0\;ldgp $29,0($26)
4913 bsr $26,$%0..ng
4914 jsr $26,%0\;ldgp $29,0($26)"
4915 [(set_attr "type" "jsr")
4916 (set_attr "length" "12,*,16")])
4917
4918 ;; Note that the DEC assembler expands "jmp foo" with $at, which
4919 ;; doesn't do what we want.
4920 (define_insn "*sibcall_osf_1_er"
4921 [(call (mem:DI (match_operand:DI 0 "symbolic_operand" "R,s"))
4922 (match_operand 1 "" ""))
4923 (use (reg:DI 29))]
4924 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
4925 "@
4926 br $31,$%0..ng
4927 ldq $27,%0($29)\t\t!literal!%#\;jmp $31,($27),%0\t\t!lituse_jsr!%#"
4928 [(set_attr "type" "jsr")
4929 (set_attr "length" "*,8")])
4930
4931 (define_insn "*sibcall_osf_1"
4932 [(call (mem:DI (match_operand:DI 0 "symbolic_operand" "R,s"))
4933 (match_operand 1 "" ""))
4934 (use (reg:DI 29))]
4935 "! TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
4936 "@
4937 br $31,$%0..ng
4938 lda $27,%0\;jmp $31,($27),%0"
4939 [(set_attr "type" "jsr")
4940 (set_attr "length" "*,8")])
4941
4942 (define_insn "*call_nt_1"
4943 [(call (mem:DI (match_operand:DI 0 "call_operand" "r,R,s"))
4944 (match_operand 1 "" ""))
4945 (clobber (reg:DI 26))]
4946 "TARGET_ABI_WINDOWS_NT"
4947 "@
4948 jsr $26,(%0)
4949 bsr $26,%0
4950 jsr $26,%0"
4951 [(set_attr "type" "jsr")
4952 (set_attr "length" "*,*,12")])
4953
4954 (define_insn "*call_vms_1"
4955 [(call (mem:DI (match_operand:DI 0 "call_operand" "r,s"))
4956 (match_operand 1 "" ""))
4957 (use (match_operand:DI 2 "nonimmediate_operand" "r,m"))
4958 (use (reg:DI 25))
4959 (use (reg:DI 26))
4960 (clobber (reg:DI 27))]
4961 "TARGET_ABI_OPEN_VMS"
4962 "@
4963 mov %2,$27\;jsr $26,0\;ldq $27,0($29)
4964 ldq $27,%2\;jsr $26,%0\;ldq $27,0($29)"
4965 [(set_attr "type" "jsr")
4966 (set_attr "length" "12,16")])
4967
4968 (define_insn "*call_umk_1"
4969 [(call (mem:DI (match_operand:DI 0 "call_operand" "r"))
4970 (match_operand 1 "" ""))
4971 (use (reg:DI 25))
4972 (clobber (reg:DI 26))]
4973 "TARGET_ABI_UNICOSMK"
4974 "jsr $26,(%0)"
4975 [(set_attr "type" "jsr")])
4976
4977 ;; Call subroutine returning any type.
4978
4979 (define_expand "untyped_call"
4980 [(parallel [(call (match_operand 0 "" "")
4981 (const_int 0))
4982 (match_operand 1 "" "")
4983 (match_operand 2 "" "")])]
4984 ""
4985 {
4986 int i;
4987
4988 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
4989
4990 for (i = 0; i < XVECLEN (operands[2], 0); i++)
4991 {
4992 rtx set = XVECEXP (operands[2], 0, i);
4993 emit_move_insn (SET_DEST (set), SET_SRC (set));
4994 }
4995
4996 /* The optimizer does not know that the call sets the function value
4997 registers we stored in the result block. We avoid problems by
4998 claiming that all hard registers are used and clobbered at this
4999 point. */
5000 emit_insn (gen_blockage ());
5001
5002 DONE;
5003 })
5004
5005 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
5006 ;; all of memory. This blocks insns from being moved across this point.
5007
5008 (define_insn "blockage"
5009 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
5010 ""
5011 ""
5012 [(set_attr "length" "0")])
5013
5014 (define_insn "jump"
5015 [(set (pc)
5016 (label_ref (match_operand 0 "" "")))]
5017 ""
5018 "br $31,%l0"
5019 [(set_attr "type" "ibr")])
5020
5021 (define_expand "return"
5022 [(return)]
5023 "direct_return ()"
5024 "")
5025
5026 (define_insn "*return_internal"
5027 [(return)]
5028 "reload_completed"
5029 "ret $31,($26),1"
5030 [(set_attr "type" "ibr")])
5031
5032 (define_insn "indirect_jump"
5033 [(set (pc) (match_operand:DI 0 "register_operand" "r"))]
5034 ""
5035 "jmp $31,(%0),0"
5036 [(set_attr "type" "ibr")])
5037
5038 (define_expand "tablejump"
5039 [(parallel [(set (pc)
5040 (match_operand 0 "register_operand" ""))
5041 (use (label_ref:DI (match_operand 1 "" "")))])]
5042 ""
5043 {
5044 if (TARGET_ABI_WINDOWS_NT)
5045 {
5046 rtx dest = gen_reg_rtx (DImode);
5047 emit_insn (gen_extendsidi2 (dest, operands[0]));
5048 operands[0] = dest;
5049 }
5050 else if (TARGET_ABI_OSF)
5051 {
5052 rtx dest = gen_reg_rtx (DImode);
5053 emit_insn (gen_extendsidi2 (dest, operands[0]));
5054 emit_insn (gen_adddi3 (dest, pic_offset_table_rtx, dest));
5055 operands[0] = dest;
5056 }
5057 })
5058
5059 (define_insn "*tablejump_osf_nt_internal"
5060 [(set (pc)
5061 (match_operand:DI 0 "register_operand" "r"))
5062 (use (label_ref:DI (match_operand 1 "" "")))]
5063 "(TARGET_ABI_OSF || TARGET_ABI_WINDOWS_NT)
5064 && alpha_tablejump_addr_vec (insn)"
5065 {
5066 operands[2] = alpha_tablejump_best_label (insn);
5067 return "jmp $31,(%0),%2";
5068 }
5069 [(set_attr "type" "ibr")])
5070
5071 (define_insn "*tablejump_internal"
5072 [(set (pc)
5073 (match_operand:DI 0 "register_operand" "r"))
5074 (use (label_ref (match_operand 1 "" "")))]
5075 ""
5076 "jmp $31,(%0),0"
5077 [(set_attr "type" "ibr")])
5078
5079 ;; Cache flush. Used by INITIALIZE_TRAMPOLINE. 0x86 is PAL_imb, but we don't
5080 ;; want to have to include pal.h in our .s file.
5081 ;;
5082 ;; Technically the type for call_pal is jsr, but we use that for determining
5083 ;; if we need a GP. Use ibr instead since it has the same EV5 scheduling
5084 ;; characteristics.
5085 (define_insn "imb"
5086 [(unspec_volatile [(const_int 0)] UNSPECV_IMB)]
5087 ""
5088 "call_pal 0x86"
5089 [(set_attr "type" "ibr")])
5090 \f
5091 ;; Finally, we have the basic data motion insns. The byte and word insns
5092 ;; are done via define_expand. Start with the floating-point insns, since
5093 ;; they are simpler.
5094
5095 (define_insn "*movsf_nofix"
5096 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,*r,*r,m,m")
5097 (match_operand:SF 1 "input_operand" "fG,m,*rG,m,fG,*r"))]
5098 "TARGET_FPREGS && ! TARGET_FIX
5099 && (register_operand (operands[0], SFmode)
5100 || reg_or_fp0_operand (operands[1], SFmode))"
5101 "@
5102 cpys %R1,%R1,%0
5103 ld%, %0,%1
5104 bis $31,%r1,%0
5105 ldl %0,%1
5106 st%, %R1,%0
5107 stl %r1,%0"
5108 [(set_attr "type" "fcpys,fld,ilog,ild,fst,ist")])
5109
5110 (define_insn "*movsf_fix"
5111 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,*r,*r,m,m,f,*r")
5112 (match_operand:SF 1 "input_operand" "fG,m,*rG,m,fG,*r,*r,f"))]
5113 "TARGET_FPREGS && TARGET_FIX
5114 && (register_operand (operands[0], SFmode)
5115 || reg_or_fp0_operand (operands[1], SFmode))"
5116 "@
5117 cpys %R1,%R1,%0
5118 ld%, %0,%1
5119 bis $31,%r1,%0
5120 ldl %0,%1
5121 st%, %R1,%0
5122 stl %r1,%0
5123 itofs %1,%0
5124 ftois %1,%0"
5125 [(set_attr "type" "fcpys,fld,ilog,ild,fst,ist,itof,ftoi")])
5126
5127 (define_insn "*movsf_nofp"
5128 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m")
5129 (match_operand:SF 1 "input_operand" "rG,m,r"))]
5130 "! TARGET_FPREGS
5131 && (register_operand (operands[0], SFmode)
5132 || reg_or_fp0_operand (operands[1], SFmode))"
5133 "@
5134 bis $31,%r1,%0
5135 ldl %0,%1
5136 stl %r1,%0"
5137 [(set_attr "type" "ilog,ild,ist")])
5138
5139 (define_insn "*movdf_nofix"
5140 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,*r,*r,m,m")
5141 (match_operand:DF 1 "input_operand" "fG,m,*rG,m,fG,*r"))]
5142 "TARGET_FPREGS && ! TARGET_FIX
5143 && (register_operand (operands[0], DFmode)
5144 || reg_or_fp0_operand (operands[1], DFmode))"
5145 "@
5146 cpys %R1,%R1,%0
5147 ld%- %0,%1
5148 bis $31,%r1,%0
5149 ldq %0,%1
5150 st%- %R1,%0
5151 stq %r1,%0"
5152 [(set_attr "type" "fcpys,fld,ilog,ild,fst,ist")])
5153
5154 (define_insn "*movdf_fix"
5155 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,*r,*r,m,m,f,*r")
5156 (match_operand:DF 1 "input_operand" "fG,m,*rG,m,fG,*r,*r,f"))]
5157 "TARGET_FPREGS && TARGET_FIX
5158 && (register_operand (operands[0], DFmode)
5159 || reg_or_fp0_operand (operands[1], DFmode))"
5160 "@
5161 cpys %R1,%R1,%0
5162 ld%- %0,%1
5163 bis $31,%r1,%0
5164 ldq %0,%1
5165 st%- %R1,%0
5166 stq %r1,%0
5167 itoft %1,%0
5168 ftoit %1,%0"
5169 [(set_attr "type" "fcpys,fld,ilog,ild,fst,ist,itof,ftoi")])
5170
5171 (define_insn "*movdf_nofp"
5172 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m")
5173 (match_operand:DF 1 "input_operand" "rG,m,r"))]
5174 "! TARGET_FPREGS
5175 && (register_operand (operands[0], DFmode)
5176 || reg_or_fp0_operand (operands[1], DFmode))"
5177 "@
5178 bis $31,%r1,%0
5179 ldq %0,%1
5180 stq %r1,%0"
5181 [(set_attr "type" "ilog,ild,ist")])
5182
5183 ;; Subregs suck for register allocation. Pretend we can move TFmode
5184 ;; data between general registers until after reload.
5185
5186 (define_insn_and_split "*movtf_internal"
5187 [(set (match_operand:TF 0 "nonimmediate_operand" "=r,o")
5188 (match_operand:TF 1 "input_operand" "roG,rG"))]
5189 "register_operand (operands[0], TFmode)
5190 || reg_or_fp0_operand (operands[1], TFmode)"
5191 "#"
5192 "reload_completed"
5193 [(set (match_dup 0) (match_dup 2))
5194 (set (match_dup 1) (match_dup 3))]
5195 {
5196 alpha_split_tfmode_pair (operands);
5197 if (reg_overlap_mentioned_p (operands[0], operands[3]))
5198 {
5199 rtx tmp;
5200 tmp = operands[0], operands[0] = operands[1], operands[1] = tmp;
5201 tmp = operands[2], operands[2] = operands[3], operands[3] = tmp;
5202 }
5203 })
5204
5205 (define_expand "movsf"
5206 [(set (match_operand:SF 0 "nonimmediate_operand" "")
5207 (match_operand:SF 1 "general_operand" ""))]
5208 ""
5209 {
5210 if (GET_CODE (operands[0]) == MEM
5211 && ! reg_or_fp0_operand (operands[1], SFmode))
5212 operands[1] = force_reg (SFmode, operands[1]);
5213 })
5214
5215 (define_expand "movdf"
5216 [(set (match_operand:DF 0 "nonimmediate_operand" "")
5217 (match_operand:DF 1 "general_operand" ""))]
5218 ""
5219 {
5220 if (GET_CODE (operands[0]) == MEM
5221 && ! reg_or_fp0_operand (operands[1], DFmode))
5222 operands[1] = force_reg (DFmode, operands[1]);
5223 })
5224
5225 (define_expand "movtf"
5226 [(set (match_operand:TF 0 "nonimmediate_operand" "")
5227 (match_operand:TF 1 "general_operand" ""))]
5228 ""
5229 {
5230 if (GET_CODE (operands[0]) == MEM
5231 && ! reg_or_fp0_operand (operands[1], TFmode))
5232 operands[1] = force_reg (TFmode, operands[1]);
5233 })
5234
5235 (define_insn "*movsi_nofix"
5236 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,m,*f,*f,m")
5237 (match_operand:SI 1 "input_operand" "rJ,K,L,m,rJ,*fJ,m,*f"))]
5238 "(TARGET_ABI_OSF || TARGET_ABI_UNICOSMK) && ! TARGET_FIX
5239 && (register_operand (operands[0], SImode)
5240 || reg_or_0_operand (operands[1], SImode))"
5241 "@
5242 bis $31,%r1,%0
5243 lda %0,%1($31)
5244 ldah %0,%h1($31)
5245 ldl %0,%1
5246 stl %r1,%0
5247 cpys %R1,%R1,%0
5248 ld%, %0,%1
5249 st%, %R1,%0"
5250 [(set_attr "type" "ilog,iadd,iadd,ild,ist,fcpys,fld,fst")])
5251
5252 (define_insn "*movsi_fix"
5253 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,m,*f,*f,m,r,*f")
5254 (match_operand:SI 1 "input_operand" "rJ,K,L,m,rJ,*fJ,m,*f,*f,r"))]
5255 "TARGET_ABI_OSF && TARGET_FIX
5256 && (register_operand (operands[0], SImode)
5257 || reg_or_0_operand (operands[1], SImode))"
5258 "@
5259 bis $31,%r1,%0
5260 lda %0,%1($31)
5261 ldah %0,%h1($31)
5262 ldl %0,%1
5263 stl %r1,%0
5264 cpys %R1,%R1,%0
5265 ld%, %0,%1
5266 st%, %R1,%0
5267 ftois %1,%0
5268 itofs %1,%0"
5269 [(set_attr "type" "ilog,iadd,iadd,ild,ist,fcpys,fld,fst,ftoi,itof")])
5270
5271 (define_insn "*movsi_nt_vms"
5272 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,r,m,*f,*f,m")
5273 (match_operand:SI 1 "input_operand" "rJ,K,L,s,m,rJ,*fJ,m,*f"))]
5274 "(TARGET_ABI_WINDOWS_NT || TARGET_ABI_OPEN_VMS)
5275 && (register_operand (operands[0], SImode)
5276 || reg_or_0_operand (operands[1], SImode))"
5277 "@
5278 bis $31,%1,%0
5279 lda %0,%1
5280 ldah %0,%h1
5281 lda %0,%1
5282 ldl %0,%1
5283 stl %r1,%0
5284 cpys %R1,%R1,%0
5285 ld%, %0,%1
5286 st%, %R1,%0"
5287 [(set_attr "type" "ilog,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst")])
5288
5289 (define_insn "*movhi_nobwx"
5290 [(set (match_operand:HI 0 "register_operand" "=r,r")
5291 (match_operand:HI 1 "input_operand" "rJ,n"))]
5292 "! TARGET_BWX
5293 && (register_operand (operands[0], HImode)
5294 || register_operand (operands[1], HImode))"
5295 "@
5296 bis $31,%r1,%0
5297 lda %0,%L1($31)"
5298 [(set_attr "type" "ilog,iadd")])
5299
5300 (define_insn "*movhi_bwx"
5301 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
5302 (match_operand:HI 1 "input_operand" "rJ,n,m,rJ"))]
5303 "TARGET_BWX
5304 && (register_operand (operands[0], HImode)
5305 || reg_or_0_operand (operands[1], HImode))"
5306 "@
5307 bis $31,%r1,%0
5308 lda %0,%L1($31)
5309 ldwu %0,%1
5310 stw %r1,%0"
5311 [(set_attr "type" "ilog,iadd,ild,ist")])
5312
5313 (define_insn "*movqi_nobwx"
5314 [(set (match_operand:QI 0 "register_operand" "=r,r")
5315 (match_operand:QI 1 "input_operand" "rJ,n"))]
5316 "! TARGET_BWX
5317 && (register_operand (operands[0], QImode)
5318 || register_operand (operands[1], QImode))"
5319 "@
5320 bis $31,%r1,%0
5321 lda %0,%L1($31)"
5322 [(set_attr "type" "ilog,iadd")])
5323
5324 (define_insn "*movqi_bwx"
5325 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,r,m")
5326 (match_operand:QI 1 "input_operand" "rJ,n,m,rJ"))]
5327 "TARGET_BWX
5328 && (register_operand (operands[0], QImode)
5329 || reg_or_0_operand (operands[1], QImode))"
5330 "@
5331 bis $31,%r1,%0
5332 lda %0,%L1($31)
5333 ldbu %0,%1
5334 stb %r1,%0"
5335 [(set_attr "type" "ilog,iadd,ild,ist")])
5336
5337 ;; We do two major things here: handle mem->mem and construct long
5338 ;; constants.
5339
5340 (define_expand "movsi"
5341 [(set (match_operand:SI 0 "nonimmediate_operand" "")
5342 (match_operand:SI 1 "general_operand" ""))]
5343 ""
5344 {
5345 if (alpha_expand_mov (SImode, operands))
5346 DONE;
5347 })
5348
5349 ;; Split a load of a large constant into the appropriate two-insn
5350 ;; sequence.
5351
5352 (define_split
5353 [(set (match_operand:SI 0 "register_operand" "")
5354 (match_operand:SI 1 "const_int_operand" ""))]
5355 "! add_operand (operands[1], SImode)"
5356 [(set (match_dup 0) (match_dup 2))
5357 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
5358 {
5359 rtx tem
5360 = alpha_emit_set_const (operands[0], SImode, INTVAL (operands[1]), 2);
5361
5362 if (tem == operands[0])
5363 DONE;
5364 else
5365 FAIL;
5366 })
5367
5368 ;; Split the load of an address into a four-insn sequence on Unicos/Mk.
5369 ;; Always generate a REG_EQUAL note for the last instruction to facilitate
5370 ;; optimisations. If the symbolic operand is a label_ref, generate REG_LABEL
5371 ;; notes and update LABEL_NUSES because this is not done automatically.
5372 ;; Labels may be incorrectly deleted if we don't do this.
5373 ;;
5374 ;; Describing what the individual instructions do correctly is too complicated
5375 ;; so use UNSPECs for each of the three parts of an address.
5376
5377 (define_split
5378 [(set (match_operand:DI 0 "register_operand" "")
5379 (match_operand:DI 1 "symbolic_operand" ""))]
5380 "TARGET_ABI_UNICOSMK && reload_completed"
5381 [(const_int 0)]
5382 {
5383 rtx insn1, insn2, insn3;
5384
5385 insn1 = emit_insn (gen_umk_laum (operands[0], operands[1]));
5386 emit_insn (gen_ashldi3 (operands[0], operands[0], GEN_INT (32)));
5387 insn2 = emit_insn (gen_umk_lalm (operands[0], operands[0], operands[1]));
5388 insn3 = emit_insn (gen_umk_lal (operands[0], operands[0], operands[1]));
5389 REG_NOTES (insn3) = gen_rtx_EXPR_LIST (REG_EQUAL, operands[1],
5390 REG_NOTES (insn3));
5391 if (GET_CODE (operands[1]) == LABEL_REF)
5392 {
5393 rtx label;
5394
5395 label = XEXP (operands[1], 0);
5396 REG_NOTES (insn1) = gen_rtx_EXPR_LIST (REG_LABEL, label,
5397 REG_NOTES (insn1));
5398 REG_NOTES (insn2) = gen_rtx_EXPR_LIST (REG_LABEL, label,
5399 REG_NOTES (insn2));
5400 REG_NOTES (insn3) = gen_rtx_EXPR_LIST (REG_LABEL, label,
5401 REG_NOTES (insn3));
5402 LABEL_NUSES (label) += 3;
5403 }
5404 DONE;
5405 })
5406
5407 ;; Instructions for loading the three parts of an address on Unicos/Mk.
5408
5409 (define_insn "umk_laum"
5410 [(set (match_operand:DI 0 "register_operand" "=r")
5411 (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
5412 UNSPEC_UMK_LAUM))]
5413 "TARGET_ABI_UNICOSMK"
5414 "laum %r0,%t1($31)"
5415 [(set_attr "type" "iadd")])
5416
5417 (define_insn "umk_lalm"
5418 [(set (match_operand:DI 0 "register_operand" "=r")
5419 (plus:DI (match_operand:DI 1 "register_operand" "r")
5420 (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
5421 UNSPEC_UMK_LALM)))]
5422 "TARGET_ABI_UNICOSMK"
5423 "lalm %r0,%t2(%r1)"
5424 [(set_attr "type" "iadd")])
5425
5426 (define_insn "umk_lal"
5427 [(set (match_operand:DI 0 "register_operand" "=r")
5428 (plus:DI (match_operand:DI 1 "register_operand" "r")
5429 (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
5430 UNSPEC_UMK_LAL)))]
5431 "TARGET_ABI_UNICOSMK"
5432 "lal %r0,%t2(%r1)"
5433 [(set_attr "type" "iadd")])
5434
5435 ;; Add a new call information word to the current function's list of CIWs
5436 ;; and load its index into $25. Doing it here ensures that the CIW will be
5437 ;; associated with the correct function even in the presence of inlining.
5438
5439 (define_insn "*umk_load_ciw"
5440 [(set (reg:DI 25)
5441 (unspec:DI [(match_operand 0 "" "")] UNSPEC_UMK_LOAD_CIW))]
5442 "TARGET_ABI_UNICOSMK"
5443 {
5444 operands[0] = unicosmk_add_call_info_word (operands[0]);
5445 return "lda $25,%0";
5446 }
5447 [(set_attr "type" "iadd")])
5448
5449 (define_insn "*movdi_er_low_l"
5450 [(set (match_operand:DI 0 "register_operand" "=r")
5451 (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
5452 (match_operand:DI 2 "local_symbolic_operand" "")))]
5453 "TARGET_EXPLICIT_RELOCS"
5454 {
5455 if (true_regnum (operands[1]) == 29)
5456 return "lda %0,%2(%1)\t\t!gprel";
5457 else
5458 return "lda %0,%2(%1)\t\t!gprellow";
5459 })
5460
5461 (define_insn "movdi_er_high_g"
5462 [(set (match_operand:DI 0 "register_operand" "=r")
5463 (unspec:DI [(match_operand:DI 1 "register_operand" "r")
5464 (match_operand:DI 2 "global_symbolic_operand" "")
5465 (match_operand 3 "const_int_operand" "")]
5466 UNSPEC_LITERAL))]
5467 "TARGET_EXPLICIT_RELOCS"
5468 "ldq %0,%2(%1)\t\t!literal"
5469 [(set_attr "type" "ldsym")])
5470
5471 (define_insn "*movdi_er_nofix"
5472 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,r,r,m,*f,*f,Q")
5473 (match_operand:DI 1 "input_operand" "rJ,K,L,T,m,rJ,*fJ,Q,*f"))]
5474 "TARGET_EXPLICIT_RELOCS && ! TARGET_FIX
5475 && (register_operand (operands[0], DImode)
5476 || reg_or_0_operand (operands[1], DImode))"
5477 "@
5478 mov %r1,%0
5479 lda %0,%1($31)
5480 ldah %0,%h1($31)
5481 ldah %0,%H1
5482 ldq%A1 %0,%1
5483 stq%A0 %r1,%0
5484 fmov %R1,%0
5485 ldt %0,%1
5486 stt %R1,%0"
5487 [(set_attr "type" "ilog,iadd,iadd,iadd,ild,ist,fcpys,fld,fst")])
5488
5489 ;; The 'U' constraint matches symbolic operands on Unicos/Mk. Those should
5490 ;; have been split up by the rules above but we shouldn't reject the
5491 ;; possibility of them getting through.
5492
5493 (define_insn "*movdi_nofix"
5494 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,r,r,r,m,*f,*f,Q")
5495 (match_operand:DI 1 "input_operand" "rJ,K,L,U,s,m,rJ,*fJ,Q,*f"))]
5496 "! TARGET_FIX
5497 && (register_operand (operands[0], DImode)
5498 || reg_or_0_operand (operands[1], DImode))"
5499 "@
5500 bis $31,%r1,%0
5501 lda %0,%1($31)
5502 ldah %0,%h1($31)
5503 laum %0,%t1($31)\;sll %0,32,%0\;lalm %0,%t1(%0)\;lal %0,%t1(%0)
5504 lda %0,%1
5505 ldq%A1 %0,%1
5506 stq%A0 %r1,%0
5507 cpys %R1,%R1,%0
5508 ldt %0,%1
5509 stt %R1,%0"
5510 [(set_attr "type" "ilog,iadd,iadd,ldsym,ldsym,ild,ist,fcpys,fld,fst")
5511 (set_attr "length" "*,*,*,16,*,*,*,*,*,*")])
5512
5513 (define_insn "*movdi_er_fix"
5514 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,r,r,m,*f,*f,Q,r,*f")
5515 (match_operand:DI 1 "input_operand" "rJ,K,L,T,m,rJ,*fJ,Q,*f,*f,r"))]
5516 "TARGET_EXPLICIT_RELOCS && TARGET_FIX
5517 && (register_operand (operands[0], DImode)
5518 || reg_or_0_operand (operands[1], DImode))"
5519 "@
5520 mov %r1,%0
5521 lda %0,%1($31)
5522 ldah %0,%h1($31)
5523 ldah %0,%H1
5524 ldq%A1 %0,%1
5525 stq%A0 %r1,%0
5526 fmov %R1,%0
5527 ldt %0,%1
5528 stt %R1,%0
5529 ftoit %1,%0
5530 itoft %1,%0"
5531 [(set_attr "type" "ilog,iadd,iadd,iadd,ild,ist,fcpys,fld,fst,ftoi,itof")])
5532
5533 (define_insn "*movdi_fix"
5534 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,r,r,m,*f,*f,Q,r,*f")
5535 (match_operand:DI 1 "input_operand" "rJ,K,L,s,m,rJ,*fJ,Q,*f,*f,r"))]
5536 "! TARGET_EXPLICIT_RELOCS && TARGET_FIX
5537 && (register_operand (operands[0], DImode)
5538 || reg_or_0_operand (operands[1], DImode))"
5539 "@
5540 bis $31,%r1,%0
5541 lda %0,%1($31)
5542 ldah %0,%h1($31)
5543 lda %0,%1
5544 ldq%A1 %0,%1
5545 stq%A0 %r1,%0
5546 cpys %R1,%R1,%0
5547 ldt %0,%1
5548 stt %R1,%0
5549 ftoit %1,%0
5550 itoft %1,%0"
5551 [(set_attr "type" "ilog,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst,ftoi,itof")])
5552
5553 ;; VMS needs to set up "vms_base_regno" for unwinding. This move
5554 ;; often appears dead to the life analysis code, at which point we
5555 ;; abort for emitting dead prologue instructions. Force this live.
5556
5557 (define_insn "force_movdi"
5558 [(set (match_operand:DI 0 "register_operand" "=r")
5559 (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "r")]
5560 UNSPECV_FORCE_MOV))]
5561 ""
5562 "mov %1,%0"
5563 [(set_attr "type" "ilog")])
5564
5565 ;; We do three major things here: handle mem->mem, put 64-bit constants in
5566 ;; memory, and construct long 32-bit constants.
5567
5568 (define_expand "movdi"
5569 [(set (match_operand:DI 0 "nonimmediate_operand" "")
5570 (match_operand:DI 1 "general_operand" ""))]
5571 ""
5572 {
5573 if (alpha_expand_mov (DImode, operands))
5574 DONE;
5575 })
5576
5577 ;; Split a load of a large constant into the appropriate two-insn
5578 ;; sequence.
5579
5580 (define_split
5581 [(set (match_operand:DI 0 "register_operand" "")
5582 (match_operand:DI 1 "const_int_operand" ""))]
5583 "! add_operand (operands[1], DImode)"
5584 [(set (match_dup 0) (match_dup 2))
5585 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
5586 {
5587 rtx tem
5588 = alpha_emit_set_const (operands[0], DImode, INTVAL (operands[1]), 2);
5589
5590 if (tem == operands[0])
5591 DONE;
5592 else
5593 FAIL;
5594 })
5595
5596 ;; These are the partial-word cases.
5597 ;;
5598 ;; First we have the code to load an aligned word. Operand 0 is the register
5599 ;; in which to place the result. It's mode is QImode or HImode. Operand 1
5600 ;; is an SImode MEM at the low-order byte of the proper word. Operand 2 is the
5601 ;; number of bits within the word that the value is. Operand 3 is an SImode
5602 ;; scratch register. If operand 0 is a hard register, operand 3 may be the
5603 ;; same register. It is allowed to conflict with operand 1 as well.
5604
5605 (define_expand "aligned_loadqi"
5606 [(set (match_operand:SI 3 "register_operand" "")
5607 (match_operand:SI 1 "memory_operand" ""))
5608 (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
5609 (zero_extract:DI (subreg:DI (match_dup 3) 0)
5610 (const_int 8)
5611 (match_operand:DI 2 "const_int_operand" "")))]
5612
5613 ""
5614 "")
5615
5616 (define_expand "aligned_loadhi"
5617 [(set (match_operand:SI 3 "register_operand" "")
5618 (match_operand:SI 1 "memory_operand" ""))
5619 (set (subreg:DI (match_operand:HI 0 "register_operand" "") 0)
5620 (zero_extract:DI (subreg:DI (match_dup 3) 0)
5621 (const_int 16)
5622 (match_operand:DI 2 "const_int_operand" "")))]
5623
5624 ""
5625 "")
5626
5627 ;; Similar for unaligned loads, where we use the sequence from the
5628 ;; Alpha Architecture manual. We have to distinguish between little-endian
5629 ;; and big-endian systems as the sequences are different.
5630 ;;
5631 ;; Operand 1 is the address. Operands 2 and 3 are temporaries, where
5632 ;; operand 3 can overlap the input and output registers.
5633
5634 (define_expand "unaligned_loadqi"
5635 [(use (match_operand:QI 0 "register_operand" ""))
5636 (use (match_operand:DI 1 "address_operand" ""))
5637 (use (match_operand:DI 2 "register_operand" ""))
5638 (use (match_operand:DI 3 "register_operand" ""))]
5639 ""
5640 {
5641 if (WORDS_BIG_ENDIAN)
5642 emit_insn (gen_unaligned_loadqi_be (operands[0], operands[1],
5643 operands[2], operands[3]));
5644 else
5645 emit_insn (gen_unaligned_loadqi_le (operands[0], operands[1],
5646 operands[2], operands[3]));
5647 DONE;
5648 })
5649
5650 (define_expand "unaligned_loadqi_le"
5651 [(set (match_operand:DI 2 "register_operand" "")
5652 (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
5653 (const_int -8))))
5654 (set (match_operand:DI 3 "register_operand" "")
5655 (match_dup 1))
5656 (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
5657 (zero_extract:DI (match_dup 2)
5658 (const_int 8)
5659 (ashift:DI (match_dup 3) (const_int 3))))]
5660 "! WORDS_BIG_ENDIAN"
5661 "")
5662
5663 (define_expand "unaligned_loadqi_be"
5664 [(set (match_operand:DI 2 "register_operand" "")
5665 (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
5666 (const_int -8))))
5667 (set (match_operand:DI 3 "register_operand" "")
5668 (match_dup 1))
5669 (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
5670 (zero_extract:DI (match_dup 2)
5671 (const_int 8)
5672 (minus:DI
5673 (const_int 56)
5674 (ashift:DI (match_dup 3) (const_int 3)))))]
5675 "WORDS_BIG_ENDIAN"
5676 "")
5677
5678 (define_expand "unaligned_loadhi"
5679 [(use (match_operand:QI 0 "register_operand" ""))
5680 (use (match_operand:DI 1 "address_operand" ""))
5681 (use (match_operand:DI 2 "register_operand" ""))
5682 (use (match_operand:DI 3 "register_operand" ""))]
5683 ""
5684 {
5685 if (WORDS_BIG_ENDIAN)
5686 emit_insn (gen_unaligned_loadhi_be (operands[0], operands[1],
5687 operands[2], operands[3]));
5688 else
5689 emit_insn (gen_unaligned_loadhi_le (operands[0], operands[1],
5690 operands[2], operands[3]));
5691 DONE;
5692 })
5693
5694 (define_expand "unaligned_loadhi_le"
5695 [(set (match_operand:DI 2 "register_operand" "")
5696 (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
5697 (const_int -8))))
5698 (set (match_operand:DI 3 "register_operand" "")
5699 (match_dup 1))
5700 (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
5701 (zero_extract:DI (match_dup 2)
5702 (const_int 16)
5703 (ashift:DI (match_dup 3) (const_int 3))))]
5704 "! WORDS_BIG_ENDIAN"
5705 "")
5706
5707 (define_expand "unaligned_loadhi_be"
5708 [(set (match_operand:DI 2 "register_operand" "")
5709 (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
5710 (const_int -8))))
5711 (set (match_operand:DI 3 "register_operand" "")
5712 (plus:DI (match_dup 1) (const_int 1)))
5713 (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
5714 (zero_extract:DI (match_dup 2)
5715 (const_int 16)
5716 (minus:DI
5717 (const_int 56)
5718 (ashift:DI (match_dup 3) (const_int 3)))))]
5719 "WORDS_BIG_ENDIAN"
5720 "")
5721
5722 ;; Storing an aligned byte or word requires two temporaries. Operand 0 is the
5723 ;; aligned SImode MEM. Operand 1 is the register containing the
5724 ;; byte or word to store. Operand 2 is the number of bits within the word that
5725 ;; the value should be placed. Operands 3 and 4 are SImode temporaries.
5726
5727 (define_expand "aligned_store"
5728 [(set (match_operand:SI 3 "register_operand" "")
5729 (match_operand:SI 0 "memory_operand" ""))
5730 (set (subreg:DI (match_dup 3) 0)
5731 (and:DI (subreg:DI (match_dup 3) 0) (match_dup 5)))
5732 (set (subreg:DI (match_operand:SI 4 "register_operand" "") 0)
5733 (ashift:DI (zero_extend:DI (match_operand 1 "register_operand" ""))
5734 (match_operand:DI 2 "const_int_operand" "")))
5735 (set (subreg:DI (match_dup 4) 0)
5736 (ior:DI (subreg:DI (match_dup 4) 0) (subreg:DI (match_dup 3) 0)))
5737 (set (match_dup 0) (match_dup 4))]
5738 ""
5739 {
5740 operands[5] = GEN_INT (~ (GET_MODE_MASK (GET_MODE (operands[1]))
5741 << INTVAL (operands[2])));
5742 })
5743
5744 ;; For the unaligned byte and halfword cases, we use code similar to that
5745 ;; in the ;; Architecture book, but reordered to lower the number of registers
5746 ;; required. Operand 0 is the address. Operand 1 is the data to store.
5747 ;; Operands 2, 3, and 4 are DImode temporaries, where operands 2 and 4 may
5748 ;; be the same temporary, if desired. If the address is in a register,
5749 ;; operand 2 can be that register.
5750
5751 (define_expand "unaligned_storeqi"
5752 [(use (match_operand:DI 0 "address_operand" ""))
5753 (use (match_operand:QI 1 "register_operand" ""))
5754 (use (match_operand:DI 2 "register_operand" ""))
5755 (use (match_operand:DI 3 "register_operand" ""))
5756 (use (match_operand:DI 4 "register_operand" ""))]
5757 ""
5758 {
5759 if (WORDS_BIG_ENDIAN)
5760 emit_insn (gen_unaligned_storeqi_be (operands[0], operands[1],
5761 operands[2], operands[3],
5762 operands[4]));
5763 else
5764 emit_insn (gen_unaligned_storeqi_le (operands[0], operands[1],
5765 operands[2], operands[3],
5766 operands[4]));
5767 DONE;
5768 })
5769
5770 (define_expand "unaligned_storeqi_le"
5771 [(set (match_operand:DI 3 "register_operand" "")
5772 (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
5773 (const_int -8))))
5774 (set (match_operand:DI 2 "register_operand" "")
5775 (match_dup 0))
5776 (set (match_dup 3)
5777 (and:DI (not:DI (ashift:DI (const_int 255)
5778 (ashift:DI (match_dup 2) (const_int 3))))
5779 (match_dup 3)))
5780 (set (match_operand:DI 4 "register_operand" "")
5781 (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" ""))
5782 (ashift:DI (match_dup 2) (const_int 3))))
5783 (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
5784 (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
5785 (match_dup 4))]
5786 "! WORDS_BIG_ENDIAN"
5787 "")
5788
5789 (define_expand "unaligned_storeqi_be"
5790 [(set (match_operand:DI 3 "register_operand" "")
5791 (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
5792 (const_int -8))))
5793 (set (match_operand:DI 2 "register_operand" "")
5794 (match_dup 0))
5795 (set (match_dup 3)
5796 (and:DI (not:DI (ashift:DI (const_int 255)
5797 (minus:DI (const_int 56)
5798 (ashift:DI (match_dup 2) (const_int 3)))))
5799 (match_dup 3)))
5800 (set (match_operand:DI 4 "register_operand" "")
5801 (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" ""))
5802 (minus:DI (const_int 56)
5803 (ashift:DI (match_dup 2) (const_int 3)))))
5804 (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
5805 (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
5806 (match_dup 4))]
5807 "WORDS_BIG_ENDIAN"
5808 "")
5809
5810 (define_expand "unaligned_storehi"
5811 [(use (match_operand:DI 0 "address_operand" ""))
5812 (use (match_operand:HI 1 "register_operand" ""))
5813 (use (match_operand:DI 2 "register_operand" ""))
5814 (use (match_operand:DI 3 "register_operand" ""))
5815 (use (match_operand:DI 4 "register_operand" ""))]
5816 ""
5817 {
5818 if (WORDS_BIG_ENDIAN)
5819 emit_insn (gen_unaligned_storehi_be (operands[0], operands[1],
5820 operands[2], operands[3],
5821 operands[4]));
5822 else
5823 emit_insn (gen_unaligned_storehi_le (operands[0], operands[1],
5824 operands[2], operands[3],
5825 operands[4]));
5826 DONE;
5827 })
5828
5829 (define_expand "unaligned_storehi_le"
5830 [(set (match_operand:DI 3 "register_operand" "")
5831 (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
5832 (const_int -8))))
5833 (set (match_operand:DI 2 "register_operand" "")
5834 (match_dup 0))
5835 (set (match_dup 3)
5836 (and:DI (not:DI (ashift:DI (const_int 65535)
5837 (ashift:DI (match_dup 2) (const_int 3))))
5838 (match_dup 3)))
5839 (set (match_operand:DI 4 "register_operand" "")
5840 (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" ""))
5841 (ashift:DI (match_dup 2) (const_int 3))))
5842 (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
5843 (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
5844 (match_dup 4))]
5845 "! WORDS_BIG_ENDIAN"
5846 "")
5847
5848 (define_expand "unaligned_storehi_be"
5849 [(set (match_operand:DI 3 "register_operand" "")
5850 (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
5851 (const_int -8))))
5852 (set (match_operand:DI 2 "register_operand" "")
5853 (plus:DI (match_dup 0) (const_int 1)))
5854 (set (match_dup 3)
5855 (and:DI (not:DI (ashift:DI
5856 (const_int 65535)
5857 (minus:DI (const_int 56)
5858 (ashift:DI (match_dup 2) (const_int 3)))))
5859 (match_dup 3)))
5860 (set (match_operand:DI 4 "register_operand" "")
5861 (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" ""))
5862 (minus:DI (const_int 56)
5863 (ashift:DI (match_dup 2) (const_int 3)))))
5864 (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
5865 (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
5866 (match_dup 4))]
5867 "WORDS_BIG_ENDIAN"
5868 "")
5869 \f
5870 ;; Here are the define_expand's for QI and HI moves that use the above
5871 ;; patterns. We have the normal sets, plus the ones that need scratch
5872 ;; registers for reload.
5873
5874 (define_expand "movqi"
5875 [(set (match_operand:QI 0 "nonimmediate_operand" "")
5876 (match_operand:QI 1 "general_operand" ""))]
5877 ""
5878 {
5879 if (TARGET_BWX
5880 ? alpha_expand_mov (QImode, operands)
5881 : alpha_expand_mov_nobwx (QImode, operands))
5882 DONE;
5883 })
5884
5885 (define_expand "movhi"
5886 [(set (match_operand:HI 0 "nonimmediate_operand" "")
5887 (match_operand:HI 1 "general_operand" ""))]
5888 ""
5889 {
5890 if (TARGET_BWX
5891 ? alpha_expand_mov (HImode, operands)
5892 : alpha_expand_mov_nobwx (HImode, operands))
5893 DONE;
5894 })
5895
5896 ;; Here are the versions for reload. Note that in the unaligned cases
5897 ;; we know that the operand must not be a pseudo-register because stack
5898 ;; slots are always aligned references.
5899
5900 (define_expand "reload_inqi"
5901 [(parallel [(match_operand:QI 0 "register_operand" "=r")
5902 (match_operand:QI 1 "any_memory_operand" "m")
5903 (match_operand:TI 2 "register_operand" "=&r")])]
5904 "! TARGET_BWX"
5905 {
5906 rtx scratch, seq;
5907
5908 if (GET_CODE (operands[1]) != MEM)
5909 abort ();
5910
5911 if (aligned_memory_operand (operands[1], QImode))
5912 {
5913 seq = gen_reload_inqi_help (operands[0], operands[1],
5914 gen_rtx_REG (SImode, REGNO (operands[2])));
5915 }
5916 else
5917 {
5918 rtx addr;
5919
5920 /* It is possible that one of the registers we got for operands[2]
5921 might coincide with that of operands[0] (which is why we made
5922 it TImode). Pick the other one to use as our scratch. */
5923 if (REGNO (operands[0]) == REGNO (operands[2]))
5924 scratch = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
5925 else
5926 scratch = gen_rtx_REG (DImode, REGNO (operands[2]));
5927
5928 addr = get_unaligned_address (operands[1], 0);
5929 seq = gen_unaligned_loadqi (operands[0], addr, scratch,
5930 gen_rtx_REG (DImode, REGNO (operands[0])));
5931 alpha_set_memflags (seq, operands[1]);
5932 }
5933 emit_insn (seq);
5934 DONE;
5935 })
5936
5937 (define_expand "reload_inhi"
5938 [(parallel [(match_operand:HI 0 "register_operand" "=r")
5939 (match_operand:HI 1 "any_memory_operand" "m")
5940 (match_operand:TI 2 "register_operand" "=&r")])]
5941 "! TARGET_BWX"
5942 {
5943 rtx scratch, seq;
5944
5945 if (GET_CODE (operands[1]) != MEM)
5946 abort ();
5947
5948 if (aligned_memory_operand (operands[1], HImode))
5949 {
5950 seq = gen_reload_inhi_help (operands[0], operands[1],
5951 gen_rtx_REG (SImode, REGNO (operands[2])));
5952 }
5953 else
5954 {
5955 rtx addr;
5956
5957 /* It is possible that one of the registers we got for operands[2]
5958 might coincide with that of operands[0] (which is why we made
5959 it TImode). Pick the other one to use as our scratch. */
5960 if (REGNO (operands[0]) == REGNO (operands[2]))
5961 scratch = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
5962 else
5963 scratch = gen_rtx_REG (DImode, REGNO (operands[2]));
5964
5965 addr = get_unaligned_address (operands[1], 0);
5966 seq = gen_unaligned_loadhi (operands[0], addr, scratch,
5967 gen_rtx_REG (DImode, REGNO (operands[0])));
5968 alpha_set_memflags (seq, operands[1]);
5969 }
5970 emit_insn (seq);
5971 DONE;
5972 })
5973
5974 (define_expand "reload_outqi"
5975 [(parallel [(match_operand:QI 0 "any_memory_operand" "=m")
5976 (match_operand:QI 1 "register_operand" "r")
5977 (match_operand:TI 2 "register_operand" "=&r")])]
5978 "! TARGET_BWX"
5979 {
5980 if (GET_CODE (operands[0]) != MEM)
5981 abort ();
5982
5983 if (aligned_memory_operand (operands[0], QImode))
5984 {
5985 emit_insn (gen_reload_outqi_help
5986 (operands[0], operands[1],
5987 gen_rtx_REG (SImode, REGNO (operands[2])),
5988 gen_rtx_REG (SImode, REGNO (operands[2]) + 1)));
5989 }
5990 else
5991 {
5992 rtx addr = get_unaligned_address (operands[0], 0);
5993 rtx scratch1 = gen_rtx_REG (DImode, REGNO (operands[2]));
5994 rtx scratch2 = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
5995 rtx scratch3 = scratch1;
5996 rtx seq;
5997
5998 if (GET_CODE (addr) == REG)
5999 scratch1 = addr;
6000
6001 seq = gen_unaligned_storeqi (addr, operands[1], scratch1,
6002 scratch2, scratch3);
6003 alpha_set_memflags (seq, operands[0]);
6004 emit_insn (seq);
6005 }
6006 DONE;
6007 })
6008
6009 (define_expand "reload_outhi"
6010 [(parallel [(match_operand:HI 0 "any_memory_operand" "=m")
6011 (match_operand:HI 1 "register_operand" "r")
6012 (match_operand:TI 2 "register_operand" "=&r")])]
6013 "! TARGET_BWX"
6014 {
6015 if (GET_CODE (operands[0]) != MEM)
6016 abort ();
6017
6018 if (aligned_memory_operand (operands[0], HImode))
6019 {
6020 emit_insn (gen_reload_outhi_help
6021 (operands[0], operands[1],
6022 gen_rtx_REG (SImode, REGNO (operands[2])),
6023 gen_rtx_REG (SImode, REGNO (operands[2]) + 1)));
6024 }
6025 else
6026 {
6027 rtx addr = get_unaligned_address (operands[0], 0);
6028 rtx scratch1 = gen_rtx_REG (DImode, REGNO (operands[2]));
6029 rtx scratch2 = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
6030 rtx scratch3 = scratch1;
6031 rtx seq;
6032
6033 if (GET_CODE (addr) == REG)
6034 scratch1 = addr;
6035
6036 seq = gen_unaligned_storehi (addr, operands[1], scratch1,
6037 scratch2, scratch3);
6038 alpha_set_memflags (seq, operands[0]);
6039 emit_insn (seq);
6040 }
6041 DONE;
6042 })
6043
6044 ;; Helpers for the above. The way reload is structured, we can't
6045 ;; always get a proper address for a stack slot during reload_foo
6046 ;; expansion, so we must delay our address manipulations until after.
6047
6048 (define_insn "reload_inqi_help"
6049 [(set (match_operand:QI 0 "register_operand" "=r")
6050 (match_operand:QI 1 "memory_operand" "m"))
6051 (clobber (match_operand:SI 2 "register_operand" "=r"))]
6052 "! TARGET_BWX && (reload_in_progress || reload_completed)"
6053 "#")
6054
6055 (define_insn "reload_inhi_help"
6056 [(set (match_operand:HI 0 "register_operand" "=r")
6057 (match_operand:HI 1 "memory_operand" "m"))
6058 (clobber (match_operand:SI 2 "register_operand" "=r"))]
6059 "! TARGET_BWX && (reload_in_progress || reload_completed)"
6060 "#")
6061
6062 (define_insn "reload_outqi_help"
6063 [(set (match_operand:QI 0 "memory_operand" "=m")
6064 (match_operand:QI 1 "register_operand" "r"))
6065 (clobber (match_operand:SI 2 "register_operand" "=r"))
6066 (clobber (match_operand:SI 3 "register_operand" "=r"))]
6067 "! TARGET_BWX && (reload_in_progress || reload_completed)"
6068 "#")
6069
6070 (define_insn "reload_outhi_help"
6071 [(set (match_operand:HI 0 "memory_operand" "=m")
6072 (match_operand:HI 1 "register_operand" "r"))
6073 (clobber (match_operand:SI 2 "register_operand" "=r"))
6074 (clobber (match_operand:SI 3 "register_operand" "=r"))]
6075 "! TARGET_BWX && (reload_in_progress || reload_completed)"
6076 "#")
6077
6078 (define_split
6079 [(set (match_operand:QI 0 "register_operand" "")
6080 (match_operand:QI 1 "memory_operand" ""))
6081 (clobber (match_operand:SI 2 "register_operand" ""))]
6082 "! TARGET_BWX && reload_completed"
6083 [(const_int 0)]
6084 {
6085 rtx aligned_mem, bitnum;
6086 get_aligned_mem (operands[1], &aligned_mem, &bitnum);
6087
6088 emit_insn (gen_aligned_loadqi (operands[0], aligned_mem, bitnum,
6089 operands[2]));
6090 DONE;
6091 })
6092
6093 (define_split
6094 [(set (match_operand:HI 0 "register_operand" "")
6095 (match_operand:HI 1 "memory_operand" ""))
6096 (clobber (match_operand:SI 2 "register_operand" ""))]
6097 "! TARGET_BWX && reload_completed"
6098 [(const_int 0)]
6099 {
6100 rtx aligned_mem, bitnum;
6101 get_aligned_mem (operands[1], &aligned_mem, &bitnum);
6102
6103 emit_insn (gen_aligned_loadhi (operands[0], aligned_mem, bitnum,
6104 operands[2]));
6105 DONE;
6106 })
6107
6108 (define_split
6109 [(set (match_operand:QI 0 "memory_operand" "")
6110 (match_operand:QI 1 "register_operand" ""))
6111 (clobber (match_operand:SI 2 "register_operand" ""))
6112 (clobber (match_operand:SI 3 "register_operand" ""))]
6113 "! TARGET_BWX && reload_completed"
6114 [(const_int 0)]
6115 {
6116 rtx aligned_mem, bitnum;
6117 get_aligned_mem (operands[0], &aligned_mem, &bitnum);
6118 emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
6119 operands[2], operands[3]));
6120 DONE;
6121 })
6122
6123 (define_split
6124 [(set (match_operand:HI 0 "memory_operand" "")
6125 (match_operand:HI 1 "register_operand" ""))
6126 (clobber (match_operand:SI 2 "register_operand" ""))
6127 (clobber (match_operand:SI 3 "register_operand" ""))]
6128 "! TARGET_BWX && reload_completed"
6129 [(const_int 0)]
6130 {
6131 rtx aligned_mem, bitnum;
6132 get_aligned_mem (operands[0], &aligned_mem, &bitnum);
6133 emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
6134 operands[2], operands[3]));
6135 DONE;
6136 })
6137 \f
6138 ;; Bit field extract patterns which use ext[wlq][lh]
6139
6140 (define_expand "extv"
6141 [(set (match_operand:DI 0 "register_operand" "")
6142 (sign_extract:DI (match_operand:QI 1 "memory_operand" "")
6143 (match_operand:DI 2 "immediate_operand" "")
6144 (match_operand:DI 3 "immediate_operand" "")))]
6145 ""
6146 {
6147 int ofs;
6148
6149 /* We can do 16, 32 and 64 bit fields, if aligned on byte boundaries. */
6150 if (INTVAL (operands[3]) % 8 != 0
6151 || (INTVAL (operands[2]) != 16
6152 && INTVAL (operands[2]) != 32
6153 && INTVAL (operands[2]) != 64))
6154 FAIL;
6155
6156 /* From mips.md: extract_bit_field doesn't verify that our source
6157 matches the predicate, so we force it to be a MEM here. */
6158 if (GET_CODE (operands[1]) != MEM)
6159 FAIL;
6160
6161 /* The bit number is relative to the mode of operand 1 which is
6162 usually QImode (this might actually be a bug in expmed.c). Note
6163 that the bit number is negative in big-endian mode in this case.
6164 We have to convert that to the offset. */
6165 if (WORDS_BIG_ENDIAN)
6166 ofs = GET_MODE_BITSIZE (GET_MODE (operands[1]))
6167 - INTVAL (operands[2]) - INTVAL (operands[3]);
6168 else
6169 ofs = INTVAL (operands[3]);
6170
6171 ofs = ofs / 8;
6172
6173 alpha_expand_unaligned_load (operands[0], operands[1],
6174 INTVAL (operands[2]) / 8,
6175 ofs, 1);
6176 DONE;
6177 })
6178
6179 (define_expand "extzv"
6180 [(set (match_operand:DI 0 "register_operand" "")
6181 (zero_extract:DI (match_operand:DI 1 "nonimmediate_operand" "")
6182 (match_operand:DI 2 "immediate_operand" "")
6183 (match_operand:DI 3 "immediate_operand" "")))]
6184 ""
6185 {
6186 /* We can do 8, 16, 32 and 64 bit fields, if aligned on byte boundaries. */
6187 if (INTVAL (operands[3]) % 8 != 0
6188 || (INTVAL (operands[2]) != 8
6189 && INTVAL (operands[2]) != 16
6190 && INTVAL (operands[2]) != 32
6191 && INTVAL (operands[2]) != 64))
6192 FAIL;
6193
6194 if (GET_CODE (operands[1]) == MEM)
6195 {
6196 int ofs;
6197
6198 /* Fail 8 bit fields, falling back on a simple byte load. */
6199 if (INTVAL (operands[2]) == 8)
6200 FAIL;
6201
6202 /* The bit number is relative to the mode of operand 1 which is
6203 usually QImode (this might actually be a bug in expmed.c). Note
6204 that the bit number is negative in big-endian mode in this case.
6205 We have to convert that to the offset. */
6206 if (WORDS_BIG_ENDIAN)
6207 ofs = GET_MODE_BITSIZE (GET_MODE (operands[1]))
6208 - INTVAL (operands[2]) - INTVAL (operands[3]);
6209 else
6210 ofs = INTVAL (operands[3]);
6211
6212 ofs = ofs / 8;
6213
6214 alpha_expand_unaligned_load (operands[0], operands[1],
6215 INTVAL (operands[2]) / 8,
6216 ofs, 0);
6217 DONE;
6218 }
6219 })
6220
6221 (define_expand "insv"
6222 [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "")
6223 (match_operand:DI 1 "immediate_operand" "")
6224 (match_operand:DI 2 "immediate_operand" ""))
6225 (match_operand:DI 3 "register_operand" ""))]
6226 ""
6227 {
6228 int ofs;
6229
6230 /* We can do 16, 32 and 64 bit fields, if aligned on byte boundaries. */
6231 if (INTVAL (operands[2]) % 8 != 0
6232 || (INTVAL (operands[1]) != 16
6233 && INTVAL (operands[1]) != 32
6234 && INTVAL (operands[1]) != 64))
6235 FAIL;
6236
6237 /* From mips.md: store_bit_field doesn't verify that our source
6238 matches the predicate, so we force it to be a MEM here. */
6239 if (GET_CODE (operands[0]) != MEM)
6240 FAIL;
6241
6242 /* The bit number is relative to the mode of operand 1 which is
6243 usually QImode (this might actually be a bug in expmed.c). Note
6244 that the bit number is negative in big-endian mode in this case.
6245 We have to convert that to the offset. */
6246 if (WORDS_BIG_ENDIAN)
6247 ofs = GET_MODE_BITSIZE (GET_MODE (operands[0]))
6248 - INTVAL (operands[1]) - INTVAL (operands[2]);
6249 else
6250 ofs = INTVAL (operands[2]);
6251
6252 ofs = ofs / 8;
6253
6254 alpha_expand_unaligned_store (operands[0], operands[3],
6255 INTVAL (operands[1]) / 8, ofs);
6256 DONE;
6257 })
6258
6259 ;; Block move/clear, see alpha.c for more details.
6260 ;; Argument 0 is the destination
6261 ;; Argument 1 is the source
6262 ;; Argument 2 is the length
6263 ;; Argument 3 is the alignment
6264
6265 (define_expand "movstrqi"
6266 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
6267 (match_operand:BLK 1 "memory_operand" ""))
6268 (use (match_operand:DI 2 "immediate_operand" ""))
6269 (use (match_operand:DI 3 "immediate_operand" ""))])]
6270 ""
6271 {
6272 if (alpha_expand_block_move (operands))
6273 DONE;
6274 else
6275 FAIL;
6276 })
6277
6278 (define_expand "clrstrqi"
6279 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
6280 (const_int 0))
6281 (use (match_operand:DI 1 "immediate_operand" ""))
6282 (use (match_operand:DI 2 "immediate_operand" ""))])]
6283 ""
6284 {
6285 if (alpha_expand_block_clear (operands))
6286 DONE;
6287 else
6288 FAIL;
6289 })
6290 \f
6291 ;; Subroutine of stack space allocation. Perform a stack probe.
6292 (define_expand "probe_stack"
6293 [(set (match_dup 1) (match_operand:DI 0 "const_int_operand" ""))]
6294 ""
6295 {
6296 operands[1] = gen_rtx_MEM (DImode, plus_constant (stack_pointer_rtx,
6297 INTVAL (operands[0])));
6298 MEM_VOLATILE_P (operands[1]) = 1;
6299
6300 operands[0] = const0_rtx;
6301 })
6302
6303 ;; This is how we allocate stack space. If we are allocating a
6304 ;; constant amount of space and we know it is less than 4096
6305 ;; bytes, we need do nothing.
6306 ;;
6307 ;; If it is more than 4096 bytes, we need to probe the stack
6308 ;; periodically.
6309 (define_expand "allocate_stack"
6310 [(set (reg:DI 30)
6311 (plus:DI (reg:DI 30)
6312 (match_operand:DI 1 "reg_or_cint_operand" "")))
6313 (set (match_operand:DI 0 "register_operand" "=r")
6314 (match_dup 2))]
6315 ""
6316 {
6317 if (GET_CODE (operands[1]) == CONST_INT
6318 && INTVAL (operands[1]) < 32768)
6319 {
6320 if (INTVAL (operands[1]) >= 4096)
6321 {
6322 /* We do this the same way as in the prologue and generate explicit
6323 probes. Then we update the stack by the constant. */
6324
6325 int probed = 4096;
6326
6327 emit_insn (gen_probe_stack (GEN_INT (- probed)));
6328 while (probed + 8192 < INTVAL (operands[1]))
6329 emit_insn (gen_probe_stack (GEN_INT (- (probed += 8192))));
6330
6331 if (probed + 4096 < INTVAL (operands[1]))
6332 emit_insn (gen_probe_stack (GEN_INT (- INTVAL(operands[1]))));
6333 }
6334
6335 operands[1] = GEN_INT (- INTVAL (operands[1]));
6336 operands[2] = virtual_stack_dynamic_rtx;
6337 }
6338 else
6339 {
6340 rtx out_label = 0;
6341 rtx loop_label = gen_label_rtx ();
6342 rtx want = gen_reg_rtx (Pmode);
6343 rtx tmp = gen_reg_rtx (Pmode);
6344 rtx memref;
6345
6346 emit_insn (gen_subdi3 (want, stack_pointer_rtx,
6347 force_reg (Pmode, operands[1])));
6348 emit_insn (gen_adddi3 (tmp, stack_pointer_rtx, GEN_INT (-4096)));
6349
6350 if (GET_CODE (operands[1]) != CONST_INT)
6351 {
6352 out_label = gen_label_rtx ();
6353 emit_insn (gen_cmpdi (want, tmp));
6354 emit_jump_insn (gen_bgeu (out_label));
6355 }
6356
6357 emit_label (loop_label);
6358 memref = gen_rtx_MEM (DImode, tmp);
6359 MEM_VOLATILE_P (memref) = 1;
6360 emit_move_insn (memref, const0_rtx);
6361 emit_insn (gen_adddi3 (tmp, tmp, GEN_INT(-8192)));
6362 emit_insn (gen_cmpdi (tmp, want));
6363 emit_jump_insn (gen_bgtu (loop_label));
6364
6365 memref = gen_rtx_MEM (DImode, want);
6366 MEM_VOLATILE_P (memref) = 1;
6367 emit_move_insn (memref, const0_rtx);
6368
6369 if (out_label)
6370 emit_label (out_label);
6371
6372 emit_move_insn (stack_pointer_rtx, want);
6373 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
6374 DONE;
6375 }
6376 })
6377
6378 ;; This is used by alpha_expand_prolog to do the same thing as above,
6379 ;; except we cannot at that time generate new basic blocks, so we hide
6380 ;; the loop in this one insn.
6381
6382 (define_insn "prologue_stack_probe_loop"
6383 [(unspec_volatile [(match_operand:DI 0 "register_operand" "r")
6384 (match_operand:DI 1 "register_operand" "r")]
6385 UNSPECV_PSPL)]
6386 ""
6387 {
6388 operands[2] = gen_label_rtx ();
6389 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
6390 CODE_LABEL_NUMBER (operands[2]));
6391
6392 return "stq $31,-8192(%1)\;subq %0,1,%0\;lda %1,-8192(%1)\;bne %0,%l2";
6393 }
6394 [(set_attr "length" "16")
6395 (set_attr "type" "multi")])
6396
6397 (define_expand "prologue"
6398 [(clobber (const_int 0))]
6399 ""
6400 {
6401 alpha_expand_prologue ();
6402 DONE;
6403 })
6404
6405 ;; These take care of emitting the ldgp insn in the prologue. This will be
6406 ;; an lda/ldah pair and we want to align them properly. So we have two
6407 ;; unspec_volatile insns, the first of which emits the ldgp assembler macro
6408 ;; and the second of which emits nothing. However, both are marked as type
6409 ;; IADD (the default) so the alignment code in alpha.c does the right thing
6410 ;; with them.
6411
6412 (define_expand "prologue_ldgp"
6413 [(set (match_dup 0)
6414 (unspec_volatile:DI [(match_dup 1) (match_dup 2)] UNSPECV_LDGP1))
6415 (set (match_dup 0)
6416 (unspec_volatile:DI [(match_dup 0) (match_dup 2)] UNSPECV_PLDGP2))]
6417 ""
6418 {
6419 operands[0] = pic_offset_table_rtx;
6420 operands[1] = gen_rtx_REG (Pmode, 27);
6421 operands[2] = (TARGET_EXPLICIT_RELOCS
6422 ? GEN_INT (alpha_next_sequence_number++)
6423 : const0_rtx);
6424 })
6425
6426 (define_insn "*ldgp_er_1"
6427 [(set (match_operand:DI 0 "register_operand" "=r")
6428 (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "r")
6429 (match_operand 2 "const_int_operand" "")]
6430 UNSPECV_LDGP1))]
6431 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
6432 "ldah %0,0(%1)\t\t!gpdisp!%2")
6433
6434 (define_insn "*ldgp_er_2"
6435 [(set (match_operand:DI 0 "register_operand" "=r")
6436 (unspec:DI [(match_operand:DI 1 "register_operand" "r")
6437 (match_operand 2 "const_int_operand" "")]
6438 UNSPEC_LDGP2))]
6439 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
6440 "lda %0,0(%1)\t\t!gpdisp!%2")
6441
6442 (define_insn "*prologue_ldgp_er_2"
6443 [(set (match_operand:DI 0 "register_operand" "=r")
6444 (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "r")
6445 (match_operand 2 "const_int_operand" "")]
6446 UNSPECV_PLDGP2))]
6447 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
6448 "lda %0,0(%1)\t\t!gpdisp!%2\n$%~..ng:")
6449
6450 (define_insn "*prologue_ldgp_1"
6451 [(set (match_operand:DI 0 "register_operand" "=r")
6452 (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "r")
6453 (match_operand 2 "const_int_operand" "")]
6454 UNSPECV_LDGP1))]
6455 ""
6456 "ldgp %0,0(%1)\n$%~..ng:")
6457
6458 (define_insn "*prologue_ldgp_2"
6459 [(set (match_operand:DI 0 "register_operand" "=r")
6460 (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "r")
6461 (match_operand 2 "const_int_operand" "")]
6462 UNSPECV_PLDGP2))]
6463 ""
6464 "")
6465
6466 ;; The _mcount profiling hook has special calling conventions, and
6467 ;; does not clobber all the registers that a normal call would. So
6468 ;; hide the fact this is a call at all.
6469
6470 (define_insn "prologue_mcount"
6471 [(unspec_volatile [(const_int 0)] UNSPECV_MCOUNT)]
6472 ""
6473 "lda $28,_mcount\;jsr $28,($28),_mcount"
6474 [(set_attr "type" "multi")
6475 (set_attr "length" "8")])
6476
6477 (define_insn "init_fp"
6478 [(set (match_operand:DI 0 "register_operand" "=r")
6479 (match_operand:DI 1 "register_operand" "r"))
6480 (clobber (mem:BLK (match_operand:DI 2 "register_operand" "=r")))]
6481 ""
6482 "bis $31,%1,%0")
6483
6484 (define_expand "epilogue"
6485 [(return)]
6486 ""
6487 {
6488 alpha_expand_epilogue ();
6489 })
6490
6491 (define_expand "sibcall_epilogue"
6492 [(return)]
6493 "TARGET_ABI_OSF"
6494 {
6495 alpha_expand_epilogue ();
6496 DONE;
6497 })
6498
6499 ;; In creating a large stack frame, NT _must_ use ldah+lda to load
6500 ;; the frame size into a register. We use this pattern to ensure
6501 ;; we get lda instead of addq.
6502 (define_insn "nt_lda"
6503 [(set (match_operand:DI 0 "register_operand" "=r")
6504 (unspec:DI [(match_dup 0)
6505 (match_operand:DI 1 "const_int_operand" "n")]
6506 UNSPEC_NT_LDA))]
6507 ""
6508 "lda %0,%1(%0)")
6509
6510 (define_expand "builtin_longjmp"
6511 [(use (match_operand:DI 0 "register_operand" "r"))]
6512 "TARGET_ABI_OSF"
6513 {
6514 /* The elements of the buffer are, in order: */
6515 rtx fp = gen_rtx_MEM (Pmode, operands[0]);
6516 rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0], 8));
6517 rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0], 16));
6518 rtx pv = gen_rtx_REG (Pmode, 27);
6519
6520 /* This bit is the same as expand_builtin_longjmp. */
6521 emit_move_insn (hard_frame_pointer_rtx, fp);
6522 emit_move_insn (pv, lab);
6523 emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
6524 emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
6525 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
6526
6527 /* Load the label we are jumping through into $27 so that we know
6528 where to look for it when we get back to setjmp's function for
6529 restoring the gp. */
6530 emit_jump_insn (gen_builtin_longjmp_internal (pv));
6531 emit_barrier ();
6532 DONE;
6533 })
6534
6535 ;; This is effectively a copy of indirect_jump, but constrained such
6536 ;; that register renaming cannot foil our cunning plan with $27.
6537 (define_insn "builtin_longjmp_internal"
6538 [(set (pc)
6539 (unspec_volatile [(match_operand:DI 0 "register_operand" "c")]
6540 UNSPECV_LONGJMP))]
6541 ""
6542 "jmp $31,(%0),0"
6543 [(set_attr "type" "ibr")])
6544
6545 (define_insn "*builtin_setjmp_receiver_er_sl_1"
6546 [(unspec_volatile [(label_ref (match_operand 0 "" ""))] UNSPECV_SETJMPR)]
6547 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF && TARGET_AS_CAN_SUBTRACT_LABELS"
6548 "lda $27,$LSJ%=-%l0($27)\n$LSJ%=:")
6549
6550 (define_insn "*builtin_setjmp_receiver_er_1"
6551 [(unspec_volatile [(label_ref (match_operand 0 "" ""))] UNSPECV_SETJMPR)]
6552 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
6553 "br $27,$LSJ%=\n$LSJ%=:"
6554 [(set_attr "type" "ibr")])
6555
6556 (define_split
6557 [(unspec_volatile [(label_ref (match_operand 0 "" ""))] UNSPECV_SETJMPR)]
6558 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF
6559 && prev_nonnote_insn (insn) == operands[0]"
6560 [(const_int 0)]
6561 "DONE;")
6562
6563 (define_insn "*builtin_setjmp_receiver_1"
6564 [(unspec_volatile [(label_ref (match_operand 0 "" ""))] UNSPECV_SETJMPR)]
6565 "TARGET_ABI_OSF"
6566 "br $27,$LSJ%=\n$LSJ%=:\;ldgp $29,0($27)"
6567 [(set_attr "length" "12")
6568 (set_attr "type" "multi")])
6569
6570 (define_expand "builtin_setjmp_receiver_er"
6571 [(unspec_volatile [(label_ref (match_operand 0 "" ""))] UNSPECV_SETJMPR)
6572 (set (match_dup 1)
6573 (unspec_volatile:DI [(match_dup 2) (match_dup 3)] UNSPECV_LDGP1))
6574 (set (match_dup 1)
6575 (unspec:DI [(match_dup 1) (match_dup 3)] UNSPEC_LDGP2))]
6576 ""
6577 {
6578 operands[1] = pic_offset_table_rtx;
6579 operands[2] = gen_rtx_REG (Pmode, 27);
6580 operands[3] = GEN_INT (alpha_next_sequence_number++);
6581 })
6582
6583 (define_expand "builtin_setjmp_receiver"
6584 [(unspec_volatile [(label_ref (match_operand 0 "" ""))] UNSPECV_SETJMPR)]
6585 "TARGET_ABI_OSF"
6586 {
6587 if (TARGET_EXPLICIT_RELOCS)
6588 {
6589 emit_insn (gen_builtin_setjmp_receiver_er (operands[0]));
6590 DONE;
6591 }
6592 })
6593
6594 (define_expand "exception_receiver_er"
6595 [(set (match_dup 0)
6596 (unspec_volatile:DI [(match_dup 1) (match_dup 2)] UNSPECV_LDGP1))
6597 (set (match_dup 0)
6598 (unspec:DI [(match_dup 0) (match_dup 2)] UNSPEC_LDGP2))]
6599 ""
6600 {
6601 operands[0] = pic_offset_table_rtx;
6602 operands[1] = gen_rtx_REG (Pmode, 26);
6603 operands[2] = GEN_INT (alpha_next_sequence_number++);
6604 })
6605
6606 (define_expand "exception_receiver"
6607 [(unspec_volatile [(match_dup 0)] UNSPECV_EHR)]
6608 "TARGET_ABI_OSF"
6609 {
6610 if (TARGET_LD_BUGGY_LDGP)
6611 operands[0] = alpha_gp_save_rtx ();
6612 else if (TARGET_EXPLICIT_RELOCS)
6613 {
6614 emit_insn (gen_exception_receiver_er ());
6615 DONE;
6616 }
6617 else
6618 operands[0] = const0_rtx;
6619 })
6620
6621 (define_insn "*exception_receiver_1"
6622 [(unspec_volatile [(const_int 0)] UNSPECV_EHR)]
6623 "! TARGET_LD_BUGGY_LDGP"
6624 "ldgp $29,0($26)"
6625 [(set_attr "length" "8")
6626 (set_attr "type" "multi")])
6627
6628 (define_insn "*exception_receiver_2"
6629 [(unspec_volatile [(match_operand:DI 0 "nonimmediate_operand" "r,m")]
6630 UNSPECV_EHR)]
6631 "TARGET_LD_BUGGY_LDGP"
6632 "@
6633 bis $31,%0,$29
6634 ldq $29,%0"
6635 [(set_attr "type" "ilog,ild")])
6636
6637 (define_expand "nonlocal_goto_receiver"
6638 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
6639 (set (reg:DI 27) (mem:DI (reg:DI 29)))
6640 (unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
6641 (use (reg:DI 27))]
6642 "TARGET_ABI_OPEN_VMS"
6643 "")
6644
6645 (define_insn "arg_home"
6646 [(unspec [(const_int 0)] UNSPEC_ARG_HOME)
6647 (use (reg:DI 1))
6648 (use (reg:DI 25))
6649 (use (reg:DI 16))
6650 (use (reg:DI 17))
6651 (use (reg:DI 18))
6652 (use (reg:DI 19))
6653 (use (reg:DI 20))
6654 (use (reg:DI 21))
6655 (use (reg:DI 48))
6656 (use (reg:DI 49))
6657 (use (reg:DI 50))
6658 (use (reg:DI 51))
6659 (use (reg:DI 52))
6660 (use (reg:DI 53))
6661 (clobber (mem:BLK (const_int 0)))
6662 (clobber (reg:DI 24))
6663 (clobber (reg:DI 25))
6664 (clobber (reg:DI 0))]
6665 "TARGET_ABI_OPEN_VMS"
6666 "lda $0,OTS$HOME_ARGS\;ldq $0,8($0)\;jsr $0,OTS$HOME_ARGS"
6667 [(set_attr "length" "16")
6668 (set_attr "type" "multi")])
6669
6670 ;; Load the CIW into r2 for calling __T3E_MISMATCH
6671
6672 (define_expand "umk_mismatch_args"
6673 [(set:DI (match_dup 1) (mem:DI (plus:DI (reg:DI 15) (const_int -16))))
6674 (set:DI (match_dup 2) (mem:DI (plus:DI (match_dup 1) (const_int -32))))
6675 (set:DI (reg:DI 1) (match_operand:DI 0 "const_int_operand" ""))
6676 (set:DI (match_dup 3) (plus:DI (mult:DI (reg:DI 25)
6677 (const_int 8))
6678 (match_dup 2)))
6679 (set:DI (reg:DI 2) (mem:DI (match_dup 3)))]
6680 "TARGET_ABI_UNICOSMK"
6681 {
6682 operands[1] = gen_reg_rtx (DImode);
6683 operands[2] = gen_reg_rtx (DImode);
6684 operands[3] = gen_reg_rtx (DImode);
6685 })
6686
6687 (define_insn "arg_home_umk"
6688 [(unspec [(const_int 0)] UNSPEC_ARG_HOME)
6689 (use (reg:DI 1))
6690 (use (reg:DI 2))
6691 (use (reg:DI 16))
6692 (use (reg:DI 17))
6693 (use (reg:DI 18))
6694 (use (reg:DI 19))
6695 (use (reg:DI 20))
6696 (use (reg:DI 21))
6697 (use (reg:DI 48))
6698 (use (reg:DI 49))
6699 (use (reg:DI 50))
6700 (use (reg:DI 51))
6701 (use (reg:DI 52))
6702 (use (reg:DI 53))
6703 (clobber (mem:BLK (const_int 0)))
6704 (parallel [
6705 (clobber (reg:DI 22))
6706 (clobber (reg:DI 23))
6707 (clobber (reg:DI 24))
6708 (clobber (reg:DI 0))
6709 (clobber (reg:DI 1))
6710 (clobber (reg:DI 2))
6711 (clobber (reg:DI 3))
6712 (clobber (reg:DI 4))
6713 (clobber (reg:DI 5))
6714 (clobber (reg:DI 6))
6715 (clobber (reg:DI 7))
6716 (clobber (reg:DI 8))])]
6717 "TARGET_ABI_UNICOSMK"
6718 "laum $4,__T3E_MISMATCH($31)\;sll $4,32,$4\;lalm $4,__T3E_MISMATCH($4)\;lal $4,__T3E_MISMATCH($4)\;jsr $3,($4)"
6719 [(set_attr "length" "16")
6720 (set_attr "type" "multi")])
6721
6722 ;; Prefetch data.
6723 ;;
6724 ;; On EV4, these instructions are nops -- no load occurs.
6725 ;;
6726 ;; On EV5, these instructions act as a normal load, and thus can trap
6727 ;; if the address is invalid. The OS may (or may not) handle this in
6728 ;; the entMM fault handler and suppress the fault. If so, then this
6729 ;; has the effect of a read prefetch instruction.
6730 ;;
6731 ;; On EV6, these become official prefetch instructions.
6732
6733 (define_insn "prefetch"
6734 [(prefetch (match_operand:DI 0 "address_operand" "p")
6735 (match_operand:DI 1 "const_int_operand" "n")
6736 (match_operand:DI 2 "const_int_operand" "n"))]
6737 "TARGET_FIXUP_EV5_PREFETCH || TARGET_CPU_EV6"
6738 {
6739 /* Interpret "no temporal locality" as this data should be evicted once
6740 it is used. The "evict next" alternatives load the data into the cache
6741 and leave the LRU eviction counter pointing to that block. */
6742 static const char * const alt[2][2] = {
6743 {
6744 "lds $f31,%a0", /* read, evict next */
6745 "ldl $31,%a0", /* read, evict last */
6746 },
6747 {
6748 "ldt $f31,%a0", /* write, evict next */
6749 "ldq $31,%a0", /* write, evict last */
6750 }
6751 };
6752
6753 bool write = INTVAL (operands[1]) != 0;
6754 bool lru = INTVAL (operands[2]) != 0;
6755
6756 return alt[write][lru];
6757 }
6758 [(set_attr "type" "ild")])
6759
6760 ;; Close the trap shadow of preceding instructions. This is generated
6761 ;; by alpha_reorg.
6762
6763 (define_insn "trapb"
6764 [(unspec_volatile [(const_int 0)] UNSPECV_TRAPB)]
6765 ""
6766 "trapb"
6767 [(set_attr "type" "misc")])
6768
6769 ;; No-op instructions used by machine-dependent reorg to preserve
6770 ;; alignment for instruction issue.
6771 ;; The Unicos/Mk assembler does not support these opcodes.
6772
6773 (define_insn "nop"
6774 [(const_int 0)]
6775 ""
6776 "bis $31,$31,$31"
6777 [(set_attr "type" "ilog")])
6778
6779 (define_insn "fnop"
6780 [(const_int 1)]
6781 "TARGET_FP"
6782 "cpys $f31,$f31,$f31"
6783 [(set_attr "type" "fcpys")])
6784
6785 (define_insn "unop"
6786 [(const_int 2)]
6787 ""
6788 "ldq_u $31,0($30)")
6789
6790 ;; On Unicos/Mk we use a macro for aligning code.
6791
6792 (define_insn "realign"
6793 [(unspec_volatile [(match_operand 0 "immediate_operand" "i")]
6794 UNSPECV_REALIGN)]
6795 ""
6796 {
6797 if (TARGET_ABI_UNICOSMK)
6798 return "gcc@code@align %0";
6799 else
6800 return ".align %0 #realign";
6801 })
6802
6803 ;; The call patterns are at the end of the file because their
6804 ;; wildcard operand0 interferes with nice recognition.
6805
6806 (define_insn "*call_value_osf_1_er"
6807 [(set (match_operand 0 "" "")
6808 (call (mem:DI (match_operand:DI 1 "call_operand" "c,R,s"))
6809 (match_operand 2 "" "")))
6810 (use (reg:DI 29))
6811 (clobber (reg:DI 26))]
6812 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
6813 "@
6814 jsr $26,(%1),0\;ldah $29,0($26)\t\t!gpdisp!%*\;lda $29,0($29)\t\t!gpdisp!%*
6815 bsr $26,$%1..ng
6816 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!%*"
6817 [(set_attr "type" "jsr")
6818 (set_attr "length" "12,*,16")])
6819
6820 ;; We must use peep2 instead of a split because we need accurate life
6821 ;; information for $gp. Consider the case of { bar(); while (1); }.
6822 (define_peephole2
6823 [(parallel [(set (match_operand 0 "" "")
6824 (call (mem:DI (match_operand:DI 1 "call_operand" ""))
6825 (match_operand 2 "" "")))
6826 (use (reg:DI 29))
6827 (clobber (reg:DI 26))])]
6828 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF && reload_completed
6829 && ! current_file_function_operand (operands[0], Pmode)
6830 && peep2_regno_dead_p (1, 29)"
6831 [(parallel [(set (match_dup 0)
6832 (call (mem:DI (match_dup 3))
6833 (match_dup 2)))
6834 (set (reg:DI 26) (plus:DI (pc) (const_int 4)))
6835 (unspec_volatile [(reg:DI 29)] UNSPECV_BLOCKAGE)
6836 (use (match_dup 1))])]
6837 {
6838 if (CONSTANT_P (operands[1]))
6839 {
6840 operands[3] = gen_rtx_REG (Pmode, 27);
6841 emit_move_insn (operands[3], operands[1]);
6842 }
6843 else
6844 {
6845 operands[3] = operands[1];
6846 operands[1] = const0_rtx;
6847 }
6848 })
6849
6850 (define_peephole2
6851 [(parallel [(set (match_operand 0 "" "")
6852 (call (mem:DI (match_operand:DI 1 "call_operand" ""))
6853 (match_operand 2 "" "")))
6854 (use (reg:DI 29))
6855 (clobber (reg:DI 26))])]
6856 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF && reload_completed
6857 && ! current_file_function_operand (operands[0], Pmode)
6858 && ! peep2_regno_dead_p (1, 29)"
6859 [(parallel [(set (match_dup 0)
6860 (call (mem:DI (match_dup 3))
6861 (match_dup 2)))
6862 (set (reg:DI 26) (plus:DI (pc) (const_int 4)))
6863 (unspec_volatile [(reg:DI 29)] UNSPECV_BLOCKAGE)
6864 (use (match_dup 1))])
6865 (set (reg:DI 29)
6866 (unspec_volatile:DI [(reg:DI 26) (match_dup 4)] UNSPECV_LDGP1))
6867 (set (reg:DI 29)
6868 (unspec:DI [(reg:DI 29) (match_dup 4)] UNSPEC_LDGP2))]
6869 {
6870 if (CONSTANT_P (operands[1]))
6871 {
6872 operands[3] = gen_rtx_REG (Pmode, 27);
6873 emit_move_insn (operands[3], operands[1]);
6874 }
6875 else
6876 {
6877 operands[3] = operands[1];
6878 operands[1] = const0_rtx;
6879 }
6880 operands[4] = GEN_INT (alpha_next_sequence_number++);
6881 })
6882
6883 ;; We add a blockage unspec_volatile to prevent insns from moving down
6884 ;; from above the call to in between the call and the ldah gpdisp.
6885 (define_insn "*call_value_osf_2_er"
6886 [(set (match_operand 0 "" "")
6887 (call (mem:DI (match_operand:DI 1 "register_operand" "c"))
6888 (match_operand 2 "" "")))
6889 (set (reg:DI 26)
6890 (plus:DI (pc) (const_int 4)))
6891 (unspec_volatile [(reg:DI 29)] UNSPECV_BLOCKAGE)
6892 (use (match_operand 3 "" ""))]
6893 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
6894 "jsr $26,(%1),%3"
6895 [(set_attr "type" "jsr")])
6896
6897 (define_insn "*call_value_osf_1_noreturn"
6898 [(set (match_operand 0 "" "")
6899 (call (mem:DI (match_operand:DI 1 "call_operand" "c,R,s"))
6900 (match_operand 2 "" "")))
6901 (use (reg:DI 29))
6902 (clobber (reg:DI 26))]
6903 "! TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF
6904 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
6905 "@
6906 jsr $26,($27),0
6907 bsr $26,$%1..ng
6908 jsr $26,%1"
6909 [(set_attr "type" "jsr")
6910 (set_attr "length" "*,*,8")])
6911
6912 (define_insn "*call_value_osf_1"
6913 [(set (match_operand 0 "" "")
6914 (call (mem:DI (match_operand:DI 1 "call_operand" "c,R,s"))
6915 (match_operand 2 "" "")))
6916 (use (reg:DI 29))
6917 (clobber (reg:DI 26))]
6918 "! TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
6919 "@
6920 jsr $26,($27),0\;ldgp $29,0($26)
6921 bsr $26,$%1..ng
6922 jsr $26,%1\;ldgp $29,0($26)"
6923 [(set_attr "type" "jsr")
6924 (set_attr "length" "12,*,16")])
6925
6926 (define_insn "*sibcall_value_osf_1_er"
6927 [(set (match_operand 0 "" "")
6928 (call (mem:DI (match_operand:DI 1 "symbolic_operand" "R,s"))
6929 (match_operand 2 "" "")))
6930 (use (reg:DI 29))]
6931 "TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
6932 "@
6933 br $31,$%1..ng
6934 ldq $27,%1($29)\t\t!literal!%#\;jmp $31,($27),%1\t\t!lituse_jsr!%#"
6935 [(set_attr "type" "jsr")
6936 (set_attr "length" "*,8")])
6937
6938 (define_insn "*sibcall_value_osf_1"
6939 [(set (match_operand 0 "" "")
6940 (call (mem:DI (match_operand:DI 1 "symbolic_operand" "R,s"))
6941 (match_operand 2 "" "")))
6942 (use (reg:DI 29))]
6943 "! TARGET_EXPLICIT_RELOCS && TARGET_ABI_OSF"
6944 "@
6945 br $31,$%1..ng
6946 lda $27,%1\;jmp $31,($27),%1"
6947 [(set_attr "type" "jsr")
6948 (set_attr "length" "*,8")])
6949
6950 (define_insn "*call_value_nt_1"
6951 [(set (match_operand 0 "" "")
6952 (call (mem:DI (match_operand:DI 1 "call_operand" "r,R,s"))
6953 (match_operand 2 "" "")))
6954 (clobber (reg:DI 26))]
6955 "TARGET_ABI_WINDOWS_NT"
6956 "@
6957 jsr $26,(%1)
6958 bsr $26,%1
6959 jsr $26,%1"
6960 [(set_attr "type" "jsr")
6961 (set_attr "length" "*,*,12")])
6962
6963 (define_insn "*call_value_vms_1"
6964 [(set (match_operand 0 "" "")
6965 (call (mem:DI (match_operand:DI 1 "call_operand" "r,s"))
6966 (match_operand 2 "" "")))
6967 (use (match_operand:DI 3 "nonimmediate_operand" "r,m"))
6968 (use (reg:DI 25))
6969 (use (reg:DI 26))
6970 (clobber (reg:DI 27))]
6971 "TARGET_ABI_OPEN_VMS"
6972 "@
6973 mov %3,$27\;jsr $26,0\;ldq $27,0($29)
6974 ldq $27,%3\;jsr $26,%1\;ldq $27,0($29)"
6975 [(set_attr "type" "jsr")
6976 (set_attr "length" "12,16")])
6977
6978 (define_insn "*call_value_umk"
6979 [(set (match_operand 0 "" "")
6980 (call (mem:DI (match_operand:DI 1 "call_operand" "r"))
6981 (match_operand 2 "" "")))
6982 (use (reg:DI 25))
6983 (clobber (reg:DI 26))]
6984 "TARGET_ABI_UNICOSMK"
6985 "jsr $26,(%1)"
6986 [(set_attr "type" "jsr")])
6987