1 ;; GCC machine description for MMIX
2 ;; Copyright (C) 2000-2021 Free Software Foundation, Inc.
3 ;; Contributed by Hans-Peter Nilsson (hp@bitrange.com)
5 ;; This file is part of GCC.
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)
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.
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/>.
21 ;; The original PO technology requires these to be ordered by speed,
22 ;; so that assigner will pick the fastest.
24 ;; See file "rtl.def" for documentation on define_insn, match_*, et al.
26 ;; Uses of UNSPEC in this file:
29 ;; 0 sync_icache (sync icache before trampoline jump)
30 ;; 1 nonlocal_goto_receiver
33 ;; The order of insns is as in Node: Standard Names, with smaller modes
34 ;; before bigger modes.
39 (MMIX_fp_rO_OFFSET -24)]
42 (define_mode_iterator MM [QI HI SI DI SF DF])
44 ;; Operand and operator predicates.
46 (include "predicates.md")
47 (include "constraints.md")
49 ;; FIXME: Can we remove the reg-to-reg for smaller modes? Shouldn't they
51 (define_expand "mov<mode>"
52 [(set (match_operand:MM 0 "nonimmediate_operand")
53 (match_operand:MM 1 "general_operand"))]
56 /* Help pre-register-allocation to use at least one register in a move.
57 FIXME: support STCO also for DFmode (storing 0.0). */
58 if (!REG_P (operands[0]) && !REG_P (operands[1])
59 && (<MODE>mode != DImode
60 || !memory_operand (operands[0], DImode)
61 || !satisfies_constraint_I (operands[1])))
62 operands[1] = force_reg (<MODE>mode, operands[1]);
65 (define_insn "*movqi_expanded"
66 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r ,r,x ,r,r,m,??r")
67 (match_operand:QI 1 "general_operand" "r,LS,K,rI,x,m,r,n"))]
68 "register_operand (operands[0], QImode)
69 || register_operand (operands[1], QImode)"
80 (define_insn "*movhi_expanded"
81 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r ,r ,x,r,r,m,??r")
82 (match_operand:HI 1 "general_operand" "r,LS,K,r,x,m,r,n"))]
83 "register_operand (operands[0], HImode)
84 || register_operand (operands[1], HImode)"
95 ;; gcc.c-torture/compile/920428-2.c fails if there's no "n".
96 (define_insn "*movsi_expanded"
97 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r ,r,x,r,r,m,??r")
98 (match_operand:SI 1 "general_operand" "r,LS,K,r,x,m,r,n"))]
99 "register_operand (operands[0], SImode)
100 || register_operand (operands[1], SImode)"
111 ;; We assume all "s" are addresses. Does that hold?
112 (define_insn "*movdi_expanded"
113 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r ,r,x,r,m,r,m,r,r,??r")
114 (match_operand:DI 1 "general_operand" "r,LS,K,r,x,I,m,r,R,s,n"))]
115 "register_operand (operands[0], DImode)
116 || register_operand (operands[1], DImode)
117 || (memory_operand (operands[0], DImode)
118 && satisfies_constraint_I (operands[1]))"
132 ;; Note that we move around the float as a collection of bits; no
133 ;; conversion to double.
134 (define_insn "*movsf_expanded"
135 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,x,r,r,m,??r")
136 (match_operand:SF 1 "general_operand" "r,G,r,x,m,r,F"))]
137 "register_operand (operands[0], SFmode)
138 || register_operand (operands[1], SFmode)"
148 (define_insn "*movdf_expanded"
149 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,x,r,r,m,??r")
150 (match_operand:DF 1 "general_operand" "r,G,r,x,m,r,F"))]
151 "register_operand (operands[0], DFmode)
152 || register_operand (operands[1], DFmode)"
162 ;; We need to be able to move around the values used as condition codes.
163 ;; First spotted as reported in
164 ;; <URL:http://gcc.gnu.org/ml/gcc-bugs/2003-03/msg00008.html> due to
165 ;; changes in loop optimization. The file machmode.def says they're of
166 ;; size 4 QI. Valid bit-patterns correspond to integers -1, 0 and 1, so
167 ;; we treat them as signed entities; see mmix-modes.def. The following
168 ;; expanders should cover all MODE_CC modes, and expand for this pattern.
169 (define_insn "*movcc_expanded"
170 [(set (match_operand 0 "nonimmediate_operand" "=r,x,r,r,m")
171 (match_operand 1 "nonimmediate_operand" "r,r,x,m,r"))]
172 "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_CC
173 && GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_CC"
181 (define_expand "movcc"
182 [(set (match_operand:CC 0 "nonimmediate_operand" "")
183 (match_operand:CC 1 "nonimmediate_operand" ""))]
187 (define_expand "movcc_uns"
188 [(set (match_operand:CC_UNS 0 "nonimmediate_operand" "")
189 (match_operand:CC_UNS 1 "nonimmediate_operand" ""))]
193 (define_expand "movcc_fp"
194 [(set (match_operand:CC_FP 0 "nonimmediate_operand" "")
195 (match_operand:CC_FP 1 "nonimmediate_operand" ""))]
199 (define_expand "movcc_fpeq"
200 [(set (match_operand:CC_FPEQ 0 "nonimmediate_operand" "")
201 (match_operand:CC_FPEQ 1 "nonimmediate_operand" ""))]
205 (define_expand "movcc_fun"
206 [(set (match_operand:CC_FUN 0 "nonimmediate_operand" "")
207 (match_operand:CC_FUN 1 "nonimmediate_operand" ""))]
211 (define_insn "adddi3"
212 [(set (match_operand:DI 0 "register_operand" "=r,r,r")
214 (match_operand:DI 1 "register_operand" "%r,r,0")
215 (match_operand:DI 2 "mmix_reg_or_constant_operand" "rI,K,LS")))]
222 (define_insn "adddf3"
223 [(set (match_operand:DF 0 "register_operand" "=r")
224 (plus:DF (match_operand:DF 1 "register_operand" "%r")
225 (match_operand:DF 2 "register_operand" "r")))]
229 ;; Insn canonicalization *should* have removed the need for an integer
231 (define_insn "subdi3"
232 [(set (match_operand:DI 0 "register_operand" "=r,r")
233 (minus:DI (match_operand:DI 1 "mmix_reg_or_8bit_operand" "r,I")
234 (match_operand:DI 2 "register_operand" "r,r")))]
240 (define_insn "subdf3"
241 [(set (match_operand:DF 0 "register_operand" "=r")
242 (minus:DF (match_operand:DF 1 "register_operand" "r")
243 (match_operand:DF 2 "register_operand" "r")))]
247 ;; FIXME: Should we define_expand and match 2, 4, 8 (etc) with shift (or
248 ;; %{something}2ADDU %0,%1,0)? Hopefully GCC should still handle it, so
249 ;; we don't have to taint the machine description. If results are bad
250 ;; enough, we may have to do it anyway.
251 (define_insn "muldi3"
252 [(set (match_operand:DI 0 "register_operand" "=r,r")
253 (mult:DI (match_operand:DI 1 "register_operand" "%r,r")
254 (match_operand:DI 2 "mmix_reg_or_8bit_operand" "O,rI")))
255 (clobber (match_scratch:DI 3 "=X,z"))]
261 (define_insn "muldf3"
262 [(set (match_operand:DF 0 "register_operand" "=r")
263 (mult:DF (match_operand:DF 1 "register_operand" "r")
264 (match_operand:DF 2 "register_operand" "r")))]
268 (define_insn "divdf3"
269 [(set (match_operand:DF 0 "register_operand" "=r")
270 (div:DF (match_operand:DF 1 "register_operand" "r")
271 (match_operand:DF 2 "register_operand" "r")))]
275 ;; FIXME: Is "frem" doing the right operation for moddf3?
276 (define_insn "moddf3"
277 [(set (match_operand:DF 0 "register_operand" "=r")
278 (mod:DF (match_operand:DF 1 "register_operand" "r")
279 (match_operand:DF 2 "register_operand" "r")))]
283 ;; FIXME: Should we define_expand for smin, smax, umin, umax using a
284 ;; nifty conditional sequence?
286 ;; FIXME: The cuter andn combinations don't get here, presumably because
287 ;; they ended up in the constant pool. Check: still?
288 (define_insn "anddi3"
289 [(set (match_operand:DI 0 "register_operand" "=r,r")
291 (match_operand:DI 1 "register_operand" "%r,0")
292 (match_operand:DI 2 "mmix_reg_or_constant_operand" "rI,NT")))]
298 (define_insn "iordi3"
299 [(set (match_operand:DI 0 "register_operand" "=r,r")
300 (ior:DI (match_operand:DI 1 "register_operand" "%r,0")
301 (match_operand:DI 2 "mmix_reg_or_constant_operand" "rI,LS")))]
307 (define_insn "xordi3"
308 [(set (match_operand:DI 0 "register_operand" "=r")
309 (xor:DI (match_operand:DI 1 "register_operand" "%r")
310 (match_operand:DI 2 "mmix_reg_or_8bit_operand" "rI")))]
314 ;; FIXME: When TImode works for other reasons (like cross-compiling from
315 ;; a 32-bit host), add back umulditi3 and umuldi3_highpart here.
317 ;; FIXME: Check what's really reasonable for the mod part.
319 ;; One day we might persuade GCC to expand divisions with constants the
320 ;; way MMIX does; giving the remainder the sign of the divisor. But even
321 ;; then, it might be good to have an option to divide the way "everybody
322 ;; else" does. Perhaps then, this option can be on by default. However,
323 ;; it's not likely to happen because major (C, C++, Fortran) language
324 ;; standards in effect at 2002-04-29 reportedly demand that the sign of
325 ;; the remainder must follow the sign of the dividend.
327 (define_insn "divmoddi4"
328 [(set (match_operand:DI 0 "register_operand" "=r")
329 (div:DI (match_operand:DI 1 "register_operand" "r")
330 (match_operand:DI 2 "mmix_reg_or_8bit_operand" "rI")))
331 (set (match_operand:DI 3 "register_operand" "=y")
332 (mod:DI (match_dup 1) (match_dup 2)))]
333 ;; Do the library stuff later.
334 "TARGET_KNUTH_DIVISION"
337 (define_insn "udivmoddi4"
338 [(set (match_operand:DI 0 "register_operand" "=r")
339 (udiv:DI (match_operand:DI 1 "register_operand" "r")
340 (match_operand:DI 2 "mmix_reg_or_8bit_operand" "rI")))
341 (set (match_operand:DI 3 "register_operand" "=y")
342 (umod:DI (match_dup 1) (match_dup 2)))]
346 (define_expand "divdi3"
348 [(set (match_operand:DI 0 "register_operand" "=&r")
349 (div:DI (match_operand:DI 1 "register_operand" "r")
350 (match_operand:DI 2 "register_operand" "r")))
351 (clobber (scratch:DI))
352 (clobber (scratch:DI))
353 (clobber (reg:DI MMIX_rR_REGNUM))])]
354 "! TARGET_KNUTH_DIVISION"
357 ;; The %2-is-%1-case is there just to make sure things don't fail. Could
358 ;; presumably happen with optimizations off; no evidence.
359 (define_insn "*divdi3_nonknuth"
360 [(set (match_operand:DI 0 "register_operand" "=&r,&r")
361 (div:DI (match_operand:DI 1 "register_operand" "r,r")
362 (match_operand:DI 2 "register_operand" "1,r")))
363 (clobber (match_scratch:DI 3 "=1,1"))
364 (clobber (match_scratch:DI 4 "=2,2"))
365 (clobber (reg:DI MMIX_rR_REGNUM))]
366 "! TARGET_KNUTH_DIVISION"
369 XOR $255,%1,%2\;NEGU %0,0,%2\;CSN %2,%2,%0\;NEGU %0,0,%1\;CSN %1,%1,%0\;\
370 DIVU %0,%1,%2\;NEGU %1,0,%0\;CSN %0,$255,%1")
372 (define_expand "moddi3"
374 [(set (match_operand:DI 0 "register_operand" "=&r")
375 (mod:DI (match_operand:DI 1 "register_operand" "r")
376 (match_operand:DI 2 "register_operand" "r")))
377 (clobber (scratch:DI))
378 (clobber (scratch:DI))
379 (clobber (reg:DI MMIX_rR_REGNUM))])]
380 "! TARGET_KNUTH_DIVISION"
383 ;; The %2-is-%1-case is there just to make sure things don't fail. Could
384 ;; presumably happen with optimizations off; no evidence.
385 (define_insn "*moddi3_nonknuth"
386 [(set (match_operand:DI 0 "register_operand" "=&r,&r")
387 (mod:DI (match_operand:DI 1 "register_operand" "r,r")
388 (match_operand:DI 2 "register_operand" "1,r")))
389 (clobber (match_scratch:DI 3 "=1,1"))
390 (clobber (match_scratch:DI 4 "=2,2"))
391 (clobber (reg:DI MMIX_rR_REGNUM))]
392 "! TARGET_KNUTH_DIVISION"
395 NEGU %0,0,%2\;CSN %2,%2,%0\;NEGU $255,0,%1\;CSN %1,%1,$255\;\
396 DIVU %1,%1,%2\;GET %0,:rR\;NEGU %2,0,%0\;CSNN %0,$255,%2")
398 (define_insn "ashldi3"
399 [(set (match_operand:DI 0 "register_operand" "=r")
401 (match_operand:DI 1 "register_operand" "r")
402 (match_operand:DI 2 "mmix_reg_or_8bit_operand" "rI")))]
406 (define_insn "ashrdi3"
407 [(set (match_operand:DI 0 "register_operand" "=r")
409 (match_operand:DI 1 "register_operand" "r")
410 (match_operand:DI 2 "mmix_reg_or_8bit_operand" "rI")))]
414 (define_insn "lshrdi3"
415 [(set (match_operand:DI 0 "register_operand" "=r")
417 (match_operand:DI 1 "register_operand" "r")
418 (match_operand:DI 2 "mmix_reg_or_8bit_operand" "rI")))]
422 (define_insn "negdi2"
423 [(set (match_operand:DI 0 "register_operand" "=r")
424 (neg:DI (match_operand:DI 1 "register_operand" "r")))]
428 (define_expand "negdf2"
429 [(parallel [(set (match_operand:DF 0 "register_operand" "=r")
430 (neg:DF (match_operand:DF 1 "register_operand" "r")))
431 (use (match_dup 2))])]
434 /* Emit bit-flipping sequence to be IEEE-safe wrt. -+0. */
435 operands[2] = force_reg (DImode, GEN_INT ((HOST_WIDE_INT) 1 << 63));
438 (define_insn "*expanded_negdf2"
439 [(set (match_operand:DF 0 "register_operand" "=r")
440 (neg:DF (match_operand:DF 1 "register_operand" "r")))
441 (use (match_operand:DI 2 "register_operand" "r"))]
445 ;; FIXME: define_expand for absdi2?
447 (define_insn "absdf2"
448 [(set (match_operand:DF 0 "register_operand" "=r")
449 (abs:DF (match_operand:DF 1 "register_operand" "0")))]
453 (define_insn "sqrtdf2"
454 [(set (match_operand:DF 0 "register_operand" "=r")
455 (sqrt:DF (match_operand:DF 1 "register_operand" "r")))]
459 ;; FIXME: define_expand for ffssi2? (not ffsdi2 since int is SImode).
461 (define_insn "one_cmpldi2"
462 [(set (match_operand:DI 0 "register_operand" "=r")
463 (not:DI (match_operand:DI 1 "register_operand" "r")))]
467 ;; When the user-patterns expand, the resulting insns will match the
470 ;; We can fold the signed-compare where the register value is
471 ;; already equal to (compare:CCTYPE (reg) (const_int 0)).
472 ;; We can't do that at all for floating-point, due to NaN, +0.0
473 ;; and -0.0, and we can only do it for the non/zero test of
474 ;; unsigned, so that has to be done another way.
475 ;; FIXME: Perhaps a peep2 changing CCcode to a new code, that
477 (define_insn "*cmpdi_folded"
478 [(set (match_operand:CC 0 "register_operand" "=r")
480 (match_operand:DI 1 "register_operand" "r")
482 ;; FIXME: Can we test equivalence any other way?
483 ;; FIXME: Can we fold any other way?
484 "REG_P (operands[0]) && REG_P (operands[1])
485 && REGNO (operands[1]) == REGNO (operands[0])"
486 "%% folded: cmp %0,%1,0")
489 [(set (match_operand:CC 0 "register_operand" "=r")
491 (match_operand:DI 1 "register_operand" "r")
492 (match_operand:DI 2 "mmix_reg_or_8bit_operand" "rI")))]
497 [(set (match_operand:CC_UNS 0 "register_operand" "=r")
499 (match_operand:DI 1 "register_operand" "r")
500 (match_operand:DI 2 "mmix_reg_or_8bit_operand" "rI")))]
505 [(set (match_operand:CC_FP 0 "register_operand" "=r")
507 (match_operand:DF 1 "register_operand" "r")
508 (match_operand:DF 2 "register_operand" "r")))]
512 ;; FIXME: for -mieee, add fsub %0,%1,%1\;fsub %0,%2,%2 before to
513 ;; make signalling compliant.
515 [(set (match_operand:CC_FPEQ 0 "register_operand" "=r")
517 (match_operand:DF 1 "register_operand" "r")
518 (match_operand:DF 2 "register_operand" "r")))]
523 [(set (match_operand:CC_FUN 0 "register_operand" "=r")
525 (match_operand:DF 1 "register_operand" "r")
526 (match_operand:DF 2 "register_operand" "r")))]
530 ;; In order to get correct rounding, we have to use SFLOT and SFLOTU for
531 ;; conversion. They do not convert to SFmode; they convert to DFmode,
532 ;; with rounding as of SFmode. They are not usable as is, but we pretend
533 ;; we have a single instruction but emit two.
535 ;; Note that this will (somewhat unexpectedly) create an inexact
536 ;; exception if rounding is necessary - has to be masked off in crt0?
537 (define_expand "floatdisf2"
538 [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "=rm")
540 (match_operand:DI 1 "mmix_reg_or_8bit_operand" "rI")))
541 ;; Let's use a DI scratch, since SF don't generally get into
542 ;; registers. Dunno what's best; it's really a DF, but that
543 ;; doesn't logically follow from operands in the pattern.
544 (clobber (match_scratch:DI 2 "=&r"))])]
548 if (GET_CODE (operands[0]) != MEM)
552 /* FIXME: This stack-slot remains even at -O3. There must be a
555 = validize_mem (assign_stack_temp (SFmode,
556 GET_MODE_SIZE (SFmode)));
557 emit_insn (gen_floatdisf2 (stack_slot, operands[1]));
558 emit_move_insn (operands[0], stack_slot);
563 (define_insn "*floatdisf2_real"
564 [(set (match_operand:SF 0 "memory_operand" "=m")
566 (match_operand:DI 1 "mmix_reg_or_8bit_operand" "rI")))
567 (clobber (match_scratch:DI 2 "=&r"))]
569 "SFLOT %2,%1\;STSF %2,%0")
571 (define_expand "floatunsdisf2"
572 [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "=rm")
574 (match_operand:DI 1 "mmix_reg_or_8bit_operand" "rI")))
575 ;; Let's use a DI scratch, since SF don't generally get into
576 ;; registers. Dunno what's best; it's really a DF, but that
577 ;; doesn't logically follow from operands in the pattern.
578 (clobber (scratch:DI))])]
582 if (GET_CODE (operands[0]) != MEM)
586 /* FIXME: This stack-slot remains even at -O3. Must be a better
589 = validize_mem (assign_stack_temp (SFmode,
590 GET_MODE_SIZE (SFmode)));
591 emit_insn (gen_floatunsdisf2 (stack_slot, operands[1]));
592 emit_move_insn (operands[0], stack_slot);
597 (define_insn "*floatunsdisf2_real"
598 [(set (match_operand:SF 0 "memory_operand" "=m")
600 (match_operand:DI 1 "mmix_reg_or_8bit_operand" "rI")))
601 (clobber (match_scratch:DI 2 "=&r"))]
603 "SFLOTU %2,%1\;STSF %2,%0")
605 ;; Note that this will (somewhat unexpectedly) create an inexact
606 ;; exception if rounding is necessary - has to be masked off in crt0?
607 (define_insn "floatdidf2"
608 [(set (match_operand:DF 0 "register_operand" "=r")
610 (match_operand:DI 1 "mmix_reg_or_8bit_operand" "rI")))]
614 (define_insn "floatunsdidf2"
615 [(set (match_operand:DF 0 "register_operand" "=r")
617 (match_operand:DI 1 "mmix_reg_or_8bit_operand" "rI")))]
621 (define_insn "ftruncdf2"
622 [(set (match_operand:DF 0 "register_operand" "=r")
623 (fix:DF (match_operand:DF 1 "register_operand" "r")))]
628 ;; Note that this will (somewhat unexpectedly) create an inexact
629 ;; exception if rounding is necessary - has to be masked off in crt0?
630 (define_insn "fix_truncdfdi2"
631 [(set (match_operand:DI 0 "register_operand" "=r")
632 (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "r"))))]
637 (define_insn "fixuns_truncdfdi2"
638 [(set (match_operand:DI 0 "register_operand" "=r")
640 (fix:DF (match_operand:DF 1 "register_operand" "r"))))]
645 ;; It doesn't seem like it's possible to have memory_operand as a
646 ;; predicate here (testcase: libgcc2 floathisf). FIXME: Shouldn't it be
647 ;; possible to do that? Bug in GCC? Anyway, this used to be a simple
648 ;; pattern with a memory_operand predicate, but was split up with a
649 ;; define_expand with the old pattern as "anonymous".
650 ;; FIXME: Perhaps with TARGET_SECONDARY_MEMORY_NEEDED?
651 (define_expand "truncdfsf2"
652 [(set (match_operand:SF 0 "nonimmediate_operand")
653 (float_truncate:SF (match_operand:DF 1 "register_operand")))]
657 if (GET_CODE (operands[0]) != MEM)
659 /* FIXME: There should be a way to say: 'put this in operands[0]
660 but *after* the expanded insn'. */
663 /* There is no sane destination but a register here, if it wasn't
664 already MEM. (It's too hard to get fatal_insn to work here.) */
665 if (! REG_P (operands[0]))
666 internal_error (\"MMIX Internal: Bad truncdfsf2 expansion\");
668 /* FIXME: This stack-slot remains even at -O3. Must be a better
671 = validize_mem (assign_stack_temp (SFmode,
672 GET_MODE_SIZE (SFmode)));
673 emit_insn (gen_truncdfsf2 (stack_slot, operands[1]));
674 emit_move_insn (operands[0], stack_slot);
679 (define_insn "*truncdfsf2_real"
680 [(set (match_operand:SF 0 "memory_operand" "=m")
681 (float_truncate:SF (match_operand:DF 1 "register_operand" "r")))]
685 ;; Same comment as for truncdfsf2.
686 (define_expand "extendsfdf2"
687 [(set (match_operand:DF 0 "register_operand")
688 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand")))]
692 if (GET_CODE (operands[1]) != MEM)
696 /* There is no sane destination but a register here, if it wasn't
697 already MEM. (It's too hard to get fatal_insn to work here.) */
698 if (! REG_P (operands[0]))
699 internal_error (\"MMIX Internal: Bad extendsfdf2 expansion\");
701 /* FIXME: This stack-slot remains even at -O3. There must be a
704 = validize_mem (assign_stack_temp (SFmode,
705 GET_MODE_SIZE (SFmode)));
706 emit_move_insn (stack_slot, operands[1]);
707 emit_insn (gen_extendsfdf2 (operands[0], stack_slot));
712 (define_insn "*extendsfdf2_real"
713 [(set (match_operand:DF 0 "register_operand" "=r")
714 (float_extend:DF (match_operand:SF 1 "memory_operand" "m")))]
718 ;; Neither sign-extend nor zero-extend are necessary; gcc knows how to
719 ;; synthesize using shifts or and, except with a memory source and not
720 ;; completely optimal. FIXME: Actually, other bugs surface when those
721 ;; patterns are defined; fix later.
723 ;; There are no sane values with the bit-patterns of (int) 0..255 except
724 ;; 0 to use in movdfcc.
726 (define_expand "movdfcc"
727 [(set (match_dup 4) (match_dup 5))
728 (set (match_operand:DF 0 "register_operand" "")
730 (match_operand 1 "comparison_operator" "")
731 (match_operand:DF 2 "mmix_reg_or_0_operand" "")
732 (match_operand:DF 3 "mmix_reg_or_0_operand" "")))]
736 enum rtx_code code = GET_CODE (operands[1]);
737 if (code == LE || code == GE)
740 operands[4] = mmix_gen_compare_reg (code, XEXP (operands[1], 0),
741 XEXP (operands[1], 1));
742 operands[5] = gen_rtx_COMPARE (GET_MODE (operands[4]),
743 XEXP (operands[1], 0),
744 XEXP (operands[1], 1));
745 operands[1] = gen_rtx_fmt_ee (code, VOIDmode, operands[4], const0_rtx);
748 (define_expand "movdicc"
749 [(set (match_dup 4) (match_dup 5))
750 (set (match_operand:DI 0 "register_operand" "")
752 (match_operand 1 "comparison_operator" "")
753 (match_operand:DI 2 "mmix_reg_or_8bit_operand" "")
754 (match_operand:DI 3 "mmix_reg_or_8bit_operand" "")))]
758 enum rtx_code code = GET_CODE (operands[1]);
759 if (code == LE || code == GE)
762 operands[4] = mmix_gen_compare_reg (code, XEXP (operands[1], 0),
763 XEXP (operands[1], 1));
764 operands[5] = gen_rtx_COMPARE (GET_MODE (operands[4]),
765 XEXP (operands[1], 0),
766 XEXP (operands[1], 1));
767 operands[1] = gen_rtx_fmt_ee (code, VOIDmode, operands[4], const0_rtx);
770 ;; FIXME: Is this the right way to do "folding" of CCmode -> DImode?
771 (define_insn "*movdicc_real_foldable"
772 [(set (match_operand:DI 0 "register_operand" "=r,r,r,r")
774 (match_operator 2 "mmix_foldable_comparison_operator"
775 [(match_operand:DI 3 "register_operand" "r,r,r,r")
777 (match_operand:DI 1 "mmix_reg_or_8bit_operand" "rI,0 ,rI,GM")
778 (match_operand:DI 4 "mmix_reg_or_8bit_operand" "0 ,rI,GM,rI")))]
786 (define_insn "*movdicc_real_reversible"
788 (match_operand:DI 0 "register_operand" "=r ,r ,r ,r")
791 2 "mmix_comparison_operator"
792 [(match_operand 3 "mmix_reg_cc_operand" "r ,r ,r ,r")
794 (match_operand:DI 1 "mmix_reg_or_8bit_operand" "rI,0 ,rI,GM")
795 (match_operand:DI 4 "mmix_reg_or_8bit_operand" "0 ,rI,GM,rI")))]
796 "REVERSIBLE_CC_MODE (GET_MODE (operands[3]))"
803 (define_insn "*movdicc_real_nonreversible"
805 (match_operand:DI 0 "register_operand" "=r ,r")
808 2 "mmix_comparison_operator"
809 [(match_operand 3 "mmix_reg_cc_operand" "r ,r")
811 (match_operand:DI 1 "mmix_reg_or_8bit_operand" "rI,rI")
812 (match_operand:DI 4 "mmix_reg_or_0_operand" "0 ,GM")))]
813 "!REVERSIBLE_CC_MODE (GET_MODE (operands[3]))"
818 (define_insn "*movdfcc_real_foldable"
820 (match_operand:DF 0 "register_operand" "=r ,r ,r ,r")
823 2 "mmix_foldable_comparison_operator"
824 [(match_operand:DI 3 "register_operand" "r ,r ,r ,r")
826 (match_operand:DF 1 "mmix_reg_or_0_operand" "rGM,0 ,rGM,GM")
827 (match_operand:DF 4 "mmix_reg_or_0_operand" "0 ,rGM,GM ,rGM")))]
835 (define_insn "*movdfcc_real_reversible"
837 (match_operand:DF 0 "register_operand" "=r ,r ,r ,r")
840 2 "mmix_comparison_operator"
841 [(match_operand 3 "mmix_reg_cc_operand" "r ,r ,r ,r")
843 (match_operand:DF 1 "mmix_reg_or_0_operand" "rGM,0 ,rGM,GM")
844 (match_operand:DF 4 "mmix_reg_or_0_operand" "0 ,rGM,GM ,rGM")))]
845 "REVERSIBLE_CC_MODE (GET_MODE (operands[3]))"
852 (define_insn "*movdfcc_real_nonreversible"
854 (match_operand:DF 0 "register_operand" "=r ,r")
857 2 "mmix_comparison_operator"
858 [(match_operand 3 "mmix_reg_cc_operand" "r ,r")
860 (match_operand:DF 1 "mmix_reg_or_0_operand" "rGM,rGM")
861 (match_operand:DF 4 "mmix_reg_or_0_operand" "0 ,GM")))]
862 "!REVERSIBLE_CC_MODE (GET_MODE (operands[3]))"
867 ;; FIXME: scc insns will probably help, I just skip them
868 ;; right now. Revisit.
870 (define_expand "cbranchdi4"
873 [(match_operand:DI 1 "register_operand" "")
874 (match_operand:DI 2 "mmix_reg_or_8bit_operand" "")]))
877 (match_operator 0 "ordered_comparison_operator"
880 (label_ref (match_operand 3 "" ""))
885 operands[4] = mmix_gen_compare_reg (GET_CODE (operands[0]),
886 operands[1], operands[2]);
887 operands[5] = gen_rtx_fmt_ee (COMPARE,
888 GET_MODE (operands[4]),
889 operands[1], operands[2]);
892 (define_expand "cbranchdf4"
895 [(match_operand:DF 1 "register_operand" "")
896 (match_operand:DF 2 "register_operand" "")]))
899 (match_operator 0 "float_comparison_operator"
902 (label_ref (match_operand 3 "" ""))
907 /* The head comment of optabs.c:can_compare_p says we're required to
908 implement this, so we have to clean up the mess here. */
909 if (GET_CODE (operands[0]) == LE || GET_CODE (operands[0]) == GE)
911 enum rtx_code ltgt_code = GET_CODE (operands[0]) == LE ? LT : GT;
912 emit_cmp_and_jump_insns (operands[1], operands[2], ltgt_code, NULL_RTX,
913 DFmode, 0, operands[3]);
914 emit_cmp_and_jump_insns (operands[1], operands[2], EQ, NULL_RTX,
915 DFmode, 0, operands[3]);
919 operands[4] = mmix_gen_compare_reg (GET_CODE (operands[0]),
920 operands[1], operands[2]);
921 operands[5] = gen_rtx_fmt_ee (COMPARE,
922 GET_MODE (operands[4]),
923 operands[1], operands[2]);
927 ;; FIXME: we can emit an unordered-or-*not*-equal compare in one insn, but
928 ;; there's no RTL code for it. Maybe revisit in future.
930 ;; FIXME: Odd/Even matchers?
931 (define_insn "*bCC_foldable"
934 (match_operator 1 "mmix_foldable_comparison_operator"
935 [(match_operand:DI 2 "register_operand" "r")
937 (label_ref (match_operand 0 "" ""))
945 (match_operator 1 "mmix_comparison_operator"
946 [(match_operand 2 "mmix_reg_cc_operand" "r")
948 (label_ref (match_operand 0 "" ""))
953 (define_insn "*bCC_inverted_foldable"
956 (match_operator 1 "mmix_foldable_comparison_operator"
957 [(match_operand:DI 2 "register_operand" "r")
960 (label_ref (match_operand 0 "" ""))))]
961 ;; REVERSIBLE_CC_MODE is checked by mmix_foldable_comparison_operator.
965 (define_insn "*bCC_inverted"
968 (match_operator 1 "mmix_comparison_operator"
969 [(match_operand 2 "mmix_reg_cc_operand" "r")
972 (label_ref (match_operand 0 "" ""))))]
973 "REVERSIBLE_CC_MODE (GET_MODE (operands[2]))"
976 (define_expand "call"
977 [(parallel [(call (match_operand:QI 0 "memory_operand" "") (const_int 0))
978 (clobber (match_dup 1))])
979 (set (match_dup 1) (match_dup 2))]
983 /* The caller checks that the operand is generally valid as an
984 address, but at -O0 nothing makes sure that it's also a valid
985 call address for a *call*; a mmix_symbolic_or_address_operand.
986 Force into a register if it isn't. */
987 if (!mmix_symbolic_or_address_operand (XEXP (operands[0], 0),
988 GET_MODE (XEXP (operands[0], 0))))
990 = replace_equiv_address (operands[0],
991 force_reg (Pmode, XEXP (operands[0], 0)));
993 /* Note that we overwrite the generic operands[1] and operands[2]; we
994 don't use those values. */
995 operands[1] = gen_rtx_REG (DImode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM);
997 /* Since the epilogue 'uses' the return address, and it is clobbered
998 in the call, and we set it back after every call (all but one setting
999 will be optimized away), integrity is maintained. */
1001 = mmix_get_hard_reg_initial_val (Pmode,
1002 MMIX_INCOMING_RETURN_ADDRESS_REGNUM);
1005 (define_expand "call_value"
1006 [(parallel [(set (match_operand 0 "" "")
1007 (call (match_operand:QI 1 "memory_operand" "")
1009 (clobber (match_dup 2))])
1010 (set (match_dup 2) (match_dup 3))]
1014 /* The caller checks that the operand is generally valid as an
1015 address, but at -O0 nothing makes sure that it's also a valid
1016 call address for a *call*; a mmix_symbolic_or_address_operand.
1017 Force into a register if it isn't. */
1018 if (!mmix_symbolic_or_address_operand (XEXP (operands[1], 0),
1019 GET_MODE (XEXP (operands[1], 0))))
1021 = replace_equiv_address (operands[1],
1022 force_reg (Pmode, XEXP (operands[1], 0)));
1024 /* Note that we overwrite the generic operands[2] and operands[3]; we
1025 don't use those values. */
1026 operands[2] = gen_rtx_REG (DImode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM);
1028 /* Since the epilogue 'uses' the return address, and it is clobbered
1029 in the call, and we set it back after every call (all but one setting
1030 will be optimized away), integrity is maintained. */
1032 = mmix_get_hard_reg_initial_val (Pmode,
1033 MMIX_INCOMING_RETURN_ADDRESS_REGNUM);
1036 ;; Don't use 'p' here. A 'p' must stand first in constraints, or reload
1037 ;; messes up, not registering the address for reload. Several C++
1038 ;; testcases, including g++.brendan/crash40.C. FIXME: This is arguably a
1039 ;; bug in gcc. Note line ~2612 in reload.c, that does things on the
1040 ;; condition <<else if (constraints[i][0] == 'p')>> and the comment on
1043 ;; /* All necessary reloads for an address_operand
1044 ;; were handled in find_reloads_address. */>>
1045 ;; Sorry, I have not dug deeper. If symbolic addresses are used
1046 ;; rarely compared to addresses in registers, disparaging the
1047 ;; first ("p") alternative by adding ? in the first operand
1048 ;; might do the trick. We define 'U' as a synonym to 'p', but without the
1049 ;; caveats (and very small advantages) of 'p'.
1050 ;; As of r190682 still so: newlib/libc/stdlib/dtoa.c ICEs if "p" is used.
1051 (define_insn "*call_real"
1053 (match_operand:DI 0 "mmix_symbolic_or_address_operand" "s,rU"))
1055 (clobber (reg:DI MMIX_rJ_REGNUM))]
1061 (define_insn "*call_value_real"
1062 [(set (match_operand 0 "register_operand" "=r,r")
1064 (match_operand:DI 1 "mmix_symbolic_or_address_operand" "s,rU"))
1066 (clobber (reg:DI MMIX_rJ_REGNUM))]
1072 ;; I hope untyped_call and untyped_return are not needed for MMIX.
1073 ;; Users of Objective-C will notice.
1076 (define_expand "return"
1078 "mmix_use_simple_return ()"
1081 ; Generated by the epilogue expander.
1082 (define_insn "*expanded_return"
1087 (define_expand "prologue"
1090 "mmix_expand_prologue (); DONE;")
1092 ; Note that the (return) from the expander itself is always the last insn
1094 (define_expand "epilogue"
1097 "mmix_expand_epilogue ();")
1105 [(set (pc) (label_ref (match_operand 0 "" "")))]
1109 (define_insn "indirect_jump"
1110 [(set (pc) (match_operand 0 "address_operand" "p"))]
1114 ;; FIXME: This is just a jump, and should be expanded to one.
1115 (define_insn "tablejump"
1116 [(set (pc) (match_operand:DI 0 "address_operand" "p"))
1117 (use (label_ref (match_operand 1 "" "")))]
1121 ;; The only peculiar thing is that the register stack has to be unwound at
1122 ;; nonlocal_goto_receiver. At each function that has a nonlocal label, we
1123 ;; save at function entry the location of the "alpha" register stack
1124 ;; pointer, rO, in a stack slot known to that function (right below where
1125 ;; the frame-pointer would be located).
1126 ;; In the nonlocal goto receiver, we unwind the register stack by a series
1127 ;; of "pop 0,0" until rO equals the saved value. (If it goes lower, we
1128 ;; should die with a trap.)
1129 (define_expand "nonlocal_goto_receiver"
1130 [(parallel [(unspec_volatile [(match_dup 1)] 1)
1131 (clobber (scratch:DI))
1132 (clobber (reg:DI MMIX_rJ_REGNUM))])
1133 (set (reg:DI MMIX_rJ_REGNUM) (match_dup 0))]
1138 = mmix_get_hard_reg_initial_val (Pmode,
1139 MMIX_INCOMING_RETURN_ADDRESS_REGNUM);
1141 /* We need the frame-pointer to be live or the equivalent
1142 expression, so refer to it in the pattern. We can't use a MEM
1143 (that may contain out-of-range offsets in the final expression)
1144 for fear that middle-end will legitimize it or replace the address
1145 using temporary registers (which are not revived at this point). */
1146 operands[1] = frame_pointer_rtx;
1148 /* Mark this function as containing a landing-pad. */
1149 cfun->machine->has_landing_pad = 1;
1152 ;; GCC can insist on using saved registers to keep the slot address in
1153 ;; "across" the exception, or (perhaps) to use saved registers in the
1154 ;; address and re-use them after the register stack unwind, so it's best
1155 ;; to form the address ourselves.
1156 (define_insn "*nonlocal_goto_receiver_expanded"
1157 [(unspec_volatile [(match_operand:DI 1 "frame_pointer_operand" "Yf")] 1)
1158 (clobber (match_scratch:DI 0 "=&r"))
1159 (clobber (reg:DI MMIX_rJ_REGNUM))]
1163 const char *my_template
1164 = "GETA $255,0f\;PUT rJ,$255\;LDOU $255,%a0\n\
1165 0:\;GET %1,rO\;CMPU %1,%1,$255\;BNP %1,1f\;POP 0,0\n1:";
1167 my_operands[1] = operands[0];
1168 my_operands[2] = GEN_INT (-MMIX_fp_rO_OFFSET);
1170 if (operands[1] == hard_frame_pointer_rtx)
1172 mmix_output_register_setting (asm_out_file, REGNO (operands[0]),
1173 MMIX_fp_rO_OFFSET, 1);
1175 = gen_rtx_PLUS (Pmode, hard_frame_pointer_rtx, operands[0]);
1179 int64_t offs = INTVAL (XEXP (operands[1], 1));
1180 offs += MMIX_fp_rO_OFFSET;
1182 if (insn_const_int_ok_for_constraint (offs, CONSTRAINT_I))
1184 = gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (offs));
1187 mmix_output_register_setting (asm_out_file, REGNO (operands[0]),
1190 = gen_rtx_PLUS (Pmode, stack_pointer_rtx, operands[0]);
1194 output_asm_insn (my_template, my_operands);
1198 (define_insn "*Naddu"
1199 [(set (match_operand:DI 0 "register_operand" "=r")
1200 (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "r")
1201 (match_operand:DI 2 "const_int_operand" "n"))
1202 (match_operand:DI 3 "mmix_reg_or_8bit_operand" "rI")))]
1203 "GET_CODE (operands[2]) == CONST_INT
1204 && (INTVAL (operands[2]) == 2
1205 || INTVAL (operands[2]) == 4
1206 || INTVAL (operands[2]) == 8
1207 || INTVAL (operands[2]) == 16)"
1210 (define_insn "*andn"
1211 [(set (match_operand:DI 0 "register_operand" "=r")
1213 (not:DI (match_operand:DI 1 "mmix_reg_or_8bit_operand" "rI"))
1214 (match_operand:DI 2 "register_operand" "r")))]
1218 (define_insn "*nand"
1219 [(set (match_operand:DI 0 "register_operand" "=r")
1221 (not:DI (match_operand:DI 1 "register_operand" "%r"))
1222 (not:DI (match_operand:DI 2 "mmix_reg_or_8bit_operand" "rI"))))]
1227 [(set (match_operand:DI 0 "register_operand" "=r")
1229 (not:DI (match_operand:DI 1 "register_operand" "%r"))
1230 (not:DI (match_operand:DI 2 "mmix_reg_or_8bit_operand" "rI"))))]
1234 (define_insn "*nxor"
1235 [(set (match_operand:DI 0 "register_operand" "=r")
1237 (xor:DI (match_operand:DI 1 "register_operand" "%r")
1238 (match_operand:DI 2 "mmix_reg_or_8bit_operand" "rI"))))]
1242 (define_insn "sync_icache"
1243 [(unspec_volatile [(match_operand:DI 0 "memory_operand" "m")
1244 (match_operand:DI 1 "const_int_operand" "I")] 0)]
1250 ;; indent-tabs-mode: t