1 |
38 |
julius |
;; Predicate definitions for DEC Alpha.
|
2 |
|
|
;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
3 |
|
|
;;
|
4 |
|
|
;; This file is part of GCC.
|
5 |
|
|
;;
|
6 |
|
|
;; GCC is free software; you can redistribute it and/or modify
|
7 |
|
|
;; it under the terms of the GNU General Public License as published by
|
8 |
|
|
;; the Free Software Foundation; either version 3, or (at your option)
|
9 |
|
|
;; any later version.
|
10 |
|
|
;;
|
11 |
|
|
;; GCC is distributed in the hope that it will be useful,
|
12 |
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
|
|
;; GNU General Public License for more details.
|
15 |
|
|
;;
|
16 |
|
|
;; You should have received a copy of the GNU General Public License
|
17 |
|
|
;; along with GCC; see the file COPYING3. If not see
|
18 |
|
|
;; .
|
19 |
|
|
|
20 |
|
|
;; Return 1 if OP is the zero constant for MODE.
|
21 |
|
|
(define_predicate "const0_operand"
|
22 |
|
|
(and (match_code "const_int,const_double,const_vector")
|
23 |
|
|
(match_test "op == CONST0_RTX (mode)")))
|
24 |
|
|
|
25 |
|
|
;; Returns true if OP is either the constant zero or a register.
|
26 |
|
|
(define_predicate "reg_or_0_operand"
|
27 |
|
|
(ior (match_operand 0 "register_operand")
|
28 |
|
|
(match_operand 0 "const0_operand")))
|
29 |
|
|
|
30 |
|
|
;; Return 1 if OP is a constant in the range of 0-63 (for a shift) or
|
31 |
|
|
;; any register.
|
32 |
|
|
(define_predicate "reg_or_6bit_operand"
|
33 |
|
|
(if_then_else (match_code "const_int")
|
34 |
|
|
(match_test "INTVAL (op) >= 0 && INTVAL (op) < 64")
|
35 |
|
|
(match_operand 0 "register_operand")))
|
36 |
|
|
|
37 |
|
|
;; Return 1 if OP is an 8-bit constant.
|
38 |
|
|
(define_predicate "cint8_operand"
|
39 |
|
|
(and (match_code "const_int")
|
40 |
|
|
(match_test "INTVAL (op) >= 0 && INTVAL (op) < 256")))
|
41 |
|
|
|
42 |
|
|
;; Return 1 if OP is an 8-bit constant or any register.
|
43 |
|
|
(define_predicate "reg_or_8bit_operand"
|
44 |
|
|
(if_then_else (match_code "const_int")
|
45 |
|
|
(match_test "INTVAL (op) >= 0 && INTVAL (op) < 256")
|
46 |
|
|
(match_operand 0 "register_operand")))
|
47 |
|
|
|
48 |
|
|
;; Return 1 if OP is a constant or any register.
|
49 |
|
|
(define_predicate "reg_or_cint_operand"
|
50 |
|
|
(ior (match_operand 0 "register_operand")
|
51 |
|
|
(match_operand 0 "const_int_operand")))
|
52 |
|
|
|
53 |
|
|
;; Return 1 if the operand is a valid second operand to an add insn.
|
54 |
|
|
(define_predicate "add_operand"
|
55 |
|
|
(if_then_else (match_code "const_int")
|
56 |
|
|
(match_test "CONST_OK_FOR_LETTER_P (INTVAL (op), 'K')
|
57 |
|
|
|| CONST_OK_FOR_LETTER_P (INTVAL (op), 'L')")
|
58 |
|
|
(match_operand 0 "register_operand")))
|
59 |
|
|
|
60 |
|
|
;; Return 1 if the operand is a valid second operand to a
|
61 |
|
|
;; sign-extending add insn.
|
62 |
|
|
(define_predicate "sext_add_operand"
|
63 |
|
|
(if_then_else (match_code "const_int")
|
64 |
|
|
(match_test "CONST_OK_FOR_LETTER_P (INTVAL (op), 'I')
|
65 |
|
|
|| CONST_OK_FOR_LETTER_P (INTVAL (op), 'O')")
|
66 |
|
|
(match_operand 0 "register_operand")))
|
67 |
|
|
|
68 |
|
|
;; Return 1 if the operand is a non-symbolic constant operand that
|
69 |
|
|
;; does not satisfy add_operand.
|
70 |
|
|
(define_predicate "non_add_const_operand"
|
71 |
|
|
(and (match_code "const_int,const_double,const_vector")
|
72 |
|
|
(not (match_operand 0 "add_operand"))))
|
73 |
|
|
|
74 |
|
|
;; Return 1 if the operand is a non-symbolic, nonzero constant operand.
|
75 |
|
|
(define_predicate "non_zero_const_operand"
|
76 |
|
|
(and (match_code "const_int,const_double,const_vector")
|
77 |
|
|
(match_test "op != CONST0_RTX (mode)")))
|
78 |
|
|
|
79 |
|
|
;; Return 1 if OP is the constant 4 or 8.
|
80 |
|
|
(define_predicate "const48_operand"
|
81 |
|
|
(and (match_code "const_int")
|
82 |
|
|
(match_test "INTVAL (op) == 4 || INTVAL (op) == 8")))
|
83 |
|
|
|
84 |
|
|
;; Return 1 if OP is a valid first operand to an AND insn.
|
85 |
|
|
(define_predicate "and_operand"
|
86 |
|
|
(if_then_else (match_code "const_int")
|
87 |
|
|
(match_test "(unsigned HOST_WIDE_INT) INTVAL (op) < 0x100
|
88 |
|
|
|| (unsigned HOST_WIDE_INT) ~ INTVAL (op) < 0x100
|
89 |
|
|
|| zap_mask (INTVAL (op))")
|
90 |
|
|
(if_then_else (match_code "const_double")
|
91 |
|
|
(match_test "GET_MODE (op) == VOIDmode
|
92 |
|
|
&& zap_mask (CONST_DOUBLE_LOW (op))
|
93 |
|
|
&& zap_mask (CONST_DOUBLE_HIGH (op))")
|
94 |
|
|
(match_operand 0 "register_operand"))))
|
95 |
|
|
|
96 |
|
|
;; Return 1 if OP is a valid first operand to an IOR or XOR insn.
|
97 |
|
|
(define_predicate "or_operand"
|
98 |
|
|
(if_then_else (match_code "const_int")
|
99 |
|
|
(match_test "(unsigned HOST_WIDE_INT) INTVAL (op) < 0x100
|
100 |
|
|
|| (unsigned HOST_WIDE_INT) ~ INTVAL (op) < 0x100")
|
101 |
|
|
(match_operand 0 "register_operand")))
|
102 |
|
|
|
103 |
|
|
;; Return 1 if OP is a constant that is the width, in bits, of an integral
|
104 |
|
|
;; mode not larger than DImode.
|
105 |
|
|
(define_predicate "mode_width_operand"
|
106 |
|
|
(match_code "const_int")
|
107 |
|
|
{
|
108 |
|
|
HOST_WIDE_INT i = INTVAL (op);
|
109 |
|
|
return i == 8 || i == 16 || i == 32 || i == 64;
|
110 |
|
|
})
|
111 |
|
|
|
112 |
|
|
;; Return 1 if OP is a constant that is a mask of ones of width of an
|
113 |
|
|
;; integral machine mode not larger than DImode.
|
114 |
|
|
(define_predicate "mode_mask_operand"
|
115 |
|
|
(match_code "const_int,const_double")
|
116 |
|
|
{
|
117 |
|
|
if (GET_CODE (op) == CONST_INT)
|
118 |
|
|
{
|
119 |
|
|
HOST_WIDE_INT value = INTVAL (op);
|
120 |
|
|
|
121 |
|
|
if (value == 0xff)
|
122 |
|
|
return 1;
|
123 |
|
|
if (value == 0xffff)
|
124 |
|
|
return 1;
|
125 |
|
|
if (value == 0xffffffff)
|
126 |
|
|
return 1;
|
127 |
|
|
if (value == -1)
|
128 |
|
|
return 1;
|
129 |
|
|
}
|
130 |
|
|
else if (HOST_BITS_PER_WIDE_INT == 32 && GET_CODE (op) == CONST_DOUBLE)
|
131 |
|
|
{
|
132 |
|
|
if (CONST_DOUBLE_LOW (op) == 0xffffffff && CONST_DOUBLE_HIGH (op) == 0)
|
133 |
|
|
return 1;
|
134 |
|
|
}
|
135 |
|
|
return 0;
|
136 |
|
|
})
|
137 |
|
|
|
138 |
|
|
;; Return 1 if OP is a multiple of 8 less than 64.
|
139 |
|
|
(define_predicate "mul8_operand"
|
140 |
|
|
(match_code "const_int")
|
141 |
|
|
{
|
142 |
|
|
unsigned HOST_WIDE_INT i = INTVAL (op);
|
143 |
|
|
return i < 64 && i % 8 == 0;
|
144 |
|
|
})
|
145 |
|
|
|
146 |
|
|
;; Return 1 if OP is a hard floating-point register.
|
147 |
|
|
(define_predicate "hard_fp_register_operand"
|
148 |
|
|
(match_operand 0 "register_operand")
|
149 |
|
|
{
|
150 |
|
|
if (GET_CODE (op) == SUBREG)
|
151 |
|
|
op = SUBREG_REG (op);
|
152 |
|
|
return REGNO_REG_CLASS (REGNO (op)) == FLOAT_REGS;
|
153 |
|
|
})
|
154 |
|
|
|
155 |
|
|
;; Return 1 if OP is a hard general register.
|
156 |
|
|
(define_predicate "hard_int_register_operand"
|
157 |
|
|
(match_operand 0 "register_operand")
|
158 |
|
|
{
|
159 |
|
|
if (GET_CODE (op) == SUBREG)
|
160 |
|
|
op = SUBREG_REG (op);
|
161 |
|
|
return REGNO_REG_CLASS (REGNO (op)) == GENERAL_REGS;
|
162 |
|
|
})
|
163 |
|
|
|
164 |
|
|
;; Return 1 if OP is something that can be reloaded into a register;
|
165 |
|
|
;; if it is a MEM, it need not be valid.
|
166 |
|
|
(define_predicate "some_operand"
|
167 |
|
|
(ior (match_code "reg,mem,const_int,const_double,const_vector,
|
168 |
|
|
label_ref,symbol_ref,const,high")
|
169 |
|
|
(and (match_code "subreg")
|
170 |
|
|
(match_test "some_operand (SUBREG_REG (op), VOIDmode)"))))
|
171 |
|
|
|
172 |
|
|
;; Likewise, but don't accept constants.
|
173 |
|
|
(define_predicate "some_ni_operand"
|
174 |
|
|
(ior (match_code "reg,mem")
|
175 |
|
|
(and (match_code "subreg")
|
176 |
|
|
(match_test "some_ni_operand (SUBREG_REG (op), VOIDmode)"))))
|
177 |
|
|
|
178 |
|
|
;; Return 1 if OP is a valid operand for the source of a move insn.
|
179 |
|
|
(define_predicate "input_operand"
|
180 |
|
|
(match_code "label_ref,symbol_ref,const,high,reg,subreg,mem,
|
181 |
|
|
const_double,const_vector,const_int")
|
182 |
|
|
{
|
183 |
|
|
switch (GET_CODE (op))
|
184 |
|
|
{
|
185 |
|
|
case LABEL_REF:
|
186 |
|
|
case SYMBOL_REF:
|
187 |
|
|
case CONST:
|
188 |
|
|
if (TARGET_EXPLICIT_RELOCS)
|
189 |
|
|
{
|
190 |
|
|
/* We don't split symbolic operands into something unintelligable
|
191 |
|
|
until after reload, but we do not wish non-small, non-global
|
192 |
|
|
symbolic operands to be reconstructed from their high/lo_sum
|
193 |
|
|
form. */
|
194 |
|
|
return (small_symbolic_operand (op, mode)
|
195 |
|
|
|| global_symbolic_operand (op, mode)
|
196 |
|
|
|| gotdtp_symbolic_operand (op, mode)
|
197 |
|
|
|| gottp_symbolic_operand (op, mode));
|
198 |
|
|
}
|
199 |
|
|
|
200 |
|
|
/* This handles both the Windows/NT and OSF cases. */
|
201 |
|
|
return mode == ptr_mode || mode == DImode;
|
202 |
|
|
|
203 |
|
|
case HIGH:
|
204 |
|
|
return (TARGET_EXPLICIT_RELOCS
|
205 |
|
|
&& local_symbolic_operand (XEXP (op, 0), mode));
|
206 |
|
|
|
207 |
|
|
case REG:
|
208 |
|
|
return 1;
|
209 |
|
|
|
210 |
|
|
case SUBREG:
|
211 |
|
|
if (register_operand (op, mode))
|
212 |
|
|
return 1;
|
213 |
|
|
/* ... fall through ... */
|
214 |
|
|
case MEM:
|
215 |
|
|
return ((TARGET_BWX || (mode != HImode && mode != QImode))
|
216 |
|
|
&& general_operand (op, mode));
|
217 |
|
|
|
218 |
|
|
case CONST_DOUBLE:
|
219 |
|
|
return op == CONST0_RTX (mode);
|
220 |
|
|
|
221 |
|
|
case CONST_VECTOR:
|
222 |
|
|
if (reload_in_progress || reload_completed)
|
223 |
|
|
return alpha_legitimate_constant_p (op);
|
224 |
|
|
return op == CONST0_RTX (mode);
|
225 |
|
|
|
226 |
|
|
case CONST_INT:
|
227 |
|
|
if (mode == QImode || mode == HImode)
|
228 |
|
|
return true;
|
229 |
|
|
if (reload_in_progress || reload_completed)
|
230 |
|
|
return alpha_legitimate_constant_p (op);
|
231 |
|
|
return add_operand (op, mode);
|
232 |
|
|
|
233 |
|
|
default:
|
234 |
|
|
gcc_unreachable ();
|
235 |
|
|
}
|
236 |
|
|
return 0;
|
237 |
|
|
})
|
238 |
|
|
|
239 |
|
|
;; Return 1 if OP is a SYMBOL_REF for a function known to be in this
|
240 |
|
|
;; file, and in the same section as the current function.
|
241 |
|
|
|
242 |
|
|
(define_predicate "samegp_function_operand"
|
243 |
|
|
(match_code "symbol_ref")
|
244 |
|
|
{
|
245 |
|
|
/* Easy test for recursion. */
|
246 |
|
|
if (op == XEXP (DECL_RTL (current_function_decl), 0))
|
247 |
|
|
return true;
|
248 |
|
|
|
249 |
|
|
/* Functions that are not local can be overridden, and thus may
|
250 |
|
|
not share the same gp. */
|
251 |
|
|
if (! SYMBOL_REF_LOCAL_P (op))
|
252 |
|
|
return false;
|
253 |
|
|
|
254 |
|
|
/* If -msmall-data is in effect, assume that there is only one GP
|
255 |
|
|
for the module, and so any local symbol has this property. We
|
256 |
|
|
need explicit relocations to be able to enforce this for symbols
|
257 |
|
|
not defined in this unit of translation, however. */
|
258 |
|
|
if (TARGET_EXPLICIT_RELOCS && TARGET_SMALL_DATA)
|
259 |
|
|
return true;
|
260 |
|
|
|
261 |
|
|
/* Functions that are not external are defined in this UoT,
|
262 |
|
|
and thus must share the same gp. */
|
263 |
|
|
return ! SYMBOL_REF_EXTERNAL_P (op);
|
264 |
|
|
})
|
265 |
|
|
|
266 |
|
|
;; Return 1 if OP is a SYMBOL_REF for which we can make a call via bsr.
|
267 |
|
|
(define_predicate "direct_call_operand"
|
268 |
|
|
(match_operand 0 "samegp_function_operand")
|
269 |
|
|
{
|
270 |
|
|
tree op_decl, cfun_sec, op_sec;
|
271 |
|
|
|
272 |
|
|
/* If profiling is implemented via linker tricks, we can't jump
|
273 |
|
|
to the nogp alternate entry point. Note that current_function_profile
|
274 |
|
|
would not be correct, since that doesn't indicate if the target
|
275 |
|
|
function uses profiling. */
|
276 |
|
|
/* ??? TARGET_PROFILING_NEEDS_GP isn't really the right test,
|
277 |
|
|
but is approximately correct for the OSF ABIs. Don't know
|
278 |
|
|
what to do for VMS, NT, or UMK. */
|
279 |
|
|
if (!TARGET_PROFILING_NEEDS_GP && profile_flag)
|
280 |
|
|
return false;
|
281 |
|
|
|
282 |
|
|
/* Must be a function. In some cases folks create thunks in static
|
283 |
|
|
data structures and then make calls to them. If we allow the
|
284 |
|
|
direct call, we'll get an error from the linker about !samegp reloc
|
285 |
|
|
against a symbol without a .prologue directive. */
|
286 |
|
|
if (!SYMBOL_REF_FUNCTION_P (op))
|
287 |
|
|
return false;
|
288 |
|
|
|
289 |
|
|
/* Must be "near" so that the branch is assumed to reach. With
|
290 |
|
|
-msmall-text, this is assumed true of all local symbols. Since
|
291 |
|
|
we've already checked samegp, locality is already assured. */
|
292 |
|
|
if (TARGET_SMALL_TEXT)
|
293 |
|
|
return true;
|
294 |
|
|
|
295 |
|
|
/* Otherwise, a decl is "near" if it is defined in the same section. */
|
296 |
|
|
if (flag_function_sections)
|
297 |
|
|
return false;
|
298 |
|
|
|
299 |
|
|
op_decl = SYMBOL_REF_DECL (op);
|
300 |
|
|
if (DECL_ONE_ONLY (current_function_decl)
|
301 |
|
|
|| (op_decl && DECL_ONE_ONLY (op_decl)))
|
302 |
|
|
return false;
|
303 |
|
|
|
304 |
|
|
cfun_sec = DECL_SECTION_NAME (current_function_decl);
|
305 |
|
|
op_sec = op_decl ? DECL_SECTION_NAME (op_decl) : NULL;
|
306 |
|
|
return ((!cfun_sec && !op_sec)
|
307 |
|
|
|| (cfun_sec && op_sec
|
308 |
|
|
&& strcmp (TREE_STRING_POINTER (cfun_sec),
|
309 |
|
|
TREE_STRING_POINTER (op_sec)) == 0));
|
310 |
|
|
})
|
311 |
|
|
|
312 |
|
|
;; Return 1 if OP is a valid operand for the MEM of a CALL insn.
|
313 |
|
|
;;
|
314 |
|
|
;; For TARGET_ABI_OSF, we want to restrict to R27 or a pseudo.
|
315 |
|
|
;; For TARGET_ABI_UNICOSMK, we want to restrict to registers.
|
316 |
|
|
|
317 |
|
|
(define_predicate "call_operand"
|
318 |
|
|
(if_then_else (match_code "reg")
|
319 |
|
|
(match_test "!TARGET_ABI_OSF
|
320 |
|
|
|| REGNO (op) == 27 || REGNO (op) > LAST_VIRTUAL_REGISTER")
|
321 |
|
|
(and (match_test "!TARGET_ABI_UNICOSMK")
|
322 |
|
|
(match_code "symbol_ref"))))
|
323 |
|
|
|
324 |
|
|
;; Return true if OP is a LABEL_REF, or SYMBOL_REF or CONST referencing
|
325 |
|
|
;; a (non-tls) variable known to be defined in this file.
|
326 |
|
|
(define_predicate "local_symbolic_operand"
|
327 |
|
|
(match_code "label_ref,const,symbol_ref")
|
328 |
|
|
{
|
329 |
|
|
if (GET_CODE (op) == LABEL_REF)
|
330 |
|
|
return 1;
|
331 |
|
|
|
332 |
|
|
if (GET_CODE (op) == CONST
|
333 |
|
|
&& GET_CODE (XEXP (op, 0)) == PLUS
|
334 |
|
|
&& GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT)
|
335 |
|
|
op = XEXP (XEXP (op, 0), 0);
|
336 |
|
|
|
337 |
|
|
if (GET_CODE (op) != SYMBOL_REF)
|
338 |
|
|
return 0;
|
339 |
|
|
|
340 |
|
|
return (SYMBOL_REF_LOCAL_P (op)
|
341 |
|
|
&& !SYMBOL_REF_WEAK (op)
|
342 |
|
|
&& !SYMBOL_REF_TLS_MODEL (op));
|
343 |
|
|
})
|
344 |
|
|
|
345 |
|
|
;; Return true if OP is a SYMBOL_REF or CONST referencing a variable
|
346 |
|
|
;; known to be defined in this file in the small data area.
|
347 |
|
|
(define_predicate "small_symbolic_operand"
|
348 |
|
|
(match_code "const,symbol_ref")
|
349 |
|
|
{
|
350 |
|
|
if (! TARGET_SMALL_DATA)
|
351 |
|
|
return 0;
|
352 |
|
|
|
353 |
|
|
if (GET_CODE (op) == CONST
|
354 |
|
|
&& GET_CODE (XEXP (op, 0)) == PLUS
|
355 |
|
|
&& GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT)
|
356 |
|
|
op = XEXP (XEXP (op, 0), 0);
|
357 |
|
|
|
358 |
|
|
if (GET_CODE (op) != SYMBOL_REF)
|
359 |
|
|
return 0;
|
360 |
|
|
|
361 |
|
|
/* ??? There's no encode_section_info equivalent for the rtl
|
362 |
|
|
constant pool, so SYMBOL_FLAG_SMALL never gets set. */
|
363 |
|
|
if (CONSTANT_POOL_ADDRESS_P (op))
|
364 |
|
|
return GET_MODE_SIZE (get_pool_mode (op)) <= g_switch_value;
|
365 |
|
|
|
366 |
|
|
return (SYMBOL_REF_LOCAL_P (op)
|
367 |
|
|
&& SYMBOL_REF_SMALL_P (op)
|
368 |
|
|
&& !SYMBOL_REF_WEAK (op)
|
369 |
|
|
&& !SYMBOL_REF_TLS_MODEL (op));
|
370 |
|
|
})
|
371 |
|
|
|
372 |
|
|
;; Return true if OP is a SYMBOL_REF or CONST referencing a variable
|
373 |
|
|
;; not known (or known not) to be defined in this file.
|
374 |
|
|
(define_predicate "global_symbolic_operand"
|
375 |
|
|
(match_code "const,symbol_ref")
|
376 |
|
|
{
|
377 |
|
|
if (GET_CODE (op) == CONST
|
378 |
|
|
&& GET_CODE (XEXP (op, 0)) == PLUS
|
379 |
|
|
&& GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT)
|
380 |
|
|
op = XEXP (XEXP (op, 0), 0);
|
381 |
|
|
|
382 |
|
|
if (GET_CODE (op) != SYMBOL_REF)
|
383 |
|
|
return 0;
|
384 |
|
|
|
385 |
|
|
return ((!SYMBOL_REF_LOCAL_P (op) || SYMBOL_REF_WEAK (op))
|
386 |
|
|
&& !SYMBOL_REF_TLS_MODEL (op));
|
387 |
|
|
})
|
388 |
|
|
|
389 |
|
|
;; Returns 1 if OP is a symbolic operand, i.e. a symbol_ref or a label_ref,
|
390 |
|
|
;; possibly with an offset.
|
391 |
|
|
(define_predicate "symbolic_operand"
|
392 |
|
|
(ior (match_code "symbol_ref,label_ref")
|
393 |
|
|
(and (match_code "const")
|
394 |
|
|
(match_test "GET_CODE (XEXP (op,0)) == PLUS
|
395 |
|
|
&& GET_CODE (XEXP (XEXP (op,0), 0)) == SYMBOL_REF
|
396 |
|
|
&& GET_CODE (XEXP (XEXP (op,0), 1)) == CONST_INT"))))
|
397 |
|
|
|
398 |
|
|
;; Return true if OP is valid for 16-bit DTP relative relocations.
|
399 |
|
|
(define_predicate "dtp16_symbolic_operand"
|
400 |
|
|
(and (match_code "const")
|
401 |
|
|
(match_test "tls_symbolic_operand_1 (op, 16, UNSPEC_DTPREL)")))
|
402 |
|
|
|
403 |
|
|
;; Return true if OP is valid for 32-bit DTP relative relocations.
|
404 |
|
|
(define_predicate "dtp32_symbolic_operand"
|
405 |
|
|
(and (match_code "const")
|
406 |
|
|
(match_test "tls_symbolic_operand_1 (op, 32, UNSPEC_DTPREL)")))
|
407 |
|
|
|
408 |
|
|
;; Return true if OP is valid for 64-bit DTP relative relocations.
|
409 |
|
|
(define_predicate "gotdtp_symbolic_operand"
|
410 |
|
|
(and (match_code "const")
|
411 |
|
|
(match_test "tls_symbolic_operand_1 (op, 64, UNSPEC_DTPREL)")))
|
412 |
|
|
|
413 |
|
|
;; Return true if OP is valid for 16-bit TP relative relocations.
|
414 |
|
|
(define_predicate "tp16_symbolic_operand"
|
415 |
|
|
(and (match_code "const")
|
416 |
|
|
(match_test "tls_symbolic_operand_1 (op, 16, UNSPEC_TPREL)")))
|
417 |
|
|
|
418 |
|
|
;; Return true if OP is valid for 32-bit TP relative relocations.
|
419 |
|
|
(define_predicate "tp32_symbolic_operand"
|
420 |
|
|
(and (match_code "const")
|
421 |
|
|
(match_test "tls_symbolic_operand_1 (op, 32, UNSPEC_TPREL)")))
|
422 |
|
|
|
423 |
|
|
;; Return true if OP is valid for 64-bit TP relative relocations.
|
424 |
|
|
(define_predicate "gottp_symbolic_operand"
|
425 |
|
|
(and (match_code "const")
|
426 |
|
|
(match_test "tls_symbolic_operand_1 (op, 64, UNSPEC_TPREL)")))
|
427 |
|
|
|
428 |
|
|
;; Return 1 if this memory address is a known aligned register plus
|
429 |
|
|
;; a constant. It must be a valid address. This means that we can do
|
430 |
|
|
;; this as an aligned reference plus some offset.
|
431 |
|
|
;;
|
432 |
|
|
;; Take into account what reload will do. Oh god this is awful.
|
433 |
|
|
;; The horrible comma-operator construct below is to prevent genrecog
|
434 |
|
|
;; from thinking that this predicate accepts REG and SUBREG. We don't
|
435 |
|
|
;; use recog during reload, so pretending these codes are accepted
|
436 |
|
|
;; pessimizes things a tad.
|
437 |
|
|
|
438 |
|
|
(define_predicate "aligned_memory_operand"
|
439 |
|
|
(ior (match_test "op = resolve_reload_operand (op), 0")
|
440 |
|
|
(match_code "mem"))
|
441 |
|
|
{
|
442 |
|
|
rtx base;
|
443 |
|
|
|
444 |
|
|
if (MEM_ALIGN (op) >= 32)
|
445 |
|
|
return 1;
|
446 |
|
|
op = XEXP (op, 0);
|
447 |
|
|
|
448 |
|
|
/* LEGITIMIZE_RELOAD_ADDRESS creates (plus (plus reg const_hi) const_lo)
|
449 |
|
|
sorts of constructs. Dig for the real base register. */
|
450 |
|
|
if (reload_in_progress
|
451 |
|
|
&& GET_CODE (op) == PLUS
|
452 |
|
|
&& GET_CODE (XEXP (op, 0)) == PLUS)
|
453 |
|
|
base = XEXP (XEXP (op, 0), 0);
|
454 |
|
|
else
|
455 |
|
|
{
|
456 |
|
|
if (! memory_address_p (mode, op))
|
457 |
|
|
return 0;
|
458 |
|
|
base = (GET_CODE (op) == PLUS ? XEXP (op, 0) : op);
|
459 |
|
|
}
|
460 |
|
|
|
461 |
|
|
return (GET_CODE (base) == REG && REGNO_POINTER_ALIGN (REGNO (base)) >= 32);
|
462 |
|
|
})
|
463 |
|
|
|
464 |
|
|
;; Similar, but return 1 if OP is a MEM which is not alignable.
|
465 |
|
|
|
466 |
|
|
(define_predicate "unaligned_memory_operand"
|
467 |
|
|
(ior (match_test "op = resolve_reload_operand (op), 0")
|
468 |
|
|
(match_code "mem"))
|
469 |
|
|
{
|
470 |
|
|
rtx base;
|
471 |
|
|
|
472 |
|
|
if (MEM_ALIGN (op) >= 32)
|
473 |
|
|
return 0;
|
474 |
|
|
op = XEXP (op, 0);
|
475 |
|
|
|
476 |
|
|
/* LEGITIMIZE_RELOAD_ADDRESS creates (plus (plus reg const_hi) const_lo)
|
477 |
|
|
sorts of constructs. Dig for the real base register. */
|
478 |
|
|
if (reload_in_progress
|
479 |
|
|
&& GET_CODE (op) == PLUS
|
480 |
|
|
&& GET_CODE (XEXP (op, 0)) == PLUS)
|
481 |
|
|
base = XEXP (XEXP (op, 0), 0);
|
482 |
|
|
else
|
483 |
|
|
{
|
484 |
|
|
if (! memory_address_p (mode, op))
|
485 |
|
|
return 0;
|
486 |
|
|
base = (GET_CODE (op) == PLUS ? XEXP (op, 0) : op);
|
487 |
|
|
}
|
488 |
|
|
|
489 |
|
|
return (GET_CODE (base) == REG && REGNO_POINTER_ALIGN (REGNO (base)) < 32);
|
490 |
|
|
})
|
491 |
|
|
|
492 |
|
|
;; Return 1 if OP is any memory location. During reload a pseudo matches.
|
493 |
|
|
(define_predicate "any_memory_operand"
|
494 |
|
|
(ior (match_code "mem,reg")
|
495 |
|
|
(and (match_code "subreg")
|
496 |
|
|
(match_test "GET_CODE (SUBREG_REG (op)) == REG"))))
|
497 |
|
|
|
498 |
|
|
;; Return 1 if OP is either a register or an unaligned memory location.
|
499 |
|
|
(define_predicate "reg_or_unaligned_mem_operand"
|
500 |
|
|
(ior (match_operand 0 "register_operand")
|
501 |
|
|
(match_operand 0 "unaligned_memory_operand")))
|
502 |
|
|
|
503 |
|
|
;; Return 1 is OP is a memory location that is not a reference
|
504 |
|
|
;; (using an AND) to an unaligned location. Take into account
|
505 |
|
|
;; what reload will do.
|
506 |
|
|
(define_predicate "normal_memory_operand"
|
507 |
|
|
(ior (match_test "op = resolve_reload_operand (op), 0")
|
508 |
|
|
(and (match_code "mem")
|
509 |
|
|
(match_test "GET_CODE (XEXP (op, 0)) != AND"))))
|
510 |
|
|
|
511 |
|
|
;; Returns 1 if OP is not an eliminable register.
|
512 |
|
|
;;
|
513 |
|
|
;; This exists to cure a pathological failure in the s8addq (et al) patterns,
|
514 |
|
|
;;
|
515 |
|
|
;; long foo () { long t; bar(); return (long) &t * 26107; }
|
516 |
|
|
;;
|
517 |
|
|
;; which run afoul of a hack in reload to cure a (presumably) similar
|
518 |
|
|
;; problem with lea-type instructions on other targets. But there is
|
519 |
|
|
;; one of us and many of them, so work around the problem by selectively
|
520 |
|
|
;; preventing combine from making the optimization.
|
521 |
|
|
|
522 |
|
|
(define_predicate "reg_not_elim_operand"
|
523 |
|
|
(match_operand 0 "register_operand")
|
524 |
|
|
{
|
525 |
|
|
if (GET_CODE (op) == SUBREG)
|
526 |
|
|
op = SUBREG_REG (op);
|
527 |
|
|
return op != frame_pointer_rtx && op != arg_pointer_rtx;
|
528 |
|
|
})
|
529 |
|
|
|
530 |
|
|
;; Accept a register, but not a subreg of any kind. This allows us to
|
531 |
|
|
;; avoid pathological cases in reload wrt data movement common in
|
532 |
|
|
;; int->fp conversion. */
|
533 |
|
|
(define_predicate "reg_no_subreg_operand"
|
534 |
|
|
(and (match_code "reg")
|
535 |
|
|
(match_operand 0 "register_operand")))
|
536 |
|
|
|
537 |
|
|
;; Return 1 if OP is a valid Alpha comparison operator for "cmp" style
|
538 |
|
|
;; instructions.
|
539 |
|
|
(define_predicate "alpha_comparison_operator"
|
540 |
|
|
(match_code "eq,le,lt,leu,ltu"))
|
541 |
|
|
|
542 |
|
|
;; Similarly, but with swapped operands.
|
543 |
|
|
(define_predicate "alpha_swapped_comparison_operator"
|
544 |
|
|
(match_code "eq,ge,gt,gtu"))
|
545 |
|
|
|
546 |
|
|
;; Return 1 if OP is a valid Alpha comparison operator against zero
|
547 |
|
|
;; for "bcc" style instructions.
|
548 |
|
|
(define_predicate "alpha_zero_comparison_operator"
|
549 |
|
|
(match_code "eq,ne,le,lt,leu,ltu"))
|
550 |
|
|
|
551 |
|
|
;; Return 1 if OP is a signed comparison operation.
|
552 |
|
|
(define_predicate "signed_comparison_operator"
|
553 |
|
|
(match_code "eq,ne,le,lt,ge,gt"))
|
554 |
|
|
|
555 |
|
|
;; Return 1 if OP is a valid Alpha floating point comparison operator.
|
556 |
|
|
(define_predicate "alpha_fp_comparison_operator"
|
557 |
|
|
(match_code "eq,le,lt,unordered"))
|
558 |
|
|
|
559 |
|
|
;; Return 1 if this is a divide or modulus operator.
|
560 |
|
|
(define_predicate "divmod_operator"
|
561 |
|
|
(match_code "div,mod,udiv,umod"))
|
562 |
|
|
|
563 |
|
|
;; Return 1 if this is a float->int conversion operator.
|
564 |
|
|
(define_predicate "fix_operator"
|
565 |
|
|
(match_code "fix,unsigned_fix"))
|
566 |
|
|
|
567 |
|
|
;; Recognize an addition operation that includes a constant. Used to
|
568 |
|
|
;; convince reload to canonize (plus (plus reg c1) c2) during register
|
569 |
|
|
;; elimination.
|
570 |
|
|
|
571 |
|
|
(define_predicate "addition_operation"
|
572 |
|
|
(and (match_code "plus")
|
573 |
|
|
(match_test "register_operand (XEXP (op, 0), mode)
|
574 |
|
|
&& GET_CODE (XEXP (op, 1)) == CONST_INT
|
575 |
|
|
&& CONST_OK_FOR_LETTER_P (INTVAL (XEXP (op, 1)), 'K')")))
|
576 |
|
|
|
577 |
|
|
;; For TARGET_EXPLICIT_RELOCS, we don't obfuscate a SYMBOL_REF to a
|
578 |
|
|
;; small symbolic operand until after reload. At which point we need
|
579 |
|
|
;; to replace (mem (symbol_ref)) with (mem (lo_sum $29 symbol_ref))
|
580 |
|
|
;; so that sched2 has the proper dependency information. */
|
581 |
|
|
(define_predicate "some_small_symbolic_operand"
|
582 |
|
|
(match_code "set,parallel,prefetch,unspec,unspec_volatile")
|
583 |
|
|
{
|
584 |
|
|
/* Avoid search unless necessary. */
|
585 |
|
|
if (!TARGET_EXPLICIT_RELOCS || !reload_completed)
|
586 |
|
|
return false;
|
587 |
|
|
return for_each_rtx (&op, some_small_symbolic_operand_int, NULL);
|
588 |
|
|
})
|