1 |
38 |
julius |
;; Machine Descriptions for R8C/M16C/M32C
|
2 |
|
|
;; Copyright (C) 2005, 2007
|
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 3, or (at your
|
11 |
|
|
;; option) any later version.
|
12 |
|
|
;;
|
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.
|
17 |
|
|
;;
|
18 |
|
|
;; You should have received a copy of the GNU General Public License
|
19 |
|
|
;; along with GCC; see the file COPYING3. If not see
|
20 |
|
|
;; .
|
21 |
|
|
|
22 |
|
|
;; Predicates
|
23 |
|
|
|
24 |
|
|
; TRUE for any valid operand. We do this because general_operand
|
25 |
|
|
; refuses to match volatile memory refs.
|
26 |
|
|
|
27 |
|
|
(define_predicate "m32c_any_operand"
|
28 |
|
|
(ior (match_operand 0 "general_operand")
|
29 |
|
|
(match_operand 1 "memory_operand")))
|
30 |
|
|
|
31 |
|
|
; Likewise for nonimmediate_operand.
|
32 |
|
|
|
33 |
|
|
(define_predicate "m32c_nonimmediate_operand"
|
34 |
|
|
(ior (match_operand 0 "nonimmediate_operand")
|
35 |
|
|
(match_operand 1 "memory_operand")))
|
36 |
|
|
|
37 |
|
|
; TRUE if the operand is a pseudo-register.
|
38 |
|
|
(define_predicate "m32c_pseudo"
|
39 |
|
|
(ior (and (match_code "reg")
|
40 |
|
|
(match_test "REGNO(op) >= FIRST_PSEUDO_REGISTER"))
|
41 |
|
|
(and (match_code "subreg")
|
42 |
|
|
(and (match_test "GET_CODE (XEXP (op, 0)) == REG")
|
43 |
|
|
(match_test "REGNO(XEXP (op,0)) >= FIRST_PSEUDO_REGISTER")))))
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
; Returning true causes many predicates to NOT match. We allow
|
47 |
|
|
; subregs for type changing, but not for size changing.
|
48 |
|
|
(define_predicate "m32c_wide_subreg"
|
49 |
|
|
(and (match_code "subreg")
|
50 |
|
|
(not (match_operand 0 "m32c_pseudo")))
|
51 |
|
|
{
|
52 |
|
|
unsigned int sizeo = GET_MODE_SIZE (GET_MODE (op));
|
53 |
|
|
unsigned int sizei = GET_MODE_SIZE (GET_MODE (XEXP (op, 0)));
|
54 |
|
|
sizeo = (sizeo + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
|
55 |
|
|
sizei = (sizei + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
|
56 |
|
|
return sizeo != sizei;
|
57 |
|
|
})
|
58 |
|
|
|
59 |
|
|
; TRUE for r0 through r3, or a pseudo that reload could put in r0
|
60 |
|
|
; through r3 (likewise for the next couple too)
|
61 |
|
|
(define_predicate "r0123_operand"
|
62 |
|
|
(ior (match_operand 0 "m32c_pseudo" "")
|
63 |
|
|
(and (match_code "reg")
|
64 |
|
|
(match_test "REGNO(op) <= R3_REGNO"))))
|
65 |
|
|
|
66 |
|
|
; TRUE for r0
|
67 |
|
|
(define_predicate "m32c_r0_operand"
|
68 |
|
|
(ior (match_operand 0 "m32c_pseudo" "")
|
69 |
|
|
(and (match_code "reg")
|
70 |
|
|
(match_test "REGNO(op) == R0_REGNO"))))
|
71 |
|
|
|
72 |
|
|
; TRUE for r1
|
73 |
|
|
(define_predicate "m32c_r1_operand"
|
74 |
|
|
(ior (match_operand 0 "m32c_pseudo" "")
|
75 |
|
|
(and (match_code "reg")
|
76 |
|
|
(match_test "REGNO(op) == R1_REGNO"))))
|
77 |
|
|
|
78 |
|
|
; TRUE for HL_CLASS (r0 or r1)
|
79 |
|
|
(define_predicate "m32c_hl_operand"
|
80 |
|
|
(ior (match_operand 0 "m32c_pseudo" "")
|
81 |
|
|
(and (match_code "reg")
|
82 |
|
|
(match_test "REGNO(op) == R0_REGNO || REGNO(op) == R1_REGNO"))))
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
; TRUE for r2
|
86 |
|
|
(define_predicate "m32c_r2_operand"
|
87 |
|
|
(ior (match_operand 0 "m32c_pseudo" "")
|
88 |
|
|
(and (match_code "reg")
|
89 |
|
|
(match_test "REGNO(op) == R2_REGNO"))))
|
90 |
|
|
|
91 |
|
|
; TRUE for r3
|
92 |
|
|
(define_predicate "m32c_r3_operand"
|
93 |
|
|
(ior (match_operand 0 "m32c_pseudo" "")
|
94 |
|
|
(and (match_code "reg")
|
95 |
|
|
(match_test "REGNO(op) == R3_REGNO"))))
|
96 |
|
|
|
97 |
|
|
; TRUE for any general operand except r2.
|
98 |
|
|
(define_predicate "m32c_notr2_operand"
|
99 |
|
|
(and (match_operand 0 "general_operand")
|
100 |
|
|
(ior (not (match_code "reg"))
|
101 |
|
|
(match_test "REGNO(op) != R2_REGNO"))))
|
102 |
|
|
|
103 |
|
|
; TRUE for the stack pointer.
|
104 |
|
|
(define_predicate "m32c_sp_operand"
|
105 |
|
|
(ior (match_operand 0 "m32c_pseudo" "")
|
106 |
|
|
(and (match_code "reg")
|
107 |
|
|
(match_test "REGNO(op) == SP_REGNO"))))
|
108 |
|
|
|
109 |
|
|
; TRUE for control registers.
|
110 |
|
|
(define_predicate "cr_operand"
|
111 |
|
|
(match_code "reg")
|
112 |
|
|
"return (REGNO (op) >= SB_REGNO
|
113 |
|
|
&& REGNO (op) <= FLG_REGNO);")
|
114 |
|
|
|
115 |
|
|
; TRUE for $a0 or $a1.
|
116 |
|
|
(define_predicate "a_operand"
|
117 |
|
|
(and (match_code "reg")
|
118 |
|
|
(match_test "REGNO (op) == A0_REGNO || REGNO (op) == A1_REGNO")))
|
119 |
|
|
|
120 |
|
|
; TRUE for $a0 or $a1 or a pseudo
|
121 |
|
|
(define_predicate "ap_operand"
|
122 |
|
|
(ior (match_operand 0 "m32c_pseudo" "")
|
123 |
|
|
(and (match_code "reg")
|
124 |
|
|
(match_test "REGNO (op) == A0_REGNO || REGNO (op) == A1_REGNO"))))
|
125 |
|
|
|
126 |
|
|
; TRUE for r0 through r3, or a0 or a1.
|
127 |
|
|
(define_predicate "ra_operand"
|
128 |
|
|
(and (and (match_operand 0 "register_operand" "")
|
129 |
|
|
(not (match_operand 1 "cr_operand" "")))
|
130 |
|
|
(not (match_operand 2 "m32c_wide_subreg" ""))))
|
131 |
|
|
|
132 |
|
|
; Likewise, plus TRUE for memory references.
|
133 |
|
|
(define_predicate "mra_operand"
|
134 |
|
|
(and (and (match_operand 0 "nonimmediate_operand" "")
|
135 |
|
|
(not (match_operand 1 "cr_operand" "")))
|
136 |
|
|
(not (match_operand 2 "m32c_wide_subreg" ""))))
|
137 |
|
|
|
138 |
|
|
; Likewise, plus TRUE for subregs.
|
139 |
|
|
(define_predicate "mras_operand"
|
140 |
|
|
(and (match_operand 0 "nonimmediate_operand" "")
|
141 |
|
|
(not (match_operand 1 "cr_operand" ""))))
|
142 |
|
|
|
143 |
|
|
; As above, but no push/pop operations
|
144 |
|
|
(define_predicate "mra_nopp_operand"
|
145 |
|
|
(match_operand 0 "mra_operand" "")
|
146 |
|
|
{
|
147 |
|
|
if (GET_CODE (op) == MEM
|
148 |
|
|
&& (GET_CODE (XEXP (op, 0)) == PRE_DEC
|
149 |
|
|
|| (GET_CODE (XEXP (op, 0)) == POST_INC)))
|
150 |
|
|
return 0;
|
151 |
|
|
return 1;
|
152 |
|
|
})
|
153 |
|
|
|
154 |
|
|
; TRUE for memory, r0..r3, a0..a1, or immediates.
|
155 |
|
|
(define_predicate "mrai_operand"
|
156 |
|
|
(and (and (match_operand 0 "m32c_any_operand" "")
|
157 |
|
|
(not (match_operand 1 "cr_operand" "")))
|
158 |
|
|
(not (match_operand 2 "m32c_wide_subreg" ""))))
|
159 |
|
|
|
160 |
|
|
; Likewise, plus true for subregs.
|
161 |
|
|
(define_predicate "mrasi_operand"
|
162 |
|
|
(and (match_operand 0 "general_operand" "")
|
163 |
|
|
(not (match_operand 1 "cr_operand" ""))))
|
164 |
|
|
|
165 |
|
|
; TRUE for r0..r3 or memory.
|
166 |
|
|
(define_predicate "mr_operand"
|
167 |
|
|
(and (match_operand 0 "mra_operand" "")
|
168 |
|
|
(not (match_operand 1 "a_operand" ""))))
|
169 |
|
|
|
170 |
|
|
; TRUE for a0..a1 or memory.
|
171 |
|
|
(define_predicate "ma_operand"
|
172 |
|
|
(ior (match_operand 0 "a_operand" "")
|
173 |
|
|
(match_operand 1 "memory_operand" "")))
|
174 |
|
|
|
175 |
|
|
; TRUE for memory operands that are not indexed
|
176 |
|
|
(define_predicate "memsym_operand"
|
177 |
|
|
(and (match_operand 0 "memory_operand" "")
|
178 |
|
|
(match_test "m32c_extra_constraint_p (op, 'S', \"Si\")")))
|
179 |
|
|
|
180 |
|
|
; TRUE for memory operands with small integer addresses
|
181 |
|
|
(define_predicate "memimmed_operand"
|
182 |
|
|
(and (match_operand 0 "memory_operand" "")
|
183 |
|
|
(match_test "m32c_extra_constraint_p (op, 'S', \"Sp\")")))
|
184 |
|
|
|
185 |
|
|
; TRUE for r1h. This is complicated since r1h isn't a register GCC
|
186 |
|
|
; normally knows about.
|
187 |
|
|
(define_predicate "r1h_operand"
|
188 |
|
|
(match_code "zero_extract")
|
189 |
|
|
{
|
190 |
|
|
rtx reg = XEXP (op, 0);
|
191 |
|
|
rtx size = XEXP (op, 1);
|
192 |
|
|
rtx pos = XEXP (op, 2);
|
193 |
|
|
return (GET_CODE (reg) == REG
|
194 |
|
|
&& REGNO (reg) == R1_REGNO
|
195 |
|
|
&& GET_CODE (size) == CONST_INT
|
196 |
|
|
&& INTVAL (size) == 8
|
197 |
|
|
&& GET_CODE (pos) == CONST_INT
|
198 |
|
|
&& INTVAL (pos) == 8);
|
199 |
|
|
})
|
200 |
|
|
|
201 |
|
|
; TRUE if we can shift by this amount. Constant shift counts have a
|
202 |
|
|
; limited range.
|
203 |
|
|
(define_predicate "shiftcount_operand"
|
204 |
|
|
(ior (match_operand 0 "mra_operand" "")
|
205 |
|
|
(and (match_operand 2 "const_int_operand" "")
|
206 |
|
|
(match_test "-8 <= INTVAL (op) && INTVAL (op) && INTVAL (op) <= 8"))))
|
207 |
|
|
(define_predicate "longshiftcount_operand"
|
208 |
|
|
(ior (match_operand 0 "mra_operand" "")
|
209 |
|
|
(and (match_operand 2 "const_int_operand" "")
|
210 |
|
|
(match_test "-32 <= INTVAL (op) && INTVAL (op) && INTVAL (op) <= 32"))))
|
211 |
|
|
|
212 |
|
|
; TRUE for r0..r3, a0..a1, or sp.
|
213 |
|
|
(define_predicate "mra_or_sp_operand"
|
214 |
|
|
(and (ior (match_operand 0 "mra_operand")
|
215 |
|
|
(match_operand 1 "m32c_sp_operand"))
|
216 |
|
|
(not (match_operand 2 "m32c_wide_subreg" ""))))
|
217 |
|
|
|
218 |
|
|
|
219 |
|
|
; TRUE for r2 or r3.
|
220 |
|
|
(define_predicate "m32c_r2r3_operand"
|
221 |
|
|
(ior (and (match_code "reg")
|
222 |
|
|
(ior (match_test "REGNO(op) == R2_REGNO")
|
223 |
|
|
(match_test "REGNO(op) == R3_REGNO")))
|
224 |
|
|
(and (match_code "subreg")
|
225 |
|
|
(match_test "GET_CODE (XEXP (op, 0)) == REG && (REGNO (XEXP (op, 0)) == R2_REGNO || REGNO (XEXP (op, 0)) == R3_REGNO)"))))
|
226 |
|
|
|
227 |
|
|
; Likewise, plus TRUE for a0..a1.
|
228 |
|
|
(define_predicate "m32c_r2r3a_operand"
|
229 |
|
|
(ior (match_operand 0 "m32c_r2r3_operand" "")
|
230 |
|
|
(match_operand 0 "a_operand" "")))
|
231 |
|
|
|
232 |
|
|
; These two are only for movqi - no subreg limit
|
233 |
|
|
(define_predicate "mra_qi_operand"
|
234 |
|
|
(and (and (match_operand 0 "m32c_nonimmediate_operand" "")
|
235 |
|
|
(not (match_operand 1 "cr_operand" "")))
|
236 |
|
|
(not (match_operand 1 "m32c_r2r3a_operand" ""))))
|
237 |
|
|
|
238 |
|
|
(define_predicate "mrai_qi_operand"
|
239 |
|
|
(and (and (match_operand 0 "m32c_any_operand" "")
|
240 |
|
|
(not (match_operand 1 "cr_operand" "")))
|
241 |
|
|
(not (match_operand 1 "m32c_r2r3a_operand" ""))))
|
242 |
|
|
|
243 |
|
|
(define_predicate "a_qi_operand"
|
244 |
|
|
(ior (match_operand 0 "m32c_pseudo" "")
|
245 |
|
|
(match_operand 1 "a_operand" "")))
|
246 |
|
|
|
247 |
|
|
; TRUE for comparisons we support.
|
248 |
|
|
(define_predicate "m32c_cmp_operator"
|
249 |
|
|
(match_code "eq,ne,gt,gtu,lt,ltu,ge,geu,le,leu"))
|
250 |
|
|
|
251 |
|
|
(define_predicate "m32c_eqne_operator"
|
252 |
|
|
(match_code "eq,ne"))
|
253 |
|
|
|
254 |
|
|
; TRUE for mem0
|
255 |
|
|
(define_predicate "m32c_mem0_operand"
|
256 |
|
|
(ior (match_operand 0 "m32c_pseudo" "")
|
257 |
|
|
(and (match_code "reg")
|
258 |
|
|
(match_test "REGNO(op) == MEM0_REGNO"))))
|
259 |
|
|
|
260 |
|
|
; TRUE for things the call patterns can return.
|
261 |
|
|
(define_predicate "m32c_return_operand"
|
262 |
|
|
(ior (match_operand 0 "m32c_r0_operand")
|
263 |
|
|
(ior (match_operand 0 "m32c_mem0_operand")
|
264 |
|
|
(match_code "parallel"))))
|
265 |
|
|
|
266 |
|
|
; TRUE for constants we can multiply pointers by
|
267 |
|
|
(define_predicate "m32c_psi_scale"
|
268 |
|
|
(and (match_operand 0 "const_int_operand")
|
269 |
|
|
(match_test "m32c_const_ok_for_constraint_p(INTVAL(op), 'I', \"Ilb\")")))
|
270 |
|
|
|
271 |
|
|
; TRUE for one bit set (bit) or clear (mask) out of N bits.
|
272 |
|
|
|
273 |
|
|
(define_predicate "m32c_1bit8_operand"
|
274 |
|
|
(and (match_operand 0 "const_int_operand")
|
275 |
|
|
(match_test "m32c_const_ok_for_constraint_p(INTVAL(op), 'I', \"Ilb\")")))
|
276 |
|
|
|
277 |
|
|
(define_predicate "m32c_1bit16_operand"
|
278 |
|
|
(and (match_operand 0 "const_int_operand")
|
279 |
|
|
(match_test "m32c_const_ok_for_constraint_p(INTVAL(op), 'I', \"Ilw\")")))
|
280 |
|
|
|
281 |
|
|
(define_predicate "m32c_1mask8_operand"
|
282 |
|
|
(and (match_operand 0 "const_int_operand")
|
283 |
|
|
(match_test "m32c_const_ok_for_constraint_p(INTVAL(op), 'I', \"Imb\")")))
|
284 |
|
|
|
285 |
|
|
(define_predicate "m32c_1mask16_operand"
|
286 |
|
|
(and (match_operand 0 "const_int_operand")
|
287 |
|
|
(match_test "m32c_const_ok_for_constraint_p(INTVAL(op), 'I', \"Imw\")")))
|