Daily bump.
[gcc.git] / gcc / config / m32c / jump.md
1 ;; Machine Descriptions for R8C/M16C/M32C
2 ;; Copyright (C) 2005-2021 Free Software Foundation, Inc.
3 ;; Contributed by Red Hat.
4 ;;
5 ;; This file is part of GCC.
6 ;;
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published
9 ;; by the Free Software Foundation; either version 3, or (at your
10 ;; option) any later version.
11 ;;
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 ;; 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 ;; jump, conditionals, calls, etc
22
23 (define_insn "indirect_jump_16"
24 [(set (pc)
25 (match_operand:HI 0 "register_operand" "Rhi"))]
26 "TARGET_A16"
27 ; "jmpi.a\t%0"
28 ; no 16-bit jmpi in r8c
29 "push.b #0 | push.w\t%0 | rts"
30 [(set_attr "flags" "x")]
31 )
32
33 (define_insn "indirect_jump_24"
34 [(set (pc)
35 (match_operand:PSI 0 "register_operand" "Rpi"))]
36 "TARGET_A24"
37 "jmpi.a\t%0"
38 [(set_attr "flags" "n")]
39 )
40
41 (define_expand "indirect_jump"
42 [(match_operand 0 "register_operand" "")]
43 ""
44 "if (TARGET_A16)
45 emit_jump_insn (gen_indirect_jump_16(operands[0]));
46 else
47 emit_jump_insn (gen_indirect_jump_24(operands[0]));
48 DONE;"
49 )
50
51 ; We can replace this with jmp.s when gas supports relaxing. m32c
52 ; opcodes are too complicated to try to compute their sizes here, it's
53 ; far easier (and more reliable) to let gas worry about it.
54 (define_insn "jump"
55 [(set (pc)
56 (label_ref (match_operand 0 "" "")))]
57 ""
58 "jmp.a\t%l0"
59 [(set_attr "flags" "n")]
60 )
61
62 ; No 16-bit indirect calls on r8c/m16c. */
63 (define_insn "call"
64 [(call (match_operand:QI 0 "memory_operand" "Si,SaSb,?Rmm")
65 (match_operand 1 "" ""))
66 (use (match_operand 2 "immediate_operand" ""))]
67 ""
68 "*
69 switch (which_alternative) {
70 case 0:
71 {
72 HOST_WIDE_INT func_vect_num =
73 current_function_special_page_vector(XEXP (operands[0], 0));
74 if (func_vect_num)
75 {
76 operands[3] = gen_rtx_CONST_INT (VOIDmode, func_vect_num);
77 return \"jsrs\t%3\";
78 }
79 else
80 return \"jsr.a\t%0\";
81 }
82 case 1: return TARGET_A16 ? \"push.w %a0 | jsr.a\tm32c_jsri16\" : \"jsri.a\t%a0\";
83 case 2: return \"jsri.a\t%a0\";
84 default: gcc_unreachable ();
85 }"
86 [(set_attr "flags" "x")]
87 )
88
89 (define_insn "call_value"
90 [(set (match_operand 0 "m32c_return_operand" "=RdiRmmRpa,RdiRmmRpa,RdiRmmRpa")
91 (call (match_operand:QI 1 "memory_operand" "Si,SaSb,?Rmm")
92 (match_operand 2 "" "")))
93 (use (match_operand 3 "immediate_operand" ""))]
94 ""
95 "*
96 switch (which_alternative) {
97 case 0:
98 {
99 HOST_WIDE_INT func_vect_num =
100 current_function_special_page_vector(XEXP (operands[1], 0));
101 if (func_vect_num)
102 {
103 operands[4] = gen_rtx_CONST_INT (VOIDmode, func_vect_num);
104 return \"jsrs\t%4\";
105 }
106 else
107 return \"jsr.a\t%1\";
108 }
109 case 1: return TARGET_A16 ? \"push.w %a1 | jsr.a\tm32c_jsri16\" : \"jsri.a\t%a1\";
110 case 2: return \"jsri.a\t%a1\";
111 default: gcc_unreachable ();
112 }"
113 [(set_attr "flags" "x,x,x")]
114 )
115
116 (define_expand "untyped_call"
117 [(parallel [(call (match_operand 0 "" "")
118 (const_int 0))
119 (match_operand 1 "" "")
120 (match_operand 2 "" "")])]
121 ""
122 "
123 {
124 int i;
125
126 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
127
128 for (i = 0; i < XVECLEN (operands[2], 0); i++)
129 {
130 rtx set = XVECEXP (operands[2], 0, i);
131 emit_move_insn (SET_DEST (set), SET_SRC (set));
132 }
133 DONE;
134 }")