Debian Codegraph @

gcc/config/alpha/alpha.md

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