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