]>
Commit | Line | Data |
---|---|---|
f5a1b0d2 | 1 | /* Definitions of target machine for GNU compiler, for ARM. |
cf011243 | 2 | Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, |
66647d44 | 3 | 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
bf98ec6c | 4 | Free Software Foundation, Inc. |
35d965d5 | 5 | Contributed by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl) |
8b109b37 | 6 | and Martin Simmons (@harleqn.co.uk). |
949d79eb | 7 | More major hacks by Richard Earnshaw (rearnsha@arm.com) |
6cfc7210 NC |
8 | Minor hacks by Nick Clifton (nickc@cygnus.com) |
9 | ||
4f448245 | 10 | This file is part of GCC. |
35d965d5 | 11 | |
4f448245 NC |
12 | GCC is free software; you can redistribute it and/or modify it |
13 | under the terms of the GNU General Public License as published | |
2f83c7d6 | 14 | by the Free Software Foundation; either version 3, or (at your |
4f448245 | 15 | option) any later version. |
35d965d5 | 16 | |
4f448245 NC |
17 | GCC is distributed in the hope that it will be useful, but WITHOUT |
18 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
19 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | |
20 | License for more details. | |
35d965d5 | 21 | |
4f448245 | 22 | You should have received a copy of the GNU General Public License |
2f83c7d6 NC |
23 | along with GCC; see the file COPYING3. If not see |
24 | <http://www.gnu.org/licenses/>. */ | |
35d965d5 | 25 | |
88657302 RH |
26 | #ifndef GCC_ARM_H |
27 | #define GCC_ARM_H | |
b355a481 | 28 | |
9403b7f7 RS |
29 | #include "config/vxworks-dummy.h" |
30 | ||
35fd3193 | 31 | /* The architecture define. */ |
78011587 PB |
32 | extern char arm_arch_name[]; |
33 | ||
e6471be6 NB |
34 | /* Target CPU builtins. */ |
35 | #define TARGET_CPU_CPP_BUILTINS() \ | |
36 | do \ | |
37 | { \ | |
9b66ebb1 PB |
38 | /* Define __arm__ even when in thumb mode, for \ |
39 | consistency with armcc. */ \ | |
40 | builtin_define ("__arm__"); \ | |
61f0ccff | 41 | builtin_define ("__APCS_32__"); \ |
9b66ebb1 | 42 | if (TARGET_THUMB) \ |
e6471be6 | 43 | builtin_define ("__thumb__"); \ |
5b3e6663 PB |
44 | if (TARGET_THUMB2) \ |
45 | builtin_define ("__thumb2__"); \ | |
e6471be6 NB |
46 | \ |
47 | if (TARGET_BIG_END) \ | |
48 | { \ | |
49 | builtin_define ("__ARMEB__"); \ | |
50 | if (TARGET_THUMB) \ | |
51 | builtin_define ("__THUMBEB__"); \ | |
52 | if (TARGET_LITTLE_WORDS) \ | |
53 | builtin_define ("__ARMWEL__"); \ | |
54 | } \ | |
55 | else \ | |
56 | { \ | |
57 | builtin_define ("__ARMEL__"); \ | |
58 | if (TARGET_THUMB) \ | |
59 | builtin_define ("__THUMBEL__"); \ | |
60 | } \ | |
61 | \ | |
e6471be6 NB |
62 | if (TARGET_SOFT_FLOAT) \ |
63 | builtin_define ("__SOFTFP__"); \ | |
64 | \ | |
9b66ebb1 | 65 | if (TARGET_VFP) \ |
b5b620a4 JT |
66 | builtin_define ("__VFP_FP__"); \ |
67 | \ | |
88f77cba JB |
68 | if (TARGET_NEON) \ |
69 | builtin_define ("__ARM_NEON__"); \ | |
70 | \ | |
e6471be6 NB |
71 | /* Add a define for interworking. \ |
72 | Needed when building libgcc.a. */ \ | |
2ad4dcf9 | 73 | if (arm_cpp_interwork) \ |
e6471be6 NB |
74 | builtin_define ("__THUMB_INTERWORK__"); \ |
75 | \ | |
76 | builtin_assert ("cpu=arm"); \ | |
77 | builtin_assert ("machine=arm"); \ | |
78011587 PB |
78 | \ |
79 | builtin_define (arm_arch_name); \ | |
80 | if (arm_arch_cirrus) \ | |
81 | builtin_define ("__MAVERICK__"); \ | |
82 | if (arm_arch_xscale) \ | |
83 | builtin_define ("__XSCALE__"); \ | |
84 | if (arm_arch_iwmmxt) \ | |
85 | builtin_define ("__IWMMXT__"); \ | |
4adf3e34 PB |
86 | if (TARGET_AAPCS_BASED) \ |
87 | builtin_define ("__ARM_EABI__"); \ | |
e6471be6 NB |
88 | } while (0) |
89 | ||
9b66ebb1 PB |
90 | /* The various ARM cores. */ |
91 | enum processor_type | |
92 | { | |
d98a72fd RE |
93 | #define ARM_CORE(NAME, IDENT, ARCH, FLAGS, COSTS) \ |
94 | IDENT, | |
9b66ebb1 PB |
95 | #include "arm-cores.def" |
96 | #undef ARM_CORE | |
97 | /* Used to indicate that no processor has been specified. */ | |
98 | arm_none | |
99 | }; | |
100 | ||
78011587 PB |
101 | enum target_cpus |
102 | { | |
d98a72fd RE |
103 | #define ARM_CORE(NAME, IDENT, ARCH, FLAGS, COSTS) \ |
104 | TARGET_CPU_##IDENT, | |
78011587 PB |
105 | #include "arm-cores.def" |
106 | #undef ARM_CORE | |
107 | TARGET_CPU_generic | |
108 | }; | |
109 | ||
9b66ebb1 PB |
110 | /* The processor for which instructions should be scheduled. */ |
111 | extern enum processor_type arm_tune; | |
112 | ||
d5b7b3ae | 113 | typedef enum arm_cond_code |
89c7ca52 RE |
114 | { |
115 | ARM_EQ = 0, ARM_NE, ARM_CS, ARM_CC, ARM_MI, ARM_PL, ARM_VS, ARM_VC, | |
116 | ARM_HI, ARM_LS, ARM_GE, ARM_LT, ARM_GT, ARM_LE, ARM_AL, ARM_NV | |
d5b7b3ae RE |
117 | } |
118 | arm_cc; | |
6cfc7210 | 119 | |
d5b7b3ae | 120 | extern arm_cc arm_current_cc; |
ff9940b0 | 121 | |
d5b7b3ae | 122 | #define ARM_INVERSE_CONDITION_CODE(X) ((arm_cc) (((int)X) ^ 1)) |
89c7ca52 | 123 | |
6cfc7210 NC |
124 | extern int arm_target_label; |
125 | extern int arm_ccfsm_state; | |
e2500fed | 126 | extern GTY(()) rtx arm_target_insn; |
d5b7b3ae | 127 | /* The label of the current constant pool. */ |
e2500fed | 128 | extern rtx pool_vector_label; |
d5b7b3ae | 129 | /* Set to 1 when a return insn is output, this means that the epilogue |
d6b4baa4 | 130 | is not needed. */ |
d5b7b3ae | 131 | extern int return_used_this_function; |
b76c3c4b PB |
132 | /* Callback to output language specific object attributes. */ |
133 | extern void (*arm_lang_output_object_attributes_hook)(void); | |
35d965d5 | 134 | \f |
d6b4baa4 | 135 | /* Just in case configure has failed to define anything. */ |
7a801826 RE |
136 | #ifndef TARGET_CPU_DEFAULT |
137 | #define TARGET_CPU_DEFAULT TARGET_CPU_generic | |
138 | #endif | |
139 | ||
7a801826 | 140 | |
5742588d | 141 | #undef CPP_SPEC |
78011587 | 142 | #define CPP_SPEC "%(subtarget_cpp_spec) \ |
e6471be6 NB |
143 | %{msoft-float:%{mhard-float: \ |
144 | %e-msoft-float and -mhard_float may not be used together}} \ | |
145 | %{mbig-endian:%{mlittle-endian: \ | |
146 | %e-mbig-endian and -mlittle-endian may not be used together}}" | |
7a801826 | 147 | |
be393ecf | 148 | #ifndef CC1_SPEC |
dfa08768 | 149 | #define CC1_SPEC "" |
be393ecf | 150 | #endif |
7a801826 RE |
151 | |
152 | /* This macro defines names of additional specifications to put in the specs | |
153 | that can be used in various specifications like CC1_SPEC. Its definition | |
154 | is an initializer with a subgrouping for each command option. | |
155 | ||
156 | Each subgrouping contains a string constant, that defines the | |
4f448245 | 157 | specification name, and a string constant that used by the GCC driver |
7a801826 RE |
158 | program. |
159 | ||
160 | Do not define this macro if it does not need to do anything. */ | |
161 | #define EXTRA_SPECS \ | |
38fc909b | 162 | { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC }, \ |
7a801826 RE |
163 | SUBTARGET_EXTRA_SPECS |
164 | ||
914a3b8c | 165 | #ifndef SUBTARGET_EXTRA_SPECS |
7a801826 | 166 | #define SUBTARGET_EXTRA_SPECS |
914a3b8c DM |
167 | #endif |
168 | ||
6cfc7210 | 169 | #ifndef SUBTARGET_CPP_SPEC |
38fc909b | 170 | #define SUBTARGET_CPP_SPEC "" |
6cfc7210 | 171 | #endif |
35d965d5 RS |
172 | \f |
173 | /* Run-time Target Specification. */ | |
ff9940b0 | 174 | #ifndef TARGET_VERSION |
6cfc7210 | 175 | #define TARGET_VERSION fputs (" (ARM/generic)", stderr); |
ff9940b0 | 176 | #endif |
35d965d5 | 177 | |
9b66ebb1 | 178 | #define TARGET_SOFT_FLOAT (arm_float_abi == ARM_FLOAT_ABI_SOFT) |
72cdc543 PB |
179 | /* Use hardware floating point instructions. */ |
180 | #define TARGET_HARD_FLOAT (arm_float_abi != ARM_FLOAT_ABI_SOFT) | |
181 | /* Use hardware floating point calling convention. */ | |
182 | #define TARGET_HARD_FLOAT_ABI (arm_float_abi == ARM_FLOAT_ABI_HARD) | |
9b66ebb1 PB |
183 | #define TARGET_FPA (arm_fp_model == ARM_FP_MODEL_FPA) |
184 | #define TARGET_MAVERICK (arm_fp_model == ARM_FP_MODEL_MAVERICK) | |
185 | #define TARGET_VFP (arm_fp_model == ARM_FP_MODEL_VFP) | |
5a9335ef | 186 | #define TARGET_IWMMXT (arm_arch_iwmmxt) |
5b3e6663 PB |
187 | #define TARGET_REALLY_IWMMXT (TARGET_IWMMXT && TARGET_32BIT) |
188 | #define TARGET_IWMMXT_ABI (TARGET_32BIT && arm_abi == ARM_ABI_IWMMXT) | |
d5b7b3ae RE |
189 | #define TARGET_ARM (! TARGET_THUMB) |
190 | #define TARGET_EITHER 1 /* (TARGET_ARM | TARGET_THUMB) */ | |
c54c7322 RS |
191 | #define TARGET_BACKTRACE (leaf_function_p () \ |
192 | ? TARGET_TPCS_LEAF_FRAME \ | |
193 | : TARGET_TPCS_FRAME) | |
fdd695fd | 194 | #define TARGET_LDRD (arm_arch5e && ARM_DOUBLEWORD_ALIGN) |
b6685939 PB |
195 | #define TARGET_AAPCS_BASED \ |
196 | (arm_abi != ARM_ABI_APCS && arm_abi != ARM_ABI_ATPCS) | |
3ada8e17 | 197 | |
d3585b76 DJ |
198 | #define TARGET_HARD_TP (target_thread_pointer == TP_CP15) |
199 | #define TARGET_SOFT_TP (target_thread_pointer == TP_SOFT) | |
200 | ||
5b3e6663 PB |
201 | /* Only 16-bit thumb code. */ |
202 | #define TARGET_THUMB1 (TARGET_THUMB && !arm_arch_thumb2) | |
203 | /* Arm or Thumb-2 32-bit code. */ | |
204 | #define TARGET_32BIT (TARGET_ARM || arm_arch_thumb2) | |
205 | /* 32-bit Thumb-2 code. */ | |
206 | #define TARGET_THUMB2 (TARGET_THUMB && arm_arch_thumb2) | |
bf98ec6c PB |
207 | /* Thumb-1 only. */ |
208 | #define TARGET_THUMB1_ONLY (TARGET_THUMB1 && !arm_arch_notm) | |
5b3e6663 | 209 | |
88f77cba | 210 | /* The following two macros concern the ability to execute coprocessor |
302c3d8e PB |
211 | instructions for VFPv3 or NEON. TARGET_VFP3/TARGET_VFPD32 are currently |
212 | only ever tested when we know we are generating for VFP hardware; we need | |
213 | to be more careful with TARGET_NEON as noted below. */ | |
88f77cba | 214 | |
302c3d8e PB |
215 | /* FPU is has the full VFPv3/NEON register file of 32 D registers. */ |
216 | #define TARGET_VFPD32 (arm_fp_model == ARM_FP_MODEL_VFP \ | |
217 | && (arm_fpu_arch == FPUTYPE_VFP3 \ | |
0fd8c3ad SL |
218 | || arm_fpu_arch == FPUTYPE_NEON \ |
219 | || arm_fpu_arch == FPUTYPE_NEON_FP16)) | |
302c3d8e PB |
220 | |
221 | /* FPU supports VFPv3 instructions. */ | |
f1adb0a9 | 222 | #define TARGET_VFP3 (arm_fp_model == ARM_FP_MODEL_VFP \ |
302c3d8e PB |
223 | && (arm_fpu_arch == FPUTYPE_VFP3D16 \ |
224 | || TARGET_VFPD32)) | |
225 | ||
0fd8c3ad SL |
226 | /* FPU supports NEON/VFP half-precision floating-point. */ |
227 | #define TARGET_NEON_FP16 (arm_fpu_arch == FPUTYPE_NEON_FP16) | |
228 | ||
88f77cba JB |
229 | /* FPU supports Neon instructions. The setting of this macro gets |
230 | revealed via __ARM_NEON__ so we add extra guards upon TARGET_32BIT | |
231 | and TARGET_HARD_FLOAT to ensure that NEON instructions are | |
232 | available. */ | |
233 | #define TARGET_NEON (TARGET_32BIT && TARGET_HARD_FLOAT \ | |
234 | && arm_fp_model == ARM_FP_MODEL_VFP \ | |
0fd8c3ad SL |
235 | && (arm_fpu_arch == FPUTYPE_NEON \ |
236 | || arm_fpu_arch == FPUTYPE_NEON_FP16)) | |
f1adb0a9 | 237 | |
5b3e6663 PB |
238 | /* "DSP" multiply instructions, eg. SMULxy. */ |
239 | #define TARGET_DSP_MULTIPLY \ | |
240 | (TARGET_32BIT && arm_arch5e && arm_arch_notm) | |
241 | /* Integer SIMD instructions, and extend-accumulate instructions. */ | |
242 | #define TARGET_INT_SIMD \ | |
243 | (TARGET_32BIT && arm_arch6 && arm_arch_notm) | |
244 | ||
571191af PB |
245 | /* Should MOVW/MOVT be used in preference to a constant pool. */ |
246 | #define TARGET_USE_MOVT (arm_arch_thumb2 && !optimize_size) | |
247 | ||
5b3e6663 PB |
248 | /* We could use unified syntax for arm mode, but for now we just use it |
249 | for Thumb-2. */ | |
250 | #define TARGET_UNIFIED_ASM TARGET_THUMB2 | |
251 | ||
252 | ||
b3f8d95d MM |
253 | /* True iff the full BPABI is being used. If TARGET_BPABI is true, |
254 | then TARGET_AAPCS_BASED must be true -- but the converse does not | |
255 | hold. TARGET_BPABI implies the use of the BPABI runtime library, | |
256 | etc., in addition to just the AAPCS calling conventions. */ | |
257 | #ifndef TARGET_BPABI | |
258 | #define TARGET_BPABI false | |
f676971a | 259 | #endif |
b3f8d95d | 260 | |
7816bea0 DJ |
261 | /* Support for a compile-time default CPU, et cetera. The rules are: |
262 | --with-arch is ignored if -march or -mcpu are specified. | |
263 | --with-cpu is ignored if -march or -mcpu are specified, and is overridden | |
264 | by --with-arch. | |
265 | --with-tune is ignored if -mtune or -mcpu are specified (but not affected | |
266 | by -march). | |
9b66ebb1 PB |
267 | --with-float is ignored if -mhard-float, -msoft-float or -mfloat-abi are |
268 | specified. | |
5848830f PB |
269 | --with-fpu is ignored if -mfpu is specified. |
270 | --with-abi is ignored is -mabi is specified. */ | |
7816bea0 DJ |
271 | #define OPTION_DEFAULT_SPECS \ |
272 | {"arch", "%{!march=*:%{!mcpu=*:-march=%(VALUE)}}" }, \ | |
273 | {"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \ | |
274 | {"tune", "%{!mcpu=*:%{!mtune=*:-mtune=%(VALUE)}}" }, \ | |
9b66ebb1 PB |
275 | {"float", \ |
276 | "%{!msoft-float:%{!mhard-float:%{!mfloat-abi=*:-mfloat-abi=%(VALUE)}}}" }, \ | |
5848830f | 277 | {"fpu", "%{!mfpu=*:-mfpu=%(VALUE)}"}, \ |
3cf94279 PB |
278 | {"abi", "%{!mabi=*:-mabi=%(VALUE)}"}, \ |
279 | {"mode", "%{!marm:%{!mthumb:-m%(VALUE)}}"}, | |
7816bea0 | 280 | |
9b66ebb1 PB |
281 | /* Which floating point model to use. */ |
282 | enum arm_fp_model | |
283 | { | |
284 | ARM_FP_MODEL_UNKNOWN, | |
285 | /* FPA model (Hardware or software). */ | |
286 | ARM_FP_MODEL_FPA, | |
287 | /* Cirrus Maverick floating point model. */ | |
288 | ARM_FP_MODEL_MAVERICK, | |
289 | /* VFP floating point model. */ | |
290 | ARM_FP_MODEL_VFP | |
291 | }; | |
292 | ||
293 | extern enum arm_fp_model arm_fp_model; | |
294 | ||
295 | /* Which floating point hardware is available. Also update | |
296 | fp_model_for_fpu in arm.c when adding entries to this list. */ | |
29ad9694 | 297 | enum fputype |
24f0c1b4 | 298 | { |
9b66ebb1 PB |
299 | /* No FP hardware. */ |
300 | FPUTYPE_NONE, | |
29ad9694 RE |
301 | /* Full FPA support. */ |
302 | FPUTYPE_FPA, | |
303 | /* Emulated FPA hardware, Issue 2 emulator (no LFM/SFM). */ | |
304 | FPUTYPE_FPA_EMU2, | |
305 | /* Emulated FPA hardware, Issue 3 emulator. */ | |
306 | FPUTYPE_FPA_EMU3, | |
307 | /* Cirrus Maverick floating point co-processor. */ | |
9b66ebb1 PB |
308 | FPUTYPE_MAVERICK, |
309 | /* VFP. */ | |
f1adb0a9 | 310 | FPUTYPE_VFP, |
302c3d8e PB |
311 | /* VFPv3-D16. */ |
312 | FPUTYPE_VFP3D16, | |
f1adb0a9 | 313 | /* VFPv3. */ |
88f77cba JB |
314 | FPUTYPE_VFP3, |
315 | /* Neon. */ | |
0fd8c3ad SL |
316 | FPUTYPE_NEON, |
317 | /* Neon with half-precision float extensions. */ | |
318 | FPUTYPE_NEON_FP16 | |
24f0c1b4 RE |
319 | }; |
320 | ||
321 | /* Recast the floating point class to be the floating point attribute. */ | |
29ad9694 | 322 | #define arm_fpu_attr ((enum attr_fpu) arm_fpu_tune) |
24f0c1b4 | 323 | |
71791e16 | 324 | /* What type of floating point to tune for */ |
29ad9694 | 325 | extern enum fputype arm_fpu_tune; |
24f0c1b4 | 326 | |
71791e16 | 327 | /* What type of floating point instructions are available */ |
29ad9694 | 328 | extern enum fputype arm_fpu_arch; |
71791e16 | 329 | |
9b66ebb1 PB |
330 | enum float_abi_type |
331 | { | |
332 | ARM_FLOAT_ABI_SOFT, | |
333 | ARM_FLOAT_ABI_SOFTFP, | |
334 | ARM_FLOAT_ABI_HARD | |
335 | }; | |
336 | ||
337 | extern enum float_abi_type arm_float_abi; | |
338 | ||
3d8532aa PB |
339 | #ifndef TARGET_DEFAULT_FLOAT_ABI |
340 | #define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT | |
341 | #endif | |
342 | ||
0fd8c3ad SL |
343 | /* Which __fp16 format to use. |
344 | The enumeration values correspond to the numbering for the | |
345 | Tag_ABI_FP_16bit_format attribute. | |
346 | */ | |
347 | enum arm_fp16_format_type | |
348 | { | |
349 | ARM_FP16_FORMAT_NONE = 0, | |
350 | ARM_FP16_FORMAT_IEEE = 1, | |
351 | ARM_FP16_FORMAT_ALTERNATIVE = 2 | |
352 | }; | |
353 | ||
354 | extern enum arm_fp16_format_type arm_fp16_format; | |
355 | #define LARGEST_EXPONENT_IS_NORMAL(bits) \ | |
356 | ((bits) == 16 && arm_fp16_format == ARM_FP16_FORMAT_ALTERNATIVE) | |
357 | ||
5848830f PB |
358 | /* Which ABI to use. */ |
359 | enum arm_abi_type | |
360 | { | |
361 | ARM_ABI_APCS, | |
362 | ARM_ABI_ATPCS, | |
363 | ARM_ABI_AAPCS, | |
077fc835 KH |
364 | ARM_ABI_IWMMXT, |
365 | ARM_ABI_AAPCS_LINUX | |
5848830f PB |
366 | }; |
367 | ||
368 | extern enum arm_abi_type arm_abi; | |
369 | ||
370 | #ifndef ARM_DEFAULT_ABI | |
371 | #define ARM_DEFAULT_ABI ARM_ABI_APCS | |
372 | #endif | |
373 | ||
d3585b76 DJ |
374 | /* Which thread pointer access sequence to use. */ |
375 | enum arm_tp_type { | |
376 | TP_AUTO, | |
377 | TP_SOFT, | |
378 | TP_CP15 | |
379 | }; | |
380 | ||
381 | extern enum arm_tp_type target_thread_pointer; | |
382 | ||
9b66ebb1 PB |
383 | /* Nonzero if this chip supports the ARM Architecture 3M extensions. */ |
384 | extern int arm_arch3m; | |
11c1a207 | 385 | |
9b66ebb1 | 386 | /* Nonzero if this chip supports the ARM Architecture 4 extensions. */ |
11c1a207 RE |
387 | extern int arm_arch4; |
388 | ||
68d560d4 RE |
389 | /* Nonzero if this chip supports the ARM Architecture 4T extensions. */ |
390 | extern int arm_arch4t; | |
391 | ||
9b66ebb1 | 392 | /* Nonzero if this chip supports the ARM Architecture 5 extensions. */ |
62b10bbc NC |
393 | extern int arm_arch5; |
394 | ||
9b66ebb1 | 395 | /* Nonzero if this chip supports the ARM Architecture 5E extensions. */ |
b15bca31 RE |
396 | extern int arm_arch5e; |
397 | ||
9b66ebb1 PB |
398 | /* Nonzero if this chip supports the ARM Architecture 6 extensions. */ |
399 | extern int arm_arch6; | |
400 | ||
5b3e6663 PB |
401 | /* Nonzero if instructions not present in the 'M' profile can be used. */ |
402 | extern int arm_arch_notm; | |
403 | ||
f5a1b0d2 NC |
404 | /* Nonzero if this chip can benefit from load scheduling. */ |
405 | extern int arm_ld_sched; | |
406 | ||
0616531f RE |
407 | /* Nonzero if generating thumb code. */ |
408 | extern int thumb_code; | |
409 | ||
f5a1b0d2 | 410 | /* Nonzero if this chip is a StrongARM. */ |
abac3b49 | 411 | extern int arm_tune_strongarm; |
f5a1b0d2 | 412 | |
9b6b54e2 | 413 | /* Nonzero if this chip is a Cirrus variant. */ |
78011587 | 414 | extern int arm_arch_cirrus; |
9b6b54e2 | 415 | |
5a9335ef NC |
416 | /* Nonzero if this chip supports Intel XScale with Wireless MMX technology. */ |
417 | extern int arm_arch_iwmmxt; | |
418 | ||
d19fb8e3 | 419 | /* Nonzero if this chip is an XScale. */ |
4b3c2e48 PB |
420 | extern int arm_arch_xscale; |
421 | ||
abac3b49 | 422 | /* Nonzero if tuning for XScale. */ |
4b3c2e48 | 423 | extern int arm_tune_xscale; |
d19fb8e3 | 424 | |
abac3b49 RE |
425 | /* Nonzero if tuning for stores via the write buffer. */ |
426 | extern int arm_tune_wbuf; | |
f5a1b0d2 | 427 | |
7612f14d PB |
428 | /* Nonzero if tuning for Cortex-A9. */ |
429 | extern int arm_tune_cortex_a9; | |
430 | ||
2ad4dcf9 | 431 | /* Nonzero if we should define __THUMB_INTERWORK__ in the |
f676971a | 432 | preprocessor. |
2ad4dcf9 RE |
433 | XXX This is a bit of a hack, it's intended to help work around |
434 | problems in GLD which doesn't understand that armv5t code is | |
435 | interworking clean. */ | |
436 | extern int arm_cpp_interwork; | |
437 | ||
5b3e6663 PB |
438 | /* Nonzero if chip supports Thumb 2. */ |
439 | extern int arm_arch_thumb2; | |
440 | ||
441 | /* Nonzero if chip supports integer division instruction. */ | |
442 | extern int arm_arch_hwdiv; | |
443 | ||
2ce9c1b9 | 444 | #ifndef TARGET_DEFAULT |
c54c7322 | 445 | #define TARGET_DEFAULT (MASK_APCS_FRAME) |
2ce9c1b9 | 446 | #endif |
35d965d5 | 447 | |
11c1a207 RE |
448 | /* The frame pointer register used in gcc has nothing to do with debugging; |
449 | that is controlled by the APCS-FRAME option. */ | |
d5b7b3ae | 450 | #define CAN_DEBUG_WITHOUT_FP |
35d965d5 | 451 | |
11c1a207 | 452 | #define OVERRIDE_OPTIONS arm_override_options () |
86efdc8e | 453 | |
f67358da PB |
454 | #define OPTIMIZATION_OPTIONS(LEVEL,SIZE) \ |
455 | arm_optimization_options ((LEVEL), (SIZE)) | |
456 | ||
86efdc8e PB |
457 | /* Nonzero if PIC code requires explicit qualifiers to generate |
458 | PLT and GOT relocs rather than the assembler doing so implicitly. | |
ed0e6530 PB |
459 | Subtargets can override these if required. */ |
460 | #ifndef NEED_GOT_RELOC | |
461 | #define NEED_GOT_RELOC 0 | |
462 | #endif | |
463 | #ifndef NEED_PLT_RELOC | |
464 | #define NEED_PLT_RELOC 0 | |
e2723c62 | 465 | #endif |
84306176 PB |
466 | |
467 | /* Nonzero if we need to refer to the GOT with a PC-relative | |
468 | offset. In other words, generate | |
469 | ||
f676971a | 470 | .word _GLOBAL_OFFSET_TABLE_ - [. - (.Lxx + 8)] |
84306176 PB |
471 | |
472 | rather than | |
473 | ||
474 | .word _GLOBAL_OFFSET_TABLE_ - (.Lxx + 8) | |
475 | ||
f676971a | 476 | The default is true, which matches NetBSD. Subtargets can |
84306176 PB |
477 | override this if required. */ |
478 | #ifndef GOT_PCREL | |
479 | #define GOT_PCREL 1 | |
480 | #endif | |
35d965d5 RS |
481 | \f |
482 | /* Target machine storage Layout. */ | |
483 | ||
ff9940b0 RE |
484 | |
485 | /* Define this macro if it is advisable to hold scalars in registers | |
486 | in a wider mode than that declared by the program. In such cases, | |
487 | the value is constrained to be within the bounds of the declared | |
488 | type, but kept valid in the wider mode. The signedness of the | |
489 | extension may differ from that of the type. */ | |
490 | ||
491 | /* It is far faster to zero extend chars than to sign extend them */ | |
492 | ||
6cfc7210 | 493 | #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \ |
2ce9c1b9 RE |
494 | if (GET_MODE_CLASS (MODE) == MODE_INT \ |
495 | && GET_MODE_SIZE (MODE) < 4) \ | |
496 | { \ | |
497 | if (MODE == QImode) \ | |
498 | UNSIGNEDP = 1; \ | |
499 | else if (MODE == HImode) \ | |
61f0ccff | 500 | UNSIGNEDP = 1; \ |
2ce9c1b9 | 501 | (MODE) = SImode; \ |
ff9940b0 RE |
502 | } |
503 | ||
35d965d5 RS |
504 | /* Define this if most significant bit is lowest numbered |
505 | in instructions that operate on numbered bit-fields. */ | |
506 | #define BITS_BIG_ENDIAN 0 | |
507 | ||
f676971a | 508 | /* Define this if most significant byte of a word is the lowest numbered. |
3ada8e17 DE |
509 | Most ARM processors are run in little endian mode, so that is the default. |
510 | If you want to have it run-time selectable, change the definition in a | |
511 | cover file to be TARGET_BIG_ENDIAN. */ | |
11c1a207 | 512 | #define BYTES_BIG_ENDIAN (TARGET_BIG_END != 0) |
35d965d5 RS |
513 | |
514 | /* Define this if most significant word of a multiword number is the lowest | |
11c1a207 RE |
515 | numbered. |
516 | This is always false, even when in big-endian mode. */ | |
ddee6aba RE |
517 | #define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN && ! TARGET_LITTLE_WORDS) |
518 | ||
519 | /* LIBGCC2_WORDS_BIG_ENDIAN has to be a constant, so we define this based | |
520 | on processor pre-defineds when compiling libgcc2.c. */ | |
521 | #if defined(__ARMEB__) && !defined(__ARMWEL__) | |
522 | #define LIBGCC2_WORDS_BIG_ENDIAN 1 | |
523 | #else | |
524 | #define LIBGCC2_WORDS_BIG_ENDIAN 0 | |
525 | #endif | |
35d965d5 | 526 | |
11c1a207 | 527 | /* Define this if most significant word of doubles is the lowest numbered. |
f0375c66 NC |
528 | The rules are different based on whether or not we use FPA-format, |
529 | VFP-format or some other floating point co-processor's format doubles. */ | |
b5b620a4 | 530 | #define FLOAT_WORDS_BIG_ENDIAN (arm_float_words_big_endian ()) |
7fc6c9f0 | 531 | |
35d965d5 RS |
532 | #define UNITS_PER_WORD 4 |
533 | ||
88f77cba JB |
534 | /* Use the option -mvectorize-with-neon-quad to override the use of doubleword |
535 | registers when autovectorizing for Neon, at least until multiple vector | |
536 | widths are supported properly by the middle-end. */ | |
9d3a9de1 | 537 | #define UNITS_PER_SIMD_WORD(MODE) \ |
88f77cba JB |
538 | (TARGET_NEON ? (TARGET_NEON_VECTORIZE_QUAD ? 16 : 8) : UNITS_PER_WORD) |
539 | ||
5848830f | 540 | /* True if natural alignment is used for doubleword types. */ |
b6685939 PB |
541 | #define ARM_DOUBLEWORD_ALIGN TARGET_AAPCS_BASED |
542 | ||
5848830f | 543 | #define DOUBLEWORD_ALIGNMENT 64 |
35d965d5 | 544 | |
5848830f | 545 | #define PARM_BOUNDARY 32 |
5a9335ef | 546 | |
5848830f | 547 | #define STACK_BOUNDARY (ARM_DOUBLEWORD_ALIGN ? DOUBLEWORD_ALIGNMENT : 32) |
35d965d5 | 548 | |
5848830f PB |
549 | #define PREFERRED_STACK_BOUNDARY \ |
550 | (arm_abi == ARM_ABI_ATPCS ? 64 : STACK_BOUNDARY) | |
0977774b | 551 | |
f711a87a | 552 | #define FUNCTION_BOUNDARY ((TARGET_THUMB && optimize_size) ? 16 : 32) |
35d965d5 | 553 | |
92928d71 AO |
554 | /* The lowest bit is used to indicate Thumb-mode functions, so the |
555 | vbit must go into the delta field of pointers to member | |
556 | functions. */ | |
557 | #define TARGET_PTRMEMFUNC_VBIT_LOCATION ptrmemfunc_vbit_in_delta | |
558 | ||
35d965d5 RS |
559 | #define EMPTY_FIELD_BOUNDARY 32 |
560 | ||
5848830f | 561 | #define BIGGEST_ALIGNMENT (ARM_DOUBLEWORD_ALIGN ? DOUBLEWORD_ALIGNMENT : 32) |
5a9335ef | 562 | |
27847754 NC |
563 | /* XXX Blah -- this macro is used directly by libobjc. Since it |
564 | supports no vector modes, cut out the complexity and fall back | |
565 | on BIGGEST_FIELD_ALIGNMENT. */ | |
566 | #ifdef IN_TARGET_LIBS | |
8fca31a2 | 567 | #define BIGGEST_FIELD_ALIGNMENT 64 |
27847754 | 568 | #endif |
5a9335ef | 569 | |
ff9940b0 | 570 | /* Make strings word-aligned so strcpy from constants will be faster. */ |
591af218 | 571 | #define CONSTANT_ALIGNMENT_FACTOR (TARGET_THUMB || ! arm_tune_xscale ? 1 : 2) |
f676971a | 572 | |
d19fb8e3 | 573 | #define CONSTANT_ALIGNMENT(EXP, ALIGN) \ |
5848830f | 574 | ((TREE_CODE (EXP) == STRING_CST \ |
36b15ad0 | 575 | && !optimize_size \ |
5848830f PB |
576 | && (ALIGN) < BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR) \ |
577 | ? BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR : (ALIGN)) | |
ff9940b0 | 578 | |
96339268 RE |
579 | /* Align definitions of arrays, unions and structures so that |
580 | initializations and copies can be made more efficient. This is not | |
581 | ABI-changing, so it only affects places where we can see the | |
582 | definition. */ | |
583 | #define DATA_ALIGNMENT(EXP, ALIGN) \ | |
584 | ((((ALIGN) < BITS_PER_WORD) \ | |
585 | && (TREE_CODE (EXP) == ARRAY_TYPE \ | |
586 | || TREE_CODE (EXP) == UNION_TYPE \ | |
587 | || TREE_CODE (EXP) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN)) | |
588 | ||
589 | /* Similarly, make sure that objects on the stack are sensibly aligned. */ | |
590 | #define LOCAL_ALIGNMENT(EXP, ALIGN) DATA_ALIGNMENT(EXP, ALIGN) | |
591 | ||
723ae7c1 NC |
592 | /* Setting STRUCTURE_SIZE_BOUNDARY to 32 produces more efficient code, but the |
593 | value set in previous versions of this toolchain was 8, which produces more | |
594 | compact structures. The command line option -mstructure_size_boundary=<n> | |
f710504c | 595 | can be used to change this value. For compatibility with the ARM SDK |
723ae7c1 | 596 | however the value should be left at 32. ARM SDT Reference Manual (ARM DUI |
5848830f PB |
597 | 0020D) page 2-20 says "Structures are aligned on word boundaries". |
598 | The AAPCS specifies a value of 8. */ | |
6ead9ba5 NC |
599 | #define STRUCTURE_SIZE_BOUNDARY arm_structure_size_boundary |
600 | extern int arm_structure_size_boundary; | |
723ae7c1 | 601 | |
4912a07c | 602 | /* This is the value used to initialize arm_structure_size_boundary. If a |
723ae7c1 | 603 | particular arm target wants to change the default value it should change |
6bc82793 | 604 | the definition of this macro, not STRUCTURE_SIZE_BOUNDARY. See netbsd.h |
723ae7c1 NC |
605 | for an example of this. */ |
606 | #ifndef DEFAULT_STRUCTURE_SIZE_BOUNDARY | |
607 | #define DEFAULT_STRUCTURE_SIZE_BOUNDARY 32 | |
b355a481 | 608 | #endif |
2a5307b1 | 609 | |
825dda42 | 610 | /* Nonzero if move instructions will actually fail to work |
ff9940b0 | 611 | when given unaligned data. */ |
35d965d5 | 612 | #define STRICT_ALIGNMENT 1 |
b6685939 PB |
613 | |
614 | /* wchar_t is unsigned under the AAPCS. */ | |
615 | #ifndef WCHAR_TYPE | |
616 | #define WCHAR_TYPE (TARGET_AAPCS_BASED ? "unsigned int" : "int") | |
617 | ||
618 | #define WCHAR_TYPE_SIZE BITS_PER_WORD | |
619 | #endif | |
620 | ||
621 | #ifndef SIZE_TYPE | |
622 | #define SIZE_TYPE (TARGET_AAPCS_BASED ? "unsigned int" : "long unsigned int") | |
623 | #endif | |
d81d0bdd | 624 | |
077fc835 KH |
625 | #ifndef PTRDIFF_TYPE |
626 | #define PTRDIFF_TYPE (TARGET_AAPCS_BASED ? "int" : "long int") | |
627 | #endif | |
628 | ||
d81d0bdd PB |
629 | /* AAPCS requires that structure alignment is affected by bitfields. */ |
630 | #ifndef PCC_BITFIELD_TYPE_MATTERS | |
631 | #define PCC_BITFIELD_TYPE_MATTERS TARGET_AAPCS_BASED | |
632 | #endif | |
633 | ||
35d965d5 RS |
634 | \f |
635 | /* Standard register usage. */ | |
636 | ||
637 | /* Register allocation in ARM Procedure Call Standard (as used on RISCiX): | |
638 | (S - saved over call). | |
639 | ||
640 | r0 * argument word/integer result | |
641 | r1-r3 argument word | |
642 | ||
643 | r4-r8 S register variable | |
644 | r9 S (rfp) register variable (real frame pointer) | |
f676971a | 645 | |
f5a1b0d2 | 646 | r10 F S (sl) stack limit (used by -mapcs-stack-check) |
35d965d5 RS |
647 | r11 F S (fp) argument pointer |
648 | r12 (ip) temp workspace | |
649 | r13 F S (sp) lower end of current stack frame | |
650 | r14 (lr) link address/workspace | |
651 | r15 F (pc) program counter | |
652 | ||
653 | f0 floating point result | |
654 | f1-f3 floating point scratch | |
655 | ||
656 | f4-f7 S floating point variable | |
657 | ||
ff9940b0 RE |
658 | cc This is NOT a real register, but is used internally |
659 | to represent things that use or set the condition | |
660 | codes. | |
661 | sfp This isn't either. It is used during rtl generation | |
662 | since the offset between the frame pointer and the | |
663 | auto's isn't known until after register allocation. | |
664 | afp Nor this, we only need this because of non-local | |
665 | goto. Without it fp appears to be used and the | |
666 | elimination code won't get rid of sfp. It tracks | |
667 | fp exactly at all times. | |
668 | ||
35d965d5 RS |
669 | *: See CONDITIONAL_REGISTER_USAGE */ |
670 | ||
9b6b54e2 NC |
671 | /* |
672 | mvf0 Cirrus floating point result | |
673 | mvf1-mvf3 Cirrus floating point scratch | |
674 | mvf4-mvf15 S Cirrus floating point variable. */ | |
675 | ||
9b66ebb1 PB |
676 | /* s0-s15 VFP scratch (aka d0-d7). |
677 | s16-s31 S VFP variable (aka d8-d15). | |
678 | vfpcc Not a real register. Represents the VFP condition | |
679 | code flags. */ | |
680 | ||
ff9940b0 RE |
681 | /* The stack backtrace structure is as follows: |
682 | fp points to here: | save code pointer | [fp] | |
683 | | return link value | [fp, #-4] | |
684 | | return sp value | [fp, #-8] | |
685 | | return fp value | [fp, #-12] | |
686 | [| saved r10 value |] | |
687 | [| saved r9 value |] | |
688 | [| saved r8 value |] | |
689 | [| saved r7 value |] | |
690 | [| saved r6 value |] | |
691 | [| saved r5 value |] | |
692 | [| saved r4 value |] | |
693 | [| saved r3 value |] | |
694 | [| saved r2 value |] | |
695 | [| saved r1 value |] | |
696 | [| saved r0 value |] | |
697 | [| saved f7 value |] three words | |
698 | [| saved f6 value |] three words | |
699 | [| saved f5 value |] three words | |
700 | [| saved f4 value |] three words | |
701 | r0-r3 are not normally saved in a C function. */ | |
702 | ||
35d965d5 RS |
703 | /* 1 for registers that have pervasive standard uses |
704 | and are not available for the register allocator. */ | |
9b66ebb1 PB |
705 | #define FIXED_REGISTERS \ |
706 | { \ | |
707 | 0,0,0,0,0,0,0,0, \ | |
708 | 0,0,0,0,0,1,0,1, \ | |
709 | 0,0,0,0,0,0,0,0, \ | |
9b6b54e2 NC |
710 | 1,1,1, \ |
711 | 1,1,1,1,1,1,1,1, \ | |
9b66ebb1 PB |
712 | 1,1,1,1,1,1,1,1, \ |
713 | 1,1,1,1,1,1,1,1, \ | |
714 | 1,1,1,1,1,1,1,1, \ | |
715 | 1,1,1,1, \ | |
716 | 1,1,1,1,1,1,1,1, \ | |
717 | 1,1,1,1,1,1,1,1, \ | |
718 | 1,1,1,1,1,1,1,1, \ | |
719 | 1,1,1,1,1,1,1,1, \ | |
f1adb0a9 JB |
720 | 1,1,1,1,1,1,1,1, \ |
721 | 1,1,1,1,1,1,1,1, \ | |
722 | 1,1,1,1,1,1,1,1, \ | |
723 | 1,1,1,1,1,1,1,1, \ | |
9b66ebb1 | 724 | 1 \ |
35d965d5 RS |
725 | } |
726 | ||
727 | /* 1 for registers not available across function calls. | |
728 | These must include the FIXED_REGISTERS and also any | |
729 | registers that can be used without being saved. | |
730 | The latter must include the registers where values are returned | |
731 | and the register where structure-value addresses are passed. | |
ff9940b0 | 732 | Aside from that, you can include as many other registers as you like. |
f676971a | 733 | The CC is not preserved over function calls on the ARM 6, so it is |
d6b4baa4 | 734 | easier to assume this for all. SFP is preserved, since FP is. */ |
35d965d5 RS |
735 | #define CALL_USED_REGISTERS \ |
736 | { \ | |
737 | 1,1,1,1,0,0,0,0, \ | |
d5b7b3ae | 738 | 0,0,0,0,1,1,1,1, \ |
ff9940b0 | 739 | 1,1,1,1,0,0,0,0, \ |
9b6b54e2 NC |
740 | 1,1,1, \ |
741 | 1,1,1,1,1,1,1,1, \ | |
5a9335ef NC |
742 | 1,1,1,1,1,1,1,1, \ |
743 | 1,1,1,1,1,1,1,1, \ | |
744 | 1,1,1,1,1,1,1,1, \ | |
9b66ebb1 PB |
745 | 1,1,1,1, \ |
746 | 1,1,1,1,1,1,1,1, \ | |
747 | 1,1,1,1,1,1,1,1, \ | |
748 | 1,1,1,1,1,1,1,1, \ | |
749 | 1,1,1,1,1,1,1,1, \ | |
f1adb0a9 JB |
750 | 1,1,1,1,1,1,1,1, \ |
751 | 1,1,1,1,1,1,1,1, \ | |
752 | 1,1,1,1,1,1,1,1, \ | |
753 | 1,1,1,1,1,1,1,1, \ | |
9b66ebb1 | 754 | 1 \ |
35d965d5 RS |
755 | } |
756 | ||
6cc8c0b3 NC |
757 | #ifndef SUBTARGET_CONDITIONAL_REGISTER_USAGE |
758 | #define SUBTARGET_CONDITIONAL_REGISTER_USAGE | |
759 | #endif | |
760 | ||
d5b7b3ae RE |
761 | #define CONDITIONAL_REGISTER_USAGE \ |
762 | { \ | |
4b02997f NC |
763 | int regno; \ |
764 | \ | |
5b3e6663 | 765 | if (TARGET_SOFT_FLOAT || TARGET_THUMB1 || !TARGET_FPA) \ |
d5b7b3ae | 766 | { \ |
9b66ebb1 PB |
767 | for (regno = FIRST_FPA_REGNUM; \ |
768 | regno <= LAST_FPA_REGNUM; ++regno) \ | |
d5b7b3ae RE |
769 | fixed_regs[regno] = call_used_regs[regno] = 1; \ |
770 | } \ | |
9b6b54e2 | 771 | \ |
c769a35d RE |
772 | if (TARGET_THUMB && optimize_size) \ |
773 | { \ | |
774 | /* When optimizing for size, it's better not to use \ | |
775 | the HI regs, because of the overhead of stacking \ | |
d6b4baa4 | 776 | them. */ \ |
5b3e6663 | 777 | /* ??? Is this still true for thumb2? */ \ |
c769a35d RE |
778 | for (regno = FIRST_HI_REGNUM; \ |
779 | regno <= LAST_HI_REGNUM; ++regno) \ | |
780 | fixed_regs[regno] = call_used_regs[regno] = 1; \ | |
781 | } \ | |
782 | \ | |
fb14bc89 RE |
783 | /* The link register can be clobbered by any branch insn, \ |
784 | but we have no way to track that at present, so mark \ | |
785 | it as unavailable. */ \ | |
5b3e6663 | 786 | if (TARGET_THUMB1) \ |
fb14bc89 RE |
787 | fixed_regs[LR_REGNUM] = call_used_regs[LR_REGNUM] = 1; \ |
788 | \ | |
5b3e6663 | 789 | if (TARGET_32BIT && TARGET_HARD_FLOAT) \ |
9b6b54e2 | 790 | { \ |
9b66ebb1 | 791 | if (TARGET_MAVERICK) \ |
9b6b54e2 | 792 | { \ |
9b66ebb1 PB |
793 | for (regno = FIRST_FPA_REGNUM; \ |
794 | regno <= LAST_FPA_REGNUM; ++ regno) \ | |
795 | fixed_regs[regno] = call_used_regs[regno] = 1; \ | |
796 | for (regno = FIRST_CIRRUS_FP_REGNUM; \ | |
797 | regno <= LAST_CIRRUS_FP_REGNUM; ++ regno) \ | |
798 | { \ | |
799 | fixed_regs[regno] = 0; \ | |
800 | call_used_regs[regno] = regno < FIRST_CIRRUS_FP_REGNUM + 4; \ | |
801 | } \ | |
802 | } \ | |
803 | if (TARGET_VFP) \ | |
804 | { \ | |
f1adb0a9 JB |
805 | /* VFPv3 registers are disabled when earlier VFP \ |
806 | versions are selected due to the definition of \ | |
807 | LAST_VFP_REGNUM. */ \ | |
9b66ebb1 PB |
808 | for (regno = FIRST_VFP_REGNUM; \ |
809 | regno <= LAST_VFP_REGNUM; ++ regno) \ | |
810 | { \ | |
811 | fixed_regs[regno] = 0; \ | |
f1adb0a9 JB |
812 | call_used_regs[regno] = regno < FIRST_VFP_REGNUM + 16 \ |
813 | || regno >= FIRST_VFP_REGNUM + 32; \ | |
9b66ebb1 | 814 | } \ |
9b6b54e2 NC |
815 | } \ |
816 | } \ | |
817 | \ | |
5a9335ef NC |
818 | if (TARGET_REALLY_IWMMXT) \ |
819 | { \ | |
820 | regno = FIRST_IWMMXT_GR_REGNUM; \ | |
821 | /* The 2002/10/09 revision of the XScale ABI has wCG0 \ | |
822 | and wCG1 as call-preserved registers. The 2002/11/21 \ | |
823 | revision changed this so that all wCG registers are \ | |
824 | scratch registers. */ \ | |
825 | for (regno = FIRST_IWMMXT_GR_REGNUM; \ | |
826 | regno <= LAST_IWMMXT_GR_REGNUM; ++ regno) \ | |
119bb233 | 827 | fixed_regs[regno] = 0; \ |
5a9335ef NC |
828 | /* The XScale ABI has wR0 - wR9 as scratch registers, \ |
829 | the rest as call-preserved registers. */ \ | |
830 | for (regno = FIRST_IWMMXT_REGNUM; \ | |
831 | regno <= LAST_IWMMXT_REGNUM; ++ regno) \ | |
832 | { \ | |
833 | fixed_regs[regno] = 0; \ | |
834 | call_used_regs[regno] = regno < FIRST_IWMMXT_REGNUM + 10; \ | |
835 | } \ | |
836 | } \ | |
837 | \ | |
fc555370 | 838 | if ((unsigned) PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) \ |
d5b7b3ae RE |
839 | { \ |
840 | fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ | |
841 | call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ | |
842 | } \ | |
843 | else if (TARGET_APCS_STACK) \ | |
844 | { \ | |
845 | fixed_regs[10] = 1; \ | |
846 | call_used_regs[10] = 1; \ | |
847 | } \ | |
a2503645 RS |
848 | /* -mcaller-super-interworking reserves r11 for calls to \ |
849 | _interwork_r11_call_via_rN(). Making the register global \ | |
850 | is an easy way of ensuring that it remains valid for all \ | |
851 | calls. */ \ | |
685c9c11 | 852 | if (TARGET_APCS_FRAME || TARGET_CALLER_INTERWORKING \ |
c54c7322 | 853 | || TARGET_TPCS_FRAME || TARGET_TPCS_LEAF_FRAME) \ |
d5b7b3ae RE |
854 | { \ |
855 | fixed_regs[ARM_HARD_FRAME_POINTER_REGNUM] = 1; \ | |
856 | call_used_regs[ARM_HARD_FRAME_POINTER_REGNUM] = 1; \ | |
a2503645 RS |
857 | if (TARGET_CALLER_INTERWORKING) \ |
858 | global_regs[ARM_HARD_FRAME_POINTER_REGNUM] = 1; \ | |
d5b7b3ae RE |
859 | } \ |
860 | SUBTARGET_CONDITIONAL_REGISTER_USAGE \ | |
35d965d5 | 861 | } |
f676971a | 862 | |
6bc82793 | 863 | /* These are a couple of extensions to the formats accepted |
dd18ae56 NC |
864 | by asm_fprintf: |
865 | %@ prints out ASM_COMMENT_START | |
866 | %r prints out REGISTER_PREFIX reg_names[arg] */ | |
867 | #define ASM_FPRINTF_EXTENSIONS(FILE, ARGS, P) \ | |
868 | case '@': \ | |
869 | fputs (ASM_COMMENT_START, FILE); \ | |
870 | break; \ | |
871 | \ | |
872 | case 'r': \ | |
873 | fputs (REGISTER_PREFIX, FILE); \ | |
874 | fputs (reg_names [va_arg (ARGS, int)], FILE); \ | |
875 | break; | |
876 | ||
d5b7b3ae | 877 | /* Round X up to the nearest word. */ |
0c2ca901 | 878 | #define ROUND_UP_WORD(X) (((X) + 3) & ~3) |
d5b7b3ae | 879 | |
6cfc7210 | 880 | /* Convert fron bytes to ints. */ |
e9d7b180 | 881 | #define ARM_NUM_INTS(X) (((X) + UNITS_PER_WORD - 1) / UNITS_PER_WORD) |
6cfc7210 | 882 | |
9b66ebb1 PB |
883 | /* The number of (integer) registers required to hold a quantity of type MODE. |
884 | Also used for VFP registers. */ | |
e9d7b180 JD |
885 | #define ARM_NUM_REGS(MODE) \ |
886 | ARM_NUM_INTS (GET_MODE_SIZE (MODE)) | |
6cfc7210 NC |
887 | |
888 | /* The number of (integer) registers required to hold a quantity of TYPE MODE. */ | |
e9d7b180 JD |
889 | #define ARM_NUM_REGS2(MODE, TYPE) \ |
890 | ARM_NUM_INTS ((MODE) == BLKmode ? \ | |
d5b7b3ae | 891 | int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE)) |
6cfc7210 NC |
892 | |
893 | /* The number of (integer) argument register available. */ | |
d5b7b3ae | 894 | #define NUM_ARG_REGS 4 |
6cfc7210 | 895 | |
390b17c2 RE |
896 | /* And similarly for the VFP. */ |
897 | #define NUM_VFP_ARG_REGS 16 | |
898 | ||
093354e0 | 899 | /* Return the register number of the N'th (integer) argument. */ |
d5b7b3ae | 900 | #define ARG_REGISTER(N) (N - 1) |
6cfc7210 | 901 | |
d5b7b3ae RE |
902 | /* Specify the registers used for certain standard purposes. |
903 | The values of these macros are register numbers. */ | |
35d965d5 | 904 | |
d5b7b3ae RE |
905 | /* The number of the last argument register. */ |
906 | #define LAST_ARG_REGNUM ARG_REGISTER (NUM_ARG_REGS) | |
35d965d5 | 907 | |
c769a35d RE |
908 | /* The numbers of the Thumb register ranges. */ |
909 | #define FIRST_LO_REGNUM 0 | |
6d3d9133 | 910 | #define LAST_LO_REGNUM 7 |
c769a35d RE |
911 | #define FIRST_HI_REGNUM 8 |
912 | #define LAST_HI_REGNUM 11 | |
6d3d9133 | 913 | |
617a1b71 | 914 | #ifndef TARGET_UNWIND_INFO |
c9ca9b88 PB |
915 | /* We use sjlj exceptions for backwards compatibility. */ |
916 | #define MUST_USE_SJLJ_EXCEPTIONS 1 | |
617a1b71 PB |
917 | #endif |
918 | ||
c9ca9b88 PB |
919 | /* We can generate DWARF2 Unwind info, even though we don't use it. */ |
920 | #define DWARF2_UNWIND_INFO 1 | |
f676971a | 921 | |
c9ca9b88 PB |
922 | /* Use r0 and r1 to pass exception handling information. */ |
923 | #define EH_RETURN_DATA_REGNO(N) (((N) < 2) ? N : INVALID_REGNUM) | |
924 | ||
6d3d9133 | 925 | /* The register that holds the return address in exception handlers. */ |
c9ca9b88 PB |
926 | #define ARM_EH_STACKADJ_REGNUM 2 |
927 | #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (SImode, ARM_EH_STACKADJ_REGNUM) | |
35d965d5 | 928 | |
d5b7b3ae RE |
929 | /* The native (Norcroft) Pascal compiler for the ARM passes the static chain |
930 | as an invisible last argument (possible since varargs don't exist in | |
931 | Pascal), so the following is not true. */ | |
5b3e6663 | 932 | #define STATIC_CHAIN_REGNUM 12 |
35d965d5 | 933 | |
d5b7b3ae RE |
934 | /* Define this to be where the real frame pointer is if it is not possible to |
935 | work out the offset between the frame pointer and the automatic variables | |
936 | until after register allocation has taken place. FRAME_POINTER_REGNUM | |
937 | should point to a special register that we will make sure is eliminated. | |
938 | ||
939 | For the Thumb we have another problem. The TPCS defines the frame pointer | |
6bc82793 | 940 | as r11, and GCC believes that it is always possible to use the frame pointer |
d5b7b3ae RE |
941 | as base register for addressing purposes. (See comments in |
942 | find_reloads_address()). But - the Thumb does not allow high registers, | |
943 | including r11, to be used as base address registers. Hence our problem. | |
944 | ||
945 | The solution used here, and in the old thumb port is to use r7 instead of | |
946 | r11 as the hard frame pointer and to have special code to generate | |
947 | backtrace structures on the stack (if required to do so via a command line | |
6bc82793 | 948 | option) using r11. This is the only 'user visible' use of r11 as a frame |
d5b7b3ae RE |
949 | pointer. */ |
950 | #define ARM_HARD_FRAME_POINTER_REGNUM 11 | |
951 | #define THUMB_HARD_FRAME_POINTER_REGNUM 7 | |
35d965d5 | 952 | |
b15bca31 RE |
953 | #define HARD_FRAME_POINTER_REGNUM \ |
954 | (TARGET_ARM \ | |
955 | ? ARM_HARD_FRAME_POINTER_REGNUM \ | |
956 | : THUMB_HARD_FRAME_POINTER_REGNUM) | |
d5b7b3ae | 957 | |
b15bca31 | 958 | #define FP_REGNUM HARD_FRAME_POINTER_REGNUM |
d5b7b3ae | 959 | |
b15bca31 RE |
960 | /* Register to use for pushing function arguments. */ |
961 | #define STACK_POINTER_REGNUM SP_REGNUM | |
d5b7b3ae RE |
962 | |
963 | /* ARM floating pointer registers. */ | |
9b66ebb1 PB |
964 | #define FIRST_FPA_REGNUM 16 |
965 | #define LAST_FPA_REGNUM 23 | |
2fa330b2 PB |
966 | #define IS_FPA_REGNUM(REGNUM) \ |
967 | (((REGNUM) >= FIRST_FPA_REGNUM) && ((REGNUM) <= LAST_FPA_REGNUM)) | |
d5b7b3ae | 968 | |
5a9335ef NC |
969 | #define FIRST_IWMMXT_GR_REGNUM 43 |
970 | #define LAST_IWMMXT_GR_REGNUM 46 | |
971 | #define FIRST_IWMMXT_REGNUM 47 | |
972 | #define LAST_IWMMXT_REGNUM 62 | |
973 | #define IS_IWMMXT_REGNUM(REGNUM) \ | |
974 | (((REGNUM) >= FIRST_IWMMXT_REGNUM) && ((REGNUM) <= LAST_IWMMXT_REGNUM)) | |
975 | #define IS_IWMMXT_GR_REGNUM(REGNUM) \ | |
976 | (((REGNUM) >= FIRST_IWMMXT_GR_REGNUM) && ((REGNUM) <= LAST_IWMMXT_GR_REGNUM)) | |
977 | ||
35d965d5 | 978 | /* Base register for access to local variables of the function. */ |
ff9940b0 RE |
979 | #define FRAME_POINTER_REGNUM 25 |
980 | ||
d5b7b3ae RE |
981 | /* Base register for access to arguments of the function. */ |
982 | #define ARG_POINTER_REGNUM 26 | |
62b10bbc | 983 | |
9b6b54e2 NC |
984 | #define FIRST_CIRRUS_FP_REGNUM 27 |
985 | #define LAST_CIRRUS_FP_REGNUM 42 | |
986 | #define IS_CIRRUS_REGNUM(REGNUM) \ | |
987 | (((REGNUM) >= FIRST_CIRRUS_FP_REGNUM) && ((REGNUM) <= LAST_CIRRUS_FP_REGNUM)) | |
988 | ||
9b66ebb1 | 989 | #define FIRST_VFP_REGNUM 63 |
f1adb0a9 JB |
990 | #define D7_VFP_REGNUM 78 /* Registers 77 and 78 == VFP reg D7. */ |
991 | #define LAST_VFP_REGNUM \ | |
302c3d8e | 992 | (TARGET_VFPD32 ? LAST_HI_VFP_REGNUM : LAST_LO_VFP_REGNUM) |
f1adb0a9 | 993 | |
9b66ebb1 PB |
994 | #define IS_VFP_REGNUM(REGNUM) \ |
995 | (((REGNUM) >= FIRST_VFP_REGNUM) && ((REGNUM) <= LAST_VFP_REGNUM)) | |
996 | ||
f1adb0a9 JB |
997 | /* VFP registers are split into two types: those defined by VFP versions < 3 |
998 | have D registers overlaid on consecutive pairs of S registers. VFP version 3 | |
999 | defines 16 new D registers (d16-d31) which, for simplicity and correctness | |
1000 | in various parts of the backend, we implement as "fake" single-precision | |
1001 | registers (which would be S32-S63, but cannot be used in that way). The | |
1002 | following macros define these ranges of registers. */ | |
1003 | #define LAST_LO_VFP_REGNUM 94 | |
1004 | #define FIRST_HI_VFP_REGNUM 95 | |
1005 | #define LAST_HI_VFP_REGNUM 126 | |
1006 | ||
1007 | #define VFP_REGNO_OK_FOR_SINGLE(REGNUM) \ | |
1008 | ((REGNUM) <= LAST_LO_VFP_REGNUM) | |
1009 | ||
1010 | /* DFmode values are only valid in even register pairs. */ | |
1011 | #define VFP_REGNO_OK_FOR_DOUBLE(REGNUM) \ | |
1012 | ((((REGNUM) - FIRST_VFP_REGNUM) & 1) == 0) | |
1013 | ||
88f77cba JB |
1014 | /* Neon Quad values must start at a multiple of four registers. */ |
1015 | #define NEON_REGNO_OK_FOR_QUAD(REGNUM) \ | |
1016 | ((((REGNUM) - FIRST_VFP_REGNUM) & 3) == 0) | |
1017 | ||
1018 | /* Neon structures of vectors must be in even register pairs and there | |
1019 | must be enough registers available. Because of various patterns | |
1020 | requiring quad registers, we require them to start at a multiple of | |
1021 | four. */ | |
1022 | #define NEON_REGNO_OK_FOR_NREGS(REGNUM, N) \ | |
1023 | ((((REGNUM) - FIRST_VFP_REGNUM) & 3) == 0 \ | |
1024 | && (LAST_VFP_REGNUM - (REGNUM) >= 2 * (N) - 1)) | |
1025 | ||
6f8c9bd1 NC |
1026 | /* The number of hard registers is 16 ARM + 8 FPA + 1 CC + 1 SFP + 1 AFP. */ |
1027 | /* + 16 Cirrus registers take us up to 43. */ | |
5a9335ef | 1028 | /* Intel Wireless MMX Technology registers add 16 + 4 more. */ |
f1adb0a9 JB |
1029 | /* VFP (VFP3) adds 32 (64) + 1 more. */ |
1030 | #define FIRST_PSEUDO_REGISTER 128 | |
62b10bbc | 1031 | |
2fa330b2 PB |
1032 | #define DBX_REGISTER_NUMBER(REGNO) arm_dbx_register_number (REGNO) |
1033 | ||
35d965d5 RS |
1034 | /* Value should be nonzero if functions must have frame pointers. |
1035 | Zero means the frame pointer need not be set up (and parms may be accessed | |
f676971a | 1036 | via the stack pointer) in functions that seem suitable. |
ff9940b0 RE |
1037 | If we have to have a frame pointer we might as well make use of it. |
1038 | APCS says that the frame pointer does not need to be pushed in leaf | |
2a5307b1 | 1039 | functions, or simple tail call functions. */ |
a15900b5 DJ |
1040 | |
1041 | #ifndef SUBTARGET_FRAME_POINTER_REQUIRED | |
1042 | #define SUBTARGET_FRAME_POINTER_REQUIRED 0 | |
1043 | #endif | |
1044 | ||
d5b7b3ae RE |
1045 | /* Return number of consecutive hard regs needed starting at reg REGNO |
1046 | to hold something of mode MODE. | |
1047 | This is ordinarily the length in words of a value of mode MODE | |
1048 | but can be less for certain modes in special long registers. | |
35d965d5 | 1049 | |
3b684012 | 1050 | On the ARM regs are UNITS_PER_WORD bits wide; FPA regs can hold any FP |
d5b7b3ae RE |
1051 | mode. */ |
1052 | #define HARD_REGNO_NREGS(REGNO, MODE) \ | |
5b3e6663 | 1053 | ((TARGET_32BIT \ |
9b66ebb1 | 1054 | && REGNO >= FIRST_FPA_REGNUM \ |
d5b7b3ae RE |
1055 | && REGNO != FRAME_POINTER_REGNUM \ |
1056 | && REGNO != ARG_POINTER_REGNUM) \ | |
9b66ebb1 | 1057 | && !IS_VFP_REGNUM (REGNO) \ |
e9d7b180 | 1058 | ? 1 : ARM_NUM_REGS (MODE)) |
35d965d5 | 1059 | |
4b02997f | 1060 | /* Return true if REGNO is suitable for holding a quantity of type MODE. */ |
d5b7b3ae | 1061 | #define HARD_REGNO_MODE_OK(REGNO, MODE) \ |
4b02997f | 1062 | arm_hard_regno_mode_ok ((REGNO), (MODE)) |
35d965d5 | 1063 | |
d5b7b3ae RE |
1064 | /* Value is 1 if it is a good idea to tie two pseudo registers |
1065 | when one has mode MODE1 and one has mode MODE2. | |
1066 | If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2, | |
1067 | for any hard reg, then this must be 0 for correct output. */ | |
1068 | #define MODES_TIEABLE_P(MODE1, MODE2) \ | |
1069 | (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2)) | |
ff9940b0 | 1070 | |
5a9335ef | 1071 | #define VALID_IWMMXT_REG_MODE(MODE) \ |
f676971a | 1072 | (arm_vector_mode_supported_p (MODE) || (MODE) == DImode) |
5a9335ef | 1073 | |
88f77cba JB |
1074 | /* Modes valid for Neon D registers. */ |
1075 | #define VALID_NEON_DREG_MODE(MODE) \ | |
1076 | ((MODE) == V2SImode || (MODE) == V4HImode || (MODE) == V8QImode \ | |
1077 | || (MODE) == V2SFmode || (MODE) == DImode) | |
1078 | ||
1079 | /* Modes valid for Neon Q registers. */ | |
1080 | #define VALID_NEON_QREG_MODE(MODE) \ | |
1081 | ((MODE) == V4SImode || (MODE) == V8HImode || (MODE) == V16QImode \ | |
1082 | || (MODE) == V4SFmode || (MODE) == V2DImode) | |
1083 | ||
1084 | /* Structure modes valid for Neon registers. */ | |
1085 | #define VALID_NEON_STRUCT_MODE(MODE) \ | |
1086 | ((MODE) == TImode || (MODE) == EImode || (MODE) == OImode \ | |
1087 | || (MODE) == CImode || (MODE) == XImode) | |
1088 | ||
35d965d5 | 1089 | /* The order in which register should be allocated. It is good to use ip |
ff9940b0 RE |
1090 | since no saving is required (though calls clobber it) and it never contains |
1091 | function parameters. It is quite good to use lr since other calls may | |
f676971a | 1092 | clobber it anyway. Allocate r0 through r3 in reverse order since r3 is |
ff9940b0 | 1093 | least likely to contain a function parameter; in addition results are |
f1adb0a9 JB |
1094 | returned in r0. |
1095 | For VFP/VFPv3, allocate D16-D31 first, then caller-saved registers (D0-D7), | |
1096 | then D8-D15. The reason for doing this is to attempt to reduce register | |
1097 | pressure when both single- and double-precision registers are used in a | |
1098 | function. */ | |
1099 | ||
1100 | #define REG_ALLOC_ORDER \ | |
1101 | { \ | |
1102 | 3, 2, 1, 0, 12, 14, 4, 5, \ | |
1103 | 6, 7, 8, 10, 9, 11, 13, 15, \ | |
1104 | 16, 17, 18, 19, 20, 21, 22, 23, \ | |
1105 | 27, 28, 29, 30, 31, 32, 33, 34, \ | |
1106 | 35, 36, 37, 38, 39, 40, 41, 42, \ | |
1107 | 43, 44, 45, 46, 47, 48, 49, 50, \ | |
1108 | 51, 52, 53, 54, 55, 56, 57, 58, \ | |
1109 | 59, 60, 61, 62, \ | |
1110 | 24, 25, 26, \ | |
1111 | 95, 96, 97, 98, 99, 100, 101, 102, \ | |
1112 | 103, 104, 105, 106, 107, 108, 109, 110, \ | |
1113 | 111, 112, 113, 114, 115, 116, 117, 118, \ | |
1114 | 119, 120, 121, 122, 123, 124, 125, 126, \ | |
1115 | 78, 77, 76, 75, 74, 73, 72, 71, \ | |
1116 | 70, 69, 68, 67, 66, 65, 64, 63, \ | |
1117 | 79, 80, 81, 82, 83, 84, 85, 86, \ | |
1118 | 87, 88, 89, 90, 91, 92, 93, 94, \ | |
1119 | 127 \ | |
35d965d5 | 1120 | } |
9338ffe6 | 1121 | |
795dc4fc PB |
1122 | /* Use different register alloc ordering for Thumb. */ |
1123 | #define ORDER_REGS_FOR_LOCAL_ALLOC arm_order_regs_for_local_alloc () | |
1124 | ||
9338ffe6 PB |
1125 | /* Interrupt functions can only use registers that have already been |
1126 | saved by the prologue, even if they would normally be | |
1127 | call-clobbered. */ | |
1128 | #define HARD_REGNO_RENAME_OK(SRC, DST) \ | |
1129 | (! IS_INTERRUPT (cfun->machine->func_type) || \ | |
6fb5fa3c | 1130 | df_regs_ever_live_p (DST)) |
35d965d5 RS |
1131 | \f |
1132 | /* Register and constant classes. */ | |
1133 | ||
3b684012 | 1134 | /* Register classes: used to be simple, just all ARM regs or all FPA regs |
d6a7951f | 1135 | Now that the Thumb is involved it has become more complicated. */ |
35d965d5 RS |
1136 | enum reg_class |
1137 | { | |
1138 | NO_REGS, | |
3b684012 | 1139 | FPA_REGS, |
9b6b54e2 | 1140 | CIRRUS_REGS, |
f1adb0a9 JB |
1141 | VFP_D0_D7_REGS, |
1142 | VFP_LO_REGS, | |
1143 | VFP_HI_REGS, | |
9b66ebb1 | 1144 | VFP_REGS, |
5a9335ef NC |
1145 | IWMMXT_GR_REGS, |
1146 | IWMMXT_REGS, | |
d5b7b3ae RE |
1147 | LO_REGS, |
1148 | STACK_REG, | |
1149 | BASE_REGS, | |
1150 | HI_REGS, | |
1151 | CC_REG, | |
9b66ebb1 | 1152 | VFPCC_REG, |
35d965d5 | 1153 | GENERAL_REGS, |
f5c630c3 | 1154 | CORE_REGS, |
35d965d5 RS |
1155 | ALL_REGS, |
1156 | LIM_REG_CLASSES | |
1157 | }; | |
1158 | ||
1159 | #define N_REG_CLASSES (int) LIM_REG_CLASSES | |
1160 | ||
d6b4baa4 | 1161 | /* Give names of register classes as strings for dump file. */ |
35d965d5 RS |
1162 | #define REG_CLASS_NAMES \ |
1163 | { \ | |
1164 | "NO_REGS", \ | |
3b684012 | 1165 | "FPA_REGS", \ |
9b6b54e2 | 1166 | "CIRRUS_REGS", \ |
f1adb0a9 JB |
1167 | "VFP_D0_D7_REGS", \ |
1168 | "VFP_LO_REGS", \ | |
1169 | "VFP_HI_REGS", \ | |
9b66ebb1 | 1170 | "VFP_REGS", \ |
5a9335ef NC |
1171 | "IWMMXT_GR_REGS", \ |
1172 | "IWMMXT_REGS", \ | |
d5b7b3ae RE |
1173 | "LO_REGS", \ |
1174 | "STACK_REG", \ | |
1175 | "BASE_REGS", \ | |
1176 | "HI_REGS", \ | |
1177 | "CC_REG", \ | |
5384443a | 1178 | "VFPCC_REG", \ |
35d965d5 | 1179 | "GENERAL_REGS", \ |
f5c630c3 | 1180 | "CORE_REGS", \ |
35d965d5 RS |
1181 | "ALL_REGS", \ |
1182 | } | |
1183 | ||
1184 | /* Define which registers fit in which classes. | |
1185 | This is an initializer for a vector of HARD_REG_SET | |
1186 | of length N_REG_CLASSES. */ | |
f1adb0a9 JB |
1187 | #define REG_CLASS_CONTENTS \ |
1188 | { \ | |
1189 | { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \ | |
1190 | { 0x00FF0000, 0x00000000, 0x00000000, 0x00000000 }, /* FPA_REGS */ \ | |
1191 | { 0xF8000000, 0x000007FF, 0x00000000, 0x00000000 }, /* CIRRUS_REGS */ \ | |
1192 | { 0x00000000, 0x80000000, 0x00007FFF, 0x00000000 }, /* VFP_D0_D7_REGS */ \ | |
1193 | { 0x00000000, 0x80000000, 0x7FFFFFFF, 0x00000000 }, /* VFP_LO_REGS */ \ | |
1194 | { 0x00000000, 0x00000000, 0x80000000, 0x7FFFFFFF }, /* VFP_HI_REGS */ \ | |
1195 | { 0x00000000, 0x80000000, 0xFFFFFFFF, 0x7FFFFFFF }, /* VFP_REGS */ \ | |
1196 | { 0x00000000, 0x00007800, 0x00000000, 0x00000000 }, /* IWMMXT_GR_REGS */ \ | |
1197 | { 0x00000000, 0x7FFF8000, 0x00000000, 0x00000000 }, /* IWMMXT_REGS */ \ | |
1198 | { 0x000000FF, 0x00000000, 0x00000000, 0x00000000 }, /* LO_REGS */ \ | |
1199 | { 0x00002000, 0x00000000, 0x00000000, 0x00000000 }, /* STACK_REG */ \ | |
1200 | { 0x000020FF, 0x00000000, 0x00000000, 0x00000000 }, /* BASE_REGS */ \ | |
f5c630c3 | 1201 | { 0x0000DF00, 0x00000000, 0x00000000, 0x00000000 }, /* HI_REGS */ \ |
f1adb0a9 JB |
1202 | { 0x01000000, 0x00000000, 0x00000000, 0x00000000 }, /* CC_REG */ \ |
1203 | { 0x00000000, 0x00000000, 0x00000000, 0x80000000 }, /* VFPCC_REG */ \ | |
f5c630c3 PB |
1204 | { 0x0200DFFF, 0x00000000, 0x00000000, 0x00000000 }, /* GENERAL_REGS */ \ |
1205 | { 0x0200FFFF, 0x00000000, 0x00000000, 0x00000000 }, /* CORE_REGS */ \ | |
f1adb0a9 | 1206 | { 0xFAFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF } /* ALL_REGS */ \ |
35d965d5 | 1207 | } |
4b02997f | 1208 | |
f1adb0a9 JB |
1209 | /* Any of the VFP register classes. */ |
1210 | #define IS_VFP_CLASS(X) \ | |
1211 | ((X) == VFP_D0_D7_REGS || (X) == VFP_LO_REGS \ | |
1212 | || (X) == VFP_HI_REGS || (X) == VFP_REGS) | |
1213 | ||
35d965d5 RS |
1214 | /* The same information, inverted: |
1215 | Return the class number of the smallest class containing | |
1216 | reg number REGNO. This could be a conditional expression | |
1217 | or could index an array. */ | |
d5b7b3ae | 1218 | #define REGNO_REG_CLASS(REGNO) arm_regno_class (REGNO) |
35d965d5 | 1219 | |
058e97ec VM |
1220 | /* The following macro defines cover classes for Integrated Register |
1221 | Allocator. Cover classes is a set of non-intersected register | |
1222 | classes covering all hard registers used for register allocation | |
1223 | purpose. Any move between two registers of a cover class should be | |
1224 | cheaper than load or store of the registers. The macro value is | |
1225 | array of register classes with LIM_REG_CLASSES used as the end | |
1226 | marker. */ | |
1227 | ||
1228 | #define IRA_COVER_CLASSES \ | |
1229 | { \ | |
1230 | GENERAL_REGS, FPA_REGS, CIRRUS_REGS, VFP_REGS, IWMMXT_GR_REGS, IWMMXT_REGS,\ | |
1231 | LIM_REG_CLASSES \ | |
1232 | } | |
1233 | ||
9b66ebb1 | 1234 | /* FPA registers can't do subreg as all values are reformatted to internal |
59b9a953 | 1235 | precision. VFP registers may only be accessed in the mode they |
9b66ebb1 | 1236 | were set. */ |
75d2580c RE |
1237 | #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \ |
1238 | (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \ | |
9b66ebb1 PB |
1239 | ? reg_classes_intersect_p (FPA_REGS, (CLASS)) \ |
1240 | || reg_classes_intersect_p (VFP_REGS, (CLASS)) \ | |
1241 | : 0) | |
75d2580c | 1242 | |
cc81dde8 PB |
1243 | /* We need to define this for LO_REGS on thumb. Otherwise we can end up |
1244 | using r0-r4 for function arguments, r7 for the stack frame and don't | |
1245 | have enough left over to do doubleword arithmetic. */ | |
1246 | #define CLASS_LIKELY_SPILLED_P(CLASS) \ | |
1247 | ((TARGET_THUMB && (CLASS) == LO_REGS) \ | |
1248 | || (CLASS) == CC_REG) | |
f676971a | 1249 | |
35d965d5 | 1250 | /* The class value for index registers, and the one for base regs. */ |
5b3e6663 | 1251 | #define INDEX_REG_CLASS (TARGET_THUMB1 ? LO_REGS : GENERAL_REGS) |
f5c630c3 | 1252 | #define BASE_REG_CLASS (TARGET_THUMB1 ? LO_REGS : CORE_REGS) |
d5b7b3ae | 1253 | |
b93a0fe6 | 1254 | /* For the Thumb the high registers cannot be used as base registers |
6bc82793 | 1255 | when addressing quantities in QI or HI mode; if we don't know the |
888d2cd6 | 1256 | mode, then we must be conservative. */ |
3dcc68a4 | 1257 | #define MODE_BASE_REG_CLASS(MODE) \ |
f5c630c3 | 1258 | (TARGET_32BIT ? CORE_REGS : \ |
888d2cd6 DJ |
1259 | (((MODE) == SImode) ? BASE_REGS : LO_REGS)) |
1260 | ||
1261 | /* For Thumb we can not support SP+reg addressing, so we return LO_REGS | |
1262 | instead of BASE_REGS. */ | |
1263 | #define MODE_BASE_REG_REG_CLASS(MODE) BASE_REG_CLASS | |
3dcc68a4 | 1264 | |
d5b7b3ae RE |
1265 | /* When SMALL_REGISTER_CLASSES is nonzero, the compiler allows |
1266 | registers explicitly used in the rtl to be used as spill registers | |
1267 | but prevents the compiler from extending the lifetime of these | |
d6b4baa4 | 1268 | registers. */ |
5b3e6663 | 1269 | #define SMALL_REGISTER_CLASSES TARGET_THUMB1 |
35d965d5 | 1270 | |
35d965d5 RS |
1271 | /* Given an rtx X being reloaded into a reg required to be |
1272 | in class CLASS, return the class of reg to actually use. | |
5b3e6663 PB |
1273 | In general this is just CLASS, but for the Thumb core registers and |
1274 | immediate constants we prefer a LO_REGS class or a subset. */ | |
1275 | #define PREFERRED_RELOAD_CLASS(X, CLASS) \ | |
1276 | (TARGET_ARM ? (CLASS) : \ | |
1277 | ((CLASS) == GENERAL_REGS || (CLASS) == HI_REGS \ | |
f5c630c3 PB |
1278 | || (CLASS) == NO_REGS || (CLASS) == STACK_REG \ |
1279 | ? LO_REGS : (CLASS))) | |
d5b7b3ae RE |
1280 | |
1281 | /* Must leave BASE_REGS reloads alone */ | |
1282 | #define THUMB_SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \ | |
1283 | ((CLASS) != LO_REGS && (CLASS) != BASE_REGS \ | |
1284 | ? ((true_regnum (X) == -1 ? LO_REGS \ | |
1285 | : (true_regnum (X) + HARD_REGNO_NREGS (0, MODE) > 8) ? LO_REGS \ | |
1286 | : NO_REGS)) \ | |
1287 | : NO_REGS) | |
1288 | ||
1289 | #define THUMB_SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \ | |
97358092 | 1290 | ((CLASS) != LO_REGS && (CLASS) != BASE_REGS \ |
d5b7b3ae RE |
1291 | ? ((true_regnum (X) == -1 ? LO_REGS \ |
1292 | : (true_regnum (X) + HARD_REGNO_NREGS (0, MODE) > 8) ? LO_REGS \ | |
1293 | : NO_REGS)) \ | |
1294 | : NO_REGS) | |
35d965d5 | 1295 | |
ff9940b0 RE |
1296 | /* Return the register class of a scratch register needed to copy IN into |
1297 | or out of a register in CLASS in MODE. If it can be done directly, | |
1298 | NO_REGS is returned. */ | |
d5b7b3ae | 1299 | #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \ |
fe2d934b | 1300 | /* Restrict which direct reloads are allowed for VFP/iWMMXt regs. */ \ |
9b66ebb1 | 1301 | ((TARGET_VFP && TARGET_HARD_FLOAT \ |
f1adb0a9 | 1302 | && IS_VFP_CLASS (CLASS)) \ |
fe2d934b PB |
1303 | ? coproc_secondary_reload_class (MODE, X, FALSE) \ |
1304 | : (TARGET_IWMMXT && (CLASS) == IWMMXT_REGS) \ | |
1305 | ? coproc_secondary_reload_class (MODE, X, TRUE) \ | |
5b3e6663 | 1306 | : TARGET_32BIT \ |
9b66ebb1 | 1307 | ? (((MODE) == HImode && ! arm_arch4 && true_regnum (X) == -1) \ |
d5b7b3ae RE |
1308 | ? GENERAL_REGS : NO_REGS) \ |
1309 | : THUMB_SECONDARY_OUTPUT_RELOAD_CLASS (CLASS, MODE, X)) | |
f676971a | 1310 | |
d6b4baa4 | 1311 | /* If we need to load shorts byte-at-a-time, then we need a scratch. */ |
d5b7b3ae | 1312 | #define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \ |
fe2d934b | 1313 | /* Restrict which direct reloads are allowed for VFP/iWMMXt regs. */ \ |
9b66ebb1 | 1314 | ((TARGET_VFP && TARGET_HARD_FLOAT \ |
f1adb0a9 | 1315 | && IS_VFP_CLASS (CLASS)) \ |
fe2d934b PB |
1316 | ? coproc_secondary_reload_class (MODE, X, FALSE) : \ |
1317 | (TARGET_IWMMXT && (CLASS) == IWMMXT_REGS) ? \ | |
1318 | coproc_secondary_reload_class (MODE, X, TRUE) : \ | |
9b6b54e2 | 1319 | /* Cannot load constants into Cirrus registers. */ \ |
9b66ebb1 | 1320 | (TARGET_MAVERICK && TARGET_HARD_FLOAT \ |
9b6b54e2 NC |
1321 | && (CLASS) == CIRRUS_REGS \ |
1322 | && (CONSTANT_P (X) || GET_CODE (X) == SYMBOL_REF)) \ | |
1323 | ? GENERAL_REGS : \ | |
5b3e6663 | 1324 | (TARGET_32BIT ? \ |
5a9335ef NC |
1325 | (((CLASS) == IWMMXT_REGS || (CLASS) == IWMMXT_GR_REGS) \ |
1326 | && CONSTANT_P (X)) \ | |
1327 | ? GENERAL_REGS : \ | |
61f0ccff | 1328 | (((MODE) == HImode && ! arm_arch4 \ |
d5b7b3ae RE |
1329 | && (GET_CODE (X) == MEM \ |
1330 | || ((GET_CODE (X) == REG || GET_CODE (X) == SUBREG) \ | |
1331 | && true_regnum (X) == -1))) \ | |
1332 | ? GENERAL_REGS : NO_REGS) \ | |
9b6b54e2 | 1333 | : THUMB_SECONDARY_INPUT_RELOAD_CLASS (CLASS, MODE, X))) |
2ce9c1b9 | 1334 | |
6f734908 RE |
1335 | /* Try a machine-dependent way of reloading an illegitimate address |
1336 | operand. If we find one, push the reload and jump to WIN. This | |
1337 | macro is used in only one place: `find_reloads_address' in reload.c. | |
1338 | ||
1339 | For the ARM, we wish to handle large displacements off a base | |
1340 | register by splitting the addend across a MOV and the mem insn. | |
d5b7b3ae RE |
1341 | This can cut the number of reloads needed. */ |
1342 | #define ARM_LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND, WIN) \ | |
1343 | do \ | |
1344 | { \ | |
1345 | if (GET_CODE (X) == PLUS \ | |
1346 | && GET_CODE (XEXP (X, 0)) == REG \ | |
1347 | && REGNO (XEXP (X, 0)) < FIRST_PSEUDO_REGISTER \ | |
1348 | && REG_MODE_OK_FOR_BASE_P (XEXP (X, 0), MODE) \ | |
1349 | && GET_CODE (XEXP (X, 1)) == CONST_INT) \ | |
1350 | { \ | |
1351 | HOST_WIDE_INT val = INTVAL (XEXP (X, 1)); \ | |
1352 | HOST_WIDE_INT low, high; \ | |
1353 | \ | |
de6f27a8 | 1354 | if (MODE == DImode || (MODE == DFmode && TARGET_SOFT_FLOAT)) \ |
d5b7b3ae | 1355 | low = ((val & 0xf) ^ 0x8) - 0x8; \ |
9b66ebb1 | 1356 | else if (TARGET_MAVERICK && TARGET_HARD_FLOAT) \ |
9b6b54e2 NC |
1357 | /* Need to be careful, -256 is not a valid offset. */ \ |
1358 | low = val >= 0 ? (val & 0xff) : -((-val) & 0xff); \ | |
d5b7b3ae | 1359 | else if (MODE == SImode \ |
de6f27a8 | 1360 | || (MODE == SFmode && TARGET_SOFT_FLOAT) \ |
d5b7b3ae RE |
1361 | || ((MODE == HImode || MODE == QImode) && ! arm_arch4)) \ |
1362 | /* Need to be careful, -4096 is not a valid offset. */ \ | |
1363 | low = val >= 0 ? (val & 0xfff) : -((-val) & 0xfff); \ | |
1364 | else if ((MODE == HImode || MODE == QImode) && arm_arch4) \ | |
1365 | /* Need to be careful, -256 is not a valid offset. */ \ | |
1366 | low = val >= 0 ? (val & 0xff) : -((-val) & 0xff); \ | |
1367 | else if (GET_MODE_CLASS (MODE) == MODE_FLOAT \ | |
9b66ebb1 | 1368 | && TARGET_HARD_FLOAT && TARGET_FPA) \ |
d5b7b3ae RE |
1369 | /* Need to be careful, -1024 is not a valid offset. */ \ |
1370 | low = val >= 0 ? (val & 0x3ff) : -((-val) & 0x3ff); \ | |
1371 | else \ | |
1372 | break; \ | |
1373 | \ | |
30cf4896 KG |
1374 | high = ((((val - low) & (unsigned HOST_WIDE_INT) 0xffffffff) \ |
1375 | ^ (unsigned HOST_WIDE_INT) 0x80000000) \ | |
1376 | - (unsigned HOST_WIDE_INT) 0x80000000); \ | |
d5b7b3ae RE |
1377 | /* Check for overflow or zero */ \ |
1378 | if (low == 0 || high == 0 || (high + low != val)) \ | |
1379 | break; \ | |
1380 | \ | |
1381 | /* Reload the high part into a base reg; leave the low part \ | |
1382 | in the mem. */ \ | |
1383 | X = gen_rtx_PLUS (GET_MODE (X), \ | |
1384 | gen_rtx_PLUS (GET_MODE (X), XEXP (X, 0), \ | |
1385 | GEN_INT (high)), \ | |
1386 | GEN_INT (low)); \ | |
df4ae160 | 1387 | push_reload (XEXP (X, 0), NULL_RTX, &XEXP (X, 0), NULL, \ |
4a692617 NC |
1388 | MODE_BASE_REG_CLASS (MODE), GET_MODE (X), \ |
1389 | VOIDmode, 0, 0, OPNUM, TYPE); \ | |
d5b7b3ae RE |
1390 | goto WIN; \ |
1391 | } \ | |
1392 | } \ | |
62b10bbc | 1393 | while (0) |
6f734908 | 1394 | |
27847754 | 1395 | /* XXX If an HImode FP+large_offset address is converted to an HImode |
d5b7b3ae RE |
1396 | SP+large_offset address, then reload won't know how to fix it. It sees |
1397 | only that SP isn't valid for HImode, and so reloads the SP into an index | |
1398 | register, but the resulting address is still invalid because the offset | |
1399 | is too big. We fix it here instead by reloading the entire address. */ | |
1400 | /* We could probably achieve better results by defining PROMOTE_MODE to help | |
1401 | cope with the variances between the Thumb's signed and unsigned byte and | |
1402 | halfword load instructions. */ | |
5b3e6663 | 1403 | /* ??? This should be safe for thumb2, but we may be able to do better. */ |
a132dad6 RE |
1404 | #define THUMB_LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_L, WIN) \ |
1405 | do { \ | |
1406 | rtx new_x = thumb_legitimize_reload_address (&X, MODE, OPNUM, TYPE, IND_L); \ | |
1407 | if (new_x) \ | |
1408 | { \ | |
1409 | X = new_x; \ | |
1410 | goto WIN; \ | |
1411 | } \ | |
1412 | } while (0) | |
d5b7b3ae RE |
1413 | |
1414 | #define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_LEVELS, WIN) \ | |
1415 | if (TARGET_ARM) \ | |
1416 | ARM_LEGITIMIZE_RELOAD_ADDRESS (X, MODE, OPNUM, TYPE, IND_LEVELS, WIN); \ | |
1417 | else \ | |
1418 | THUMB_LEGITIMIZE_RELOAD_ADDRESS (X, MODE, OPNUM, TYPE, IND_LEVELS, WIN) | |
f676971a | 1419 | |
35d965d5 RS |
1420 | /* Return the maximum number of consecutive registers |
1421 | needed to represent mode MODE in a register of class CLASS. | |
3b684012 | 1422 | ARM regs are UNITS_PER_WORD bits while FPA regs can hold any FP mode */ |
35d965d5 | 1423 | #define CLASS_MAX_NREGS(CLASS, MODE) \ |
3b684012 | 1424 | (((CLASS) == FPA_REGS || (CLASS) == CIRRUS_REGS) ? 1 : ARM_NUM_REGS (MODE)) |
9b6b54e2 NC |
1425 | |
1426 | /* If defined, gives a class of registers that cannot be used as the | |
1427 | operand of a SUBREG that changes the mode of the object illegally. */ | |
35d965d5 | 1428 | |
356ecb15 DJ |
1429 | /* Moves between FPA_REGS and GENERAL_REGS are two memory insns. |
1430 | Moves between VFP_REGS and GENERAL_REGS are a single insn, but | |
1431 | it is typically more expensive than a single memory access. We set | |
1432 | the cost to less than two memory accesses so that floating | |
1433 | point to integer conversion does not go through memory. */ | |
cf011243 | 1434 | #define REGISTER_MOVE_COST(MODE, FROM, TO) \ |
5b3e6663 | 1435 | (TARGET_32BIT ? \ |
3b684012 RE |
1436 | ((FROM) == FPA_REGS && (TO) != FPA_REGS ? 20 : \ |
1437 | (FROM) != FPA_REGS && (TO) == FPA_REGS ? 20 : \ | |
356ecb15 DJ |
1438 | IS_VFP_CLASS (FROM) && !IS_VFP_CLASS (TO) ? 15 : \ |
1439 | !IS_VFP_CLASS (FROM) && IS_VFP_CLASS (TO) ? 15 : \ | |
5a9335ef NC |
1440 | (FROM) == IWMMXT_REGS && (TO) != IWMMXT_REGS ? 4 : \ |
1441 | (FROM) != IWMMXT_REGS && (TO) == IWMMXT_REGS ? 4 : \ | |
1442 | (FROM) == IWMMXT_GR_REGS || (TO) == IWMMXT_GR_REGS ? 20 : \ | |
9b6b54e2 NC |
1443 | (FROM) == CIRRUS_REGS && (TO) != CIRRUS_REGS ? 20 : \ |
1444 | (FROM) != CIRRUS_REGS && (TO) == CIRRUS_REGS ? 20 : \ | |
1445 | 2) \ | |
d5b7b3ae RE |
1446 | : \ |
1447 | ((FROM) == HI_REGS || (TO) == HI_REGS) ? 4 : 2) | |
35d965d5 RS |
1448 | \f |
1449 | /* Stack layout; function entry, exit and calling. */ | |
1450 | ||
1451 | /* Define this if pushing a word on the stack | |
1452 | makes the stack pointer a smaller address. */ | |
1453 | #define STACK_GROWS_DOWNWARD 1 | |
1454 | ||
a4d05547 | 1455 | /* Define this to nonzero if the nominal address of the stack frame |
35d965d5 RS |
1456 | is at the high-address end of the local variables; |
1457 | that is, each additional local variable allocated | |
1458 | goes at a more negative offset in the frame. */ | |
1459 | #define FRAME_GROWS_DOWNWARD 1 | |
1460 | ||
a2503645 RS |
1461 | /* The amount of scratch space needed by _interwork_{r7,r11}_call_via_rN(). |
1462 | When present, it is one word in size, and sits at the top of the frame, | |
1463 | between the soft frame pointer and either r7 or r11. | |
1464 | ||
1465 | We only need _interwork_rM_call_via_rN() for -mcaller-super-interworking, | |
1466 | and only then if some outgoing arguments are passed on the stack. It would | |
1467 | be tempting to also check whether the stack arguments are passed by indirect | |
1468 | calls, but there seems to be no reason in principle why a post-reload pass | |
1469 | couldn't convert a direct call into an indirect one. */ | |
1470 | #define CALLER_INTERWORKING_SLOT_SIZE \ | |
1471 | (TARGET_CALLER_INTERWORKING \ | |
38173d38 | 1472 | && crtl->outgoing_args_size != 0 \ |
a2503645 RS |
1473 | ? UNITS_PER_WORD : 0) |
1474 | ||
35d965d5 RS |
1475 | /* Offset within stack frame to start allocating local variables at. |
1476 | If FRAME_GROWS_DOWNWARD, this is the offset to the END of the | |
1477 | first local allocated. Otherwise, it is the offset to the BEGINNING | |
1478 | of the first local allocated. */ | |
1479 | #define STARTING_FRAME_OFFSET 0 | |
1480 | ||
1481 | /* If we generate an insn to push BYTES bytes, | |
1482 | this says how many the stack pointer really advances by. */ | |
d5b7b3ae | 1483 | /* The push insns do not do this rounding implicitly. |
d6b4baa4 | 1484 | So don't define this. */ |
0c2ca901 | 1485 | /* #define PUSH_ROUNDING(NPUSHED) ROUND_UP_WORD (NPUSHED) */ |
18543a22 ILT |
1486 | |
1487 | /* Define this if the maximum size of all the outgoing args is to be | |
1488 | accumulated and pushed during the prologue. The amount can be | |
38173d38 | 1489 | found in the variable crtl->outgoing_args_size. */ |
6cfc7210 | 1490 | #define ACCUMULATE_OUTGOING_ARGS 1 |
35d965d5 RS |
1491 | |
1492 | /* Offset of first parameter from the argument pointer register value. */ | |
d5b7b3ae | 1493 | #define FIRST_PARM_OFFSET(FNDECL) (TARGET_ARM ? 4 : 0) |
35d965d5 RS |
1494 | |
1495 | /* Value is the number of byte of arguments automatically | |
1496 | popped when returning from a subroutine call. | |
8b109b37 | 1497 | FUNDECL is the declaration node of the function (as a tree), |
35d965d5 RS |
1498 | FUNTYPE is the data type of the function (as a tree), |
1499 | or for a library call it is an identifier node for the subroutine name. | |
1500 | SIZE is the number of bytes of arguments passed on the stack. | |
1501 | ||
1502 | On the ARM, the caller does not pop any of its arguments that were passed | |
1503 | on the stack. */ | |
6cfc7210 | 1504 | #define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, SIZE) 0 |
35d965d5 RS |
1505 | |
1506 | /* Define how to find the value returned by a library function | |
1507 | assuming the value has mode MODE. */ | |
390b17c2 RE |
1508 | #define LIBCALL_VALUE(MODE) \ |
1509 | (TARGET_AAPCS_BASED ? aapcs_libcall_value (MODE) \ | |
1510 | : (TARGET_32BIT && TARGET_HARD_FLOAT_ABI && TARGET_FPA \ | |
1511 | && GET_MODE_CLASS (MODE) == MODE_FLOAT) \ | |
9b66ebb1 | 1512 | ? gen_rtx_REG (MODE, FIRST_FPA_REGNUM) \ |
5b3e6663 | 1513 | : TARGET_32BIT && TARGET_HARD_FLOAT_ABI && TARGET_MAVERICK \ |
9b66ebb1 | 1514 | && GET_MODE_CLASS (MODE) == MODE_FLOAT \ |
9b6b54e2 | 1515 | ? gen_rtx_REG (MODE, FIRST_CIRRUS_FP_REGNUM) \ |
f676971a | 1516 | : TARGET_IWMMXT_ABI && arm_vector_mode_supported_p (MODE) \ |
5a9335ef | 1517 | ? gen_rtx_REG (MODE, FIRST_IWMMXT_REGNUM) \ |
d5b7b3ae | 1518 | : gen_rtx_REG (MODE, ARG_REGISTER (1))) |
35d965d5 | 1519 | |
390b17c2 RE |
1520 | /* 1 if REGNO is a possible register number for a function value. */ |
1521 | #define FUNCTION_VALUE_REGNO_P(REGNO) \ | |
1522 | ((REGNO) == ARG_REGISTER (1) \ | |
1523 | || (TARGET_AAPCS_BASED && TARGET_32BIT \ | |
1524 | && TARGET_VFP && TARGET_HARD_FLOAT \ | |
1525 | && (REGNO) == FIRST_VFP_REGNUM) \ | |
1526 | || (TARGET_32BIT && ((REGNO) == FIRST_CIRRUS_FP_REGNUM) \ | |
1527 | && TARGET_HARD_FLOAT_ABI && TARGET_MAVERICK) \ | |
1528 | || ((REGNO) == FIRST_IWMMXT_REGNUM && TARGET_IWMMXT_ABI) \ | |
1529 | || (TARGET_32BIT && ((REGNO) == FIRST_FPA_REGNUM) \ | |
72cdc543 | 1530 | && TARGET_HARD_FLOAT_ABI && TARGET_FPA)) |
35d965d5 | 1531 | |
9f7bf991 RE |
1532 | /* Amount of memory needed for an untyped call to save all possible return |
1533 | registers. */ | |
1534 | #define APPLY_RESULT_SIZE arm_apply_result_size() | |
1535 | ||
11c1a207 RE |
1536 | /* Define DEFAULT_PCC_STRUCT_RETURN to 1 if all structure and union return |
1537 | values must be in memory. On the ARM, they need only do so if larger | |
d6b4baa4 | 1538 | than a word, or if they contain elements offset from zero in the struct. */ |
11c1a207 RE |
1539 | #define DEFAULT_PCC_STRUCT_RETURN 0 |
1540 | ||
6d3d9133 | 1541 | /* These bits describe the different types of function supported |
112cdef5 | 1542 | by the ARM backend. They are exclusive. i.e. a function cannot be both a |
6d3d9133 NC |
1543 | normal function and an interworked function, for example. Knowing the |
1544 | type of a function is important for determining its prologue and | |
1545 | epilogue sequences. | |
1546 | Note value 7 is currently unassigned. Also note that the interrupt | |
1547 | function types all have bit 2 set, so that they can be tested for easily. | |
1548 | Note that 0 is deliberately chosen for ARM_FT_UNKNOWN so that when the | |
4912a07c | 1549 | machine_function structure is initialized (to zero) func_type will |
6d3d9133 NC |
1550 | default to unknown. This will force the first use of arm_current_func_type |
1551 | to call arm_compute_func_type. */ | |
1552 | #define ARM_FT_UNKNOWN 0 /* Type has not yet been determined. */ | |
1553 | #define ARM_FT_NORMAL 1 /* Your normal, straightforward function. */ | |
1554 | #define ARM_FT_INTERWORKED 2 /* A function that supports interworking. */ | |
6d3d9133 NC |
1555 | #define ARM_FT_ISR 4 /* An interrupt service routine. */ |
1556 | #define ARM_FT_FIQ 5 /* A fast interrupt service routine. */ | |
1557 | #define ARM_FT_EXCEPTION 6 /* An ARM exception handler (subcase of ISR). */ | |
1558 | ||
1559 | #define ARM_FT_TYPE_MASK ((1 << 3) - 1) | |
1560 | ||
1561 | /* In addition functions can have several type modifiers, | |
1562 | outlined by these bit masks: */ | |
1563 | #define ARM_FT_INTERRUPT (1 << 2) /* Note overlap with FT_ISR and above. */ | |
1564 | #define ARM_FT_NAKED (1 << 3) /* No prologue or epilogue. */ | |
1565 | #define ARM_FT_VOLATILE (1 << 4) /* Does not return. */ | |
d6b4baa4 | 1566 | #define ARM_FT_NESTED (1 << 5) /* Embedded inside another func. */ |
5b3e6663 | 1567 | #define ARM_FT_STACKALIGN (1 << 6) /* Called with misaligned stack. */ |
6d3d9133 NC |
1568 | |
1569 | /* Some macros to test these flags. */ | |
1570 | #define ARM_FUNC_TYPE(t) (t & ARM_FT_TYPE_MASK) | |
1571 | #define IS_INTERRUPT(t) (t & ARM_FT_INTERRUPT) | |
1572 | #define IS_VOLATILE(t) (t & ARM_FT_VOLATILE) | |
1573 | #define IS_NAKED(t) (t & ARM_FT_NAKED) | |
1574 | #define IS_NESTED(t) (t & ARM_FT_NESTED) | |
5b3e6663 | 1575 | #define IS_STACKALIGN(t) (t & ARM_FT_STACKALIGN) |
6d3d9133 | 1576 | |
5848830f PB |
1577 | |
1578 | /* Structure used to hold the function stack frame layout. Offsets are | |
1579 | relative to the stack pointer on function entry. Positive offsets are | |
1580 | in the direction of stack growth. | |
1581 | Only soft_frame is used in thumb mode. */ | |
1582 | ||
d1b38208 | 1583 | typedef struct GTY(()) arm_stack_offsets |
5848830f PB |
1584 | { |
1585 | int saved_args; /* ARG_POINTER_REGNUM. */ | |
1586 | int frame; /* ARM_HARD_FRAME_POINTER_REGNUM. */ | |
1587 | int saved_regs; | |
1588 | int soft_frame; /* FRAME_POINTER_REGNUM. */ | |
2591db65 | 1589 | int locals_base; /* THUMB_HARD_FRAME_POINTER_REGNUM. */ |
5848830f | 1590 | int outgoing_args; /* STACK_POINTER_REGNUM. */ |
954954d1 | 1591 | unsigned int saved_regs_mask; |
5848830f PB |
1592 | } |
1593 | arm_stack_offsets; | |
1594 | ||
6d3d9133 NC |
1595 | /* A C structure for machine-specific, per-function data. |
1596 | This is added to the cfun structure. */ | |
d1b38208 | 1597 | typedef struct GTY(()) machine_function |
d5b7b3ae | 1598 | { |
6bc82793 | 1599 | /* Additional stack adjustment in __builtin_eh_throw. */ |
e2500fed | 1600 | rtx eh_epilogue_sp_ofs; |
d5b7b3ae RE |
1601 | /* Records if LR has to be saved for far jumps. */ |
1602 | int far_jump_used; | |
1603 | /* Records if ARG_POINTER was ever live. */ | |
1604 | int arg_pointer_live; | |
6f7ebcbb NC |
1605 | /* Records if the save of LR has been eliminated. */ |
1606 | int lr_save_eliminated; | |
0977774b | 1607 | /* The size of the stack frame. Only valid after reload. */ |
5848830f | 1608 | arm_stack_offsets stack_offsets; |
6d3d9133 NC |
1609 | /* Records the type of the current function. */ |
1610 | unsigned long func_type; | |
3cb66fd7 NC |
1611 | /* Record if the function has a variable argument list. */ |
1612 | int uses_anonymous_args; | |
5a9335ef NC |
1613 | /* Records if sibcalls are blocked because an argument |
1614 | register is needed to preserve stack alignment. */ | |
1615 | int sibcall_blocked; | |
020a4035 RE |
1616 | /* The PIC register for this function. This might be a pseudo. */ |
1617 | rtx pic_reg; | |
b12a00f1 | 1618 | /* Labels for per-function Thumb call-via stubs. One per potential calling |
57ecec57 PB |
1619 | register. We can never call via LR or PC. We can call via SP if a |
1620 | trampoline happens to be on the top of the stack. */ | |
1621 | rtx call_via[14]; | |
934c2060 RR |
1622 | /* Set to 1 when a return insn is output, this means that the epilogue |
1623 | is not needed. */ | |
1624 | int return_used_this_function; | |
6d3d9133 NC |
1625 | } |
1626 | machine_function; | |
d5b7b3ae | 1627 | |
b12a00f1 | 1628 | /* As in the machine_function, a global set of call-via labels, for code |
d6b5193b | 1629 | that is in text_section. */ |
57ecec57 | 1630 | extern GTY(()) rtx thumb_call_via_label[14]; |
b12a00f1 | 1631 | |
390b17c2 RE |
1632 | /* The number of potential ways of assigning to a co-processor. */ |
1633 | #define ARM_NUM_COPROC_SLOTS 1 | |
1634 | ||
1635 | /* Enumeration of procedure calling standard variants. We don't really | |
1636 | support all of these yet. */ | |
1637 | enum arm_pcs | |
1638 | { | |
1639 | ARM_PCS_AAPCS, /* Base standard AAPCS. */ | |
1640 | ARM_PCS_AAPCS_VFP, /* Use VFP registers for floating point values. */ | |
1641 | ARM_PCS_AAPCS_IWMMXT, /* Use iWMMXT registers for vectors. */ | |
1642 | /* This must be the last AAPCS variant. */ | |
1643 | ARM_PCS_AAPCS_LOCAL, /* Private call within this compilation unit. */ | |
1644 | ARM_PCS_ATPCS, /* ATPCS. */ | |
1645 | ARM_PCS_APCS, /* APCS (legacy Linux etc). */ | |
1646 | ARM_PCS_UNKNOWN | |
1647 | }; | |
1648 | ||
1649 | /* We can't define this inside a generator file because it needs enum | |
1650 | machine_mode. */ | |
82e9d970 | 1651 | /* A C type for declaring a variable that is used as the first argument of |
390b17c2 | 1652 | `FUNCTION_ARG' and other related values. */ |
82e9d970 PB |
1653 | typedef struct |
1654 | { | |
d5b7b3ae | 1655 | /* This is the number of registers of arguments scanned so far. */ |
82e9d970 | 1656 | int nregs; |
5a9335ef NC |
1657 | /* This is the number of iWMMXt register arguments scanned so far. */ |
1658 | int iwmmxt_nregs; | |
1659 | int named_count; | |
1660 | int nargs; | |
390b17c2 RE |
1661 | /* Which procedure call variant to use for this call. */ |
1662 | enum arm_pcs pcs_variant; | |
1663 | ||
1664 | /* AAPCS related state tracking. */ | |
1665 | int aapcs_arg_processed; /* No need to lay out this argument again. */ | |
1666 | int aapcs_cprc_slot; /* Index of co-processor rules to handle | |
1667 | this argument, or -1 if using core | |
1668 | registers. */ | |
1669 | int aapcs_ncrn; | |
1670 | int aapcs_next_ncrn; | |
1671 | rtx aapcs_reg; /* Register assigned to this argument. */ | |
1672 | int aapcs_partial; /* How many bytes are passed in regs (if | |
1673 | split between core regs and stack. | |
1674 | Zero otherwise. */ | |
1675 | int aapcs_cprc_failed[ARM_NUM_COPROC_SLOTS]; | |
1676 | int can_split; /* Argument can be split between core regs | |
1677 | and the stack. */ | |
1678 | /* Private data for tracking VFP register allocation */ | |
1679 | unsigned aapcs_vfp_regs_free; | |
1680 | unsigned aapcs_vfp_reg_alloc; | |
1681 | int aapcs_vfp_rcount; | |
1682 | /* Can't include insn-modes.h because this header is needed before we | |
1683 | generate it. */ | |
1684 | int /* enum machine_mode */ aapcs_vfp_rmode; | |
d5b7b3ae | 1685 | } CUMULATIVE_ARGS; |
82e9d970 | 1686 | |
390b17c2 | 1687 | |
35d965d5 RS |
1688 | /* Define where to put the arguments to a function. |
1689 | Value is zero to push the argument on the stack, | |
1690 | or a hard register in which to store the argument. | |
1691 | ||
1692 | MODE is the argument's machine mode. | |
1693 | TYPE is the data type of the argument (as a tree). | |
1694 | This is null for libcalls where that information may | |
1695 | not be available. | |
1696 | CUM is a variable of type CUMULATIVE_ARGS which gives info about | |
1697 | the preceding args and about the function being called. | |
1698 | NAMED is nonzero if this argument is a named parameter | |
1699 | (otherwise it is an extra parameter matching an ellipsis). | |
1700 | ||
1701 | On the ARM, normally the first 16 bytes are passed in registers r0-r3; all | |
1702 | other arguments are passed on the stack. If (NAMED == 0) (which happens | |
1cc9f5f5 KH |
1703 | only in assign_parms, since TARGET_SETUP_INCOMING_VARARGS is |
1704 | defined), say it is passed in the stack (function_prologue will | |
1705 | indeed make it pass in the stack if necessary). */ | |
82e9d970 PB |
1706 | #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ |
1707 | arm_function_arg (&(CUM), (MODE), (TYPE), (NAMED)) | |
35d965d5 | 1708 | |
866af8a9 JB |
1709 | #define FUNCTION_ARG_PADDING(MODE, TYPE) \ |
1710 | (arm_pad_arg_upward (MODE, TYPE) ? upward : downward) | |
1711 | ||
1712 | #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \ | |
1713 | (arm_pad_reg_upward (MODE, TYPE, FIRST) ? upward : downward) | |
1714 | ||
1715 | /* For AAPCS, padding should never be below the argument. For other ABIs, | |
1716 | * mimic the default. */ | |
1717 | #define PAD_VARARGS_DOWN \ | |
1718 | ((TARGET_AAPCS_BASED) ? 0 : BYTES_BIG_ENDIAN) | |
1719 | ||
35d965d5 RS |
1720 | /* Initialize a variable CUM of type CUMULATIVE_ARGS |
1721 | for a call to a function whose data type is FNTYPE. | |
1722 | For a library call, FNTYPE is 0. | |
1723 | On the ARM, the offset starts at 0. */ | |
0f6937fe | 1724 | #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \ |
563a317a | 1725 | arm_init_cumulative_args (&(CUM), (FNTYPE), (LIBNAME), (FNDECL)) |
35d965d5 RS |
1726 | |
1727 | /* Update the data in CUM to advance over an argument | |
1728 | of mode MODE and data type TYPE. | |
1729 | (TYPE is null for libcalls where that information may not be available.) */ | |
6cfc7210 | 1730 | #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ |
390b17c2 | 1731 | arm_function_arg_advance (&(CUM), (MODE), (TYPE), (NAMED)) |
35d965d5 | 1732 | |
5a9335ef NC |
1733 | /* If defined, a C expression that gives the alignment boundary, in bits, of an |
1734 | argument with the specified mode and type. If it is not defined, | |
1735 | `PARM_BOUNDARY' is used for all arguments. */ | |
1736 | #define FUNCTION_ARG_BOUNDARY(MODE,TYPE) \ | |
5848830f PB |
1737 | ((ARM_DOUBLEWORD_ALIGN && arm_needs_doubleword_align (MODE, TYPE)) \ |
1738 | ? DOUBLEWORD_ALIGNMENT \ | |
1739 | : PARM_BOUNDARY ) | |
5a9335ef | 1740 | |
35d965d5 RS |
1741 | /* 1 if N is a possible register number for function argument passing. |
1742 | On the ARM, r0-r3 are used to pass args. */ | |
390b17c2 RE |
1743 | #define FUNCTION_ARG_REGNO_P(REGNO) \ |
1744 | (IN_RANGE ((REGNO), 0, 3) \ | |
1745 | || (TARGET_AAPCS_BASED && TARGET_VFP && TARGET_HARD_FLOAT \ | |
1746 | && IN_RANGE ((REGNO), FIRST_VFP_REGNUM, FIRST_VFP_REGNUM + 15)) \ | |
1747 | || (TARGET_IWMMXT_ABI \ | |
5848830f | 1748 | && IN_RANGE ((REGNO), FIRST_IWMMXT_REGNUM, FIRST_IWMMXT_REGNUM + 9))) |
35d965d5 | 1749 | |
f99fce0c | 1750 | \f |
afef3d7a | 1751 | /* If your target environment doesn't prefix user functions with an |
96a3900d | 1752 | underscore, you may wish to re-define this to prevent any conflicts. */ |
afef3d7a NC |
1753 | #ifndef ARM_MCOUNT_NAME |
1754 | #define ARM_MCOUNT_NAME "*mcount" | |
1755 | #endif | |
1756 | ||
1757 | /* Call the function profiler with a given profile label. The Acorn | |
1758 | compiler puts this BEFORE the prolog but gcc puts it afterwards. | |
1759 | On the ARM the full profile code will look like: | |
1760 | .data | |
1761 | LP1 | |
1762 | .word 0 | |
1763 | .text | |
1764 | mov ip, lr | |
1765 | bl mcount | |
1766 | .word LP1 | |
1767 | ||
1768 | profile_function() in final.c outputs the .data section, FUNCTION_PROFILER | |
1769 | will output the .text section. | |
1770 | ||
1771 | The ``mov ip,lr'' seems like a good idea to stick with cc convention. | |
59be6073 AN |
1772 | ``prof'' doesn't seem to mind about this! |
1773 | ||
1774 | Note - this version of the code is designed to work in both ARM and | |
1775 | Thumb modes. */ | |
be393ecf | 1776 | #ifndef ARM_FUNCTION_PROFILER |
d5b7b3ae | 1777 | #define ARM_FUNCTION_PROFILER(STREAM, LABELNO) \ |
6cfc7210 NC |
1778 | { \ |
1779 | char temp[20]; \ | |
1780 | rtx sym; \ | |
1781 | \ | |
dd18ae56 | 1782 | asm_fprintf (STREAM, "\tmov\t%r, %r\n\tbl\t", \ |
d5b7b3ae | 1783 | IP_REGNUM, LR_REGNUM); \ |
6cfc7210 NC |
1784 | assemble_name (STREAM, ARM_MCOUNT_NAME); \ |
1785 | fputc ('\n', STREAM); \ | |
1786 | ASM_GENERATE_INTERNAL_LABEL (temp, "LP", LABELNO); \ | |
f1c25d3b | 1787 | sym = gen_rtx_SYMBOL_REF (Pmode, temp); \ |
301d03af | 1788 | assemble_aligned_integer (UNITS_PER_WORD, sym); \ |
35d965d5 | 1789 | } |
be393ecf | 1790 | #endif |
35d965d5 | 1791 | |
59be6073 | 1792 | #ifdef THUMB_FUNCTION_PROFILER |
d5b7b3ae RE |
1793 | #define FUNCTION_PROFILER(STREAM, LABELNO) \ |
1794 | if (TARGET_ARM) \ | |
1795 | ARM_FUNCTION_PROFILER (STREAM, LABELNO) \ | |
1796 | else \ | |
1797 | THUMB_FUNCTION_PROFILER (STREAM, LABELNO) | |
59be6073 AN |
1798 | #else |
1799 | #define FUNCTION_PROFILER(STREAM, LABELNO) \ | |
1800 | ARM_FUNCTION_PROFILER (STREAM, LABELNO) | |
1801 | #endif | |
d5b7b3ae | 1802 | |
35d965d5 RS |
1803 | /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, |
1804 | the stack pointer does not matter. The value is tested only in | |
1805 | functions that have frame pointers. | |
1806 | No definition is equivalent to always zero. | |
1807 | ||
1808 | On the ARM, the function epilogue recovers the stack pointer from the | |
1809 | frame. */ | |
1810 | #define EXIT_IGNORE_STACK 1 | |
1811 | ||
6fb5fa3c | 1812 | #define EPILOGUE_USES(REGNO) ((REGNO) == LR_REGNUM) |
c7861455 | 1813 | |
35d965d5 RS |
1814 | /* Determine if the epilogue should be output as RTL. |
1815 | You should override this if you define FUNCTION_EXTRA_EPILOGUE. */ | |
5b3e6663 PB |
1816 | /* This is disabled for Thumb-2 because it will confuse the |
1817 | conditional insn counter. */ | |
d5b7b3ae | 1818 | #define USE_RETURN_INSN(ISCOND) \ |
a72d4945 | 1819 | (TARGET_ARM ? use_return_insn (ISCOND, NULL) : 0) |
ff9940b0 RE |
1820 | |
1821 | /* Definitions for register eliminations. | |
1822 | ||
1823 | This is an array of structures. Each structure initializes one pair | |
1824 | of eliminable registers. The "from" register number is given first, | |
1825 | followed by "to". Eliminations of the same "from" register are listed | |
1826 | in order of preference. | |
1827 | ||
1828 | We have two registers that can be eliminated on the ARM. First, the | |
1829 | arg pointer register can often be eliminated in favor of the stack | |
1830 | pointer register. Secondly, the pseudo frame pointer register can always | |
1831 | be eliminated; it is replaced with either the stack or the real frame | |
d5b7b3ae | 1832 | pointer. Note we have to use {ARM|THUMB}_HARD_FRAME_POINTER_REGNUM |
d6a7951f | 1833 | because the definition of HARD_FRAME_POINTER_REGNUM is not a constant. */ |
ff9940b0 | 1834 | |
d5b7b3ae RE |
1835 | #define ELIMINABLE_REGS \ |
1836 | {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM },\ | |
1837 | { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM },\ | |
1838 | { ARG_POINTER_REGNUM, ARM_HARD_FRAME_POINTER_REGNUM },\ | |
1839 | { ARG_POINTER_REGNUM, THUMB_HARD_FRAME_POINTER_REGNUM },\ | |
1840 | { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM },\ | |
1841 | { FRAME_POINTER_REGNUM, ARM_HARD_FRAME_POINTER_REGNUM },\ | |
1842 | { FRAME_POINTER_REGNUM, THUMB_HARD_FRAME_POINTER_REGNUM }} | |
ff9940b0 | 1843 | |
d5b7b3ae RE |
1844 | /* Given FROM and TO register numbers, say whether this elimination is |
1845 | allowed. Frame pointer elimination is automatically handled. | |
ff9940b0 RE |
1846 | |
1847 | All eliminations are permissible. Note that ARG_POINTER_REGNUM and | |
abc95ed3 | 1848 | HARD_FRAME_POINTER_REGNUM are in fact the same thing. If we need a frame |
ff9940b0 | 1849 | pointer, we must eliminate FRAME_POINTER_REGNUM into |
d5b7b3ae RE |
1850 | HARD_FRAME_POINTER_REGNUM and not into STACK_POINTER_REGNUM or |
1851 | ARG_POINTER_REGNUM. */ | |
1852 | #define CAN_ELIMINATE(FROM, TO) \ | |
1853 | (((TO) == FRAME_POINTER_REGNUM && (FROM) == ARG_POINTER_REGNUM) ? 0 : \ | |
1854 | ((TO) == STACK_POINTER_REGNUM && frame_pointer_needed) ? 0 : \ | |
1855 | ((TO) == ARM_HARD_FRAME_POINTER_REGNUM && TARGET_THUMB) ? 0 : \ | |
1856 | ((TO) == THUMB_HARD_FRAME_POINTER_REGNUM && TARGET_ARM) ? 0 : \ | |
1857 | 1) | |
aeaf4d25 | 1858 | |
d5b7b3ae RE |
1859 | /* Define the offset between two registers, one to be eliminated, and the |
1860 | other its replacement, at the start of a routine. */ | |
d5b7b3ae RE |
1861 | #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ |
1862 | if (TARGET_ARM) \ | |
5848830f | 1863 | (OFFSET) = arm_compute_initial_elimination_offset (FROM, TO); \ |
d5b7b3ae | 1864 | else \ |
5848830f PB |
1865 | (OFFSET) = thumb_compute_initial_elimination_offset (FROM, TO) |
1866 | ||
d5b7b3ae RE |
1867 | /* Special case handling of the location of arguments passed on the stack. */ |
1868 | #define DEBUGGER_ARG_OFFSET(value, addr) value ? value : arm_debugger_arg_offset (value, addr) | |
f676971a | 1869 | |
d5b7b3ae RE |
1870 | /* Initialize data used by insn expanders. This is called from insn_emit, |
1871 | once for every function before code is generated. */ | |
1872 | #define INIT_EXPANDERS arm_init_expanders () | |
1873 | ||
35d965d5 RS |
1874 | /* Output assembler code for a block containing the constant parts |
1875 | of a trampoline, leaving space for the variable parts. | |
1876 | ||
1877 | On the ARM, (if r8 is the static chain regnum, and remembering that | |
1878 | referencing pc adds an offset of 8) the trampoline looks like: | |
1879 | ldr r8, [pc, #0] | |
1880 | ldr pc, [pc] | |
1881 | .word static chain value | |
11c1a207 | 1882 | .word function's address |
27847754 | 1883 | XXX FIXME: When the trampoline returns, r8 will be clobbered. */ |
301d03af RS |
1884 | #define ARM_TRAMPOLINE_TEMPLATE(FILE) \ |
1885 | { \ | |
1886 | asm_fprintf (FILE, "\tldr\t%r, [%r, #0]\n", \ | |
1887 | STATIC_CHAIN_REGNUM, PC_REGNUM); \ | |
1888 | asm_fprintf (FILE, "\tldr\t%r, [%r, #0]\n", \ | |
1889 | PC_REGNUM, PC_REGNUM); \ | |
1890 | assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \ | |
1891 | assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \ | |
d5b7b3ae RE |
1892 | } |
1893 | ||
5b3e6663 PB |
1894 | /* The Thumb-2 trampoline is similar to the arm implementation. |
1895 | Unlike 16-bit Thumb, we enter the stub in thumb mode. */ | |
1896 | #define THUMB2_TRAMPOLINE_TEMPLATE(FILE) \ | |
1897 | { \ | |
1898 | asm_fprintf (FILE, "\tldr.w\t%r, [%r, #4]\n", \ | |
1899 | STATIC_CHAIN_REGNUM, PC_REGNUM); \ | |
1900 | asm_fprintf (FILE, "\tldr.w\t%r, [%r, #4]\n", \ | |
1901 | PC_REGNUM, PC_REGNUM); \ | |
1902 | assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \ | |
1903 | assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \ | |
1904 | } | |
1905 | ||
1906 | #define THUMB1_TRAMPOLINE_TEMPLATE(FILE) \ | |
d5b7b3ae | 1907 | { \ |
5b3e6663 PB |
1908 | ASM_OUTPUT_ALIGN(FILE, 2); \ |
1909 | fprintf (FILE, "\t.code\t16\n"); \ | |
d5b7b3ae | 1910 | fprintf (FILE, ".Ltrampoline_start:\n"); \ |
5b3e6663 PB |
1911 | asm_fprintf (FILE, "\tpush\t{r0, r1}\n"); \ |
1912 | asm_fprintf (FILE, "\tldr\tr0, [%r, #8]\n", \ | |
1913 | PC_REGNUM); \ | |
1914 | asm_fprintf (FILE, "\tmov\t%r, r0\n", \ | |
1915 | STATIC_CHAIN_REGNUM); \ | |
1916 | asm_fprintf (FILE, "\tldr\tr0, [%r, #8]\n", \ | |
1917 | PC_REGNUM); \ | |
1918 | asm_fprintf (FILE, "\tstr\tr0, [%r, #4]\n", \ | |
1919 | SP_REGNUM); \ | |
1920 | asm_fprintf (FILE, "\tpop\t{r0, %r}\n", \ | |
1921 | PC_REGNUM); \ | |
1922 | assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \ | |
1923 | assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \ | |
35d965d5 RS |
1924 | } |
1925 | ||
d5b7b3ae RE |
1926 | #define TRAMPOLINE_TEMPLATE(FILE) \ |
1927 | if (TARGET_ARM) \ | |
1928 | ARM_TRAMPOLINE_TEMPLATE (FILE) \ | |
5b3e6663 PB |
1929 | else if (TARGET_THUMB2) \ |
1930 | THUMB2_TRAMPOLINE_TEMPLATE (FILE) \ | |
d5b7b3ae | 1931 | else \ |
5b3e6663 PB |
1932 | THUMB1_TRAMPOLINE_TEMPLATE (FILE) |
1933 | ||
1934 | /* Thumb trampolines should be entered in thumb mode, so set the bottom bit | |
1935 | of the address. */ | |
1936 | #define TRAMPOLINE_ADJUST_ADDRESS(ADDR) do \ | |
1937 | { \ | |
1938 | if (TARGET_THUMB) \ | |
1939 | (ADDR) = expand_simple_binop (Pmode, IOR, (ADDR), GEN_INT(1), \ | |
1940 | gen_reg_rtx (Pmode), 0, OPTAB_LIB_WIDEN); \ | |
1941 | } while(0) | |
f676971a | 1942 | |
35d965d5 | 1943 | /* Length in units of the trampoline for entering a nested function. */ |
5b3e6663 | 1944 | #define TRAMPOLINE_SIZE (TARGET_32BIT ? 16 : 20) |
35d965d5 | 1945 | |
006946e4 JM |
1946 | /* Alignment required for a trampoline in bits. */ |
1947 | #define TRAMPOLINE_ALIGNMENT 32 | |
35d965d5 | 1948 | |
2a86f515 | 1949 | |
35d965d5 RS |
1950 | /* Emit RTL insns to initialize the variable parts of a trampoline. |
1951 | FNADDR is an RTX for the address of the function's pure code. | |
1952 | CXT is an RTX for the static chain value for the function. */ | |
192c8d78 RE |
1953 | #ifndef INITIALIZE_TRAMPOLINE |
1954 | #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \ | |
1955 | { \ | |
1956 | emit_move_insn (gen_rtx_MEM (SImode, \ | |
1957 | plus_constant (TRAMP, \ | |
5b3e6663 | 1958 | TARGET_32BIT ? 8 : 12)), \ |
192c8d78 RE |
1959 | CXT); \ |
1960 | emit_move_insn (gen_rtx_MEM (SImode, \ | |
1961 | plus_constant (TRAMP, \ | |
5b3e6663 | 1962 | TARGET_32BIT ? 12 : 16)), \ |
192c8d78 | 1963 | FNADDR); \ |
49755603 | 1964 | emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__clear_cache"), \ |
bbbbb16a | 1965 | LCT_NORMAL, VOIDmode, 2, TRAMP, Pmode, \ |
49755603 | 1966 | plus_constant (TRAMP, TRAMPOLINE_SIZE), Pmode); \ |
35d965d5 | 1967 | } |
192c8d78 | 1968 | #endif |
35d965d5 | 1969 | |
35d965d5 RS |
1970 | \f |
1971 | /* Addressing modes, and classification of registers for them. */ | |
3cd45774 | 1972 | #define HAVE_POST_INCREMENT 1 |
5b3e6663 PB |
1973 | #define HAVE_PRE_INCREMENT TARGET_32BIT |
1974 | #define HAVE_POST_DECREMENT TARGET_32BIT | |
1975 | #define HAVE_PRE_DECREMENT TARGET_32BIT | |
1976 | #define HAVE_PRE_MODIFY_DISP TARGET_32BIT | |
1977 | #define HAVE_POST_MODIFY_DISP TARGET_32BIT | |
1978 | #define HAVE_PRE_MODIFY_REG TARGET_32BIT | |
1979 | #define HAVE_POST_MODIFY_REG TARGET_32BIT | |
35d965d5 RS |
1980 | |
1981 | /* Macros to check register numbers against specific register classes. */ | |
1982 | ||
1983 | /* These assume that REGNO is a hard or pseudo reg number. | |
1984 | They give nonzero only if REGNO is a hard reg of the suitable class | |
1985 | or a pseudo reg currently allocated to a suitable hard reg. | |
1986 | Since they use reg_renumber, they are safe only once reg_renumber | |
d6b4baa4 | 1987 | has been allocated, which happens in local-alloc.c. */ |
d5b7b3ae RE |
1988 | #define TEST_REGNO(R, TEST, VALUE) \ |
1989 | ((R TEST VALUE) || ((unsigned) reg_renumber[R] TEST VALUE)) | |
1990 | ||
5b3e6663 | 1991 | /* Don't allow the pc to be used. */ |
f1008e52 RE |
1992 | #define ARM_REGNO_OK_FOR_BASE_P(REGNO) \ |
1993 | (TEST_REGNO (REGNO, <, PC_REGNUM) \ | |
1994 | || TEST_REGNO (REGNO, ==, FRAME_POINTER_REGNUM) \ | |
1995 | || TEST_REGNO (REGNO, ==, ARG_POINTER_REGNUM)) | |
1996 | ||
5b3e6663 | 1997 | #define THUMB1_REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) \ |
f1008e52 RE |
1998 | (TEST_REGNO (REGNO, <=, LAST_LO_REGNUM) \ |
1999 | || (GET_MODE_SIZE (MODE) >= 4 \ | |
2000 | && TEST_REGNO (REGNO, ==, STACK_POINTER_REGNUM))) | |
2001 | ||
2002 | #define REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) \ | |
5b3e6663 PB |
2003 | (TARGET_THUMB1 \ |
2004 | ? THUMB1_REGNO_MODE_OK_FOR_BASE_P (REGNO, MODE) \ | |
f1008e52 RE |
2005 | : ARM_REGNO_OK_FOR_BASE_P (REGNO)) |
2006 | ||
888d2cd6 DJ |
2007 | /* Nonzero if X can be the base register in a reg+reg addressing mode. |
2008 | For Thumb, we can not use SP + reg, so reject SP. */ | |
2009 | #define REGNO_MODE_OK_FOR_REG_BASE_P(X, MODE) \ | |
f5c630c3 | 2010 | REGNO_MODE_OK_FOR_BASE_P (X, QImode) |
888d2cd6 | 2011 | |
f1008e52 RE |
2012 | /* For ARM code, we don't care about the mode, but for Thumb, the index |
2013 | must be suitable for use in a QImode load. */ | |
d5b7b3ae | 2014 | #define REGNO_OK_FOR_INDEX_P(REGNO) \ |
f5c630c3 PB |
2015 | (REGNO_MODE_OK_FOR_BASE_P (REGNO, QImode) \ |
2016 | && !TEST_REGNO (REGNO, ==, STACK_POINTER_REGNUM)) | |
35d965d5 RS |
2017 | |
2018 | /* Maximum number of registers that can appear in a valid memory address. | |
d6b4baa4 | 2019 | Shifts in addresses can't be by a register. */ |
ff9940b0 | 2020 | #define MAX_REGS_PER_ADDRESS 2 |
35d965d5 RS |
2021 | |
2022 | /* Recognize any constant value that is a valid address. */ | |
2023 | /* XXX We can address any constant, eventually... */ | |
5b3e6663 | 2024 | /* ??? Should the TARGET_ARM here also apply to thumb2? */ |
008cf58a RE |
2025 | #define CONSTANT_ADDRESS_P(X) \ |
2026 | (GET_CODE (X) == SYMBOL_REF \ | |
2027 | && (CONSTANT_POOL_ADDRESS_P (X) \ | |
d5b7b3ae | 2028 | || (TARGET_ARM && optimize > 0 && SYMBOL_REF_FLAG (X)))) |
35d965d5 | 2029 | |
8426b956 RS |
2030 | /* True if SYMBOL + OFFSET constants must refer to something within |
2031 | SYMBOL's section. */ | |
2032 | #define ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P 0 | |
2033 | ||
571191af PB |
2034 | /* Nonzero if all target requires all absolute relocations be R_ARM_ABS32. */ |
2035 | #ifndef TARGET_DEFAULT_WORD_RELOCATIONS | |
2036 | #define TARGET_DEFAULT_WORD_RELOCATIONS 0 | |
2037 | #endif | |
2038 | ||
35d965d5 RS |
2039 | /* Nonzero if the constant value X is a legitimate general operand. |
2040 | It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. | |
2041 | ||
2042 | On the ARM, allow any integer (invalid ones are removed later by insn | |
2043 | patterns), nice doubles and symbol_refs which refer to the function's | |
d5b7b3ae | 2044 | constant pool XXX. |
f676971a | 2045 | |
82e9d970 | 2046 | When generating pic allow anything. */ |
d5b7b3ae RE |
2047 | #define ARM_LEGITIMATE_CONSTANT_P(X) (flag_pic || ! label_mentioned_p (X)) |
2048 | ||
2049 | #define THUMB_LEGITIMATE_CONSTANT_P(X) \ | |
2050 | ( GET_CODE (X) == CONST_INT \ | |
2051 | || GET_CODE (X) == CONST_DOUBLE \ | |
7b8781c8 PB |
2052 | || CONSTANT_ADDRESS_P (X) \ |
2053 | || flag_pic) | |
d5b7b3ae | 2054 | |
d3585b76 | 2055 | #define LEGITIMATE_CONSTANT_P(X) \ |
8426b956 | 2056 | (!arm_cannot_force_const_mem (X) \ |
5b3e6663 PB |
2057 | && (TARGET_32BIT ? ARM_LEGITIMATE_CONSTANT_P (X) \ |
2058 | : THUMB_LEGITIMATE_CONSTANT_P (X))) | |
d5b7b3ae | 2059 | |
c27ba912 DM |
2060 | #ifndef SUBTARGET_NAME_ENCODING_LENGTHS |
2061 | #define SUBTARGET_NAME_ENCODING_LENGTHS | |
2062 | #endif | |
2063 | ||
6bc82793 | 2064 | /* This is a C fragment for the inside of a switch statement. |
c27ba912 DM |
2065 | Each case label should return the number of characters to |
2066 | be stripped from the start of a function's name, if that | |
2067 | name starts with the indicated character. */ | |
2068 | #define ARM_NAME_ENCODING_LENGTHS \ | |
00fdafef | 2069 | case '*': return 1; \ |
f676971a | 2070 | SUBTARGET_NAME_ENCODING_LENGTHS |
c27ba912 | 2071 | |
c27ba912 DM |
2072 | /* This is how to output a reference to a user-level label named NAME. |
2073 | `assemble_name' uses this. */ | |
e5951263 | 2074 | #undef ASM_OUTPUT_LABELREF |
c27ba912 | 2075 | #define ASM_OUTPUT_LABELREF(FILE, NAME) \ |
e1944073 | 2076 | arm_asm_output_labelref (FILE, NAME) |
c27ba912 | 2077 | |
7a085dce | 2078 | /* Output IT instructions for conditionally executed Thumb-2 instructions. */ |
5b3e6663 PB |
2079 | #define ASM_OUTPUT_OPCODE(STREAM, PTR) \ |
2080 | if (TARGET_THUMB2) \ | |
2081 | thumb2_asm_output_opcode (STREAM); | |
2082 | ||
7abc66b1 JB |
2083 | /* The EABI specifies that constructors should go in .init_array. |
2084 | Other targets use .ctors for compatibility. */ | |
88c6057f | 2085 | #ifndef ARM_EABI_CTORS_SECTION_OP |
7abc66b1 JB |
2086 | #define ARM_EABI_CTORS_SECTION_OP \ |
2087 | "\t.section\t.init_array,\"aw\",%init_array" | |
88c6057f MM |
2088 | #endif |
2089 | #ifndef ARM_EABI_DTORS_SECTION_OP | |
7abc66b1 JB |
2090 | #define ARM_EABI_DTORS_SECTION_OP \ |
2091 | "\t.section\t.fini_array,\"aw\",%fini_array" | |
88c6057f | 2092 | #endif |
7abc66b1 JB |
2093 | #define ARM_CTORS_SECTION_OP \ |
2094 | "\t.section\t.ctors,\"aw\",%progbits" | |
2095 | #define ARM_DTORS_SECTION_OP \ | |
2096 | "\t.section\t.dtors,\"aw\",%progbits" | |
2097 | ||
2098 | /* Define CTORS_SECTION_ASM_OP. */ | |
2099 | #undef CTORS_SECTION_ASM_OP | |
2100 | #undef DTORS_SECTION_ASM_OP | |
2101 | #ifndef IN_LIBGCC2 | |
2102 | # define CTORS_SECTION_ASM_OP \ | |
2103 | (TARGET_AAPCS_BASED ? ARM_EABI_CTORS_SECTION_OP : ARM_CTORS_SECTION_OP) | |
2104 | # define DTORS_SECTION_ASM_OP \ | |
2105 | (TARGET_AAPCS_BASED ? ARM_EABI_DTORS_SECTION_OP : ARM_DTORS_SECTION_OP) | |
2106 | #else /* !defined (IN_LIBGCC2) */ | |
2107 | /* In libgcc, CTORS_SECTION_ASM_OP must be a compile-time constant, | |
2108 | so we cannot use the definition above. */ | |
2109 | # ifdef __ARM_EABI__ | |
2110 | /* The .ctors section is not part of the EABI, so we do not define | |
2111 | CTORS_SECTION_ASM_OP when in libgcc; that prevents crtstuff | |
2112 | from trying to use it. We do define it when doing normal | |
2113 | compilation, as .init_array can be used instead of .ctors. */ | |
2114 | /* There is no need to emit begin or end markers when using | |
2115 | init_array; the dynamic linker will compute the size of the | |
2116 | array itself based on special symbols created by the static | |
2117 | linker. However, we do need to arrange to set up | |
2118 | exception-handling here. */ | |
2119 | # define CTOR_LIST_BEGIN asm (ARM_EABI_CTORS_SECTION_OP) | |
2120 | # define CTOR_LIST_END /* empty */ | |
2121 | # define DTOR_LIST_BEGIN asm (ARM_EABI_DTORS_SECTION_OP) | |
2122 | # define DTOR_LIST_END /* empty */ | |
2123 | # else /* !defined (__ARM_EABI__) */ | |
2124 | # define CTORS_SECTION_ASM_OP ARM_CTORS_SECTION_OP | |
2125 | # define DTORS_SECTION_ASM_OP ARM_DTORS_SECTION_OP | |
2126 | # endif /* !defined (__ARM_EABI__) */ | |
2127 | #endif /* !defined (IN_LIBCC2) */ | |
2128 | ||
1e731102 MM |
2129 | /* True if the operating system can merge entities with vague linkage |
2130 | (e.g., symbols in COMDAT group) during dynamic linking. */ | |
2131 | #ifndef TARGET_ARM_DYNAMIC_VAGUE_LINKAGE_P | |
2132 | #define TARGET_ARM_DYNAMIC_VAGUE_LINKAGE_P true | |
2133 | #endif | |
2134 | ||
617a1b71 PB |
2135 | #define ARM_OUTPUT_FN_UNWIND(F, PROLOGUE) arm_output_fn_unwind (F, PROLOGUE) |
2136 | ||
2137 | #ifdef TARGET_UNWIND_INFO | |
2138 | #define ARM_EABI_UNWIND_TABLES \ | |
2139 | ((!USING_SJLJ_EXCEPTIONS && flag_exceptions) || flag_unwind_tables) | |
2140 | #else | |
2141 | #define ARM_EABI_UNWIND_TABLES 0 | |
2142 | #endif | |
2143 | ||
35d965d5 RS |
2144 | /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx |
2145 | and check its validity for a certain class. | |
2146 | We have two alternate definitions for each of them. | |
2147 | The usual definition accepts all pseudo regs; the other rejects | |
2148 | them unless they have been allocated suitable hard regs. | |
5b3e6663 | 2149 | The symbol REG_OK_STRICT causes the latter definition to be used. |
7a085dce | 2150 | Thumb-2 has the same restrictions as arm. */ |
35d965d5 | 2151 | #ifndef REG_OK_STRICT |
ff9940b0 | 2152 | |
f1008e52 RE |
2153 | #define ARM_REG_OK_FOR_BASE_P(X) \ |
2154 | (REGNO (X) <= LAST_ARM_REGNUM \ | |
2155 | || REGNO (X) >= FIRST_PSEUDO_REGISTER \ | |
2156 | || REGNO (X) == FRAME_POINTER_REGNUM \ | |
2157 | || REGNO (X) == ARG_POINTER_REGNUM) | |
ff9940b0 | 2158 | |
f5c630c3 PB |
2159 | #define ARM_REG_OK_FOR_INDEX_P(X) \ |
2160 | ((REGNO (X) <= LAST_ARM_REGNUM \ | |
2161 | && REGNO (X) != STACK_POINTER_REGNUM) \ | |
2162 | || REGNO (X) >= FIRST_PSEUDO_REGISTER \ | |
2163 | || REGNO (X) == FRAME_POINTER_REGNUM \ | |
2164 | || REGNO (X) == ARG_POINTER_REGNUM) | |
2165 | ||
5b3e6663 | 2166 | #define THUMB1_REG_MODE_OK_FOR_BASE_P(X, MODE) \ |
f1008e52 RE |
2167 | (REGNO (X) <= LAST_LO_REGNUM \ |
2168 | || REGNO (X) >= FIRST_PSEUDO_REGISTER \ | |
2169 | || (GET_MODE_SIZE (MODE) >= 4 \ | |
2170 | && (REGNO (X) == STACK_POINTER_REGNUM \ | |
2171 | || (X) == hard_frame_pointer_rtx \ | |
2172 | || (X) == arg_pointer_rtx))) | |
ff9940b0 | 2173 | |
76a318e9 RE |
2174 | #define REG_STRICT_P 0 |
2175 | ||
d5b7b3ae | 2176 | #else /* REG_OK_STRICT */ |
ff9940b0 | 2177 | |
f1008e52 RE |
2178 | #define ARM_REG_OK_FOR_BASE_P(X) \ |
2179 | ARM_REGNO_OK_FOR_BASE_P (REGNO (X)) | |
ff9940b0 | 2180 | |
f5c630c3 PB |
2181 | #define ARM_REG_OK_FOR_INDEX_P(X) \ |
2182 | ARM_REGNO_OK_FOR_INDEX_P (REGNO (X)) | |
2183 | ||
5b3e6663 PB |
2184 | #define THUMB1_REG_MODE_OK_FOR_BASE_P(X, MODE) \ |
2185 | THUMB1_REGNO_MODE_OK_FOR_BASE_P (REGNO (X), MODE) | |
ff9940b0 | 2186 | |
76a318e9 RE |
2187 | #define REG_STRICT_P 1 |
2188 | ||
d5b7b3ae | 2189 | #endif /* REG_OK_STRICT */ |
f1008e52 RE |
2190 | |
2191 | /* Now define some helpers in terms of the above. */ | |
2192 | ||
2193 | #define REG_MODE_OK_FOR_BASE_P(X, MODE) \ | |
5b3e6663 PB |
2194 | (TARGET_THUMB1 \ |
2195 | ? THUMB1_REG_MODE_OK_FOR_BASE_P (X, MODE) \ | |
f1008e52 RE |
2196 | : ARM_REG_OK_FOR_BASE_P (X)) |
2197 | ||
5b3e6663 | 2198 | /* For 16-bit Thumb, a valid index register is anything that can be used in |
f1008e52 | 2199 | a byte load instruction. */ |
5b3e6663 PB |
2200 | #define THUMB1_REG_OK_FOR_INDEX_P(X) \ |
2201 | THUMB1_REG_MODE_OK_FOR_BASE_P (X, QImode) | |
f1008e52 RE |
2202 | |
2203 | /* Nonzero if X is a hard reg that can be used as an index | |
2204 | or if it is a pseudo reg. On the Thumb, the stack pointer | |
2205 | is not suitable. */ | |
2206 | #define REG_OK_FOR_INDEX_P(X) \ | |
5b3e6663 PB |
2207 | (TARGET_THUMB1 \ |
2208 | ? THUMB1_REG_OK_FOR_INDEX_P (X) \ | |
f1008e52 RE |
2209 | : ARM_REG_OK_FOR_INDEX_P (X)) |
2210 | ||
888d2cd6 DJ |
2211 | /* Nonzero if X can be the base register in a reg+reg addressing mode. |
2212 | For Thumb, we can not use SP + reg, so reject SP. */ | |
2213 | #define REG_MODE_OK_FOR_REG_BASE_P(X, MODE) \ | |
2214 | REG_OK_FOR_INDEX_P (X) | |
35d965d5 | 2215 | \f |
f1008e52 RE |
2216 | #define ARM_BASE_REGISTER_RTX_P(X) \ |
2217 | (GET_CODE (X) == REG && ARM_REG_OK_FOR_BASE_P (X)) | |
35d965d5 | 2218 | |
f1008e52 RE |
2219 | #define ARM_INDEX_REGISTER_RTX_P(X) \ |
2220 | (GET_CODE (X) == REG && ARM_REG_OK_FOR_INDEX_P (X)) | |
35d965d5 | 2221 | \f |
360032ba JY |
2222 | /* Define this for compatibility reasons. */ |
2223 | #define HANDLE_PRAGMA_PACK_PUSH_POP | |
d5b7b3ae | 2224 | |
35d965d5 RS |
2225 | /* Specify the machine mode that this machine uses |
2226 | for the index in the tablejump instruction. */ | |
d5b7b3ae | 2227 | #define CASE_VECTOR_MODE Pmode |
35d965d5 | 2228 | |
907dd0c7 RE |
2229 | #define CASE_VECTOR_PC_RELATIVE (TARGET_THUMB2 \ |
2230 | || (TARGET_THUMB \ | |
2231 | && (optimize_size || flag_pic))) | |
2232 | ||
2233 | #define CASE_VECTOR_SHORTEN_MODE(min, max, body) \ | |
2234 | (TARGET_THUMB \ | |
2235 | ? (min >= 0 && max < 512 \ | |
2236 | ? (ADDR_DIFF_VEC_FLAGS (body).offset_unsigned = 1, QImode) \ | |
2237 | : min >= -256 && max < 256 \ | |
2238 | ? (ADDR_DIFF_VEC_FLAGS (body).offset_unsigned = 0, QImode) \ | |
2239 | : min >= 0 && max < 8192 \ | |
2240 | ? (ADDR_DIFF_VEC_FLAGS (body).offset_unsigned = 1, HImode) \ | |
2241 | : min >= -4096 && max < 4096 \ | |
2242 | ? (ADDR_DIFF_VEC_FLAGS (body).offset_unsigned = 0, HImode) \ | |
2243 | : SImode) \ | |
2244 | : ((min < 0 || max >= 0x2000 || !TARGET_THUMB2) ? SImode \ | |
2245 | : (max >= 0x200) ? HImode \ | |
2246 | : QImode)) | |
5b3e6663 | 2247 | |
ff9940b0 RE |
2248 | /* signed 'char' is most compatible, but RISC OS wants it unsigned. |
2249 | unsigned is probably best, but may break some code. */ | |
2250 | #ifndef DEFAULT_SIGNED_CHAR | |
3967692c | 2251 | #define DEFAULT_SIGNED_CHAR 0 |
35d965d5 RS |
2252 | #endif |
2253 | ||
35d965d5 | 2254 | /* Max number of bytes we can move from memory to memory |
d17ce9af TG |
2255 | in one reasonably fast instruction. */ |
2256 | #define MOVE_MAX 4 | |
35d965d5 | 2257 | |
d19fb8e3 | 2258 | #undef MOVE_RATIO |
e04ad03d | 2259 | #define MOVE_RATIO(speed) (arm_tune_xscale ? 4 : 2) |
d19fb8e3 | 2260 | |
ff9940b0 RE |
2261 | /* Define if operations between registers always perform the operation |
2262 | on the full register even if a narrower mode is specified. */ | |
2263 | #define WORD_REGISTER_OPERATIONS | |
2264 | ||
2265 | /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD | |
2266 | will either zero-extend or sign-extend. The value of this macro should | |
2267 | be the code that says which one of the two operations is implicitly | |
f822d252 | 2268 | done, UNKNOWN if none. */ |
9c872872 | 2269 | #define LOAD_EXTEND_OP(MODE) \ |
d5b7b3ae RE |
2270 | (TARGET_THUMB ? ZERO_EXTEND : \ |
2271 | ((arm_arch4 || (MODE) == QImode) ? ZERO_EXTEND \ | |
f822d252 | 2272 | : ((BYTES_BIG_ENDIAN && (MODE) == HImode) ? SIGN_EXTEND : UNKNOWN))) |
ff9940b0 | 2273 | |
35d965d5 RS |
2274 | /* Nonzero if access to memory by bytes is slow and undesirable. */ |
2275 | #define SLOW_BYTE_ACCESS 0 | |
2276 | ||
d5b7b3ae | 2277 | #define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) 1 |
f676971a | 2278 | |
35d965d5 RS |
2279 | /* Immediate shift counts are truncated by the output routines (or was it |
2280 | the assembler?). Shift counts in a register are truncated by ARM. Note | |
2281 | that the native compiler puts too large (> 32) immediate shift counts | |
2282 | into a register and shifts by the register, letting the ARM decide what | |
2283 | to do instead of doing that itself. */ | |
ff9940b0 RE |
2284 | /* This is all wrong. Defining SHIFT_COUNT_TRUNCATED tells combine that |
2285 | code like (X << (Y % 32)) for register X, Y is equivalent to (X << Y). | |
2286 | On the arm, Y in a register is used modulo 256 for the shift. Only for | |
d6b4baa4 | 2287 | rotates is modulo 32 used. */ |
ff9940b0 | 2288 | /* #define SHIFT_COUNT_TRUNCATED 1 */ |
35d965d5 | 2289 | |
35d965d5 | 2290 | /* All integers have the same format so truncation is easy. */ |
d5b7b3ae | 2291 | #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1 |
35d965d5 RS |
2292 | |
2293 | /* Calling from registers is a massive pain. */ | |
2294 | #define NO_FUNCTION_CSE 1 | |
2295 | ||
35d965d5 RS |
2296 | /* The machine modes of pointers and functions */ |
2297 | #define Pmode SImode | |
2298 | #define FUNCTION_MODE Pmode | |
2299 | ||
d5b7b3ae RE |
2300 | #define ARM_FRAME_RTX(X) \ |
2301 | ( (X) == frame_pointer_rtx || (X) == stack_pointer_rtx \ | |
3967692c RE |
2302 | || (X) == arg_pointer_rtx) |
2303 | ||
ff9940b0 | 2304 | /* Moves to and from memory are quite expensive */ |
d5b7b3ae | 2305 | #define MEMORY_MOVE_COST(M, CLASS, IN) \ |
5b3e6663 | 2306 | (TARGET_32BIT ? 10 : \ |
d5b7b3ae RE |
2307 | ((GET_MODE_SIZE (M) < 4 ? 8 : 2 * GET_MODE_SIZE (M)) \ |
2308 | * (CLASS == LO_REGS ? 1 : 2))) | |
f676971a | 2309 | |
ff9940b0 RE |
2310 | /* Try to generate sequences that don't involve branches, we can then use |
2311 | conditional instructions */ | |
3a4fd356 | 2312 | #define BRANCH_COST(speed_p, predictable_p) \ |
5b3e6663 | 2313 | (TARGET_32BIT ? 4 : (optimize > 0 ? 2 : 0)) |
7a801826 RE |
2314 | \f |
2315 | /* Position Independent Code. */ | |
2316 | /* We decide which register to use based on the compilation options and | |
2317 | the assembler in use; this is more general than the APCS restriction of | |
2318 | using sb (r9) all the time. */ | |
020a4035 | 2319 | extern unsigned arm_pic_register; |
7a801826 RE |
2320 | |
2321 | /* The register number of the register used to address a table of static | |
2322 | data addresses in memory. */ | |
2323 | #define PIC_OFFSET_TABLE_REGNUM arm_pic_register | |
2324 | ||
f5a1b0d2 | 2325 | /* We can't directly access anything that contains a symbol, |
d3585b76 DJ |
2326 | nor can we indirect via the constant pool. One exception is |
2327 | UNSPEC_TLS, which is always PIC. */ | |
82e9d970 | 2328 | #define LEGITIMATE_PIC_OPERAND_P(X) \ |
1575c31e JD |
2329 | (!(symbol_mentioned_p (X) \ |
2330 | || label_mentioned_p (X) \ | |
2331 | || (GET_CODE (X) == SYMBOL_REF \ | |
2332 | && CONSTANT_POOL_ADDRESS_P (X) \ | |
2333 | && (symbol_mentioned_p (get_pool_constant (X)) \ | |
d3585b76 DJ |
2334 | || label_mentioned_p (get_pool_constant (X))))) \ |
2335 | || tls_mentioned_p (X)) | |
1575c31e | 2336 | |
13bd191d PB |
2337 | /* We need to know when we are making a constant pool; this determines |
2338 | whether data needs to be in the GOT or can be referenced via a GOT | |
2339 | offset. */ | |
2340 | extern int making_const_table; | |
82e9d970 | 2341 | \f |
c27ba912 | 2342 | /* Handle pragmas for compatibility with Intel's compilers. */ |
b76c3c4b | 2343 | /* Also abuse this to register additional C specific EABI attributes. */ |
c58b209a NB |
2344 | #define REGISTER_TARGET_PRAGMAS() do { \ |
2345 | c_register_pragma (0, "long_calls", arm_pr_long_calls); \ | |
2346 | c_register_pragma (0, "no_long_calls", arm_pr_no_long_calls); \ | |
2347 | c_register_pragma (0, "long_calls_off", arm_pr_long_calls_off); \ | |
b76c3c4b | 2348 | arm_lang_object_attributes_init(); \ |
8b97c5f8 ZW |
2349 | } while (0) |
2350 | ||
d6b4baa4 | 2351 | /* Condition code information. */ |
ff9940b0 | 2352 | /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE, |
a5381466 | 2353 | return the mode to be used for the comparison. */ |
d5b7b3ae RE |
2354 | |
2355 | #define SELECT_CC_MODE(OP, X, Y) arm_select_cc_mode (OP, X, Y) | |
ff9940b0 | 2356 | |
880873be RE |
2357 | #define REVERSIBLE_CC_MODE(MODE) 1 |
2358 | ||
2359 | #define REVERSE_CONDITION(CODE,MODE) \ | |
2360 | (((MODE) == CCFPmode || (MODE) == CCFPEmode) \ | |
2361 | ? reverse_condition_maybe_unordered (code) \ | |
2362 | : reverse_condition (code)) | |
008cf58a | 2363 | |
62b10bbc NC |
2364 | #define CANONICALIZE_COMPARISON(CODE, OP0, OP1) \ |
2365 | do \ | |
2366 | { \ | |
2367 | if (GET_CODE (OP1) == CONST_INT \ | |
2368 | && ! (const_ok_for_arm (INTVAL (OP1)) \ | |
2369 | || (const_ok_for_arm (- INTVAL (OP1))))) \ | |
2370 | { \ | |
2371 | rtx const_op = OP1; \ | |
a14b88bb PB |
2372 | CODE = arm_canonicalize_comparison ((CODE), GET_MODE (OP0), \ |
2373 | &const_op); \ | |
62b10bbc NC |
2374 | OP1 = const_op; \ |
2375 | } \ | |
2376 | } \ | |
2377 | while (0) | |
62dd06ea | 2378 | |
7dba8395 RH |
2379 | /* The arm5 clz instruction returns 32. */ |
2380 | #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 32, 1) | |
35d965d5 | 2381 | \f |
d5b7b3ae | 2382 | #undef ASM_APP_OFF |
5b3e6663 PB |
2383 | #define ASM_APP_OFF (TARGET_THUMB1 ? "\t.code\t16\n" : \ |
2384 | TARGET_THUMB2 ? "\t.thumb\n" : "") | |
35d965d5 | 2385 | |
35d965d5 | 2386 | /* Output a push or a pop instruction (only used when profiling). */ |
d5b7b3ae | 2387 | #define ASM_OUTPUT_REG_PUSH(STREAM, REGNO) \ |
8a81cc45 RE |
2388 | do \ |
2389 | { \ | |
2390 | if (TARGET_ARM) \ | |
2391 | asm_fprintf (STREAM,"\tstmfd\t%r!,{%r}\n", \ | |
2392 | STACK_POINTER_REGNUM, REGNO); \ | |
2393 | else \ | |
2394 | asm_fprintf (STREAM, "\tpush {%r}\n", REGNO); \ | |
2395 | } while (0) | |
d5b7b3ae RE |
2396 | |
2397 | ||
2398 | #define ASM_OUTPUT_REG_POP(STREAM, REGNO) \ | |
8a81cc45 RE |
2399 | do \ |
2400 | { \ | |
2401 | if (TARGET_ARM) \ | |
2402 | asm_fprintf (STREAM, "\tldmfd\t%r!,{%r}\n", \ | |
2403 | STACK_POINTER_REGNUM, REGNO); \ | |
2404 | else \ | |
2405 | asm_fprintf (STREAM, "\tpop {%r}\n", REGNO); \ | |
2406 | } while (0) | |
d5b7b3ae | 2407 | |
5b3e6663 PB |
2408 | /* Jump table alignment is explicit in ASM_OUTPUT_CASE_LABEL. */ |
2409 | #define ADDR_VEC_ALIGN(JUMPTABLE) 0 | |
2410 | ||
d5b7b3ae RE |
2411 | /* This is how to output a label which precedes a jumptable. Since |
2412 | Thumb instructions are 2 bytes, we may need explicit alignment here. */ | |
be393ecf | 2413 | #undef ASM_OUTPUT_CASE_LABEL |
5b3e6663 PB |
2414 | #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \ |
2415 | do \ | |
2416 | { \ | |
2417 | if (TARGET_THUMB && GET_MODE (PATTERN (JUMPTABLE)) == SImode) \ | |
2418 | ASM_OUTPUT_ALIGN (FILE, 2); \ | |
2419 | (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); \ | |
2420 | } \ | |
2421 | while (0) | |
2422 | ||
2423 | /* Make sure subsequent insns are aligned after a TBB. */ | |
2424 | #define ASM_OUTPUT_CASE_END(FILE, NUM, JUMPTABLE) \ | |
2425 | do \ | |
2426 | { \ | |
2427 | if (GET_MODE (PATTERN (JUMPTABLE)) == QImode) \ | |
2428 | ASM_OUTPUT_ALIGN (FILE, 1); \ | |
2429 | } \ | |
d5b7b3ae | 2430 | while (0) |
35d965d5 | 2431 | |
6cfc7210 NC |
2432 | #define ARM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \ |
2433 | do \ | |
2434 | { \ | |
d5b7b3ae RE |
2435 | if (TARGET_THUMB) \ |
2436 | { \ | |
5b3e6663 | 2437 | if (is_called_in_ARM_mode (DECL) \ |
bf98ec6c | 2438 | || (TARGET_THUMB1 && !TARGET_THUMB1_ONLY \ |
3c072c6b | 2439 | && cfun->is_thunk)) \ |
d5b7b3ae | 2440 | fprintf (STREAM, "\t.code 32\n") ; \ |
5b3e6663 PB |
2441 | else if (TARGET_THUMB1) \ |
2442 | fprintf (STREAM, "\t.code\t16\n\t.thumb_func\n") ; \ | |
d5b7b3ae | 2443 | else \ |
5b3e6663 | 2444 | fprintf (STREAM, "\t.thumb\n\t.thumb_func\n") ; \ |
d5b7b3ae | 2445 | } \ |
6cfc7210 | 2446 | if (TARGET_POKE_FUNCTION_NAME) \ |
586de218 | 2447 | arm_poke_function_name (STREAM, (const char *) NAME); \ |
6cfc7210 NC |
2448 | } \ |
2449 | while (0) | |
35d965d5 | 2450 | |
d5b7b3ae RE |
2451 | /* For aliases of functions we use .thumb_set instead. */ |
2452 | #define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL1, DECL2) \ | |
2453 | do \ | |
2454 | { \ | |
91ea4f8d KG |
2455 | const char *const LABEL1 = XSTR (XEXP (DECL_RTL (decl), 0), 0); \ |
2456 | const char *const LABEL2 = IDENTIFIER_POINTER (DECL2); \ | |
d5b7b3ae RE |
2457 | \ |
2458 | if (TARGET_THUMB && TREE_CODE (DECL1) == FUNCTION_DECL) \ | |
2459 | { \ | |
2460 | fprintf (FILE, "\t.thumb_set "); \ | |
2461 | assemble_name (FILE, LABEL1); \ | |
2462 | fprintf (FILE, ","); \ | |
2463 | assemble_name (FILE, LABEL2); \ | |
2464 | fprintf (FILE, "\n"); \ | |
2465 | } \ | |
2466 | else \ | |
2467 | ASM_OUTPUT_DEF (FILE, LABEL1, LABEL2); \ | |
2468 | } \ | |
2469 | while (0) | |
2470 | ||
fdc2d3b0 NC |
2471 | #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN |
2472 | /* To support -falign-* switches we need to use .p2align so | |
2473 | that alignment directives in code sections will be padded | |
2474 | with no-op instructions, rather than zeroes. */ | |
5a9335ef | 2475 | #define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ |
fdc2d3b0 NC |
2476 | if ((LOG) != 0) \ |
2477 | { \ | |
2478 | if ((MAX_SKIP) == 0) \ | |
5a9335ef | 2479 | fprintf ((FILE), "\t.p2align %d\n", (int) (LOG)); \ |
fdc2d3b0 NC |
2480 | else \ |
2481 | fprintf ((FILE), "\t.p2align %d,,%d\n", \ | |
5a9335ef | 2482 | (int) (LOG), (int) (MAX_SKIP)); \ |
fdc2d3b0 NC |
2483 | } |
2484 | #endif | |
35d965d5 | 2485 | \f |
5b3e6663 PB |
2486 | /* Add two bytes to the length of conditionally executed Thumb-2 |
2487 | instructions for the IT instruction. */ | |
2488 | #define ADJUST_INSN_LENGTH(insn, length) \ | |
2489 | if (TARGET_THUMB2 && GET_CODE (PATTERN (insn)) == COND_EXEC) \ | |
2490 | length += 2; | |
2491 | ||
35d965d5 | 2492 | /* Only perform branch elimination (by making instructions conditional) if |
5b3e6663 PB |
2493 | we're optimizing. For Thumb-2 check if any IT instructions need |
2494 | outputting. */ | |
d5b7b3ae RE |
2495 | #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \ |
2496 | if (TARGET_ARM && optimize) \ | |
2497 | arm_final_prescan_insn (INSN); \ | |
5b3e6663 PB |
2498 | else if (TARGET_THUMB2) \ |
2499 | thumb2_final_prescan_insn (INSN); \ | |
2500 | else if (TARGET_THUMB1) \ | |
2501 | thumb1_final_prescan_insn (INSN) | |
35d965d5 | 2502 | |
7bc7696c | 2503 | #define PRINT_OPERAND_PUNCT_VALID_P(CODE) \ |
5b3e6663 | 2504 | (CODE == '@' || CODE == '|' || CODE == '.' \ |
88f77cba | 2505 | || CODE == '(' || CODE == ')' || CODE == '#' \ |
5b3e6663 PB |
2506 | || (TARGET_32BIT && (CODE == '?')) \ |
2507 | || (TARGET_THUMB2 && (CODE == '!')) \ | |
d5b7b3ae | 2508 | || (TARGET_THUMB && (CODE == '_'))) |
6cfc7210 | 2509 | |
7bc7696c | 2510 | /* Output an operand of an instruction. */ |
35d965d5 | 2511 | #define PRINT_OPERAND(STREAM, X, CODE) \ |
7bc7696c RE |
2512 | arm_print_operand (STREAM, X, CODE) |
2513 | ||
7b8b8ade NC |
2514 | #define ARM_SIGN_EXTEND(x) ((HOST_WIDE_INT) \ |
2515 | (HOST_BITS_PER_WIDE_INT <= 32 ? (unsigned HOST_WIDE_INT) (x) \ | |
30cf4896 KG |
2516 | : ((((unsigned HOST_WIDE_INT)(x)) & (unsigned HOST_WIDE_INT) 0xffffffff) |\ |
2517 | ((((unsigned HOST_WIDE_INT)(x)) & (unsigned HOST_WIDE_INT) 0x80000000) \ | |
2518 | ? ((~ (unsigned HOST_WIDE_INT) 0) \ | |
2519 | & ~ (unsigned HOST_WIDE_INT) 0xffffffff) \ | |
7bc7696c | 2520 | : 0)))) |
35d965d5 RS |
2521 | |
2522 | /* Output the address of an operand. */ | |
3cd45774 RE |
2523 | #define ARM_PRINT_OPERAND_ADDRESS(STREAM, X) \ |
2524 | { \ | |
2525 | int is_minus = GET_CODE (X) == MINUS; \ | |
2526 | \ | |
2527 | if (GET_CODE (X) == REG) \ | |
2528 | asm_fprintf (STREAM, "[%r, #0]", REGNO (X)); \ | |
2529 | else if (GET_CODE (X) == PLUS || is_minus) \ | |
2530 | { \ | |
2531 | rtx base = XEXP (X, 0); \ | |
2532 | rtx index = XEXP (X, 1); \ | |
2533 | HOST_WIDE_INT offset = 0; \ | |
f5c630c3 PB |
2534 | if (GET_CODE (base) != REG \ |
2535 | || (GET_CODE (index) == REG && REGNO (index) == SP_REGNUM)) \ | |
3cd45774 | 2536 | { \ |
d6b4baa4 KH |
2537 | /* Ensure that BASE is a register. */ \ |
2538 | /* (one of them must be). */ \ | |
f5c630c3 | 2539 | /* Also ensure the SP is not used as in index register. */ \ |
3cd45774 RE |
2540 | rtx temp = base; \ |
2541 | base = index; \ | |
2542 | index = temp; \ | |
2543 | } \ | |
2544 | switch (GET_CODE (index)) \ | |
2545 | { \ | |
2546 | case CONST_INT: \ | |
2547 | offset = INTVAL (index); \ | |
2548 | if (is_minus) \ | |
2549 | offset = -offset; \ | |
c53dddc2 | 2550 | asm_fprintf (STREAM, "[%r, #%wd]", \ |
3cd45774 RE |
2551 | REGNO (base), offset); \ |
2552 | break; \ | |
2553 | \ | |
2554 | case REG: \ | |
2555 | asm_fprintf (STREAM, "[%r, %s%r]", \ | |
2556 | REGNO (base), is_minus ? "-" : "", \ | |
2557 | REGNO (index)); \ | |
2558 | break; \ | |
2559 | \ | |
2560 | case MULT: \ | |
2561 | case ASHIFTRT: \ | |
2562 | case LSHIFTRT: \ | |
2563 | case ASHIFT: \ | |
2564 | case ROTATERT: \ | |
2565 | { \ | |
2566 | asm_fprintf (STREAM, "[%r, %s%r", \ | |
2567 | REGNO (base), is_minus ? "-" : "", \ | |
2568 | REGNO (XEXP (index, 0))); \ | |
2569 | arm_print_operand (STREAM, index, 'S'); \ | |
2570 | fputs ("]", STREAM); \ | |
2571 | break; \ | |
2572 | } \ | |
2573 | \ | |
2574 | default: \ | |
e6d29d15 | 2575 | gcc_unreachable (); \ |
3cd45774 RE |
2576 | } \ |
2577 | } \ | |
2578 | else if (GET_CODE (X) == PRE_INC || GET_CODE (X) == POST_INC \ | |
2579 | || GET_CODE (X) == PRE_DEC || GET_CODE (X) == POST_DEC) \ | |
2580 | { \ | |
2581 | extern enum machine_mode output_memory_reference_mode; \ | |
2582 | \ | |
e6d29d15 | 2583 | gcc_assert (GET_CODE (XEXP (X, 0)) == REG); \ |
3cd45774 RE |
2584 | \ |
2585 | if (GET_CODE (X) == PRE_DEC || GET_CODE (X) == PRE_INC) \ | |
2586 | asm_fprintf (STREAM, "[%r, #%s%d]!", \ | |
2587 | REGNO (XEXP (X, 0)), \ | |
2588 | GET_CODE (X) == PRE_DEC ? "-" : "", \ | |
2589 | GET_MODE_SIZE (output_memory_reference_mode)); \ | |
2590 | else \ | |
2591 | asm_fprintf (STREAM, "[%r], #%s%d", \ | |
2592 | REGNO (XEXP (X, 0)), \ | |
2593 | GET_CODE (X) == POST_DEC ? "-" : "", \ | |
2594 | GET_MODE_SIZE (output_memory_reference_mode)); \ | |
2595 | } \ | |
2596 | else if (GET_CODE (X) == PRE_MODIFY) \ | |
2597 | { \ | |
2598 | asm_fprintf (STREAM, "[%r, ", REGNO (XEXP (X, 0))); \ | |
2599 | if (GET_CODE (XEXP (XEXP (X, 1), 1)) == CONST_INT) \ | |
c53dddc2 | 2600 | asm_fprintf (STREAM, "#%wd]!", \ |
3cd45774 RE |
2601 | INTVAL (XEXP (XEXP (X, 1), 1))); \ |
2602 | else \ | |
2603 | asm_fprintf (STREAM, "%r]!", \ | |
2604 | REGNO (XEXP (XEXP (X, 1), 1))); \ | |
2605 | } \ | |
2606 | else if (GET_CODE (X) == POST_MODIFY) \ | |
2607 | { \ | |
2608 | asm_fprintf (STREAM, "[%r], ", REGNO (XEXP (X, 0))); \ | |
2609 | if (GET_CODE (XEXP (XEXP (X, 1), 1)) == CONST_INT) \ | |
c53dddc2 | 2610 | asm_fprintf (STREAM, "#%wd", \ |
3cd45774 RE |
2611 | INTVAL (XEXP (XEXP (X, 1), 1))); \ |
2612 | else \ | |
2613 | asm_fprintf (STREAM, "%r", \ | |
2614 | REGNO (XEXP (XEXP (X, 1), 1))); \ | |
2615 | } \ | |
2616 | else output_addr_const (STREAM, X); \ | |
35d965d5 | 2617 | } |
62dd06ea | 2618 | |
d5b7b3ae RE |
2619 | #define THUMB_PRINT_OPERAND_ADDRESS(STREAM, X) \ |
2620 | { \ | |
2621 | if (GET_CODE (X) == REG) \ | |
2622 | asm_fprintf (STREAM, "[%r]", REGNO (X)); \ | |
2623 | else if (GET_CODE (X) == POST_INC) \ | |
2624 | asm_fprintf (STREAM, "%r!", REGNO (XEXP (X, 0))); \ | |
2625 | else if (GET_CODE (X) == PLUS) \ | |
2626 | { \ | |
e6d29d15 | 2627 | gcc_assert (GET_CODE (XEXP (X, 0)) == REG); \ |
d5b7b3ae | 2628 | if (GET_CODE (XEXP (X, 1)) == CONST_INT) \ |
659bdc68 | 2629 | asm_fprintf (STREAM, "[%r, #%wd]", \ |
d5b7b3ae | 2630 | REGNO (XEXP (X, 0)), \ |
659bdc68 | 2631 | INTVAL (XEXP (X, 1))); \ |
d5b7b3ae RE |
2632 | else \ |
2633 | asm_fprintf (STREAM, "[%r, %r]", \ | |
2634 | REGNO (XEXP (X, 0)), \ | |
2635 | REGNO (XEXP (X, 1))); \ | |
2636 | } \ | |
2637 | else \ | |
2638 | output_addr_const (STREAM, X); \ | |
2639 | } | |
2640 | ||
2641 | #define PRINT_OPERAND_ADDRESS(STREAM, X) \ | |
5b3e6663 | 2642 | if (TARGET_32BIT) \ |
d5b7b3ae RE |
2643 | ARM_PRINT_OPERAND_ADDRESS (STREAM, X) \ |
2644 | else \ | |
2645 | THUMB_PRINT_OPERAND_ADDRESS (STREAM, X) | |
5a9335ef | 2646 | |
d3585b76 DJ |
2647 | #define OUTPUT_ADDR_CONST_EXTRA(file, x, fail) \ |
2648 | if (arm_output_addr_const_extra (file, x) == FALSE) \ | |
2649 | goto fail | |
5a9335ef | 2650 | |
6a5d7526 MS |
2651 | /* A C expression whose value is RTL representing the value of the return |
2652 | address for the frame COUNT steps up from the current frame. */ | |
2653 | ||
d5b7b3ae RE |
2654 | #define RETURN_ADDR_RTX(COUNT, FRAME) \ |
2655 | arm_return_addr (COUNT, FRAME) | |
2656 | ||
f676971a | 2657 | /* Mask of the bits in the PC that contain the real return address |
d5b7b3ae RE |
2658 | when running in 26-bit mode. */ |
2659 | #define RETURN_ADDR_MASK26 (0x03fffffc) | |
6a5d7526 | 2660 | |
2c849145 JM |
2661 | /* Pick up the return address upon entry to a procedure. Used for |
2662 | dwarf2 unwind information. This also enables the table driven | |
2663 | mechanism. */ | |
2c849145 JM |
2664 | #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LR_REGNUM) |
2665 | #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (LR_REGNUM) | |
2666 | ||
39950dff MS |
2667 | /* Used to mask out junk bits from the return address, such as |
2668 | processor state, interrupt status, condition codes and the like. */ | |
2669 | #define MASK_RETURN_ADDR \ | |
2670 | /* If we are generating code for an ARM2/ARM3 machine or for an ARM6 \ | |
2671 | in 26 bit mode, the condition codes must be masked out of the \ | |
2672 | return address. This does not apply to ARM6 and later processors \ | |
2673 | when running in 32 bit mode. */ \ | |
61f0ccff RE |
2674 | ((arm_arch4 || TARGET_THUMB) \ |
2675 | ? (gen_int_mode ((unsigned long)0xffffffff, Pmode)) \ | |
fcd53748 | 2676 | : arm_gen_return_addr_mask ()) |
d5b7b3ae RE |
2677 | |
2678 | \f | |
88f77cba JB |
2679 | /* Neon defines builtins from ARM_BUILTIN_MAX upwards, though they don't have |
2680 | symbolic names defined here (which would require too much duplication). | |
2681 | FIXME? */ | |
5a9335ef NC |
2682 | enum arm_builtins |
2683 | { | |
2684 | ARM_BUILTIN_GETWCX, | |
2685 | ARM_BUILTIN_SETWCX, | |
2686 | ||
2687 | ARM_BUILTIN_WZERO, | |
2688 | ||
2689 | ARM_BUILTIN_WAVG2BR, | |
2690 | ARM_BUILTIN_WAVG2HR, | |
2691 | ARM_BUILTIN_WAVG2B, | |
2692 | ARM_BUILTIN_WAVG2H, | |
2693 | ||
2694 | ARM_BUILTIN_WACCB, | |
2695 | ARM_BUILTIN_WACCH, | |
2696 | ARM_BUILTIN_WACCW, | |
2697 | ||
2698 | ARM_BUILTIN_WMACS, | |
2699 | ARM_BUILTIN_WMACSZ, | |
2700 | ARM_BUILTIN_WMACU, | |
2701 | ARM_BUILTIN_WMACUZ, | |
2702 | ||
2703 | ARM_BUILTIN_WSADB, | |
2704 | ARM_BUILTIN_WSADBZ, | |
2705 | ARM_BUILTIN_WSADH, | |
2706 | ARM_BUILTIN_WSADHZ, | |
2707 | ||
2708 | ARM_BUILTIN_WALIGN, | |
2709 | ||
2710 | ARM_BUILTIN_TMIA, | |
2711 | ARM_BUILTIN_TMIAPH, | |
2712 | ARM_BUILTIN_TMIABB, | |
2713 | ARM_BUILTIN_TMIABT, | |
2714 | ARM_BUILTIN_TMIATB, | |
2715 | ARM_BUILTIN_TMIATT, | |
2716 | ||
2717 | ARM_BUILTIN_TMOVMSKB, | |
2718 | ARM_BUILTIN_TMOVMSKH, | |
2719 | ARM_BUILTIN_TMOVMSKW, | |
2720 | ||
2721 | ARM_BUILTIN_TBCSTB, | |
2722 | ARM_BUILTIN_TBCSTH, | |
2723 | ARM_BUILTIN_TBCSTW, | |
2724 | ||
2725 | ARM_BUILTIN_WMADDS, | |
2726 | ARM_BUILTIN_WMADDU, | |
2727 | ||
2728 | ARM_BUILTIN_WPACKHSS, | |
2729 | ARM_BUILTIN_WPACKWSS, | |
2730 | ARM_BUILTIN_WPACKDSS, | |
2731 | ARM_BUILTIN_WPACKHUS, | |
2732 | ARM_BUILTIN_WPACKWUS, | |
2733 | ARM_BUILTIN_WPACKDUS, | |
2734 | ||
2735 | ARM_BUILTIN_WADDB, | |
2736 | ARM_BUILTIN_WADDH, | |
2737 | ARM_BUILTIN_WADDW, | |
2738 | ARM_BUILTIN_WADDSSB, | |
2739 | ARM_BUILTIN_WADDSSH, | |
2740 | ARM_BUILTIN_WADDSSW, | |
2741 | ARM_BUILTIN_WADDUSB, | |
2742 | ARM_BUILTIN_WADDUSH, | |
2743 | ARM_BUILTIN_WADDUSW, | |
2744 | ARM_BUILTIN_WSUBB, | |
2745 | ARM_BUILTIN_WSUBH, | |
2746 | ARM_BUILTIN_WSUBW, | |
2747 | ARM_BUILTIN_WSUBSSB, | |
2748 | ARM_BUILTIN_WSUBSSH, | |
2749 | ARM_BUILTIN_WSUBSSW, | |
2750 | ARM_BUILTIN_WSUBUSB, | |
2751 | ARM_BUILTIN_WSUBUSH, | |
2752 | ARM_BUILTIN_WSUBUSW, | |
2753 | ||
2754 | ARM_BUILTIN_WAND, | |
2755 | ARM_BUILTIN_WANDN, | |
2756 | ARM_BUILTIN_WOR, | |
2757 | ARM_BUILTIN_WXOR, | |
2758 | ||
2759 | ARM_BUILTIN_WCMPEQB, | |
2760 | ARM_BUILTIN_WCMPEQH, | |
2761 | ARM_BUILTIN_WCMPEQW, | |
2762 | ARM_BUILTIN_WCMPGTUB, | |
2763 | ARM_BUILTIN_WCMPGTUH, | |
2764 | ARM_BUILTIN_WCMPGTUW, | |
2765 | ARM_BUILTIN_WCMPGTSB, | |
2766 | ARM_BUILTIN_WCMPGTSH, | |
2767 | ARM_BUILTIN_WCMPGTSW, | |
2768 | ||
2769 | ARM_BUILTIN_TEXTRMSB, | |
2770 | ARM_BUILTIN_TEXTRMSH, | |
2771 | ARM_BUILTIN_TEXTRMSW, | |
2772 | ARM_BUILTIN_TEXTRMUB, | |
2773 | ARM_BUILTIN_TEXTRMUH, | |
2774 | ARM_BUILTIN_TEXTRMUW, | |
2775 | ARM_BUILTIN_TINSRB, | |
2776 | ARM_BUILTIN_TINSRH, | |
2777 | ARM_BUILTIN_TINSRW, | |
2778 | ||
2779 | ARM_BUILTIN_WMAXSW, | |
2780 | ARM_BUILTIN_WMAXSH, | |
2781 | ARM_BUILTIN_WMAXSB, | |
2782 | ARM_BUILTIN_WMAXUW, | |
2783 | ARM_BUILTIN_WMAXUH, | |
2784 | ARM_BUILTIN_WMAXUB, | |
2785 | ARM_BUILTIN_WMINSW, | |
2786 | ARM_BUILTIN_WMINSH, | |
2787 | ARM_BUILTIN_WMINSB, | |
2788 | ARM_BUILTIN_WMINUW, | |
2789 | ARM_BUILTIN_WMINUH, | |
2790 | ARM_BUILTIN_WMINUB, | |
2791 | ||
f07a6b21 BE |
2792 | ARM_BUILTIN_WMULUM, |
2793 | ARM_BUILTIN_WMULSM, | |
5a9335ef NC |
2794 | ARM_BUILTIN_WMULUL, |
2795 | ||
2796 | ARM_BUILTIN_PSADBH, | |
2797 | ARM_BUILTIN_WSHUFH, | |
2798 | ||
2799 | ARM_BUILTIN_WSLLH, | |
2800 | ARM_BUILTIN_WSLLW, | |
2801 | ARM_BUILTIN_WSLLD, | |
2802 | ARM_BUILTIN_WSRAH, | |
2803 | ARM_BUILTIN_WSRAW, | |
2804 | ARM_BUILTIN_WSRAD, | |
2805 | ARM_BUILTIN_WSRLH, | |
2806 | ARM_BUILTIN_WSRLW, | |
2807 | ARM_BUILTIN_WSRLD, | |
2808 | ARM_BUILTIN_WRORH, | |
2809 | ARM_BUILTIN_WRORW, | |
2810 | ARM_BUILTIN_WRORD, | |
2811 | ARM_BUILTIN_WSLLHI, | |
2812 | ARM_BUILTIN_WSLLWI, | |
2813 | ARM_BUILTIN_WSLLDI, | |
2814 | ARM_BUILTIN_WSRAHI, | |
2815 | ARM_BUILTIN_WSRAWI, | |
2816 | ARM_BUILTIN_WSRADI, | |
2817 | ARM_BUILTIN_WSRLHI, | |
2818 | ARM_BUILTIN_WSRLWI, | |
2819 | ARM_BUILTIN_WSRLDI, | |
2820 | ARM_BUILTIN_WRORHI, | |
2821 | ARM_BUILTIN_WRORWI, | |
2822 | ARM_BUILTIN_WRORDI, | |
2823 | ||
2824 | ARM_BUILTIN_WUNPCKIHB, | |
2825 | ARM_BUILTIN_WUNPCKIHH, | |
2826 | ARM_BUILTIN_WUNPCKIHW, | |
2827 | ARM_BUILTIN_WUNPCKILB, | |
2828 | ARM_BUILTIN_WUNPCKILH, | |
2829 | ARM_BUILTIN_WUNPCKILW, | |
2830 | ||
2831 | ARM_BUILTIN_WUNPCKEHSB, | |
2832 | ARM_BUILTIN_WUNPCKEHSH, | |
2833 | ARM_BUILTIN_WUNPCKEHSW, | |
2834 | ARM_BUILTIN_WUNPCKEHUB, | |
2835 | ARM_BUILTIN_WUNPCKEHUH, | |
2836 | ARM_BUILTIN_WUNPCKEHUW, | |
2837 | ARM_BUILTIN_WUNPCKELSB, | |
2838 | ARM_BUILTIN_WUNPCKELSH, | |
2839 | ARM_BUILTIN_WUNPCKELSW, | |
2840 | ARM_BUILTIN_WUNPCKELUB, | |
2841 | ARM_BUILTIN_WUNPCKELUH, | |
2842 | ARM_BUILTIN_WUNPCKELUW, | |
2843 | ||
d3585b76 DJ |
2844 | ARM_BUILTIN_THREAD_POINTER, |
2845 | ||
88f77cba JB |
2846 | ARM_BUILTIN_NEON_BASE, |
2847 | ||
2848 | ARM_BUILTIN_MAX = ARM_BUILTIN_NEON_BASE /* FIXME: Wrong! */ | |
5a9335ef | 2849 | }; |
978e411f CD |
2850 | |
2851 | /* Do not emit .note.GNU-stack by default. */ | |
2852 | #ifndef NEED_INDICATE_EXEC_STACK | |
2853 | #define NEED_INDICATE_EXEC_STACK 0 | |
2854 | #endif | |
2855 | ||
88657302 | 2856 | #endif /* ! GCC_ARM_H */ |