1 ;;- Machine description for GNU compiler
2 ;;- MIL-STD-1750A version.
3 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
4 ;; Contributed by O.M.Kellogg, DASA (oliver.kellogg@space.otn.dasa.de).
6 ;; This file is part of GNU CC.
8 ;; GNU CC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 1, or (at your option)
13 ;; GNU CC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU CC; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
24 ;;- instruction definitions
26 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
28 ;;- When naming insn's (operand 0 of define_insn) be careful about using
29 ;;- names from other targets machine descriptions.
31 ;; MIL-STD-1750 specific remarks:
33 ;; 1) BITS_PER_UNIT = 16
35 ;; 2) GCC to MIL-STD-1750 data type mappings:
36 ;; QImode => single integer (16 bits or 1 reg).
37 ;; HImode => double integer (32 bits or 2 regs).
38 ;; HFmode => single precision float (32 bits or 2 regs).
39 ;; TQFmode => extended precision float (48 bits or 3 regs).
41 ;; 3) Immediate integer operands Constraints:
46 ;; 'M' -32768 .. 32767
47 ;; 'O' => 0 (for optimizations and GCC quirks)
50 ;;- Assembly output ending in ".M" are macros in file M1750.INC
55 [(set (match_operand:QI 0 "push_operand" "=<")
56 (match_operand:QI 1 "general_operand" "r"))]
61 [(set (match_operand:HI 0 "push_operand" "=<")
62 (match_operand:HI 1 "general_operand" "r"))]
67 [(set (match_operand:HF 0 "push_operand" "=<")
68 (match_operand:HF 1 "general_operand" "r"))]
73 [(set (match_operand:TQF 0 "push_operand" "=<")
74 (match_operand:TQF 1 "general_operand" "r"))]
80 [(set (match_operand:QI 0 "general_operand" "=r")
81 (match_operand:QI 1 "push_operand" ">"))]
86 [(set (match_operand:HI 0 "general_operand" "=r")
87 (match_operand:HI 1 "push_operand" ">"))]
92 [(set (match_operand:HF 0 "general_operand" "=r")
93 (match_operand:HF 1 "push_operand" ">"))]
98 [(set (match_operand:TQF 0 "general_operand" "=r")
99 (match_operand:TQF 1 "push_operand" ">"))]
108 (match_operand:QI 0 "register_operand" "r"))]
110 "lr r%0,r%0 ; from tstqi")
114 (match_operand:HI 0 "register_operand" "r"))]
116 "dlr r%0,r%0 ; from tsthi")
118 ; With 1750A floats, testing the most significant word suffices.
122 (match_operand:HF 0 "register_operand" "r"))]
124 "lr r%0,r%0 ; tsthf")
126 (define_insn "tsttqf"
128 (match_operand:TQF 0 "register_operand" "r"))]
130 "lr r%0,r%0 ; tsttqf")
135 (define_insn "movstrqi"
136 [(set (match_operand:BLK 0 "mov_memory_operand" "m")
137 (match_operand:BLK 1 "mov_memory_operand" "m"))
138 (use (match_operand:QI 2 "general_operand" "r"))
139 (match_operand 3 "" "")
140 (clobber (match_dup 0))
141 (clobber (match_dup 1))
142 (clobber (match_dup 2))]
148 regops[0] = XEXP (operands[0], 0);
149 regops[1] = XEXP (operands[1], 0);
150 regops[2] = operands[2];
152 return movcnt_regno_adjust (regops);
156 ;; compare instructions.
160 (compare (match_operand:QI 0 "register_operand" "r,r,r,r,r")
161 (match_operand:QI 1 "general_operand" "I,J,i,r,m")))]
165 if (next_cc_user_is_unsigned (insn))
166 switch (which_alternative)
171 return \"ucim.m %0,%1\";
173 return \"ucr.m %0,%1\";
175 return \"uc.m %0,%1\";
178 switch (which_alternative)
181 return \"cisp r%0,%1\";
183 return \"cisn r%0,%J1\";
185 return \"cim r%0,%1\";
187 return \"cr r%0,r%1\";
195 (compare (match_operand:HI 0 "general_operand" "r,r")
196 (match_operand:HI 1 "general_operand" "r,m")))]
200 if (next_cc_user_is_unsigned (insn))
202 if (which_alternative == 0)
203 return \"ducr.m %0,%1\";
204 return \"duc.m %0,%1\";
208 if (which_alternative == 0)
209 return \"dcr r%0,r%1\";
210 return \"dc r%0,%1\";
216 (compare (match_operand:HF 0 "general_operand" "r,r")
217 (match_operand:HF 1 "general_operand" "r,m")))]
223 (define_insn "cmptqf"
225 (compare (match_operand:TQF 0 "general_operand" "r,r")
226 (match_operand:TQF 1 "general_operand" "r,m")))]
233 ;; truncation instructions
234 ;;- 1750: any needed?
236 (define_insn "trunchiqi2"
237 [(set (match_operand:QI 0 "register_operand" "=r")
238 (truncate:QI (match_operand:HI 1 "register_operand" "r")))]
243 ;; zero extension instructions: not defined, GCC can synthesize
245 ;; sign extension instructions
247 (define_insn "extendqihi2"
248 [(set (match_operand:HI 0 "register_operand" "=r,r")
249 (sign_extend:HI (match_operand:QI 1 "general_operand" "r,m")) )]
252 if (which_alternative == 0)
254 if (REGNO (operands [0]) != REGNO (operands [1]))
255 output_asm_insn (\"lr r%0,r%1\", operands);
258 output_asm_insn (\"l r%0,%1\", operands);
259 return \"dsra r%0,16 ;extendqihi2\";
263 ;; Conversions between float and double.
265 ; 1750 HF-to-TQF extend: just append 16 bits (least signif.) with all bits zero
266 (define_insn "extendhftqf2"
267 [(set (match_operand:TQF 0 "register_operand" "=r,r")
268 (float_extend:TQF (match_operand:HF 1 "general_operand" "r,m")))]
271 output_asm_insn(\"xorr r%t0,r%t0 ;extendhftqf2\", operands);
272 if (which_alternative == 0)
274 if (REGNO (operands[1]) != REGNO (operands[0]))
275 return \"dlr r%0,r%1\";
280 return \"dl r%0,%1\";
283 ; 1750 TQF-to-HF truncate is a no-op: just leave away the least signif. 16 bits
284 (define_insn "trunctqfhf2"
285 [(set (match_operand:HF 0 "register_operand" "=r,r")
287 (match_operand:TQF 1 "general_operand" "r,m")))]
290 dlr r%0,r%1 ;trunctqfhf2
291 dl r%0,%1 ;trunctqfhf2 ")
294 ;; Conversion between fixed point and floating point.
296 (define_insn "floatqihf2"
297 [(set (match_operand:HF 0 "register_operand" "=r")
298 (float:HF (match_operand:QI 1 "register_operand" "r")))]
302 (define_insn "floathitqf2"
303 [(set (match_operand:TQF 0 "register_operand" "=r")
304 (float:TQF (match_operand:HI 1 "register_operand" "r")))]
309 ;; Convert floats to ints
311 (define_insn "fix_trunchfqi2"
312 [(set (match_operand:QI 0 "register_operand" "=r")
313 (fix:QI (fix:HF (match_operand:HF 1 "register_operand" "r"))))]
317 (define_insn "fix_trunctqfhi2"
318 [(set (match_operand:HI 0 "register_operand" "=r")
319 (fix:HI (fix:TQF (match_operand:TQF 1 "register_operand" "r"))))]
326 ;; We can't deal with normal byte-size characters, only with WIDE characters!
327 ;; This may appear as a serious restriction, but it also opens the doors
332 ; memory indirect to reg
334 [(set (match_operand:QI 0 "register_operand" "=r")
335 (mem:QI (match_operand 1 "memory_operand" "m")))]
339 ; reg/const to memory indirect
341 [(set (mem:QI (match_operand 0 "memory_operand" "=m,m"))
342 (match_operand:QI 1 "nonmemory_operand" "r,K"))]
350 [(set (match_operand:QI 0 "general_operand" "=r,r,r,r,r,r,m,m")
351 (match_operand:QI 1 "general_operand" "O,I,J,i,r,m,r,K"))]
365 ; memory indirect to reg
367 [(set (match_operand:HI 0 "register_operand" "=r")
368 (mem:HI (match_operand 1 "memory_operand" "m")))]
372 ; reg to memory indirect
374 [(set (mem:HI (match_operand 0 "memory_operand" "=m"))
375 (match_operand:HI 1 "register_operand" "r"))]
381 [(set (match_operand:HI 0 "general_operand" "=r,r,r,r,r,m,m")
382 (match_operand:HI 1 "general_operand" "O,I,J,r,m,r,K"))]
385 xorr r%0,r%0\;xorr r%d0,r%d0
386 xorr r%0,r%0\;lisp r%d0,%1
387 lisn r%0,1 \;lisn r%d0,%J1
391 stc 0,%0 \;stc %1,%A0 ")
393 (define_expand "movhi"
394 [(set (match_operand:HI 0 "general_operand" "=g")
395 (match_operand:HI 1 "general_operand" "g"))]
399 rtx op1 = operands[1];
400 if (GET_CODE (operands[0]) == MEM)
402 if (GET_CODE (op1) == MEM
403 || (GET_CODE (op1) == CONST_INT
404 && (INTVAL (op1) < 0 || INTVAL (op1) > 15)))
405 operands[1] = force_reg (HImode, operands[1]);
407 else if (GET_CODE (op1) == CONST_INT
408 && (INTVAL (op1) < -16 || INTVAL (op1) > 16))
409 operands[1] = force_const_mem (HImode, operands[1]);
413 ;; Single-Float moves
416 [(set (match_operand:HF 0 "general_operand" "=r,r,m,m")
417 (match_operand:HF 1 "general_operand" "r,m,r,G"))]
423 stc 0,%0 \;stc 0,%A0 ")
425 (define_expand "movhf"
426 [(set (match_operand:HF 0 "general_operand" "")
427 (match_operand:HF 1 "general_operand" ""))]
431 enum rtx_code op1code = GET_CODE (operands[1]);
432 if (GET_CODE (operands[0]) == MEM)
434 if (op1code == MEM || (op1code == CONST_DOUBLE
435 && !rtx_equal_p (operands[1], CONST0_RTX (HFmode))))
436 operands[1] = force_reg (HFmode, operands[1]);
438 else if (op1code == CONST_DOUBLE)
439 operands[1] = force_const_mem (HFmode, operands[1]);
446 [(set (match_operand:TQF 0 "general_operand" "=r,r,m")
447 (match_operand:TQF 1 "general_operand" "r,m,r"))]
454 (define_expand "movtqf"
455 [(set (match_operand:TQF 0 "general_operand" "")
456 (match_operand:TQF 1 "general_operand" ""))]
460 enum rtx_code op1code = GET_CODE (operands[1]);
461 if (GET_CODE (operands[0]) == MEM)
463 if (op1code == MEM || op1code == CONST_DOUBLE)
464 operands[1] = force_reg (TQFmode, operands[1]);
466 else if (op1code == CONST_DOUBLE)
467 operands[1] = force_const_mem (TQFmode, operands[1]);
475 (define_insn "addqi3"
476 [(set (match_operand:QI 0 "general_operand" "=r,r,r,r,r,m,m")
477 (plus:QI (match_operand:QI 1 "general_operand" "%0,0,0,0,0,0,0")
478 (match_operand:QI 2 "general_operand" "I,J,i,r,m,I,J")))]
481 switch (which_alternative)
484 return \"aisp r%0,%2\";
486 return \"sisp r%0,%J2\";
488 if (INTVAL(operands[2]) < 0)
489 return \"sim r%0,%J2\";
491 return \"aim r%0,%2\";
493 return \"ar r%0,r%2\";
497 return \"incm %2,%0\";
499 return \"decm %J2,%0\";
503 (define_insn "addhi3"
504 [(set (match_operand:HI 0 "register_operand" "=r,r")
505 (plus:HI (match_operand:HI 1 "register_operand" "%0,0")
506 (match_operand:HI 2 "general_operand" "r,m")))]
512 (define_insn "addhf3"
513 [(set (match_operand:HF 0 "register_operand" "=r,r")
514 (plus:HF (match_operand:HF 1 "register_operand" "%0,0")
515 (match_operand:HF 2 "general_operand" "r,m")))]
521 (define_insn "addtqf3"
522 [(set (match_operand:TQF 0 "register_operand" "=r,r")
523 (plus:TQF (match_operand:TQF 1 "register_operand" "%0,0")
524 (match_operand:TQF 2 "general_operand" "r,m")))]
531 ;; subtract instructions
534 (define_insn "subqi3"
535 [(set (match_operand:QI 0 "general_operand" "=r,r,r,r,m")
536 (minus:QI (match_operand:QI 1 "general_operand" "0,0,0,0,0")
537 (match_operand:QI 2 "general_operand" "I,i,r,m,I")))]
547 (define_insn "subhi3"
548 [(set (match_operand:HI 0 "register_operand" "=r,r")
549 (minus:HI (match_operand:HI 1 "register_operand" "0,0")
550 (match_operand:HI 2 "general_operand" "r,m")))]
556 (define_insn "subhf3"
557 [(set (match_operand:HF 0 "register_operand" "=r,r")
558 (minus:HF (match_operand:HF 1 "register_operand" "0,0")
559 (match_operand:HF 2 "general_operand" "r,m")))]
565 (define_insn "subtqf3"
566 [(set (match_operand:TQF 0 "register_operand" "=r,r")
567 (minus:TQF (match_operand:TQF 1 "register_operand" "0,0")
568 (match_operand:TQF 2 "general_operand" "r,m")))]
575 ;; multiply instructions
577 (define_insn "mulqi3"
578 [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r")
579 (mult:QI (match_operand:QI 1 "register_operand" "%0,0,0,0,0")
580 (match_operand:QI 2 "general_operand" "I,J,M,r,m")))]
591 (define_insn "mulqihi3"
592 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
593 (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "%r,r,r"))
594 (sign_extend:HI (match_operand:QI 2 "general_operand" "r,m,i"))))]
597 if (REGNO (operands[1]) != REGNO (operands[0]))
598 output_asm_insn (\"lr r%0,r%1\", operands);
600 switch (which_alternative)
603 return \"mr r%0,r%2\";
607 return \"mim r%0,%2\";
612 (define_insn "mulhi3"
613 [(set (match_operand:HI 0 "register_operand" "=r,r")
614 (mult:HI (match_operand:HI 1 "register_operand" "%0,0")
615 (match_operand:HI 2 "general_operand" "r,m")))]
621 ; not available on 1750: "umulhi3","umulhisi3","umulsi3" (unsigned multiply's)
623 (define_insn "mulhf3"
624 [(set (match_operand:HF 0 "register_operand" "=r,r")
625 (mult:HF (match_operand:HF 1 "register_operand" "%0,0")
626 (match_operand:HF 2 "general_operand" "r,m")))]
632 (define_insn "multqf3"
633 [(set (match_operand:TQF 0 "register_operand" "=r,r")
634 (mult:TQF (match_operand:TQF 1 "register_operand" "%0,0")
635 (match_operand:TQF 2 "general_operand" "r,m")))]
642 ;; divide instructions
643 ;; The 1750 16bit integer division instructions deliver a 16-bit
644 ;; quotient and a 16-bit remainder, where the remainder is in the next higher
645 ;; register number above the quotient. For now, we haven't found a way
646 ;; to give the reload pass knowledge of this property. So we make do with
647 ;; whatever registers the allocator wants, and willy-nilly output a pair of
648 ;; register-copy ops when needed. (See mod_regno_adjust() in file aux-output.c)
649 ;; A comment in the description of `divmodM4' suggests that one leave the divM3
650 ;; undefined when there is a divmodM4 available.
652 (define_insn "divmodqi4"
653 [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r")
654 (div:QI (match_operand:QI 1 "register_operand" "0,0,0,0,0")
655 (match_operand:QI 2 "general_operand" "I,J,M,r,m")))
656 (set (match_operand:QI 3 "register_operand" "=r,r,r,r,r")
657 (mod:QI (match_dup 1) (match_dup 2)))]
662 switch(which_alternative)
670 new_opnds[0] = operands[0];
671 new_opnds[1] = operands[1];
672 new_opnds[2] = GEN_INT (-INTVAL(operands[2]));
673 new_opnds[3] = operands[3];
675 return mod_regno_adjust (istr, new_opnds);
688 return mod_regno_adjust (istr, operands);
691 ;; Division for other types is straightforward.
693 (define_insn "divhi3"
694 [(set (match_operand:HI 0 "register_operand" "=r,r")
695 (div:HI (match_operand:HI 1 "register_operand" "0,0")
696 (match_operand:HI 2 "general_operand" "r,m")))]
702 (define_insn "divhf3"
703 [(set (match_operand:HF 0 "register_operand" "=r,r")
704 (div:HF (match_operand:HF 1 "register_operand" "0,0")
705 (match_operand:HF 2 "general_operand" "r,m")))]
711 (define_insn "divtqf3"
712 [(set (match_operand:TQF 0 "register_operand" "=r,r")
713 (div:TQF (match_operand:TQF 1 "register_operand" "0,0")
714 (match_operand:TQF 2 "general_operand" "r,m")))]
721 ;; Other arithmetic instructions:
725 (define_insn "absqi2"
726 [(set (match_operand:QI 0 "register_operand" "=r")
727 (abs:QI (match_operand:QI 1 "register_operand" "r")))]
731 (define_insn "abshi2"
732 [(set (match_operand:HI 0 "register_operand" "=r")
733 (abs:HI (match_operand:HI 1 "register_operand" "r")))]
737 (define_insn "abshf2"
738 [(set (match_operand:HF 0 "register_operand" "=r")
739 (abs:HF (match_operand:HF 1 "register_operand" "r")))]
746 (define_insn "negqi2"
747 [(set (match_operand:QI 0 "register_operand" "=r")
748 (neg:QI (match_operand:QI 1 "register_operand" "r")))]
752 (define_insn "neghi2"
753 [(set (match_operand:HI 0 "register_operand" "=r")
754 (neg:HI (match_operand:HI 1 "register_operand" "r")))]
758 (define_insn "neghf2"
759 [(set (match_operand:HF 0 "register_operand" "=r")
760 (neg:HF (match_operand:HF 1 "register_operand" "r")))]
764 ; The 1750A does not have an extended float negate instruction, so simulate.
765 (define_expand "negtqf2"
766 [(set (match_operand:TQF 0 "register_operand" "=&r")
767 (neg:TQF (match_operand:TQF 1 "register_operand" "r")))]
770 emit_insn(gen_rtx(SET,VOIDmode,operands[0],CONST0_RTX(TQFmode)));
771 emit_insn(gen_rtx(SET,VOIDmode,operands[0],
772 gen_rtx(MINUS,TQFmode,operands[0],operands[1])));
777 ;; bit-logical instructions
781 [(set (match_operand:QI 0 "general_operand" "=r,m")
782 (ior:QI (match_operand:QI 1 "general_operand" "0,0")
783 (match_operand:QI 2 "const_int_operand" "i,i")))]
784 "one_bit_set_p (INTVAL (operands [2]))"
791 [(set (match_operand:QI 0 "general_operand" "=r,m")
792 (and:QI (match_operand:QI 1 "general_operand" "0,0")
793 (match_operand:QI 2 "const_int_operand" "i,i")))]
794 "one_bit_set_p ((~INTVAL (operands [2])) & 0xffff)"
801 [(set (match_operand:QI 0 "register_operand" "=r")
802 (ior:QI (match_operand:QI 1 "register_operand" "0")
803 (lshiftrt:QI (const_int 0x8000)
804 (match_operand:QI 2 "register_operand" "r"))))]
808 ;; Reset Variable Bit
810 [(set (match_operand:QI 0 "general_operand" "=r")
811 (and:QI (match_operand:QI 1 "general_operand" "0")
812 (not:QI (lshiftrt:QI (const_int 0x8000)
813 (match_operand:QI 2 "register_operand" "r")))))]
820 (define_insn "andqi3"
821 [(set (match_operand:QI 0 "general_operand" "=r,r,r")
822 (and:QI (match_operand:QI 1 "general_operand" "%0,0,0")
823 (match_operand:QI 2 "general_operand" "M,r,m")))]
830 ; This sets incorrect condition codes. See notice_update_cc()
831 (define_insn "andhi3"
832 [(set (match_operand:HI 0 "register_operand" "=r")
833 (and:HI (match_operand:HI 1 "register_operand" "%0")
834 (match_operand:HI 2 "register_operand" "r")))]
840 (define_insn "iorqi3"
841 [(set (match_operand:QI 0 "general_operand" "=r,r,r")
842 (ior:QI (match_operand:QI 1 "general_operand" "%0,0,0")
843 (match_operand:QI 2 "general_operand" "M,r,m")))]
850 ; This sets incorrect condition codes. See notice_update_cc()
851 (define_insn "iorhi3"
852 [(set (match_operand:HI 0 "register_operand" "=r")
853 (ior:HI (match_operand:HI 1 "register_operand" "%0")
854 (match_operand:HI 2 "register_operand" "r")))]
860 (define_insn "xorqi3"
861 [(set (match_operand:QI 0 "register_operand" "=r,r,r")
862 (xor:QI (match_operand:QI 1 "register_operand" "%0,0,0")
863 (match_operand:QI 2 "general_operand" "M,r,m")))]
870 ; This sets incorrect condition codes. See notice_update_cc()
871 (define_insn "xorhi3"
872 [(set (match_operand:HI 0 "register_operand" "=r")
873 (xor:HI (match_operand:HI 1 "register_operand" "%0")
874 (match_operand:HI 2 "register_operand" "r")))]
881 [(set (match_operand:QI 0 "register_operand" "=r,r,r")
882 (ior:QI (not:QI (match_operand:QI 1 "register_operand" "%0,0,0"))
883 (not:QI (match_operand:QI 2 "general_operand" "M,r,m"))))]
890 ; This sets incorrect condition codes. See notice_update_cc()
892 [(set (match_operand:HI 0 "register_operand" "=r")
893 (ior:HI (not:HI (match_operand:HI 1 "register_operand" "%0"))
894 (not:HI (match_operand:HI 2 "register_operand" "r"))))]
900 (define_insn "one_cmplqi2"
901 [(set (match_operand:QI 0 "register_operand" "=r")
902 (not:QI (match_operand:QI 1 "register_operand" "0")))]
906 ; This sets incorrect condition codes. See notice_update_cc()
907 (define_insn "one_cmplhi2"
908 [(set (match_operand:HI 0 "register_operand" "=r")
909 (not:HI (match_operand:HI 1 "register_operand" "0")))]
914 ;; Shift instructions
916 ; (What to the 1750 is logical-shift-left, GCC likes to call "arithmetic")
917 (define_insn "ashlqi3"
918 [(set (match_operand:QI 0 "register_operand" "=r,r")
919 (ashift:QI (match_operand:QI 1 "register_operand" "0,0")
920 (match_operand:QI 2 "nonmemory_operand" "I,r")))]
926 (define_insn "ashlhi3"
927 [(set (match_operand:HI 0 "register_operand" "=r,r")
928 (ashift:HI (match_operand:HI 1 "register_operand" "0,0")
929 (match_operand:QI 2 "nonmemory_operand" "L,r")))]
930 "" ; the 'L' constraint is a slight imprecise...
932 if (which_alternative == 1)
933 return \"dslr r%0,r%2\";
934 else if (INTVAL(operands[2]) <= 16)
935 return \"dsll r%0,%2\";
938 output_asm_insn (\"dsll r%0,16 ; ashlhi3 shiftcnt > 16\", operands);
939 return \"sll r%0,%w2\";
944 ;; Right shift by a variable shiftcount works by negating the shift count,
945 ;; then emitting a right shift with the shift count negated. This means
946 ;; that all actual shift counts in the RTL will be positive. This
947 ;; prevents converting shifts to ZERO_EXTRACTs with negative positions,
948 ;; which isn't valid.
949 (define_expand "lshrqi3"
950 [(set (match_operand:QI 0 "register_operand" "=r")
951 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
952 (match_operand:QI 2 "nonmemory_operand" "g")))]
956 if (GET_CODE (operands[2]) != CONST_INT)
957 operands[2] = gen_rtx (NEG, QImode, negate_rtx (QImode, operands[2]));
961 [(set (match_operand:QI 0 "register_operand" "=r")
962 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
963 (match_operand:QI 2 "immediate_operand" "I")))]
968 [(set (match_operand:QI 0 "register_operand" "=r")
969 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
970 (neg:QI (match_operand:QI 2 "register_operand" "r"))))]
974 ;; Same thing for HImode.
976 (define_expand "lshrhi3"
977 [(set (match_operand:HI 0 "register_operand" "=r")
978 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
979 (match_operand:QI 2 "nonmemory_operand" "g")))]
983 if (GET_CODE (operands[2]) != CONST_INT)
984 operands[2] = gen_rtx (NEG, QImode, negate_rtx (QImode, operands[2]));
988 [(set (match_operand:HI 0 "register_operand" "=r")
989 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
990 (match_operand:QI 2 "immediate_operand" "L")))]
993 if (INTVAL (operands[2]) <= 16)
994 return \"dsrl r%0,%2\";
995 output_asm_insn (\"dsrl r%0,16 ; lshrhi3 shiftcount > 16\", operands);
996 return \"srl r%d0,%w2\";
1000 [(set (match_operand:HI 0 "register_operand" "=r")
1001 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
1002 (neg:QI (match_operand:QI 2 "register_operand" "r"))))]
1006 ;; Same applies for arithmetic shift right.
1007 (define_expand "ashrqi3"
1008 [(set (match_operand:QI 0 "register_operand" "=r")
1009 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
1010 (match_operand:QI 2 "nonmemory_operand" "g")))]
1014 if (GET_CODE (operands[2]) != CONST_INT)
1015 operands[2] = gen_rtx (NEG, QImode, negate_rtx (QImode, operands[2]));
1019 [(set (match_operand:QI 0 "register_operand" "=r")
1020 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
1021 (match_operand:QI 2 "immediate_operand" "I")))]
1026 [(set (match_operand:QI 0 "register_operand" "=r")
1027 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
1028 (neg:QI (match_operand:QI 2 "register_operand" "r"))))]
1032 ;; HImode arithmetic shift right.
1033 (define_expand "ashrhi3"
1034 [(set (match_operand:HI 0 "register_operand" "=r")
1035 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
1036 (match_operand:QI 2 "nonmemory_operand" "g")))]
1040 if (GET_CODE (operands[2]) != CONST_INT)
1041 operands[2] = gen_rtx (NEG, QImode, negate_rtx (QImode, operands[2]));
1045 [(set (match_operand:HI 0 "register_operand" "=r")
1046 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
1047 (match_operand:QI 2 "immediate_operand" "L")))]
1050 if (INTVAL (operands[2]) <= 16)
1051 return \"dsra r%0,%2\";
1052 output_asm_insn (\"dsra r%0,16 ; ashrhi3 shiftcount > 16\", operands);
1053 return \"sra r%d0,%w2\";
1057 [(set (match_operand:HI 0 "register_operand" "=r")
1058 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
1059 (neg:QI (match_operand:QI 2 "register_operand" "r"))))]
1064 ;; rotate instructions
1066 (define_insn "rotlqi3"
1067 [(set (match_operand:QI 0 "register_operand" "=r,r")
1068 (rotate:QI (match_operand:QI 1 "register_operand" "0,0")
1069 (match_operand:QI 2 "nonmemory_operand" "I,r")))]
1075 (define_insn "rotlhi3"
1076 [(set (match_operand:HI 0 "register_operand" "=r,r")
1077 (rotate:HI (match_operand:HI 1 "register_operand" "0,0")
1078 (match_operand:QI 2 "nonmemory_operand" "I,r")))]
1084 (define_insn "rotrqi3"
1085 [(set (match_operand:QI 0 "register_operand" "=r")
1086 (rotatert:QI (match_operand:QI 1 "register_operand" "0")
1087 (match_operand:QI 2 "register_operand" "r")))]
1089 "neg r%2,r%2\;scr r%0,r%2 ")
1091 (define_insn "rotrhi3"
1092 [(set (match_operand:HI 0 "register_operand" "=r")
1093 (rotatert:HI (match_operand:HI 1 "register_operand" "0")
1094 (match_operand:QI 2 "nonmemory_operand" "r")))]
1096 "neg r%2,r%2\;dscr r%0,r%2 ")
1100 ;; Special cases of bit-field insns which we should
1101 ;; recognize in preference to the general case.
1102 ;; These handle aligned 8-bit and 16-bit fields,
1103 ;; which can usually be done with move instructions.
1105 ;********************
1107 ;; Bit field instructions, general cases.
1108 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
1109 ;; so that its address is reloaded.
1111 ;; (define_insn "extv" ...
1113 ;; (define_insn "extzv" ...
1115 ;; (define_insn "insv" ...
1117 ;; Now recognize bit field insns that operate on registers
1118 ;; (or at least were intended to do so).
1121 ;; Special patterns for optimizing bit-field instructions.
1122 ;**************************************
1124 ; cc status test ops n.a. on 1750 ......... e.g. "sleu" on 68k:
1125 ; [(set (match_operand:QI 0 "general_operand" "=d")
1126 ; (leu (cc0) (const_int 0)))]
1128 ; "* cc_status = cc_prev_status;
1129 ; return \"sls %0\"; ")
1132 ;; Basic conditional jump instructions.
1136 (if_then_else (eq (cc0)
1138 (label_ref (match_operand 0 "" ""))
1141 "* return branch_or_jump (\"ez\", CODE_LABEL_NUMBER (operands[0]));
1146 (if_then_else (ne (cc0)
1148 (label_ref (match_operand 0 "" ""))
1151 "* return branch_or_jump (\"nz\", CODE_LABEL_NUMBER (operands[0]));
1156 (if_then_else (gt (cc0)
1158 (label_ref (match_operand 0 "" ""))
1161 "* return branch_or_jump (\"gt\", CODE_LABEL_NUMBER (operands[0]));
1166 (if_then_else (lt (cc0)
1168 (label_ref (match_operand 0 "" ""))
1171 "* return branch_or_jump (\"lt\", CODE_LABEL_NUMBER (operands[0]));
1176 (if_then_else (ge (cc0)
1178 (label_ref (match_operand 0 "" ""))
1181 "* return branch_or_jump (\"ge\", CODE_LABEL_NUMBER (operands[0]));
1186 (if_then_else (le (cc0)
1188 (label_ref (match_operand 0 "" ""))
1191 "* return branch_or_jump (\"le\", CODE_LABEL_NUMBER (operands[0]));
1195 ; no unsigned branches available on 1750. But GCC still needs them, so faking:
1199 (if_then_else (gtu (cc0)
1201 (label_ref (match_operand 0 "" ""))
1204 "jc gt,%l0 ; Warning: this should be an *unsigned* test!")
1208 (if_then_else (ltu (cc0)
1210 (label_ref (match_operand 0 "" ""))
1213 "jc lt,%l0 ; Warning: this should be an *unsigned* test!")
1217 (if_then_else (geu (cc0)
1219 (label_ref (match_operand 0 "" ""))
1222 "jc ge,%l0 ; Warning: this should be an *unsigned* test!")
1226 (if_then_else (leu (cc0)
1228 (label_ref (match_operand 0 "" ""))
1231 "jc le,%l0 ; Warning: this should be an *unsigned* test!")
1234 ;; Negated conditional jump instructions.
1238 (if_then_else (eq (cc0)
1241 (label_ref (match_operand 0 "" ""))))]
1243 "* return branch_or_jump (\"nz\", CODE_LABEL_NUMBER (operands[0]));
1248 (if_then_else (ne (cc0)
1251 (label_ref (match_operand 0 "" ""))))]
1253 "* return branch_or_jump (\"ez\", CODE_LABEL_NUMBER (operands[0]));
1258 (if_then_else (gt (cc0)
1261 (label_ref (match_operand 0 "" ""))))]
1263 "* return branch_or_jump (\"le\", CODE_LABEL_NUMBER (operands[0]));
1268 (if_then_else (lt (cc0)
1271 (label_ref (match_operand 0 "" ""))))]
1273 "* return branch_or_jump (\"ge\", CODE_LABEL_NUMBER (operands[0]));
1278 (if_then_else (ge (cc0)
1281 (label_ref (match_operand 0 "" ""))))]
1283 "* return branch_or_jump (\"lt\", CODE_LABEL_NUMBER (operands[0]));
1288 (if_then_else (le (cc0)
1291 (label_ref (match_operand 0 "" ""))))]
1293 "* return branch_or_jump (\"gt\", CODE_LABEL_NUMBER (operands[0]));
1297 ;; Negated unsigned conditional jump instructions (faked for 1750).
1301 (if_then_else (gtu (cc0)
1304 (label_ref (match_operand 0 "" ""))))]
1306 "jc le,%l0 ;inv.cond. ;Warning: this should be an *unsigned* test!")
1310 (if_then_else (ltu (cc0)
1313 (label_ref (match_operand 0 "" ""))))]
1315 "jc ge,%l0 ;inv.cond. ;Warning: this should be an *unsigned* test!")
1319 (if_then_else (geu (cc0)
1322 (label_ref (match_operand 0 "" ""))))]
1324 "jc lt,%l0 ;inv.cond. ;Warning: this should be an *unsigned* test!")
1328 (if_then_else (leu (cc0)
1331 (label_ref (match_operand 0 "" ""))))]
1333 "jc gt,%l0 ;inv.cond. ;Warning: this should be an *unsigned* test!")
1336 ;; 1750 note: CASE_VECTOR_PC_RELATIVE is not defined
1337 (define_insn "tablejump"
1339 (match_operand:QI 0 "register_operand" "b"))
1340 (use (label_ref (match_operand 1 "" "")))]
1342 "jc 15,0,r%0 ; tablejump label_ref=%1")
1345 ;; Unconditional jump
1348 (label_ref (match_operand 0 "" "")))]
1352 ;; Call subroutine, returning value in operand 0
1353 ;; (which must be a hard register).
1354 (define_insn "call_value"
1355 [(set (match_operand 0 "register_operand" "r")
1356 (call (match_operand:QI 1 "memory_operand" "m")
1357 (match_operand:QI 2 "general_operand" "g")))]
1358 ;; Operand 2 not really used for 1750.
1360 "sjs r15,%1 ; return value in R0")
1362 ;; Call subroutine with no return value.
1364 ;; Operand 1 not really used in MIL-STD-1750.
1366 [(call (match_operand:QI 0 "memory_operand" "mp")
1367 (match_operand:QI 1 "general_operand" ""))]
1369 "sjs r15,%0 ; no return value")
1371 ;;;;;;;;;;;; 1750: NOT READY YET.
1373 [(call (match_operand:QI 0 "" "")
1374 (match_operand:QI 1 "" ""))]
1379 ; (define_insn "return"
1384 ; rtx oprnd = GEN_INT (get_frame_size());
1385 ; output_asm_insn(\"ret.m %0\",&oprnd);
1389 (define_insn "indirect_jump"
1390 [(set (pc) (match_operand:QI 0 "address_operand" "p"))]
1400 ;; Subtract One and Jump (if non-zero)
1402 [(set (match_operand:QI 0 "register_operand" "=r")
1403 (plus:QI (match_operand:QI 1 "register_operand" "%0")
1404 (match_operand:QI 2 "immediate_operand" "J")))
1405 (set (cc0) (match_dup 0))
1407 (if_then_else (ne (cc0) (const_int 0))
1408 (label_ref (match_operand 3 "" ""))
1411 "INTVAL(operands[2]) == -1"
1414 ;; Combine a Load Register with subsequent increment/decrement into a LIM
1416 [(set (match_operand:QI 0 "register_operand" "=r")
1417 (match_operand:QI 1 "register_operand" "b"))
1419 (plus:QI (match_dup 0)
1420 (match_operand:QI 2 "immediate_operand" "i")))]
1421 "REGNO(operands[1]) > 0"
1422 "lim r%0,%2,r%1 ; LR,inc/dec peephole")
1424 ;; Eliminate the redundant load in a store/load sequence
1426 [(set (mem:QI (plus:QI (match_operand:QI 0 "register_operand" "r")
1427 (match_operand:QI 1 "immediate_operand" "i")))
1428 (match_operand:QI 2 "register_operand" "r"))
1429 (set (match_operand:QI 3 "register_operand" "=r")
1430 (mem:QI (plus:QI (match_dup 0)
1433 "REGNO(operands[2]) == REGNO(operands[3])"
1434 "st r%2,%1,r%0 ; eliminated previous redundant load")