* config/m32c/bitops.md, config/m32c/jump.md,
[official-gcc.git] / gcc / config / m32c / jump.md
blob4a358eac40fc91794359bb49573541f3af1c0909
1 ;; Machine Descriptions for R8C/M16C/M32C
2 ;; Copyright (C) 2005
3 ;; Free Software Foundation, Inc.
4 ;; Contributed by Red Hat.
5 ;;
6 ;; This file is part of GCC.
7 ;;
8 ;; GCC is free software; you can redistribute it and/or modify it
9 ;; under the terms of the GNU General Public License as published
10 ;; by the Free Software Foundation; either version 2, or (at your
11 ;; option) any later version.
13 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
14 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16 ;; License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING.  If not, write to the Free
20 ;; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
21 ;; 02110-1301, USA.
23 ;; jump, conditionals, calls, etc
25 (define_insn "indirect_jump_16"
26   [(set (pc)
27        (match_operand:HI 0 "register_operand" "Rhi"))]
28   "TARGET_A16"
29 ;  "jmpi.a\t%0"
30   ; no 16-bit jmpi in r8c
31   "push.b #0 | push.w\t%0 | rts"
32   [(set_attr "flags" "x")]
33   )
35 (define_insn "indirect_jump_24"
36   [(set (pc)
37        (match_operand:PSI 0 "register_operand" "Rpi"))]
38   "TARGET_A24"
39   "jmpi.a\t%0"
40   [(set_attr "flags" "n")]
41   )
43 (define_expand "indirect_jump"
44   [(match_operand 0 "register_operand" "")]
45   ""
46   "if (TARGET_A16)
47      emit_jump_insn (gen_indirect_jump_16(operands[0]));
48    else
49      emit_jump_insn (gen_indirect_jump_24(operands[0]));
50    DONE;"
51   )
53 ; We can replace this with jmp.s when gas supports relaxing.  m32c
54 ; opcodes are too complicated to try to compute their sizes here, it's
55 ; far easier (and more reliable) to let gas worry about it.
56 (define_insn "jump"
57   [(set (pc)
58         (label_ref (match_operand 0 "" "")))]
59   ""
60   "jmp.a\t%l0"
61   [(set_attr "flags" "n")]
64 ; No 16-bit indirect calls on r8c/m16c.  */
65 (define_insn "call"
66   [(call (match_operand:QI 0 "memory_operand" "Si,SaSb,?Rmm")
67          (match_operand 1 "" ""))
68    (use (match_operand 2 "immediate_operand" ""))]
69   ""
70   "*
71 switch (which_alternative) {
72   case 0: return \"jsr.a\t%0\";
73   case 1: return TARGET_A16 ? \"push.w %a0 | jsr.a\tm32c_jsri16\" : \"jsri.a\t%a0\";
74   case 2: return \"jsri.a\t%a0\";
76   [(set_attr "flags" "x")]
77   )
79 (define_insn "call_value"
80   [(set (match_operand 0 "m32c_return_operand" "=RdiRmmRpa,RdiRmmRpa,RdiRmmRpa")
81         (call (match_operand:QI 1 "memory_operand" "Si,SaSb,?Rmm")
82               (match_operand 2 "" "")))
83    (use (match_operand 3 "immediate_operand" ""))]
84   ""
85   "*
86 switch (which_alternative) {
87   case 0: return \"jsr.a\t%1\";
88   case 1: return TARGET_A16 ? \"push.w %a1 | jsr.a\tm32c_jsri16\" : \"jsri.a\t%a1\";
89   case 2: return \"jsri.a\t%a1\";
91   [(set_attr "flags" "x,x,x")]
92   )