]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/arm/arm.h
re PR c++/54341 (ICE (segfault) in cx_check_missing_mem_inits, at cp/semantics.c...
[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,
18f0fe6b 3 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
bf98ec6c 4 Free Software Foundation, Inc.
35d965d5 5 Contributed by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl)
8b109b37 6 and Martin Simmons (@harleqn.co.uk).
949d79eb 7 More major hacks by Richard Earnshaw (rearnsha@arm.com)
6cfc7210
NC
8 Minor hacks by Nick Clifton (nickc@cygnus.com)
9
4f448245 10 This file is part of GCC.
35d965d5 11
4f448245
NC
12 GCC is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License as published
2f83c7d6 14 by the Free Software Foundation; either version 3, or (at your
4f448245 15 option) any later version.
35d965d5 16
4f448245
NC
17 GCC is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
20 License for more details.
35d965d5 21
4f448245 22 You should have received a copy of the GNU General Public License
2f83c7d6
NC
23 along with GCC; see the file COPYING3. If not see
24 <http://www.gnu.org/licenses/>. */
35d965d5 25
88657302
RH
26#ifndef GCC_ARM_H
27#define GCC_ARM_H
b355a481 28
46107b99
RE
29/* We can't use enum machine_mode inside a generator file because it
30 hasn't been created yet; we shouldn't be using any code that
31 needs the real definition though, so this ought to be safe. */
32#ifdef GENERATOR_FILE
33#define MACHMODE int
34#else
35#include "insn-modes.h"
36#define MACHMODE enum machine_mode
37#endif
38
9403b7f7
RS
39#include "config/vxworks-dummy.h"
40
35fd3193 41/* The architecture define. */
78011587
PB
42extern char arm_arch_name[];
43
e6471be6
NB
44/* Target CPU builtins. */
45#define TARGET_CPU_CPP_BUILTINS() \
46 do \
47 { \
c884924f
JG
48 if (TARGET_DSP_MULTIPLY) \
49 builtin_define ("__ARM_FEATURE_DSP"); \
9e94a7fc
MGD
50 if (TARGET_ARM_QBIT) \
51 builtin_define ("__ARM_FEATURE_QBIT"); \
52 if (TARGET_ARM_SAT) \
53 builtin_define ("__ARM_FEATURE_SAT"); \
5d248b41
JG
54 if (unaligned_access) \
55 builtin_define ("__ARM_FEATURE_UNALIGNED"); \
9e94a7fc
MGD
56 if (TARGET_ARM_FEATURE_LDREX) \
57 builtin_define_with_int_value ( \
58 "__ARM_FEATURE_LDREX", TARGET_ARM_FEATURE_LDREX); \
59 if ((TARGET_ARM_ARCH >= 5 && !TARGET_THUMB) \
60 || TARGET_ARM_ARCH_ISA_THUMB >=2) \
61 builtin_define ("__ARM_FEATURE_CLZ"); \
62 if (TARGET_INT_SIMD) \
63 builtin_define ("__ARM_FEATURE_SIMD32"); \
64 \
65 builtin_define_with_int_value ( \
66 "__ARM_SIZEOF_MINIMAL_ENUM", \
67 flag_short_enums ? 1 : 4); \
68 builtin_define_with_int_value ( \
69 "__ARM_SIZEOF_WCHAR_T", WCHAR_TYPE_SIZE); \
70 if (TARGET_ARM_ARCH_PROFILE) \
71 builtin_define_with_int_value ( \
72 "__ARM_ARCH_PROFILE", TARGET_ARM_ARCH_PROFILE); \
73 \
9b66ebb1
PB
74 /* Define __arm__ even when in thumb mode, for \
75 consistency with armcc. */ \
76 builtin_define ("__arm__"); \
9e94a7fc
MGD
77 if (TARGET_ARM_ARCH) \
78 builtin_define_with_int_value ( \
79 "__ARM_ARCH", TARGET_ARM_ARCH); \
80 if (arm_arch_notm) \
81 builtin_define ("__ARM_ARCH_ISA_ARM"); \
61f0ccff 82 builtin_define ("__APCS_32__"); \
9b66ebb1 83 if (TARGET_THUMB) \
e6471be6 84 builtin_define ("__thumb__"); \
5b3e6663
PB
85 if (TARGET_THUMB2) \
86 builtin_define ("__thumb2__"); \
9e94a7fc
MGD
87 if (TARGET_ARM_ARCH_ISA_THUMB) \
88 builtin_define_with_int_value ( \
89 "__ARM_ARCH_ISA_THUMB", \
90 TARGET_ARM_ARCH_ISA_THUMB); \
e6471be6
NB
91 \
92 if (TARGET_BIG_END) \
93 { \
94 builtin_define ("__ARMEB__"); \
9e94a7fc 95 builtin_define ("__ARM_BIG_ENDIAN"); \
e6471be6
NB
96 if (TARGET_THUMB) \
97 builtin_define ("__THUMBEB__"); \
98 if (TARGET_LITTLE_WORDS) \
99 builtin_define ("__ARMWEL__"); \
100 } \
101 else \
102 { \
103 builtin_define ("__ARMEL__"); \
104 if (TARGET_THUMB) \
105 builtin_define ("__THUMBEL__"); \
106 } \
107 \
e6471be6
NB
108 if (TARGET_SOFT_FLOAT) \
109 builtin_define ("__SOFTFP__"); \
110 \
9b66ebb1 111 if (TARGET_VFP) \
b5b620a4
JT
112 builtin_define ("__VFP_FP__"); \
113 \
9e94a7fc
MGD
114 if (TARGET_ARM_FP) \
115 builtin_define_with_int_value ( \
116 "__ARM_FP", TARGET_ARM_FP); \
117 if (arm_fp16_format == ARM_FP16_FORMAT_IEEE) \
118 builtin_define ("__ARM_FP16_FORMAT_IEEE"); \
119 if (arm_fp16_format == ARM_FP16_FORMAT_ALTERNATIVE) \
120 builtin_define ("__ARM_FP16_FORMAT_ALTERNATIVE"); \
121 if (TARGET_FMA) \
122 builtin_define ("__ARM_FEATURE_FMA"); \
123 \
88f77cba 124 if (TARGET_NEON) \
9e94a7fc
MGD
125 { \
126 builtin_define ("__ARM_NEON__"); \
127 builtin_define ("__ARM_NEON"); \
128 } \
129 if (TARGET_NEON_FP) \
130 builtin_define_with_int_value ( \
131 "__ARM_NEON_FP", TARGET_NEON_FP); \
88f77cba 132 \
e6471be6
NB
133 /* Add a define for interworking. \
134 Needed when building libgcc.a. */ \
2ad4dcf9 135 if (arm_cpp_interwork) \
e6471be6
NB
136 builtin_define ("__THUMB_INTERWORK__"); \
137 \
138 builtin_assert ("cpu=arm"); \
139 builtin_assert ("machine=arm"); \
78011587
PB
140 \
141 builtin_define (arm_arch_name); \
78011587
PB
142 if (arm_arch_xscale) \
143 builtin_define ("__XSCALE__"); \
144 if (arm_arch_iwmmxt) \
9e94a7fc
MGD
145 { \
146 builtin_define ("__IWMMXT__"); \
147 builtin_define ("__ARM_WMMX"); \
148 } \
8fd03515
XQ
149 if (arm_arch_iwmmxt2) \
150 builtin_define ("__IWMMXT2__"); \
4adf3e34 151 if (TARGET_AAPCS_BASED) \
12ffc7d5
CLT
152 { \
153 if (arm_pcs_default == ARM_PCS_AAPCS_VFP) \
154 builtin_define ("__ARM_PCS_VFP"); \
155 else if (arm_pcs_default == ARM_PCS_AAPCS) \
156 builtin_define ("__ARM_PCS"); \
157 builtin_define ("__ARM_EABI__"); \
158 } \
572070ef
PB
159 if (TARGET_IDIV) \
160 builtin_define ("__ARM_ARCH_EXT_IDIV__"); \
e6471be6
NB
161 } while (0)
162
ad7be009 163#include "config/arm/arm-opts.h"
9b66ebb1 164
78011587
PB
165enum target_cpus
166{
d98a72fd
RE
167#define ARM_CORE(NAME, IDENT, ARCH, FLAGS, COSTS) \
168 TARGET_CPU_##IDENT,
78011587
PB
169#include "arm-cores.def"
170#undef ARM_CORE
171 TARGET_CPU_generic
172};
173
9b66ebb1
PB
174/* The processor for which instructions should be scheduled. */
175extern enum processor_type arm_tune;
176
d5b7b3ae 177typedef enum arm_cond_code
89c7ca52
RE
178{
179 ARM_EQ = 0, ARM_NE, ARM_CS, ARM_CC, ARM_MI, ARM_PL, ARM_VS, ARM_VC,
180 ARM_HI, ARM_LS, ARM_GE, ARM_LT, ARM_GT, ARM_LE, ARM_AL, ARM_NV
d5b7b3ae
RE
181}
182arm_cc;
6cfc7210 183
d5b7b3ae 184extern arm_cc arm_current_cc;
ff9940b0 185
d5b7b3ae 186#define ARM_INVERSE_CONDITION_CODE(X) ((arm_cc) (((int)X) ^ 1))
89c7ca52 187
6cfc7210
NC
188extern int arm_target_label;
189extern int arm_ccfsm_state;
e2500fed 190extern GTY(()) rtx arm_target_insn;
d5b7b3ae 191/* The label of the current constant pool. */
e2500fed 192extern rtx pool_vector_label;
d5b7b3ae 193/* Set to 1 when a return insn is output, this means that the epilogue
d6b4baa4 194 is not needed. */
d5b7b3ae 195extern int return_used_this_function;
b76c3c4b
PB
196/* Callback to output language specific object attributes. */
197extern void (*arm_lang_output_object_attributes_hook)(void);
35d965d5 198\f
d6b4baa4 199/* Just in case configure has failed to define anything. */
7a801826
RE
200#ifndef TARGET_CPU_DEFAULT
201#define TARGET_CPU_DEFAULT TARGET_CPU_generic
202#endif
203
7a801826 204
5742588d 205#undef CPP_SPEC
78011587 206#define CPP_SPEC "%(subtarget_cpp_spec) \
5e1b4d5a
JM
207%{mfloat-abi=soft:%{mfloat-abi=hard: \
208 %e-mfloat-abi=soft and -mfloat-abi=hard may not be used together}} \
e6471be6
NB
209%{mbig-endian:%{mlittle-endian: \
210 %e-mbig-endian and -mlittle-endian may not be used together}}"
7a801826 211
be393ecf 212#ifndef CC1_SPEC
dfa08768 213#define CC1_SPEC ""
be393ecf 214#endif
7a801826
RE
215
216/* This macro defines names of additional specifications to put in the specs
217 that can be used in various specifications like CC1_SPEC. Its definition
218 is an initializer with a subgrouping for each command option.
219
220 Each subgrouping contains a string constant, that defines the
4f448245 221 specification name, and a string constant that used by the GCC driver
7a801826
RE
222 program.
223
224 Do not define this macro if it does not need to do anything. */
225#define EXTRA_SPECS \
38fc909b 226 { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC }, \
54e73f88 227 { "asm_cpu_spec", ASM_CPU_SPEC }, \
7a801826
RE
228 SUBTARGET_EXTRA_SPECS
229
914a3b8c 230#ifndef SUBTARGET_EXTRA_SPECS
7a801826 231#define SUBTARGET_EXTRA_SPECS
914a3b8c
DM
232#endif
233
6cfc7210 234#ifndef SUBTARGET_CPP_SPEC
38fc909b 235#define SUBTARGET_CPP_SPEC ""
6cfc7210 236#endif
35d965d5
RS
237\f
238/* Run-time Target Specification. */
9b66ebb1 239#define TARGET_SOFT_FLOAT (arm_float_abi == ARM_FLOAT_ABI_SOFT)
72cdc543
PB
240/* Use hardware floating point instructions. */
241#define TARGET_HARD_FLOAT (arm_float_abi != ARM_FLOAT_ABI_SOFT)
242/* Use hardware floating point calling convention. */
243#define TARGET_HARD_FLOAT_ABI (arm_float_abi == ARM_FLOAT_ABI_HARD)
d79f3032 244#define TARGET_VFP (arm_fpu_desc->model == ARM_FP_MODEL_VFP)
5a9335ef 245#define TARGET_IWMMXT (arm_arch_iwmmxt)
8fd03515 246#define TARGET_IWMMXT2 (arm_arch_iwmmxt2)
5b3e6663 247#define TARGET_REALLY_IWMMXT (TARGET_IWMMXT && TARGET_32BIT)
8fd03515 248#define TARGET_REALLY_IWMMXT2 (TARGET_IWMMXT2 && TARGET_32BIT)
5b3e6663 249#define TARGET_IWMMXT_ABI (TARGET_32BIT && arm_abi == ARM_ABI_IWMMXT)
d5b7b3ae
RE
250#define TARGET_ARM (! TARGET_THUMB)
251#define TARGET_EITHER 1 /* (TARGET_ARM | TARGET_THUMB) */
c54c7322
RS
252#define TARGET_BACKTRACE (leaf_function_p () \
253 ? TARGET_TPCS_LEAF_FRAME \
254 : TARGET_TPCS_FRAME)
fdd695fd 255#define TARGET_LDRD (arm_arch5e && ARM_DOUBLEWORD_ALIGN)
b6685939
PB
256#define TARGET_AAPCS_BASED \
257 (arm_abi != ARM_ABI_APCS && arm_abi != ARM_ABI_ATPCS)
3ada8e17 258
d3585b76
DJ
259#define TARGET_HARD_TP (target_thread_pointer == TP_CP15)
260#define TARGET_SOFT_TP (target_thread_pointer == TP_SOFT)
ccdc2164 261#define TARGET_GNU2_TLS (target_tls_dialect == TLS_GNU2)
d3585b76 262
5b3e6663
PB
263/* Only 16-bit thumb code. */
264#define TARGET_THUMB1 (TARGET_THUMB && !arm_arch_thumb2)
265/* Arm or Thumb-2 32-bit code. */
266#define TARGET_32BIT (TARGET_ARM || arm_arch_thumb2)
267/* 32-bit Thumb-2 code. */
268#define TARGET_THUMB2 (TARGET_THUMB && arm_arch_thumb2)
bf98ec6c
PB
269/* Thumb-1 only. */
270#define TARGET_THUMB1_ONLY (TARGET_THUMB1 && !arm_arch_notm)
5b3e6663 271
88f77cba 272/* The following two macros concern the ability to execute coprocessor
302c3d8e
PB
273 instructions for VFPv3 or NEON. TARGET_VFP3/TARGET_VFPD32 are currently
274 only ever tested when we know we are generating for VFP hardware; we need
275 to be more careful with TARGET_NEON as noted below. */
88f77cba 276
302c3d8e 277/* FPU is has the full VFPv3/NEON register file of 32 D registers. */
d79f3032 278#define TARGET_VFPD32 (TARGET_VFP && arm_fpu_desc->regs == VFP_REG_D32)
302c3d8e
PB
279
280/* FPU supports VFPv3 instructions. */
d79f3032 281#define TARGET_VFP3 (TARGET_VFP && arm_fpu_desc->rev >= 3)
302c3d8e 282
e0dc3601
PB
283/* FPU only supports VFP single-precision instructions. */
284#define TARGET_VFP_SINGLE (TARGET_VFP && arm_fpu_desc->regs == VFP_REG_SINGLE)
285
286/* FPU supports VFP double-precision instructions. */
287#define TARGET_VFP_DOUBLE (TARGET_VFP && arm_fpu_desc->regs != VFP_REG_SINGLE)
288
289/* FPU supports half-precision floating-point with NEON element load/store. */
d79f3032
PB
290#define TARGET_NEON_FP16 \
291 (TARGET_VFP && arm_fpu_desc->neon && arm_fpu_desc->fp16)
0fd8c3ad 292
e0dc3601
PB
293/* FPU supports VFP half-precision floating-point. */
294#define TARGET_FP16 (TARGET_VFP && arm_fpu_desc->fp16)
295
9e94a7fc
MGD
296/* FPU supports fused-multiply-add operations. */
297#define TARGET_FMA (TARGET_VFP && arm_fpu_desc->rev >= 4)
298
88f77cba
JB
299/* FPU supports Neon instructions. The setting of this macro gets
300 revealed via __ARM_NEON__ so we add extra guards upon TARGET_32BIT
301 and TARGET_HARD_FLOAT to ensure that NEON instructions are
302 available. */
303#define TARGET_NEON (TARGET_32BIT && TARGET_HARD_FLOAT \
d79f3032 304 && TARGET_VFP && arm_fpu_desc->neon)
f1adb0a9 305
9e94a7fc
MGD
306/* Q-bit is present. */
307#define TARGET_ARM_QBIT \
308 (TARGET_32BIT && arm_arch5e && (arm_arch_notm || arm_arch7))
309/* Saturation operation, e.g. SSAT. */
310#define TARGET_ARM_SAT \
311 (TARGET_32BIT && arm_arch6 && (arm_arch_notm || arm_arch7))
5b3e6663
PB
312/* "DSP" multiply instructions, eg. SMULxy. */
313#define TARGET_DSP_MULTIPLY \
60bd3528 314 (TARGET_32BIT && arm_arch5e && (arm_arch_notm || arm_arch7em))
5b3e6663
PB
315/* Integer SIMD instructions, and extend-accumulate instructions. */
316#define TARGET_INT_SIMD \
60bd3528 317 (TARGET_32BIT && arm_arch6 && (arm_arch_notm || arm_arch7em))
5b3e6663 318
571191af 319/* Should MOVW/MOVT be used in preference to a constant pool. */
7ec70105
JB
320#define TARGET_USE_MOVT \
321 (arm_arch_thumb2 && !optimize_size && !current_tune->prefer_constant_pool)
571191af 322
5b3e6663
PB
323/* We could use unified syntax for arm mode, but for now we just use it
324 for Thumb-2. */
325#define TARGET_UNIFIED_ASM TARGET_THUMB2
326
029e79eb
MS
327/* Nonzero if this chip provides the DMB instruction. */
328#define TARGET_HAVE_DMB (arm_arch7)
329
330/* Nonzero if this chip implements a memory barrier via CP15. */
80651d8e
DAG
331#define TARGET_HAVE_DMB_MCR (arm_arch6 && ! TARGET_HAVE_DMB \
332 && ! TARGET_THUMB1)
029e79eb
MS
333
334/* Nonzero if this chip implements a memory barrier instruction. */
335#define TARGET_HAVE_MEMORY_BARRIER (TARGET_HAVE_DMB || TARGET_HAVE_DMB_MCR)
336
337/* Nonzero if this chip supports ldrex and strex */
338#define TARGET_HAVE_LDREX ((arm_arch6 && TARGET_ARM) || arm_arch7)
339
cfe52743
DAG
340/* Nonzero if this chip supports ldrex{bh} and strex{bh}. */
341#define TARGET_HAVE_LDREXBH ((arm_arch6k && TARGET_ARM) || arm_arch7)
342
343/* Nonzero if this chip supports ldrexd and strexd. */
344#define TARGET_HAVE_LDREXD (((arm_arch6k && TARGET_ARM) || arm_arch7) \
345 && arm_arch_notm)
5b3e6663 346
572070ef
PB
347/* Nonzero if integer division instructions supported. */
348#define TARGET_IDIV ((TARGET_ARM && arm_arch_arm_hwdiv) \
349 || (TARGET_THUMB2 && arm_arch_thumb_hwdiv))
350
b3f8d95d
MM
351/* True iff the full BPABI is being used. If TARGET_BPABI is true,
352 then TARGET_AAPCS_BASED must be true -- but the converse does not
353 hold. TARGET_BPABI implies the use of the BPABI runtime library,
354 etc., in addition to just the AAPCS calling conventions. */
355#ifndef TARGET_BPABI
356#define TARGET_BPABI false
f676971a 357#endif
b3f8d95d 358
7816bea0
DJ
359/* Support for a compile-time default CPU, et cetera. The rules are:
360 --with-arch is ignored if -march or -mcpu are specified.
361 --with-cpu is ignored if -march or -mcpu are specified, and is overridden
362 by --with-arch.
363 --with-tune is ignored if -mtune or -mcpu are specified (but not affected
364 by -march).
5e1b4d5a 365 --with-float is ignored if -mfloat-abi is specified.
5848830f 366 --with-fpu is ignored if -mfpu is specified.
ccdc2164
NS
367 --with-abi is ignored if -mabi is specified.
368 --with-tls is ignored if -mtls-dialect is specified. */
7816bea0
DJ
369#define OPTION_DEFAULT_SPECS \
370 {"arch", "%{!march=*:%{!mcpu=*:-march=%(VALUE)}}" }, \
371 {"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
372 {"tune", "%{!mcpu=*:%{!mtune=*:-mtune=%(VALUE)}}" }, \
5e1b4d5a 373 {"float", "%{!mfloat-abi=*:-mfloat-abi=%(VALUE)}" }, \
5848830f 374 {"fpu", "%{!mfpu=*:-mfpu=%(VALUE)}"}, \
3cf94279 375 {"abi", "%{!mabi=*:-mabi=%(VALUE)}"}, \
ccdc2164 376 {"mode", "%{!marm:%{!mthumb:-m%(VALUE)}}"}, \
7cf13d1f 377 {"tls", "%{!mtls-dialect=*:-mtls-dialect=%(VALUE)}"},
7816bea0 378
9b66ebb1
PB
379/* Which floating point model to use. */
380enum arm_fp_model
381{
382 ARM_FP_MODEL_UNKNOWN,
9b66ebb1
PB
383 /* VFP floating point model. */
384 ARM_FP_MODEL_VFP
385};
386
d79f3032 387enum vfp_reg_type
24f0c1b4 388{
70dd156a 389 VFP_NONE = 0,
d79f3032
PB
390 VFP_REG_D16,
391 VFP_REG_D32,
392 VFP_REG_SINGLE
24f0c1b4
RE
393};
394
d79f3032
PB
395extern const struct arm_fpu_desc
396{
397 const char *name;
398 enum arm_fp_model model;
399 int rev;
400 enum vfp_reg_type regs;
401 int neon;
402 int fp16;
403} *arm_fpu_desc;
404
405/* Which floating point hardware to schedule for. */
406extern int arm_fpu_attr;
71791e16 407
3d8532aa
PB
408#ifndef TARGET_DEFAULT_FLOAT_ABI
409#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
410#endif
411
0fd8c3ad
SL
412#define LARGEST_EXPONENT_IS_NORMAL(bits) \
413 ((bits) == 16 && arm_fp16_format == ARM_FP16_FORMAT_ALTERNATIVE)
414
5848830f
PB
415#ifndef ARM_DEFAULT_ABI
416#define ARM_DEFAULT_ABI ARM_ABI_APCS
417#endif
418
9e94a7fc
MGD
419/* Map each of the micro-architecture variants to their corresponding
420 major architecture revision. */
421
422enum base_architecture
423{
424 BASE_ARCH_0 = 0,
425 BASE_ARCH_2 = 2,
426 BASE_ARCH_3 = 3,
427 BASE_ARCH_3M = 3,
428 BASE_ARCH_4 = 4,
429 BASE_ARCH_4T = 4,
430 BASE_ARCH_5 = 5,
431 BASE_ARCH_5E = 5,
432 BASE_ARCH_5T = 5,
433 BASE_ARCH_5TE = 5,
434 BASE_ARCH_5TEJ = 5,
435 BASE_ARCH_6 = 6,
436 BASE_ARCH_6J = 6,
437 BASE_ARCH_6ZK = 6,
438 BASE_ARCH_6K = 6,
439 BASE_ARCH_6T2 = 6,
440 BASE_ARCH_6M = 6,
441 BASE_ARCH_6Z = 6,
442 BASE_ARCH_7 = 7,
443 BASE_ARCH_7A = 7,
444 BASE_ARCH_7R = 7,
445 BASE_ARCH_7M = 7,
446 BASE_ARCH_7EM = 7
447};
448
449/* The major revision number of the ARM Architecture implemented by the target. */
450extern enum base_architecture arm_base_arch;
451
9b66ebb1
PB
452/* Nonzero if this chip supports the ARM Architecture 3M extensions. */
453extern int arm_arch3m;
11c1a207 454
9b66ebb1 455/* Nonzero if this chip supports the ARM Architecture 4 extensions. */
11c1a207
RE
456extern int arm_arch4;
457
68d560d4
RE
458/* Nonzero if this chip supports the ARM Architecture 4T extensions. */
459extern int arm_arch4t;
460
9b66ebb1 461/* Nonzero if this chip supports the ARM Architecture 5 extensions. */
62b10bbc
NC
462extern int arm_arch5;
463
9b66ebb1 464/* Nonzero if this chip supports the ARM Architecture 5E extensions. */
b15bca31
RE
465extern int arm_arch5e;
466
9b66ebb1
PB
467/* Nonzero if this chip supports the ARM Architecture 6 extensions. */
468extern int arm_arch6;
469
029e79eb
MS
470/* Nonzero if this chip supports the ARM Architecture 6k extensions. */
471extern int arm_arch6k;
472
473/* Nonzero if this chip supports the ARM Architecture 7 extensions. */
474extern int arm_arch7;
475
5b3e6663
PB
476/* Nonzero if instructions not present in the 'M' profile can be used. */
477extern int arm_arch_notm;
478
60bd3528
PB
479/* Nonzero if instructions present in ARMv7E-M can be used. */
480extern int arm_arch7em;
481
f5a1b0d2
NC
482/* Nonzero if this chip can benefit from load scheduling. */
483extern int arm_ld_sched;
484
906668bb 485/* Nonzero if generating Thumb code, either Thumb-1 or Thumb-2. */
0616531f
RE
486extern int thumb_code;
487
906668bb
BS
488/* Nonzero if generating Thumb-1 code. */
489extern int thumb1_code;
490
f5a1b0d2 491/* Nonzero if this chip is a StrongARM. */
abac3b49 492extern int arm_tune_strongarm;
f5a1b0d2 493
5a9335ef
NC
494/* Nonzero if this chip supports Intel XScale with Wireless MMX technology. */
495extern int arm_arch_iwmmxt;
496
8fd03515
XQ
497/* Nonzero if this chip supports Intel Wireless MMX2 technology. */
498extern int arm_arch_iwmmxt2;
499
d19fb8e3 500/* Nonzero if this chip is an XScale. */
4b3c2e48
PB
501extern int arm_arch_xscale;
502
abac3b49 503/* Nonzero if tuning for XScale. */
4b3c2e48 504extern int arm_tune_xscale;
d19fb8e3 505
abac3b49
RE
506/* Nonzero if tuning for stores via the write buffer. */
507extern int arm_tune_wbuf;
f5a1b0d2 508
7612f14d
PB
509/* Nonzero if tuning for Cortex-A9. */
510extern int arm_tune_cortex_a9;
511
2ad4dcf9 512/* Nonzero if we should define __THUMB_INTERWORK__ in the
f676971a 513 preprocessor.
2ad4dcf9
RE
514 XXX This is a bit of a hack, it's intended to help work around
515 problems in GLD which doesn't understand that armv5t code is
516 interworking clean. */
517extern int arm_cpp_interwork;
518
5b3e6663
PB
519/* Nonzero if chip supports Thumb 2. */
520extern int arm_arch_thumb2;
521
572070ef
PB
522/* Nonzero if chip supports integer division instruction in ARM mode. */
523extern int arm_arch_arm_hwdiv;
524
525/* Nonzero if chip supports integer division instruction in Thumb mode. */
526extern int arm_arch_thumb_hwdiv;
5b3e6663 527
2ce9c1b9 528#ifndef TARGET_DEFAULT
c54c7322 529#define TARGET_DEFAULT (MASK_APCS_FRAME)
2ce9c1b9 530#endif
35d965d5 531
86efdc8e
PB
532/* Nonzero if PIC code requires explicit qualifiers to generate
533 PLT and GOT relocs rather than the assembler doing so implicitly.
ed0e6530
PB
534 Subtargets can override these if required. */
535#ifndef NEED_GOT_RELOC
536#define NEED_GOT_RELOC 0
537#endif
538#ifndef NEED_PLT_RELOC
539#define NEED_PLT_RELOC 0
e2723c62 540#endif
84306176
PB
541
542/* Nonzero if we need to refer to the GOT with a PC-relative
543 offset. In other words, generate
544
f676971a 545 .word _GLOBAL_OFFSET_TABLE_ - [. - (.Lxx + 8)]
84306176
PB
546
547 rather than
548
549 .word _GLOBAL_OFFSET_TABLE_ - (.Lxx + 8)
550
f676971a 551 The default is true, which matches NetBSD. Subtargets can
84306176
PB
552 override this if required. */
553#ifndef GOT_PCREL
554#define GOT_PCREL 1
555#endif
35d965d5
RS
556\f
557/* Target machine storage Layout. */
558
ff9940b0
RE
559
560/* Define this macro if it is advisable to hold scalars in registers
561 in a wider mode than that declared by the program. In such cases,
562 the value is constrained to be within the bounds of the declared
563 type, but kept valid in the wider mode. The signedness of the
564 extension may differ from that of the type. */
565
566/* It is far faster to zero extend chars than to sign extend them */
567
6cfc7210 568#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
2ce9c1b9
RE
569 if (GET_MODE_CLASS (MODE) == MODE_INT \
570 && GET_MODE_SIZE (MODE) < 4) \
571 { \
572 if (MODE == QImode) \
573 UNSIGNEDP = 1; \
574 else if (MODE == HImode) \
61f0ccff 575 UNSIGNEDP = 1; \
2ce9c1b9 576 (MODE) = SImode; \
ff9940b0
RE
577 }
578
35d965d5
RS
579/* Define this if most significant bit is lowest numbered
580 in instructions that operate on numbered bit-fields. */
581#define BITS_BIG_ENDIAN 0
582
f676971a 583/* Define this if most significant byte of a word is the lowest numbered.
3ada8e17
DE
584 Most ARM processors are run in little endian mode, so that is the default.
585 If you want to have it run-time selectable, change the definition in a
586 cover file to be TARGET_BIG_ENDIAN. */
11c1a207 587#define BYTES_BIG_ENDIAN (TARGET_BIG_END != 0)
35d965d5
RS
588
589/* Define this if most significant word of a multiword number is the lowest
11c1a207
RE
590 numbered.
591 This is always false, even when in big-endian mode. */
ddee6aba
RE
592#define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN && ! TARGET_LITTLE_WORDS)
593
35d965d5
RS
594#define UNITS_PER_WORD 4
595
5848830f 596/* True if natural alignment is used for doubleword types. */
b6685939
PB
597#define ARM_DOUBLEWORD_ALIGN TARGET_AAPCS_BASED
598
5848830f 599#define DOUBLEWORD_ALIGNMENT 64
35d965d5 600
5848830f 601#define PARM_BOUNDARY 32
5a9335ef 602
5848830f 603#define STACK_BOUNDARY (ARM_DOUBLEWORD_ALIGN ? DOUBLEWORD_ALIGNMENT : 32)
35d965d5 604
5848830f
PB
605#define PREFERRED_STACK_BOUNDARY \
606 (arm_abi == ARM_ABI_ATPCS ? 64 : STACK_BOUNDARY)
0977774b 607
f711a87a 608#define FUNCTION_BOUNDARY ((TARGET_THUMB && optimize_size) ? 16 : 32)
35d965d5 609
92928d71
AO
610/* The lowest bit is used to indicate Thumb-mode functions, so the
611 vbit must go into the delta field of pointers to member
612 functions. */
613#define TARGET_PTRMEMFUNC_VBIT_LOCATION ptrmemfunc_vbit_in_delta
614
35d965d5
RS
615#define EMPTY_FIELD_BOUNDARY 32
616
5848830f 617#define BIGGEST_ALIGNMENT (ARM_DOUBLEWORD_ALIGN ? DOUBLEWORD_ALIGNMENT : 32)
5a9335ef 618
27847754
NC
619/* XXX Blah -- this macro is used directly by libobjc. Since it
620 supports no vector modes, cut out the complexity and fall back
621 on BIGGEST_FIELD_ALIGNMENT. */
622#ifdef IN_TARGET_LIBS
8fca31a2 623#define BIGGEST_FIELD_ALIGNMENT 64
27847754 624#endif
5a9335ef 625
ff9940b0 626/* Make strings word-aligned so strcpy from constants will be faster. */
591af218 627#define CONSTANT_ALIGNMENT_FACTOR (TARGET_THUMB || ! arm_tune_xscale ? 1 : 2)
f676971a 628
d19fb8e3 629#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
5848830f 630 ((TREE_CODE (EXP) == STRING_CST \
36b15ad0 631 && !optimize_size \
5848830f
PB
632 && (ALIGN) < BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR) \
633 ? BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR : (ALIGN))
ff9940b0 634
96339268
RE
635/* Align definitions of arrays, unions and structures so that
636 initializations and copies can be made more efficient. This is not
637 ABI-changing, so it only affects places where we can see the
0c86e0dd
CLT
638 definition. Increasing the alignment tends to introduce padding,
639 so don't do this when optimizing for size/conserving stack space. */
640#define ARM_EXPAND_ALIGNMENT(COND, EXP, ALIGN) \
641 (((COND) && ((ALIGN) < BITS_PER_WORD) \
96339268
RE
642 && (TREE_CODE (EXP) == ARRAY_TYPE \
643 || TREE_CODE (EXP) == UNION_TYPE \
644 || TREE_CODE (EXP) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
645
0c86e0dd
CLT
646/* Align global data. */
647#define DATA_ALIGNMENT(EXP, ALIGN) \
648 ARM_EXPAND_ALIGNMENT(!optimize_size, EXP, ALIGN)
649
96339268 650/* Similarly, make sure that objects on the stack are sensibly aligned. */
0c86e0dd
CLT
651#define LOCAL_ALIGNMENT(EXP, ALIGN) \
652 ARM_EXPAND_ALIGNMENT(!flag_conserve_stack, EXP, ALIGN)
96339268 653
723ae7c1
NC
654/* Setting STRUCTURE_SIZE_BOUNDARY to 32 produces more efficient code, but the
655 value set in previous versions of this toolchain was 8, which produces more
656 compact structures. The command line option -mstructure_size_boundary=<n>
f710504c 657 can be used to change this value. For compatibility with the ARM SDK
723ae7c1 658 however the value should be left at 32. ARM SDT Reference Manual (ARM DUI
5848830f
PB
659 0020D) page 2-20 says "Structures are aligned on word boundaries".
660 The AAPCS specifies a value of 8. */
6ead9ba5 661#define STRUCTURE_SIZE_BOUNDARY arm_structure_size_boundary
723ae7c1 662
4912a07c 663/* This is the value used to initialize arm_structure_size_boundary. If a
723ae7c1 664 particular arm target wants to change the default value it should change
6bc82793 665 the definition of this macro, not STRUCTURE_SIZE_BOUNDARY. See netbsd.h
723ae7c1
NC
666 for an example of this. */
667#ifndef DEFAULT_STRUCTURE_SIZE_BOUNDARY
668#define DEFAULT_STRUCTURE_SIZE_BOUNDARY 32
b355a481 669#endif
2a5307b1 670
825dda42 671/* Nonzero if move instructions will actually fail to work
ff9940b0 672 when given unaligned data. */
35d965d5 673#define STRICT_ALIGNMENT 1
b6685939
PB
674
675/* wchar_t is unsigned under the AAPCS. */
676#ifndef WCHAR_TYPE
677#define WCHAR_TYPE (TARGET_AAPCS_BASED ? "unsigned int" : "int")
678
679#define WCHAR_TYPE_SIZE BITS_PER_WORD
680#endif
681
655b30bf
JB
682/* Sized for fixed-point types. */
683
684#define SHORT_FRACT_TYPE_SIZE 8
685#define FRACT_TYPE_SIZE 16
686#define LONG_FRACT_TYPE_SIZE 32
687#define LONG_LONG_FRACT_TYPE_SIZE 64
688
689#define SHORT_ACCUM_TYPE_SIZE 16
690#define ACCUM_TYPE_SIZE 32
691#define LONG_ACCUM_TYPE_SIZE 64
692#define LONG_LONG_ACCUM_TYPE_SIZE 64
693
694#define MAX_FIXED_MODE_SIZE 64
695
b6685939
PB
696#ifndef SIZE_TYPE
697#define SIZE_TYPE (TARGET_AAPCS_BASED ? "unsigned int" : "long unsigned int")
698#endif
d81d0bdd 699
077fc835
KH
700#ifndef PTRDIFF_TYPE
701#define PTRDIFF_TYPE (TARGET_AAPCS_BASED ? "int" : "long int")
702#endif
703
d81d0bdd
PB
704/* AAPCS requires that structure alignment is affected by bitfields. */
705#ifndef PCC_BITFIELD_TYPE_MATTERS
706#define PCC_BITFIELD_TYPE_MATTERS TARGET_AAPCS_BASED
707#endif
708
35d965d5
RS
709\f
710/* Standard register usage. */
711
0be8bd1a 712/* Register allocation in ARM Procedure Call Standard
35d965d5
RS
713 (S - saved over call).
714
715 r0 * argument word/integer result
716 r1-r3 argument word
717
718 r4-r8 S register variable
719 r9 S (rfp) register variable (real frame pointer)
f676971a 720
f5a1b0d2 721 r10 F S (sl) stack limit (used by -mapcs-stack-check)
35d965d5
RS
722 r11 F S (fp) argument pointer
723 r12 (ip) temp workspace
724 r13 F S (sp) lower end of current stack frame
725 r14 (lr) link address/workspace
726 r15 F (pc) program counter
727
ff9940b0
RE
728 cc This is NOT a real register, but is used internally
729 to represent things that use or set the condition
730 codes.
731 sfp This isn't either. It is used during rtl generation
732 since the offset between the frame pointer and the
733 auto's isn't known until after register allocation.
734 afp Nor this, we only need this because of non-local
735 goto. Without it fp appears to be used and the
736 elimination code won't get rid of sfp. It tracks
737 fp exactly at all times.
738
5efd84c5 739 *: See TARGET_CONDITIONAL_REGISTER_USAGE */
35d965d5 740
9b66ebb1
PB
741/* s0-s15 VFP scratch (aka d0-d7).
742 s16-s31 S VFP variable (aka d8-d15).
743 vfpcc Not a real register. Represents the VFP condition
744 code flags. */
745
ff9940b0
RE
746/* The stack backtrace structure is as follows:
747 fp points to here: | save code pointer | [fp]
748 | return link value | [fp, #-4]
749 | return sp value | [fp, #-8]
750 | return fp value | [fp, #-12]
751 [| saved r10 value |]
752 [| saved r9 value |]
753 [| saved r8 value |]
754 [| saved r7 value |]
755 [| saved r6 value |]
756 [| saved r5 value |]
757 [| saved r4 value |]
758 [| saved r3 value |]
759 [| saved r2 value |]
760 [| saved r1 value |]
761 [| saved r0 value |]
ff9940b0
RE
762 r0-r3 are not normally saved in a C function. */
763
35d965d5
RS
764/* 1 for registers that have pervasive standard uses
765 and are not available for the register allocator. */
0be8bd1a
RE
766#define FIXED_REGISTERS \
767{ \
768 /* Core regs. */ \
769 0,0,0,0,0,0,0,0, \
770 0,0,0,0,0,1,0,1, \
771 /* VFP regs. */ \
772 1,1,1,1,1,1,1,1, \
773 1,1,1,1,1,1,1,1, \
774 1,1,1,1,1,1,1,1, \
775 1,1,1,1,1,1,1,1, \
776 1,1,1,1,1,1,1,1, \
777 1,1,1,1,1,1,1,1, \
778 1,1,1,1,1,1,1,1, \
779 1,1,1,1,1,1,1,1, \
780 /* IWMMXT regs. */ \
781 1,1,1,1,1,1,1,1, \
782 1,1,1,1,1,1,1,1, \
783 1,1,1,1, \
784 /* Specials. */ \
785 1,1,1,1 \
35d965d5
RS
786}
787
788/* 1 for registers not available across function calls.
789 These must include the FIXED_REGISTERS and also any
790 registers that can be used without being saved.
791 The latter must include the registers where values are returned
792 and the register where structure-value addresses are passed.
ff9940b0 793 Aside from that, you can include as many other registers as you like.
f676971a 794 The CC is not preserved over function calls on the ARM 6, so it is
d6b4baa4 795 easier to assume this for all. SFP is preserved, since FP is. */
0be8bd1a
RE
796#define CALL_USED_REGISTERS \
797{ \
798 /* Core regs. */ \
799 1,1,1,1,0,0,0,0, \
800 0,0,0,0,1,1,1,1, \
801 /* VFP Regs. */ \
802 1,1,1,1,1,1,1,1, \
803 1,1,1,1,1,1,1,1, \
804 1,1,1,1,1,1,1,1, \
805 1,1,1,1,1,1,1,1, \
806 1,1,1,1,1,1,1,1, \
807 1,1,1,1,1,1,1,1, \
808 1,1,1,1,1,1,1,1, \
809 1,1,1,1,1,1,1,1, \
810 /* IWMMXT regs. */ \
811 1,1,1,1,1,1,1,1, \
812 1,1,1,1,1,1,1,1, \
813 1,1,1,1, \
814 /* Specials. */ \
815 1,1,1,1 \
35d965d5
RS
816}
817
6cc8c0b3
NC
818#ifndef SUBTARGET_CONDITIONAL_REGISTER_USAGE
819#define SUBTARGET_CONDITIONAL_REGISTER_USAGE
820#endif
821
6bc82793 822/* These are a couple of extensions to the formats accepted
dd18ae56
NC
823 by asm_fprintf:
824 %@ prints out ASM_COMMENT_START
825 %r prints out REGISTER_PREFIX reg_names[arg] */
826#define ASM_FPRINTF_EXTENSIONS(FILE, ARGS, P) \
827 case '@': \
828 fputs (ASM_COMMENT_START, FILE); \
829 break; \
830 \
831 case 'r': \
832 fputs (REGISTER_PREFIX, FILE); \
833 fputs (reg_names [va_arg (ARGS, int)], FILE); \
834 break;
835
d5b7b3ae 836/* Round X up to the nearest word. */
0c2ca901 837#define ROUND_UP_WORD(X) (((X) + 3) & ~3)
d5b7b3ae 838
6cfc7210 839/* Convert fron bytes to ints. */
e9d7b180 840#define ARM_NUM_INTS(X) (((X) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
6cfc7210 841
9b66ebb1
PB
842/* The number of (integer) registers required to hold a quantity of type MODE.
843 Also used for VFP registers. */
e9d7b180
JD
844#define ARM_NUM_REGS(MODE) \
845 ARM_NUM_INTS (GET_MODE_SIZE (MODE))
6cfc7210
NC
846
847/* The number of (integer) registers required to hold a quantity of TYPE MODE. */
e9d7b180
JD
848#define ARM_NUM_REGS2(MODE, TYPE) \
849 ARM_NUM_INTS ((MODE) == BLKmode ? \
d5b7b3ae 850 int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE))
6cfc7210
NC
851
852/* The number of (integer) argument register available. */
d5b7b3ae 853#define NUM_ARG_REGS 4
6cfc7210 854
390b17c2
RE
855/* And similarly for the VFP. */
856#define NUM_VFP_ARG_REGS 16
857
093354e0 858/* Return the register number of the N'th (integer) argument. */
d5b7b3ae 859#define ARG_REGISTER(N) (N - 1)
6cfc7210 860
d5b7b3ae
RE
861/* Specify the registers used for certain standard purposes.
862 The values of these macros are register numbers. */
35d965d5 863
d5b7b3ae
RE
864/* The number of the last argument register. */
865#define LAST_ARG_REGNUM ARG_REGISTER (NUM_ARG_REGS)
35d965d5 866
c769a35d
RE
867/* The numbers of the Thumb register ranges. */
868#define FIRST_LO_REGNUM 0
6d3d9133 869#define LAST_LO_REGNUM 7
c769a35d
RE
870#define FIRST_HI_REGNUM 8
871#define LAST_HI_REGNUM 11
6d3d9133 872
f0a0390e
RH
873/* Overridden by config/arm/bpabi.h. */
874#ifndef ARM_UNWIND_INFO
875#define ARM_UNWIND_INFO 0
617a1b71
PB
876#endif
877
c9ca9b88
PB
878/* Use r0 and r1 to pass exception handling information. */
879#define EH_RETURN_DATA_REGNO(N) (((N) < 2) ? N : INVALID_REGNUM)
880
6d3d9133 881/* The register that holds the return address in exception handlers. */
c9ca9b88
PB
882#define ARM_EH_STACKADJ_REGNUM 2
883#define EH_RETURN_STACKADJ_RTX gen_rtx_REG (SImode, ARM_EH_STACKADJ_REGNUM)
35d965d5 884
1e874273
PB
885#ifndef ARM_TARGET2_DWARF_FORMAT
886#define ARM_TARGET2_DWARF_FORMAT DW_EH_PE_pcrel
887
888/* ttype entries (the only interesting data references used)
889 use TARGET2 relocations. */
890#define ASM_PREFERRED_EH_DATA_FORMAT(code, data) \
891 (((code) == 0 && (data) == 1 && ARM_UNWIND_INFO) ? ARM_TARGET2_DWARF_FORMAT \
892 : DW_EH_PE_absptr)
893#endif
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
e3339d0f
JM
924#define HARD_FRAME_POINTER_IS_FRAME_POINTER 0
925#define HARD_FRAME_POINTER_IS_ARG_POINTER 0
926
b15bca31 927#define FP_REGNUM HARD_FRAME_POINTER_REGNUM
d5b7b3ae 928
b15bca31
RE
929/* Register to use for pushing function arguments. */
930#define STACK_POINTER_REGNUM SP_REGNUM
d5b7b3ae 931
0be8bd1a
RE
932#define FIRST_IWMMXT_REGNUM (LAST_HI_VFP_REGNUM + 1)
933#define LAST_IWMMXT_REGNUM (FIRST_IWMMXT_REGNUM + 15)
934#define FIRST_IWMMXT_GR_REGNUM (LAST_IWMMXT_REGNUM + 1)
935#define LAST_IWMMXT_GR_REGNUM (FIRST_IWMMXT_GR_REGNUM + 3)
d5b7b3ae 936
5a9335ef
NC
937#define IS_IWMMXT_REGNUM(REGNUM) \
938 (((REGNUM) >= FIRST_IWMMXT_REGNUM) && ((REGNUM) <= LAST_IWMMXT_REGNUM))
939#define IS_IWMMXT_GR_REGNUM(REGNUM) \
940 (((REGNUM) >= FIRST_IWMMXT_GR_REGNUM) && ((REGNUM) <= LAST_IWMMXT_GR_REGNUM))
941
35d965d5 942/* Base register for access to local variables of the function. */
0be8bd1a 943#define FRAME_POINTER_REGNUM 102
ff9940b0 944
d5b7b3ae 945/* Base register for access to arguments of the function. */
0be8bd1a 946#define ARG_POINTER_REGNUM 103
62b10bbc 947
0be8bd1a
RE
948#define FIRST_VFP_REGNUM 16
949#define D7_VFP_REGNUM (FIRST_VFP_REGNUM + 15)
f1adb0a9 950#define LAST_VFP_REGNUM \
302c3d8e 951 (TARGET_VFPD32 ? LAST_HI_VFP_REGNUM : LAST_LO_VFP_REGNUM)
f1adb0a9 952
9b66ebb1
PB
953#define IS_VFP_REGNUM(REGNUM) \
954 (((REGNUM) >= FIRST_VFP_REGNUM) && ((REGNUM) <= LAST_VFP_REGNUM))
955
f1adb0a9
JB
956/* VFP registers are split into two types: those defined by VFP versions < 3
957 have D registers overlaid on consecutive pairs of S registers. VFP version 3
958 defines 16 new D registers (d16-d31) which, for simplicity and correctness
959 in various parts of the backend, we implement as "fake" single-precision
960 registers (which would be S32-S63, but cannot be used in that way). The
961 following macros define these ranges of registers. */
0be8bd1a
RE
962#define LAST_LO_VFP_REGNUM (FIRST_VFP_REGNUM + 31)
963#define FIRST_HI_VFP_REGNUM (LAST_LO_VFP_REGNUM + 1)
964#define LAST_HI_VFP_REGNUM (FIRST_HI_VFP_REGNUM + 31)
f1adb0a9
JB
965
966#define VFP_REGNO_OK_FOR_SINGLE(REGNUM) \
967 ((REGNUM) <= LAST_LO_VFP_REGNUM)
968
969/* DFmode values are only valid in even register pairs. */
970#define VFP_REGNO_OK_FOR_DOUBLE(REGNUM) \
971 ((((REGNUM) - FIRST_VFP_REGNUM) & 1) == 0)
972
88f77cba
JB
973/* Neon Quad values must start at a multiple of four registers. */
974#define NEON_REGNO_OK_FOR_QUAD(REGNUM) \
975 ((((REGNUM) - FIRST_VFP_REGNUM) & 3) == 0)
976
977/* Neon structures of vectors must be in even register pairs and there
978 must be enough registers available. Because of various patterns
979 requiring quad registers, we require them to start at a multiple of
980 four. */
981#define NEON_REGNO_OK_FOR_NREGS(REGNUM, N) \
982 ((((REGNUM) - FIRST_VFP_REGNUM) & 3) == 0 \
983 && (LAST_VFP_REGNUM - (REGNUM) >= 2 * (N) - 1))
984
0be8bd1a 985/* The number of hard registers is 16 ARM + 1 CC + 1 SFP + 1 AFP. */
5a9335ef 986/* Intel Wireless MMX Technology registers add 16 + 4 more. */
0be8bd1a
RE
987/* VFP (VFP3) adds 32 (64) + 1 VFPCC. */
988#define FIRST_PSEUDO_REGISTER 104
62b10bbc 989
2fa330b2
PB
990#define DBX_REGISTER_NUMBER(REGNO) arm_dbx_register_number (REGNO)
991
35d965d5
RS
992/* Value should be nonzero if functions must have frame pointers.
993 Zero means the frame pointer need not be set up (and parms may be accessed
f676971a 994 via the stack pointer) in functions that seem suitable.
ff9940b0
RE
995 If we have to have a frame pointer we might as well make use of it.
996 APCS says that the frame pointer does not need to be pushed in leaf
2a5307b1 997 functions, or simple tail call functions. */
a15900b5
DJ
998
999#ifndef SUBTARGET_FRAME_POINTER_REQUIRED
1000#define SUBTARGET_FRAME_POINTER_REQUIRED 0
1001#endif
1002
d5b7b3ae
RE
1003/* Return number of consecutive hard regs needed starting at reg REGNO
1004 to hold something of mode MODE.
1005 This is ordinarily the length in words of a value of mode MODE
1006 but can be less for certain modes in special long registers.
35d965d5 1007
0be8bd1a 1008 On the ARM core regs are UNITS_PER_WORD bits wide. */
d5b7b3ae 1009#define HARD_REGNO_NREGS(REGNO, MODE) \
5b3e6663 1010 ((TARGET_32BIT \
0be8bd1a 1011 && REGNO > PC_REGNUM \
d5b7b3ae
RE
1012 && REGNO != FRAME_POINTER_REGNUM \
1013 && REGNO != ARG_POINTER_REGNUM) \
9b66ebb1 1014 && !IS_VFP_REGNUM (REGNO) \
e9d7b180 1015 ? 1 : ARM_NUM_REGS (MODE))
35d965d5 1016
4b02997f 1017/* Return true if REGNO is suitable for holding a quantity of type MODE. */
d5b7b3ae 1018#define HARD_REGNO_MODE_OK(REGNO, MODE) \
4b02997f 1019 arm_hard_regno_mode_ok ((REGNO), (MODE))
35d965d5 1020
2af8e257 1021#define MODES_TIEABLE_P(MODE1, MODE2) arm_modes_tieable_p (MODE1, MODE2)
ff9940b0 1022
5a9335ef 1023#define VALID_IWMMXT_REG_MODE(MODE) \
f676971a 1024 (arm_vector_mode_supported_p (MODE) || (MODE) == DImode)
5a9335ef 1025
88f77cba
JB
1026/* Modes valid for Neon D registers. */
1027#define VALID_NEON_DREG_MODE(MODE) \
1028 ((MODE) == V2SImode || (MODE) == V4HImode || (MODE) == V8QImode \
1029 || (MODE) == V2SFmode || (MODE) == DImode)
1030
1031/* Modes valid for Neon Q registers. */
1032#define VALID_NEON_QREG_MODE(MODE) \
1033 ((MODE) == V4SImode || (MODE) == V8HImode || (MODE) == V16QImode \
1034 || (MODE) == V4SFmode || (MODE) == V2DImode)
1035
1036/* Structure modes valid for Neon registers. */
1037#define VALID_NEON_STRUCT_MODE(MODE) \
1038 ((MODE) == TImode || (MODE) == EImode || (MODE) == OImode \
1039 || (MODE) == CImode || (MODE) == XImode)
1040
37119410
BS
1041/* The register numbers in sequence, for passing to arm_gen_load_multiple. */
1042extern int arm_regs_in_sequence[];
1043
35d965d5 1044/* The order in which register should be allocated. It is good to use ip
ff9940b0
RE
1045 since no saving is required (though calls clobber it) and it never contains
1046 function parameters. It is quite good to use lr since other calls may
f676971a 1047 clobber it anyway. Allocate r0 through r3 in reverse order since r3 is
ff9940b0 1048 least likely to contain a function parameter; in addition results are
f1adb0a9
JB
1049 returned in r0.
1050 For VFP/VFPv3, allocate D16-D31 first, then caller-saved registers (D0-D7),
1051 then D8-D15. The reason for doing this is to attempt to reduce register
1052 pressure when both single- and double-precision registers are used in a
1053 function. */
1054
0be8bd1a
RE
1055#define VREG(X) (FIRST_VFP_REGNUM + (X))
1056#define WREG(X) (FIRST_IWMMXT_REGNUM + (X))
1057#define WGREG(X) (FIRST_IWMMXT_GR_REGNUM + (X))
1058
f1adb0a9
JB
1059#define REG_ALLOC_ORDER \
1060{ \
0be8bd1a
RE
1061 /* General registers. */ \
1062 3, 2, 1, 0, 12, 14, 4, 5, \
1063 6, 7, 8, 9, 10, 11, \
1064 /* High VFP registers. */ \
1065 VREG(32), VREG(33), VREG(34), VREG(35), \
1066 VREG(36), VREG(37), VREG(38), VREG(39), \
1067 VREG(40), VREG(41), VREG(42), VREG(43), \
1068 VREG(44), VREG(45), VREG(46), VREG(47), \
1069 VREG(48), VREG(49), VREG(50), VREG(51), \
1070 VREG(52), VREG(53), VREG(54), VREG(55), \
1071 VREG(56), VREG(57), VREG(58), VREG(59), \
1072 VREG(60), VREG(61), VREG(62), VREG(63), \
1073 /* VFP argument registers. */ \
1074 VREG(15), VREG(14), VREG(13), VREG(12), \
1075 VREG(11), VREG(10), VREG(9), VREG(8), \
1076 VREG(7), VREG(6), VREG(5), VREG(4), \
1077 VREG(3), VREG(2), VREG(1), VREG(0), \
1078 /* VFP call-saved registers. */ \
1079 VREG(16), VREG(17), VREG(18), VREG(19), \
1080 VREG(20), VREG(21), VREG(22), VREG(23), \
1081 VREG(24), VREG(25), VREG(26), VREG(27), \
1082 VREG(28), VREG(29), VREG(30), VREG(31), \
1083 /* IWMMX registers. */ \
1084 WREG(0), WREG(1), WREG(2), WREG(3), \
1085 WREG(4), WREG(5), WREG(6), WREG(7), \
1086 WREG(8), WREG(9), WREG(10), WREG(11), \
1087 WREG(12), WREG(13), WREG(14), WREG(15), \
1088 WGREG(0), WGREG(1), WGREG(2), WGREG(3), \
1089 /* Registers not for general use. */ \
1090 CC_REGNUM, VFPCC_REGNUM, \
1091 FRAME_POINTER_REGNUM, ARG_POINTER_REGNUM, \
1092 SP_REGNUM, PC_REGNUM \
35d965d5 1093}
9338ffe6 1094
795dc4fc 1095/* Use different register alloc ordering for Thumb. */
5a733826
BS
1096#define ADJUST_REG_ALLOC_ORDER arm_order_regs_for_local_alloc ()
1097
1098/* Tell IRA to use the order we define rather than messing it up with its
1099 own cost calculations. */
1100#define HONOR_REG_ALLOC_ORDER
795dc4fc 1101
9338ffe6
PB
1102/* Interrupt functions can only use registers that have already been
1103 saved by the prologue, even if they would normally be
1104 call-clobbered. */
1105#define HARD_REGNO_RENAME_OK(SRC, DST) \
1106 (! IS_INTERRUPT (cfun->machine->func_type) || \
6fb5fa3c 1107 df_regs_ever_live_p (DST))
35d965d5
RS
1108\f
1109/* Register and constant classes. */
1110
0be8bd1a 1111/* Register classes. */
35d965d5
RS
1112enum reg_class
1113{
1114 NO_REGS,
0be8bd1a
RE
1115 LO_REGS,
1116 STACK_REG,
1117 BASE_REGS,
1118 HI_REGS,
1119 GENERAL_REGS,
1120 CORE_REGS,
f1adb0a9
JB
1121 VFP_D0_D7_REGS,
1122 VFP_LO_REGS,
1123 VFP_HI_REGS,
9b66ebb1 1124 VFP_REGS,
5a9335ef 1125 IWMMXT_REGS,
0be8bd1a 1126 IWMMXT_GR_REGS,
d5b7b3ae 1127 CC_REG,
9b66ebb1 1128 VFPCC_REG,
0be8bd1a
RE
1129 SFP_REG,
1130 AFP_REG,
35d965d5
RS
1131 ALL_REGS,
1132 LIM_REG_CLASSES
1133};
1134
1135#define N_REG_CLASSES (int) LIM_REG_CLASSES
1136
d6b4baa4 1137/* Give names of register classes as strings for dump file. */
35d965d5
RS
1138#define REG_CLASS_NAMES \
1139{ \
1140 "NO_REGS", \
0be8bd1a
RE
1141 "LO_REGS", \
1142 "STACK_REG", \
1143 "BASE_REGS", \
1144 "HI_REGS", \
1145 "GENERAL_REGS", \
1146 "CORE_REGS", \
f1adb0a9
JB
1147 "VFP_D0_D7_REGS", \
1148 "VFP_LO_REGS", \
1149 "VFP_HI_REGS", \
9b66ebb1 1150 "VFP_REGS", \
5a9335ef 1151 "IWMMXT_REGS", \
0be8bd1a 1152 "IWMMXT_GR_REGS", \
d5b7b3ae 1153 "CC_REG", \
5384443a 1154 "VFPCC_REG", \
35d965d5
RS
1155 "ALL_REGS", \
1156}
1157
1158/* Define which registers fit in which classes.
1159 This is an initializer for a vector of HARD_REG_SET
1160 of length N_REG_CLASSES. */
f1adb0a9
JB
1161#define REG_CLASS_CONTENTS \
1162{ \
1163 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \
f1adb0a9
JB
1164 { 0x000000FF, 0x00000000, 0x00000000, 0x00000000 }, /* LO_REGS */ \
1165 { 0x00002000, 0x00000000, 0x00000000, 0x00000000 }, /* STACK_REG */ \
1166 { 0x000020FF, 0x00000000, 0x00000000, 0x00000000 }, /* BASE_REGS */ \
0be8bd1a
RE
1167 { 0x00005F00, 0x00000000, 0x00000000, 0x00000000 }, /* HI_REGS */ \
1168 { 0x00005FFF, 0x00000000, 0x00000000, 0x00000000 }, /* GENERAL_REGS */ \
1169 { 0x00007FFF, 0x00000000, 0x00000000, 0x00000000 }, /* CORE_REGS */ \
1170 { 0xFFFF0000, 0x00000000, 0x00000000, 0x00000000 }, /* VFP_D0_D7_REGS */ \
1171 { 0xFFFF0000, 0x0000FFFF, 0x00000000, 0x00000000 }, /* VFP_LO_REGS */ \
1172 { 0x00000000, 0xFFFF0000, 0x0000FFFF, 0x00000000 }, /* VFP_HI_REGS */ \
1173 { 0xFFFF0000, 0xFFFFFFFF, 0x0000FFFF, 0x00000000 }, /* VFP_REGS */ \
1174 { 0x00000000, 0x00000000, 0xFFFF0000, 0x00000000 }, /* IWMMXT_REGS */ \
1175 { 0x00000000, 0x00000000, 0x00000000, 0x0000000F }, /* IWMMXT_GR_REGS */ \
1176 { 0x00000000, 0x00000000, 0x00000000, 0x00000010 }, /* CC_REG */ \
1177 { 0x00000000, 0x00000000, 0x00000000, 0x00000020 }, /* VFPCC_REG */ \
1178 { 0x00000000, 0x00000000, 0x00000000, 0x00000040 }, /* SFP_REG */ \
1179 { 0x00000000, 0x00000000, 0x00000000, 0x00000080 }, /* AFP_REG */ \
1180 { 0xFFFF7FFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000 } /* ALL_REGS */ \
35d965d5 1181}
4b02997f 1182
f1adb0a9
JB
1183/* Any of the VFP register classes. */
1184#define IS_VFP_CLASS(X) \
1185 ((X) == VFP_D0_D7_REGS || (X) == VFP_LO_REGS \
1186 || (X) == VFP_HI_REGS || (X) == VFP_REGS)
1187
35d965d5
RS
1188/* The same information, inverted:
1189 Return the class number of the smallest class containing
1190 reg number REGNO. This could be a conditional expression
1191 or could index an array. */
d5b7b3ae 1192#define REGNO_REG_CLASS(REGNO) arm_regno_class (REGNO)
35d965d5 1193
0be8bd1a
RE
1194/* In VFPv1, VFP registers could only be accessed in the mode they
1195 were set, so subregs would be invalid there. However, we don't
1196 support VFPv1 at the moment, and the restriction was lifted in
1197 VFPv2. */
1198#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) 0
75d2580c 1199
35d965d5 1200/* The class value for index registers, and the one for base regs. */
5b3e6663 1201#define INDEX_REG_CLASS (TARGET_THUMB1 ? LO_REGS : GENERAL_REGS)
f5c630c3 1202#define BASE_REG_CLASS (TARGET_THUMB1 ? LO_REGS : CORE_REGS)
d5b7b3ae 1203
b93a0fe6 1204/* For the Thumb the high registers cannot be used as base registers
6bc82793 1205 when addressing quantities in QI or HI mode; if we don't know the
888d2cd6 1206 mode, then we must be conservative. */
3dcc68a4 1207#define MODE_BASE_REG_CLASS(MODE) \
9adc580c 1208 (TARGET_ARM || (TARGET_THUMB2 && !optimize_size) ? CORE_REGS : \
888d2cd6
DJ
1209 (((MODE) == SImode) ? BASE_REGS : LO_REGS))
1210
1211/* For Thumb we can not support SP+reg addressing, so we return LO_REGS
1212 instead of BASE_REGS. */
1213#define MODE_BASE_REG_REG_CLASS(MODE) BASE_REG_CLASS
3dcc68a4 1214
42db504c 1215/* When this hook returns true for MODE, the compiler allows
d5b7b3ae
RE
1216 registers explicitly used in the rtl to be used as spill registers
1217 but prevents the compiler from extending the lifetime of these
d6b4baa4 1218 registers. */
42db504c
SB
1219#define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P \
1220 arm_small_register_classes_for_mode_p
35d965d5 1221
d5b7b3ae
RE
1222/* Must leave BASE_REGS reloads alone */
1223#define THUMB_SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \
1224 ((CLASS) != LO_REGS && (CLASS) != BASE_REGS \
1225 ? ((true_regnum (X) == -1 ? LO_REGS \
1226 : (true_regnum (X) + HARD_REGNO_NREGS (0, MODE) > 8) ? LO_REGS \
1227 : NO_REGS)) \
1228 : NO_REGS)
1229
1230#define THUMB_SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \
97358092 1231 ((CLASS) != LO_REGS && (CLASS) != BASE_REGS \
d5b7b3ae
RE
1232 ? ((true_regnum (X) == -1 ? LO_REGS \
1233 : (true_regnum (X) + HARD_REGNO_NREGS (0, MODE) > 8) ? LO_REGS \
1234 : NO_REGS)) \
1235 : NO_REGS)
35d965d5 1236
ff9940b0
RE
1237/* Return the register class of a scratch register needed to copy IN into
1238 or out of a register in CLASS in MODE. If it can be done directly,
1239 NO_REGS is returned. */
d5b7b3ae 1240#define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \
fe2d934b 1241 /* Restrict which direct reloads are allowed for VFP/iWMMXt regs. */ \
9b66ebb1 1242 ((TARGET_VFP && TARGET_HARD_FLOAT \
f1adb0a9 1243 && IS_VFP_CLASS (CLASS)) \
fe2d934b
PB
1244 ? coproc_secondary_reload_class (MODE, X, FALSE) \
1245 : (TARGET_IWMMXT && (CLASS) == IWMMXT_REGS) \
1246 ? coproc_secondary_reload_class (MODE, X, TRUE) \
5b3e6663 1247 : TARGET_32BIT \
9b66ebb1 1248 ? (((MODE) == HImode && ! arm_arch4 && true_regnum (X) == -1) \
d5b7b3ae
RE
1249 ? GENERAL_REGS : NO_REGS) \
1250 : THUMB_SECONDARY_OUTPUT_RELOAD_CLASS (CLASS, MODE, X))
f676971a 1251
d6b4baa4 1252/* If we need to load shorts byte-at-a-time, then we need a scratch. */
d5b7b3ae 1253#define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \
fe2d934b 1254 /* Restrict which direct reloads are allowed for VFP/iWMMXt regs. */ \
9b66ebb1 1255 ((TARGET_VFP && TARGET_HARD_FLOAT \
f1adb0a9 1256 && IS_VFP_CLASS (CLASS)) \
fe2d934b
PB
1257 ? coproc_secondary_reload_class (MODE, X, FALSE) : \
1258 (TARGET_IWMMXT && (CLASS) == IWMMXT_REGS) ? \
1259 coproc_secondary_reload_class (MODE, X, TRUE) : \
0be8bd1a
RE
1260 (TARGET_32BIT ? \
1261 (((CLASS) == IWMMXT_REGS || (CLASS) == IWMMXT_GR_REGS) \
1262 && CONSTANT_P (X)) \
9b6b54e2 1263 ? GENERAL_REGS : \
0be8bd1a
RE
1264 (((MODE) == HImode && ! arm_arch4 \
1265 && (GET_CODE (X) == MEM \
1266 || ((GET_CODE (X) == REG || GET_CODE (X) == SUBREG) \
1267 && true_regnum (X) == -1))) \
1268 ? GENERAL_REGS : NO_REGS) \
1269 : THUMB_SECONDARY_INPUT_RELOAD_CLASS (CLASS, MODE, X)))
2ce9c1b9 1270
6f734908
RE
1271/* Try a machine-dependent way of reloading an illegitimate address
1272 operand. If we find one, push the reload and jump to WIN. This
1273 macro is used in only one place: `find_reloads_address' in reload.c.
1274
1275 For the ARM, we wish to handle large displacements off a base
1276 register by splitting the addend across a MOV and the mem insn.
d5b7b3ae
RE
1277 This can cut the number of reloads needed. */
1278#define ARM_LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND, WIN) \
1279 do \
1280 { \
0cd98787
JZ
1281 if (arm_legitimize_reload_address (&X, MODE, OPNUM, TYPE, IND)) \
1282 goto WIN; \
d5b7b3ae 1283 } \
62b10bbc 1284 while (0)
6f734908 1285
27847754 1286/* XXX If an HImode FP+large_offset address is converted to an HImode
d5b7b3ae
RE
1287 SP+large_offset address, then reload won't know how to fix it. It sees
1288 only that SP isn't valid for HImode, and so reloads the SP into an index
1289 register, but the resulting address is still invalid because the offset
1290 is too big. We fix it here instead by reloading the entire address. */
1291/* We could probably achieve better results by defining PROMOTE_MODE to help
1292 cope with the variances between the Thumb's signed and unsigned byte and
1293 halfword load instructions. */
5b3e6663 1294/* ??? This should be safe for thumb2, but we may be able to do better. */
a132dad6
RE
1295#define THUMB_LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_L, WIN) \
1296do { \
1297 rtx new_x = thumb_legitimize_reload_address (&X, MODE, OPNUM, TYPE, IND_L); \
1298 if (new_x) \
1299 { \
1300 X = new_x; \
1301 goto WIN; \
1302 } \
1303} while (0)
d5b7b3ae
RE
1304
1305#define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_LEVELS, WIN) \
1306 if (TARGET_ARM) \
1307 ARM_LEGITIMIZE_RELOAD_ADDRESS (X, MODE, OPNUM, TYPE, IND_LEVELS, WIN); \
1308 else \
1309 THUMB_LEGITIMIZE_RELOAD_ADDRESS (X, MODE, OPNUM, TYPE, IND_LEVELS, WIN)
f676971a 1310
35d965d5
RS
1311/* Return the maximum number of consecutive registers
1312 needed to represent mode MODE in a register of class CLASS.
0be8bd1a
RE
1313 ARM regs are UNITS_PER_WORD bits.
1314 FIXME: Is this true for iWMMX? */
35d965d5 1315#define CLASS_MAX_NREGS(CLASS, MODE) \
0be8bd1a 1316 (ARM_NUM_REGS (MODE))
9b6b54e2
NC
1317
1318/* If defined, gives a class of registers that cannot be used as the
1319 operand of a SUBREG that changes the mode of the object illegally. */
35d965d5
RS
1320\f
1321/* Stack layout; function entry, exit and calling. */
1322
1323/* Define this if pushing a word on the stack
1324 makes the stack pointer a smaller address. */
1325#define STACK_GROWS_DOWNWARD 1
1326
a4d05547 1327/* Define this to nonzero if the nominal address of the stack frame
35d965d5
RS
1328 is at the high-address end of the local variables;
1329 that is, each additional local variable allocated
1330 goes at a more negative offset in the frame. */
1331#define FRAME_GROWS_DOWNWARD 1
1332
a2503645
RS
1333/* The amount of scratch space needed by _interwork_{r7,r11}_call_via_rN().
1334 When present, it is one word in size, and sits at the top of the frame,
1335 between the soft frame pointer and either r7 or r11.
1336
1337 We only need _interwork_rM_call_via_rN() for -mcaller-super-interworking,
1338 and only then if some outgoing arguments are passed on the stack. It would
1339 be tempting to also check whether the stack arguments are passed by indirect
1340 calls, but there seems to be no reason in principle why a post-reload pass
1341 couldn't convert a direct call into an indirect one. */
1342#define CALLER_INTERWORKING_SLOT_SIZE \
1343 (TARGET_CALLER_INTERWORKING \
38173d38 1344 && crtl->outgoing_args_size != 0 \
a2503645
RS
1345 ? UNITS_PER_WORD : 0)
1346
35d965d5
RS
1347/* Offset within stack frame to start allocating local variables at.
1348 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
1349 first local allocated. Otherwise, it is the offset to the BEGINNING
1350 of the first local allocated. */
1351#define STARTING_FRAME_OFFSET 0
1352
1353/* If we generate an insn to push BYTES bytes,
1354 this says how many the stack pointer really advances by. */
d5b7b3ae 1355/* The push insns do not do this rounding implicitly.
d6b4baa4 1356 So don't define this. */
0c2ca901 1357/* #define PUSH_ROUNDING(NPUSHED) ROUND_UP_WORD (NPUSHED) */
18543a22
ILT
1358
1359/* Define this if the maximum size of all the outgoing args is to be
1360 accumulated and pushed during the prologue. The amount can be
38173d38 1361 found in the variable crtl->outgoing_args_size. */
6cfc7210 1362#define ACCUMULATE_OUTGOING_ARGS 1
35d965d5
RS
1363
1364/* Offset of first parameter from the argument pointer register value. */
d5b7b3ae 1365#define FIRST_PARM_OFFSET(FNDECL) (TARGET_ARM ? 4 : 0)
35d965d5 1366
9f7bf991
RE
1367/* Amount of memory needed for an untyped call to save all possible return
1368 registers. */
1369#define APPLY_RESULT_SIZE arm_apply_result_size()
1370
11c1a207
RE
1371/* Define DEFAULT_PCC_STRUCT_RETURN to 1 if all structure and union return
1372 values must be in memory. On the ARM, they need only do so if larger
d6b4baa4 1373 than a word, or if they contain elements offset from zero in the struct. */
11c1a207
RE
1374#define DEFAULT_PCC_STRUCT_RETURN 0
1375
6d3d9133 1376/* These bits describe the different types of function supported
112cdef5 1377 by the ARM backend. They are exclusive. i.e. a function cannot be both a
6d3d9133
NC
1378 normal function and an interworked function, for example. Knowing the
1379 type of a function is important for determining its prologue and
1380 epilogue sequences.
1381 Note value 7 is currently unassigned. Also note that the interrupt
1382 function types all have bit 2 set, so that they can be tested for easily.
1383 Note that 0 is deliberately chosen for ARM_FT_UNKNOWN so that when the
4912a07c 1384 machine_function structure is initialized (to zero) func_type will
6d3d9133
NC
1385 default to unknown. This will force the first use of arm_current_func_type
1386 to call arm_compute_func_type. */
1387#define ARM_FT_UNKNOWN 0 /* Type has not yet been determined. */
1388#define ARM_FT_NORMAL 1 /* Your normal, straightforward function. */
1389#define ARM_FT_INTERWORKED 2 /* A function that supports interworking. */
6d3d9133
NC
1390#define ARM_FT_ISR 4 /* An interrupt service routine. */
1391#define ARM_FT_FIQ 5 /* A fast interrupt service routine. */
1392#define ARM_FT_EXCEPTION 6 /* An ARM exception handler (subcase of ISR). */
1393
1394#define ARM_FT_TYPE_MASK ((1 << 3) - 1)
1395
1396/* In addition functions can have several type modifiers,
1397 outlined by these bit masks: */
1398#define ARM_FT_INTERRUPT (1 << 2) /* Note overlap with FT_ISR and above. */
1399#define ARM_FT_NAKED (1 << 3) /* No prologue or epilogue. */
1400#define ARM_FT_VOLATILE (1 << 4) /* Does not return. */
d6b4baa4 1401#define ARM_FT_NESTED (1 << 5) /* Embedded inside another func. */
5b3e6663 1402#define ARM_FT_STACKALIGN (1 << 6) /* Called with misaligned stack. */
6d3d9133
NC
1403
1404/* Some macros to test these flags. */
1405#define ARM_FUNC_TYPE(t) (t & ARM_FT_TYPE_MASK)
1406#define IS_INTERRUPT(t) (t & ARM_FT_INTERRUPT)
1407#define IS_VOLATILE(t) (t & ARM_FT_VOLATILE)
1408#define IS_NAKED(t) (t & ARM_FT_NAKED)
1409#define IS_NESTED(t) (t & ARM_FT_NESTED)
5b3e6663 1410#define IS_STACKALIGN(t) (t & ARM_FT_STACKALIGN)
6d3d9133 1411
5848830f
PB
1412
1413/* Structure used to hold the function stack frame layout. Offsets are
1414 relative to the stack pointer on function entry. Positive offsets are
1415 in the direction of stack growth.
1416 Only soft_frame is used in thumb mode. */
1417
d1b38208 1418typedef struct GTY(()) arm_stack_offsets
5848830f
PB
1419{
1420 int saved_args; /* ARG_POINTER_REGNUM. */
1421 int frame; /* ARM_HARD_FRAME_POINTER_REGNUM. */
1422 int saved_regs;
1423 int soft_frame; /* FRAME_POINTER_REGNUM. */
2591db65 1424 int locals_base; /* THUMB_HARD_FRAME_POINTER_REGNUM. */
5848830f 1425 int outgoing_args; /* STACK_POINTER_REGNUM. */
954954d1 1426 unsigned int saved_regs_mask;
5848830f
PB
1427}
1428arm_stack_offsets;
1429
906668bb 1430#ifndef GENERATOR_FILE
6d3d9133
NC
1431/* A C structure for machine-specific, per-function data.
1432 This is added to the cfun structure. */
d1b38208 1433typedef struct GTY(()) machine_function
d5b7b3ae 1434{
6bc82793 1435 /* Additional stack adjustment in __builtin_eh_throw. */
e2500fed 1436 rtx eh_epilogue_sp_ofs;
d5b7b3ae
RE
1437 /* Records if LR has to be saved for far jumps. */
1438 int far_jump_used;
1439 /* Records if ARG_POINTER was ever live. */
1440 int arg_pointer_live;
6f7ebcbb
NC
1441 /* Records if the save of LR has been eliminated. */
1442 int lr_save_eliminated;
0977774b 1443 /* The size of the stack frame. Only valid after reload. */
5848830f 1444 arm_stack_offsets stack_offsets;
6d3d9133
NC
1445 /* Records the type of the current function. */
1446 unsigned long func_type;
3cb66fd7
NC
1447 /* Record if the function has a variable argument list. */
1448 int uses_anonymous_args;
5a9335ef
NC
1449 /* Records if sibcalls are blocked because an argument
1450 register is needed to preserve stack alignment. */
1451 int sibcall_blocked;
020a4035
RE
1452 /* The PIC register for this function. This might be a pseudo. */
1453 rtx pic_reg;
b12a00f1 1454 /* Labels for per-function Thumb call-via stubs. One per potential calling
57ecec57
PB
1455 register. We can never call via LR or PC. We can call via SP if a
1456 trampoline happens to be on the top of the stack. */
1457 rtx call_via[14];
934c2060
RR
1458 /* Set to 1 when a return insn is output, this means that the epilogue
1459 is not needed. */
1460 int return_used_this_function;
906668bb
BS
1461 /* When outputting Thumb-1 code, record the last insn that provides
1462 information about condition codes, and the comparison operands. */
1463 rtx thumb1_cc_insn;
1464 rtx thumb1_cc_op0;
1465 rtx thumb1_cc_op1;
1466 /* Also record the CC mode that is supported. */
1467 enum machine_mode thumb1_cc_mode;
6d3d9133
NC
1468}
1469machine_function;
906668bb 1470#endif
d5b7b3ae 1471
b12a00f1 1472/* As in the machine_function, a global set of call-via labels, for code
d6b5193b 1473 that is in text_section. */
57ecec57 1474extern GTY(()) rtx thumb_call_via_label[14];
b12a00f1 1475
390b17c2
RE
1476/* The number of potential ways of assigning to a co-processor. */
1477#define ARM_NUM_COPROC_SLOTS 1
1478
1479/* Enumeration of procedure calling standard variants. We don't really
1480 support all of these yet. */
1481enum arm_pcs
1482{
1483 ARM_PCS_AAPCS, /* Base standard AAPCS. */
1484 ARM_PCS_AAPCS_VFP, /* Use VFP registers for floating point values. */
1485 ARM_PCS_AAPCS_IWMMXT, /* Use iWMMXT registers for vectors. */
1486 /* This must be the last AAPCS variant. */
1487 ARM_PCS_AAPCS_LOCAL, /* Private call within this compilation unit. */
1488 ARM_PCS_ATPCS, /* ATPCS. */
1489 ARM_PCS_APCS, /* APCS (legacy Linux etc). */
1490 ARM_PCS_UNKNOWN
1491};
1492
12ffc7d5
CLT
1493/* Default procedure calling standard of current compilation unit. */
1494extern enum arm_pcs arm_pcs_default;
1495
82e9d970 1496/* A C type for declaring a variable that is used as the first argument of
390b17c2 1497 `FUNCTION_ARG' and other related values. */
82e9d970
PB
1498typedef struct
1499{
d5b7b3ae 1500 /* This is the number of registers of arguments scanned so far. */
82e9d970 1501 int nregs;
5a9335ef
NC
1502 /* This is the number of iWMMXt register arguments scanned so far. */
1503 int iwmmxt_nregs;
1504 int named_count;
1505 int nargs;
390b17c2
RE
1506 /* Which procedure call variant to use for this call. */
1507 enum arm_pcs pcs_variant;
1508
1509 /* AAPCS related state tracking. */
1510 int aapcs_arg_processed; /* No need to lay out this argument again. */
1511 int aapcs_cprc_slot; /* Index of co-processor rules to handle
1512 this argument, or -1 if using core
1513 registers. */
1514 int aapcs_ncrn;
1515 int aapcs_next_ncrn;
1516 rtx aapcs_reg; /* Register assigned to this argument. */
1517 int aapcs_partial; /* How many bytes are passed in regs (if
1518 split between core regs and stack.
1519 Zero otherwise. */
1520 int aapcs_cprc_failed[ARM_NUM_COPROC_SLOTS];
1521 int can_split; /* Argument can be split between core regs
1522 and the stack. */
1523 /* Private data for tracking VFP register allocation */
1524 unsigned aapcs_vfp_regs_free;
1525 unsigned aapcs_vfp_reg_alloc;
1526 int aapcs_vfp_rcount;
46107b99 1527 MACHMODE aapcs_vfp_rmode;
d5b7b3ae 1528} CUMULATIVE_ARGS;
82e9d970 1529
866af8a9
JB
1530#define FUNCTION_ARG_PADDING(MODE, TYPE) \
1531 (arm_pad_arg_upward (MODE, TYPE) ? upward : downward)
1532
1533#define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
1534 (arm_pad_reg_upward (MODE, TYPE, FIRST) ? upward : downward)
1535
1536/* For AAPCS, padding should never be below the argument. For other ABIs,
1537 * mimic the default. */
1538#define PAD_VARARGS_DOWN \
1539 ((TARGET_AAPCS_BASED) ? 0 : BYTES_BIG_ENDIAN)
1540
35d965d5
RS
1541/* Initialize a variable CUM of type CUMULATIVE_ARGS
1542 for a call to a function whose data type is FNTYPE.
1543 For a library call, FNTYPE is 0.
1544 On the ARM, the offset starts at 0. */
0f6937fe 1545#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
563a317a 1546 arm_init_cumulative_args (&(CUM), (FNTYPE), (LIBNAME), (FNDECL))
35d965d5 1547
35d965d5
RS
1548/* 1 if N is a possible register number for function argument passing.
1549 On the ARM, r0-r3 are used to pass args. */
390b17c2
RE
1550#define FUNCTION_ARG_REGNO_P(REGNO) \
1551 (IN_RANGE ((REGNO), 0, 3) \
1552 || (TARGET_AAPCS_BASED && TARGET_VFP && TARGET_HARD_FLOAT \
1553 && IN_RANGE ((REGNO), FIRST_VFP_REGNUM, FIRST_VFP_REGNUM + 15)) \
1554 || (TARGET_IWMMXT_ABI \
5848830f 1555 && IN_RANGE ((REGNO), FIRST_IWMMXT_REGNUM, FIRST_IWMMXT_REGNUM + 9)))
35d965d5 1556
f99fce0c 1557\f
afef3d7a 1558/* If your target environment doesn't prefix user functions with an
96a3900d 1559 underscore, you may wish to re-define this to prevent any conflicts. */
afef3d7a
NC
1560#ifndef ARM_MCOUNT_NAME
1561#define ARM_MCOUNT_NAME "*mcount"
1562#endif
1563
1564/* Call the function profiler with a given profile label. The Acorn
1565 compiler puts this BEFORE the prolog but gcc puts it afterwards.
1566 On the ARM the full profile code will look like:
1567 .data
1568 LP1
1569 .word 0
1570 .text
1571 mov ip, lr
1572 bl mcount
1573 .word LP1
1574
1575 profile_function() in final.c outputs the .data section, FUNCTION_PROFILER
1576 will output the .text section.
1577
1578 The ``mov ip,lr'' seems like a good idea to stick with cc convention.
59be6073
AN
1579 ``prof'' doesn't seem to mind about this!
1580
1581 Note - this version of the code is designed to work in both ARM and
1582 Thumb modes. */
be393ecf 1583#ifndef ARM_FUNCTION_PROFILER
d5b7b3ae 1584#define ARM_FUNCTION_PROFILER(STREAM, LABELNO) \
6cfc7210
NC
1585{ \
1586 char temp[20]; \
1587 rtx sym; \
1588 \
dd18ae56 1589 asm_fprintf (STREAM, "\tmov\t%r, %r\n\tbl\t", \
d5b7b3ae 1590 IP_REGNUM, LR_REGNUM); \
6cfc7210
NC
1591 assemble_name (STREAM, ARM_MCOUNT_NAME); \
1592 fputc ('\n', STREAM); \
1593 ASM_GENERATE_INTERNAL_LABEL (temp, "LP", LABELNO); \
f1c25d3b 1594 sym = gen_rtx_SYMBOL_REF (Pmode, temp); \
301d03af 1595 assemble_aligned_integer (UNITS_PER_WORD, sym); \
35d965d5 1596}
be393ecf 1597#endif
35d965d5 1598
59be6073 1599#ifdef THUMB_FUNCTION_PROFILER
d5b7b3ae
RE
1600#define FUNCTION_PROFILER(STREAM, LABELNO) \
1601 if (TARGET_ARM) \
1602 ARM_FUNCTION_PROFILER (STREAM, LABELNO) \
1603 else \
1604 THUMB_FUNCTION_PROFILER (STREAM, LABELNO)
59be6073
AN
1605#else
1606#define FUNCTION_PROFILER(STREAM, LABELNO) \
1607 ARM_FUNCTION_PROFILER (STREAM, LABELNO)
1608#endif
d5b7b3ae 1609
35d965d5
RS
1610/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1611 the stack pointer does not matter. The value is tested only in
1612 functions that have frame pointers.
1613 No definition is equivalent to always zero.
1614
1615 On the ARM, the function epilogue recovers the stack pointer from the
1616 frame. */
1617#define EXIT_IGNORE_STACK 1
1618
6fb5fa3c 1619#define EPILOGUE_USES(REGNO) ((REGNO) == LR_REGNUM)
c7861455 1620
35d965d5
RS
1621/* Determine if the epilogue should be output as RTL.
1622 You should override this if you define FUNCTION_EXTRA_EPILOGUE. */
d5b7b3ae 1623#define USE_RETURN_INSN(ISCOND) \
7c19c715 1624 (TARGET_32BIT ? use_return_insn (ISCOND, NULL) : 0)
ff9940b0
RE
1625
1626/* Definitions for register eliminations.
1627
1628 This is an array of structures. Each structure initializes one pair
1629 of eliminable registers. The "from" register number is given first,
1630 followed by "to". Eliminations of the same "from" register are listed
1631 in order of preference.
1632
1633 We have two registers that can be eliminated on the ARM. First, the
1634 arg pointer register can often be eliminated in favor of the stack
1635 pointer register. Secondly, the pseudo frame pointer register can always
1636 be eliminated; it is replaced with either the stack or the real frame
d5b7b3ae 1637 pointer. Note we have to use {ARM|THUMB}_HARD_FRAME_POINTER_REGNUM
d6a7951f 1638 because the definition of HARD_FRAME_POINTER_REGNUM is not a constant. */
ff9940b0 1639
d5b7b3ae
RE
1640#define ELIMINABLE_REGS \
1641{{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM },\
1642 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM },\
1643 { ARG_POINTER_REGNUM, ARM_HARD_FRAME_POINTER_REGNUM },\
1644 { ARG_POINTER_REGNUM, THUMB_HARD_FRAME_POINTER_REGNUM },\
1645 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM },\
1646 { FRAME_POINTER_REGNUM, ARM_HARD_FRAME_POINTER_REGNUM },\
1647 { FRAME_POINTER_REGNUM, THUMB_HARD_FRAME_POINTER_REGNUM }}
ff9940b0 1648
d5b7b3ae
RE
1649/* Define the offset between two registers, one to be eliminated, and the
1650 other its replacement, at the start of a routine. */
d5b7b3ae
RE
1651#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1652 if (TARGET_ARM) \
5848830f 1653 (OFFSET) = arm_compute_initial_elimination_offset (FROM, TO); \
d5b7b3ae 1654 else \
5848830f
PB
1655 (OFFSET) = thumb_compute_initial_elimination_offset (FROM, TO)
1656
d5b7b3ae
RE
1657/* Special case handling of the location of arguments passed on the stack. */
1658#define DEBUGGER_ARG_OFFSET(value, addr) value ? value : arm_debugger_arg_offset (value, addr)
f676971a 1659
d5b7b3ae
RE
1660/* Initialize data used by insn expanders. This is called from insn_emit,
1661 once for every function before code is generated. */
1662#define INIT_EXPANDERS arm_init_expanders ()
1663
35d965d5 1664/* Length in units of the trampoline for entering a nested function. */
5b3e6663 1665#define TRAMPOLINE_SIZE (TARGET_32BIT ? 16 : 20)
35d965d5 1666
006946e4
JM
1667/* Alignment required for a trampoline in bits. */
1668#define TRAMPOLINE_ALIGNMENT 32
35d965d5
RS
1669\f
1670/* Addressing modes, and classification of registers for them. */
3cd45774 1671#define HAVE_POST_INCREMENT 1
5b3e6663
PB
1672#define HAVE_PRE_INCREMENT TARGET_32BIT
1673#define HAVE_POST_DECREMENT TARGET_32BIT
1674#define HAVE_PRE_DECREMENT TARGET_32BIT
1675#define HAVE_PRE_MODIFY_DISP TARGET_32BIT
1676#define HAVE_POST_MODIFY_DISP TARGET_32BIT
1677#define HAVE_PRE_MODIFY_REG TARGET_32BIT
1678#define HAVE_POST_MODIFY_REG TARGET_32BIT
35d965d5 1679
8875e939
RR
1680enum arm_auto_incmodes
1681 {
1682 ARM_POST_INC,
1683 ARM_PRE_INC,
1684 ARM_POST_DEC,
1685 ARM_PRE_DEC
1686 };
1687
1688#define ARM_AUTOINC_VALID_FOR_MODE_P(mode, code) \
1689 (TARGET_32BIT && arm_autoinc_modes_ok_p (mode, code))
1690#define USE_LOAD_POST_INCREMENT(mode) \
1691 ARM_AUTOINC_VALID_FOR_MODE_P(mode, ARM_POST_INC)
1692#define USE_LOAD_PRE_INCREMENT(mode) \
1693 ARM_AUTOINC_VALID_FOR_MODE_P(mode, ARM_PRE_INC)
1694#define USE_LOAD_POST_DECREMENT(mode) \
1695 ARM_AUTOINC_VALID_FOR_MODE_P(mode, ARM_POST_DEC)
1696#define USE_LOAD_PRE_DECREMENT(mode) \
1697 ARM_AUTOINC_VALID_FOR_MODE_P(mode, ARM_PRE_DEC)
1698
1699#define USE_STORE_PRE_DECREMENT(mode) USE_LOAD_PRE_DECREMENT(mode)
1700#define USE_STORE_PRE_INCREMENT(mode) USE_LOAD_PRE_INCREMENT(mode)
1701#define USE_STORE_POST_DECREMENT(mode) USE_LOAD_POST_DECREMENT(mode)
1702#define USE_STORE_POST_INCREMENT(mode) USE_LOAD_POST_INCREMENT(mode)
1703
35d965d5
RS
1704/* Macros to check register numbers against specific register classes. */
1705
1706/* These assume that REGNO is a hard or pseudo reg number.
1707 They give nonzero only if REGNO is a hard reg of the suitable class
1708 or a pseudo reg currently allocated to a suitable hard reg.
1709 Since they use reg_renumber, they are safe only once reg_renumber
d6b4baa4 1710 has been allocated, which happens in local-alloc.c. */
d5b7b3ae
RE
1711#define TEST_REGNO(R, TEST, VALUE) \
1712 ((R TEST VALUE) || ((unsigned) reg_renumber[R] TEST VALUE))
1713
5b3e6663 1714/* Don't allow the pc to be used. */
f1008e52
RE
1715#define ARM_REGNO_OK_FOR_BASE_P(REGNO) \
1716 (TEST_REGNO (REGNO, <, PC_REGNUM) \
1717 || TEST_REGNO (REGNO, ==, FRAME_POINTER_REGNUM) \
1718 || TEST_REGNO (REGNO, ==, ARG_POINTER_REGNUM))
1719
5b3e6663 1720#define THUMB1_REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) \
f1008e52
RE
1721 (TEST_REGNO (REGNO, <=, LAST_LO_REGNUM) \
1722 || (GET_MODE_SIZE (MODE) >= 4 \
1723 && TEST_REGNO (REGNO, ==, STACK_POINTER_REGNUM)))
1724
1725#define REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) \
5b3e6663
PB
1726 (TARGET_THUMB1 \
1727 ? THUMB1_REGNO_MODE_OK_FOR_BASE_P (REGNO, MODE) \
f1008e52
RE
1728 : ARM_REGNO_OK_FOR_BASE_P (REGNO))
1729
888d2cd6
DJ
1730/* Nonzero if X can be the base register in a reg+reg addressing mode.
1731 For Thumb, we can not use SP + reg, so reject SP. */
1732#define REGNO_MODE_OK_FOR_REG_BASE_P(X, MODE) \
f5c630c3 1733 REGNO_MODE_OK_FOR_BASE_P (X, QImode)
888d2cd6 1734
f1008e52
RE
1735/* For ARM code, we don't care about the mode, but for Thumb, the index
1736 must be suitable for use in a QImode load. */
d5b7b3ae 1737#define REGNO_OK_FOR_INDEX_P(REGNO) \
f5c630c3
PB
1738 (REGNO_MODE_OK_FOR_BASE_P (REGNO, QImode) \
1739 && !TEST_REGNO (REGNO, ==, STACK_POINTER_REGNUM))
35d965d5
RS
1740
1741/* Maximum number of registers that can appear in a valid memory address.
d6b4baa4 1742 Shifts in addresses can't be by a register. */
ff9940b0 1743#define MAX_REGS_PER_ADDRESS 2
35d965d5
RS
1744
1745/* Recognize any constant value that is a valid address. */
1746/* XXX We can address any constant, eventually... */
5b3e6663 1747/* ??? Should the TARGET_ARM here also apply to thumb2? */
008cf58a
RE
1748#define CONSTANT_ADDRESS_P(X) \
1749 (GET_CODE (X) == SYMBOL_REF \
1750 && (CONSTANT_POOL_ADDRESS_P (X) \
d5b7b3ae 1751 || (TARGET_ARM && optimize > 0 && SYMBOL_REF_FLAG (X))))
35d965d5 1752
8426b956
RS
1753/* True if SYMBOL + OFFSET constants must refer to something within
1754 SYMBOL's section. */
1755#define ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P 0
1756
571191af
PB
1757/* Nonzero if all target requires all absolute relocations be R_ARM_ABS32. */
1758#ifndef TARGET_DEFAULT_WORD_RELOCATIONS
1759#define TARGET_DEFAULT_WORD_RELOCATIONS 0
1760#endif
1761
c27ba912
DM
1762#ifndef SUBTARGET_NAME_ENCODING_LENGTHS
1763#define SUBTARGET_NAME_ENCODING_LENGTHS
1764#endif
1765
6bc82793 1766/* This is a C fragment for the inside of a switch statement.
c27ba912
DM
1767 Each case label should return the number of characters to
1768 be stripped from the start of a function's name, if that
1769 name starts with the indicated character. */
1770#define ARM_NAME_ENCODING_LENGTHS \
00fdafef 1771 case '*': return 1; \
f676971a 1772 SUBTARGET_NAME_ENCODING_LENGTHS
c27ba912 1773
c27ba912
DM
1774/* This is how to output a reference to a user-level label named NAME.
1775 `assemble_name' uses this. */
e5951263 1776#undef ASM_OUTPUT_LABELREF
c27ba912 1777#define ASM_OUTPUT_LABELREF(FILE, NAME) \
e1944073 1778 arm_asm_output_labelref (FILE, NAME)
c27ba912 1779
7a085dce 1780/* Output IT instructions for conditionally executed Thumb-2 instructions. */
5b3e6663
PB
1781#define ASM_OUTPUT_OPCODE(STREAM, PTR) \
1782 if (TARGET_THUMB2) \
1783 thumb2_asm_output_opcode (STREAM);
1784
7abc66b1
JB
1785/* The EABI specifies that constructors should go in .init_array.
1786 Other targets use .ctors for compatibility. */
88c6057f 1787#ifndef ARM_EABI_CTORS_SECTION_OP
7abc66b1
JB
1788#define ARM_EABI_CTORS_SECTION_OP \
1789 "\t.section\t.init_array,\"aw\",%init_array"
88c6057f
MM
1790#endif
1791#ifndef ARM_EABI_DTORS_SECTION_OP
7abc66b1
JB
1792#define ARM_EABI_DTORS_SECTION_OP \
1793 "\t.section\t.fini_array,\"aw\",%fini_array"
88c6057f 1794#endif
7abc66b1
JB
1795#define ARM_CTORS_SECTION_OP \
1796 "\t.section\t.ctors,\"aw\",%progbits"
1797#define ARM_DTORS_SECTION_OP \
1798 "\t.section\t.dtors,\"aw\",%progbits"
1799
1800/* Define CTORS_SECTION_ASM_OP. */
1801#undef CTORS_SECTION_ASM_OP
1802#undef DTORS_SECTION_ASM_OP
1803#ifndef IN_LIBGCC2
1804# define CTORS_SECTION_ASM_OP \
1805 (TARGET_AAPCS_BASED ? ARM_EABI_CTORS_SECTION_OP : ARM_CTORS_SECTION_OP)
1806# define DTORS_SECTION_ASM_OP \
1807 (TARGET_AAPCS_BASED ? ARM_EABI_DTORS_SECTION_OP : ARM_DTORS_SECTION_OP)
1808#else /* !defined (IN_LIBGCC2) */
1809/* In libgcc, CTORS_SECTION_ASM_OP must be a compile-time constant,
1810 so we cannot use the definition above. */
1811# ifdef __ARM_EABI__
1812/* The .ctors section is not part of the EABI, so we do not define
1813 CTORS_SECTION_ASM_OP when in libgcc; that prevents crtstuff
1814 from trying to use it. We do define it when doing normal
1815 compilation, as .init_array can be used instead of .ctors. */
1816/* There is no need to emit begin or end markers when using
1817 init_array; the dynamic linker will compute the size of the
1818 array itself based on special symbols created by the static
1819 linker. However, we do need to arrange to set up
1820 exception-handling here. */
1821# define CTOR_LIST_BEGIN asm (ARM_EABI_CTORS_SECTION_OP)
1822# define CTOR_LIST_END /* empty */
1823# define DTOR_LIST_BEGIN asm (ARM_EABI_DTORS_SECTION_OP)
1824# define DTOR_LIST_END /* empty */
1825# else /* !defined (__ARM_EABI__) */
1826# define CTORS_SECTION_ASM_OP ARM_CTORS_SECTION_OP
1827# define DTORS_SECTION_ASM_OP ARM_DTORS_SECTION_OP
1828# endif /* !defined (__ARM_EABI__) */
1829#endif /* !defined (IN_LIBCC2) */
1830
1e731102
MM
1831/* True if the operating system can merge entities with vague linkage
1832 (e.g., symbols in COMDAT group) during dynamic linking. */
1833#ifndef TARGET_ARM_DYNAMIC_VAGUE_LINKAGE_P
1834#define TARGET_ARM_DYNAMIC_VAGUE_LINKAGE_P true
1835#endif
1836
617a1b71
PB
1837#define ARM_OUTPUT_FN_UNWIND(F, PROLOGUE) arm_output_fn_unwind (F, PROLOGUE)
1838
35d965d5
RS
1839/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1840 and check its validity for a certain class.
1841 We have two alternate definitions for each of them.
1842 The usual definition accepts all pseudo regs; the other rejects
1843 them unless they have been allocated suitable hard regs.
5b3e6663 1844 The symbol REG_OK_STRICT causes the latter definition to be used.
7a085dce 1845 Thumb-2 has the same restrictions as arm. */
35d965d5 1846#ifndef REG_OK_STRICT
ff9940b0 1847
f1008e52
RE
1848#define ARM_REG_OK_FOR_BASE_P(X) \
1849 (REGNO (X) <= LAST_ARM_REGNUM \
1850 || REGNO (X) >= FIRST_PSEUDO_REGISTER \
1851 || REGNO (X) == FRAME_POINTER_REGNUM \
1852 || REGNO (X) == ARG_POINTER_REGNUM)
ff9940b0 1853
f5c630c3
PB
1854#define ARM_REG_OK_FOR_INDEX_P(X) \
1855 ((REGNO (X) <= LAST_ARM_REGNUM \
1856 && REGNO (X) != STACK_POINTER_REGNUM) \
1857 || REGNO (X) >= FIRST_PSEUDO_REGISTER \
1858 || REGNO (X) == FRAME_POINTER_REGNUM \
1859 || REGNO (X) == ARG_POINTER_REGNUM)
1860
5b3e6663 1861#define THUMB1_REG_MODE_OK_FOR_BASE_P(X, MODE) \
f1008e52
RE
1862 (REGNO (X) <= LAST_LO_REGNUM \
1863 || REGNO (X) >= FIRST_PSEUDO_REGISTER \
1864 || (GET_MODE_SIZE (MODE) >= 4 \
1865 && (REGNO (X) == STACK_POINTER_REGNUM \
1866 || (X) == hard_frame_pointer_rtx \
1867 || (X) == arg_pointer_rtx)))
ff9940b0 1868
76a318e9
RE
1869#define REG_STRICT_P 0
1870
d5b7b3ae 1871#else /* REG_OK_STRICT */
ff9940b0 1872
f1008e52
RE
1873#define ARM_REG_OK_FOR_BASE_P(X) \
1874 ARM_REGNO_OK_FOR_BASE_P (REGNO (X))
ff9940b0 1875
f5c630c3
PB
1876#define ARM_REG_OK_FOR_INDEX_P(X) \
1877 ARM_REGNO_OK_FOR_INDEX_P (REGNO (X))
1878
5b3e6663
PB
1879#define THUMB1_REG_MODE_OK_FOR_BASE_P(X, MODE) \
1880 THUMB1_REGNO_MODE_OK_FOR_BASE_P (REGNO (X), MODE)
ff9940b0 1881
76a318e9
RE
1882#define REG_STRICT_P 1
1883
d5b7b3ae 1884#endif /* REG_OK_STRICT */
f1008e52
RE
1885
1886/* Now define some helpers in terms of the above. */
1887
1888#define REG_MODE_OK_FOR_BASE_P(X, MODE) \
5b3e6663
PB
1889 (TARGET_THUMB1 \
1890 ? THUMB1_REG_MODE_OK_FOR_BASE_P (X, MODE) \
f1008e52
RE
1891 : ARM_REG_OK_FOR_BASE_P (X))
1892
5b3e6663 1893/* For 16-bit Thumb, a valid index register is anything that can be used in
f1008e52 1894 a byte load instruction. */
5b3e6663
PB
1895#define THUMB1_REG_OK_FOR_INDEX_P(X) \
1896 THUMB1_REG_MODE_OK_FOR_BASE_P (X, QImode)
f1008e52
RE
1897
1898/* Nonzero if X is a hard reg that can be used as an index
1899 or if it is a pseudo reg. On the Thumb, the stack pointer
1900 is not suitable. */
1901#define REG_OK_FOR_INDEX_P(X) \
5b3e6663
PB
1902 (TARGET_THUMB1 \
1903 ? THUMB1_REG_OK_FOR_INDEX_P (X) \
f1008e52
RE
1904 : ARM_REG_OK_FOR_INDEX_P (X))
1905
888d2cd6
DJ
1906/* Nonzero if X can be the base register in a reg+reg addressing mode.
1907 For Thumb, we can not use SP + reg, so reject SP. */
1908#define REG_MODE_OK_FOR_REG_BASE_P(X, MODE) \
1909 REG_OK_FOR_INDEX_P (X)
35d965d5 1910\f
f1008e52
RE
1911#define ARM_BASE_REGISTER_RTX_P(X) \
1912 (GET_CODE (X) == REG && ARM_REG_OK_FOR_BASE_P (X))
35d965d5 1913
f1008e52
RE
1914#define ARM_INDEX_REGISTER_RTX_P(X) \
1915 (GET_CODE (X) == REG && ARM_REG_OK_FOR_INDEX_P (X))
35d965d5 1916\f
35d965d5
RS
1917/* Specify the machine mode that this machine uses
1918 for the index in the tablejump instruction. */
d5b7b3ae 1919#define CASE_VECTOR_MODE Pmode
35d965d5 1920
907dd0c7 1921#define CASE_VECTOR_PC_RELATIVE (TARGET_THUMB2 \
83c3a2d8 1922 || (TARGET_THUMB1 \
907dd0c7
RE
1923 && (optimize_size || flag_pic)))
1924
1925#define CASE_VECTOR_SHORTEN_MODE(min, max, body) \
83c3a2d8 1926 (TARGET_THUMB1 \
907dd0c7
RE
1927 ? (min >= 0 && max < 512 \
1928 ? (ADDR_DIFF_VEC_FLAGS (body).offset_unsigned = 1, QImode) \
1929 : min >= -256 && max < 256 \
1930 ? (ADDR_DIFF_VEC_FLAGS (body).offset_unsigned = 0, QImode) \
1931 : min >= 0 && max < 8192 \
1932 ? (ADDR_DIFF_VEC_FLAGS (body).offset_unsigned = 1, HImode) \
1933 : min >= -4096 && max < 4096 \
1934 ? (ADDR_DIFF_VEC_FLAGS (body).offset_unsigned = 0, HImode) \
1935 : SImode) \
10c241af 1936 : ((min < 0 || max >= 0x20000 || !TARGET_THUMB2) ? SImode \
907dd0c7
RE
1937 : (max >= 0x200) ? HImode \
1938 : QImode))
5b3e6663 1939
ff9940b0
RE
1940/* signed 'char' is most compatible, but RISC OS wants it unsigned.
1941 unsigned is probably best, but may break some code. */
1942#ifndef DEFAULT_SIGNED_CHAR
3967692c 1943#define DEFAULT_SIGNED_CHAR 0
35d965d5
RS
1944#endif
1945
35d965d5 1946/* Max number of bytes we can move from memory to memory
d17ce9af
TG
1947 in one reasonably fast instruction. */
1948#define MOVE_MAX 4
35d965d5 1949
d19fb8e3 1950#undef MOVE_RATIO
e04ad03d 1951#define MOVE_RATIO(speed) (arm_tune_xscale ? 4 : 2)
d19fb8e3 1952
ff9940b0
RE
1953/* Define if operations between registers always perform the operation
1954 on the full register even if a narrower mode is specified. */
1955#define WORD_REGISTER_OPERATIONS
1956
1957/* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1958 will either zero-extend or sign-extend. The value of this macro should
1959 be the code that says which one of the two operations is implicitly
f822d252 1960 done, UNKNOWN if none. */
9c872872 1961#define LOAD_EXTEND_OP(MODE) \
d5b7b3ae
RE
1962 (TARGET_THUMB ? ZERO_EXTEND : \
1963 ((arm_arch4 || (MODE) == QImode) ? ZERO_EXTEND \
f822d252 1964 : ((BYTES_BIG_ENDIAN && (MODE) == HImode) ? SIGN_EXTEND : UNKNOWN)))
ff9940b0 1965
35d965d5
RS
1966/* Nonzero if access to memory by bytes is slow and undesirable. */
1967#define SLOW_BYTE_ACCESS 0
1968
d5b7b3ae 1969#define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) 1
f676971a 1970
35d965d5
RS
1971/* Immediate shift counts are truncated by the output routines (or was it
1972 the assembler?). Shift counts in a register are truncated by ARM. Note
1973 that the native compiler puts too large (> 32) immediate shift counts
1974 into a register and shifts by the register, letting the ARM decide what
1975 to do instead of doing that itself. */
ff9940b0
RE
1976/* This is all wrong. Defining SHIFT_COUNT_TRUNCATED tells combine that
1977 code like (X << (Y % 32)) for register X, Y is equivalent to (X << Y).
1978 On the arm, Y in a register is used modulo 256 for the shift. Only for
d6b4baa4 1979 rotates is modulo 32 used. */
ff9940b0 1980/* #define SHIFT_COUNT_TRUNCATED 1 */
35d965d5 1981
35d965d5 1982/* All integers have the same format so truncation is easy. */
d5b7b3ae 1983#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
35d965d5
RS
1984
1985/* Calling from registers is a massive pain. */
1986#define NO_FUNCTION_CSE 1
1987
35d965d5
RS
1988/* The machine modes of pointers and functions */
1989#define Pmode SImode
1990#define FUNCTION_MODE Pmode
1991
d5b7b3ae
RE
1992#define ARM_FRAME_RTX(X) \
1993 ( (X) == frame_pointer_rtx || (X) == stack_pointer_rtx \
3967692c
RE
1994 || (X) == arg_pointer_rtx)
1995
ff9940b0
RE
1996/* Try to generate sequences that don't involve branches, we can then use
1997 conditional instructions */
3a4fd356 1998#define BRANCH_COST(speed_p, predictable_p) \
153668ec
JB
1999 (current_tune->branch_cost (speed_p, predictable_p))
2000
7a801826
RE
2001\f
2002/* Position Independent Code. */
2003/* We decide which register to use based on the compilation options and
2004 the assembler in use; this is more general than the APCS restriction of
2005 using sb (r9) all the time. */
020a4035 2006extern unsigned arm_pic_register;
7a801826
RE
2007
2008/* The register number of the register used to address a table of static
2009 data addresses in memory. */
2010#define PIC_OFFSET_TABLE_REGNUM arm_pic_register
2011
f5a1b0d2 2012/* We can't directly access anything that contains a symbol,
d3585b76
DJ
2013 nor can we indirect via the constant pool. One exception is
2014 UNSPEC_TLS, which is always PIC. */
82e9d970 2015#define LEGITIMATE_PIC_OPERAND_P(X) \
1575c31e
JD
2016 (!(symbol_mentioned_p (X) \
2017 || label_mentioned_p (X) \
2018 || (GET_CODE (X) == SYMBOL_REF \
2019 && CONSTANT_POOL_ADDRESS_P (X) \
2020 && (symbol_mentioned_p (get_pool_constant (X)) \
d3585b76
DJ
2021 || label_mentioned_p (get_pool_constant (X))))) \
2022 || tls_mentioned_p (X))
1575c31e 2023
13bd191d
PB
2024/* We need to know when we are making a constant pool; this determines
2025 whether data needs to be in the GOT or can be referenced via a GOT
2026 offset. */
2027extern int making_const_table;
82e9d970 2028\f
c27ba912 2029/* Handle pragmas for compatibility with Intel's compilers. */
b76c3c4b 2030/* Also abuse this to register additional C specific EABI attributes. */
c58b209a
NB
2031#define REGISTER_TARGET_PRAGMAS() do { \
2032 c_register_pragma (0, "long_calls", arm_pr_long_calls); \
2033 c_register_pragma (0, "no_long_calls", arm_pr_no_long_calls); \
2034 c_register_pragma (0, "long_calls_off", arm_pr_long_calls_off); \
b76c3c4b 2035 arm_lang_object_attributes_init(); \
8b97c5f8
ZW
2036} while (0)
2037
d6b4baa4 2038/* Condition code information. */
ff9940b0 2039/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
a5381466 2040 return the mode to be used for the comparison. */
d5b7b3ae
RE
2041
2042#define SELECT_CC_MODE(OP, X, Y) arm_select_cc_mode (OP, X, Y)
ff9940b0 2043
880873be
RE
2044#define REVERSIBLE_CC_MODE(MODE) 1
2045
2046#define REVERSE_CONDITION(CODE,MODE) \
2047 (((MODE) == CCFPmode || (MODE) == CCFPEmode) \
2048 ? reverse_condition_maybe_unordered (code) \
2049 : reverse_condition (code))
008cf58a 2050
62b10bbc 2051#define CANONICALIZE_COMPARISON(CODE, OP0, OP1) \
73160ba9 2052 (CODE) = arm_canonicalize_comparison (CODE, &(OP0), &(OP1))
62dd06ea 2053
7dba8395
RH
2054/* The arm5 clz instruction returns 32. */
2055#define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 32, 1)
ca96ed43 2056#define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 32, 1)
35d965d5 2057\f
906668bb
BS
2058#define CC_STATUS_INIT \
2059 do { cfun->machine->thumb1_cc_insn = NULL_RTX; } while (0)
2060
d5b7b3ae 2061#undef ASM_APP_OFF
5b3e6663
PB
2062#define ASM_APP_OFF (TARGET_THUMB1 ? "\t.code\t16\n" : \
2063 TARGET_THUMB2 ? "\t.thumb\n" : "")
35d965d5 2064
2ee67fbb
JB
2065/* Output a push or a pop instruction (only used when profiling).
2066 We can't push STATIC_CHAIN_REGNUM (r12) directly with Thumb-1. We know
2067 that ASM_OUTPUT_REG_PUSH will be matched with ASM_OUTPUT_REG_POP, and
2068 that r7 isn't used by the function profiler, so we can use it as a
2069 scratch reg. WARNING: This isn't safe in the general case! It may be
2070 sensitive to future changes in final.c:profile_function. */
d5b7b3ae 2071#define ASM_OUTPUT_REG_PUSH(STREAM, REGNO) \
8a81cc45
RE
2072 do \
2073 { \
2074 if (TARGET_ARM) \
2075 asm_fprintf (STREAM,"\tstmfd\t%r!,{%r}\n", \
2076 STACK_POINTER_REGNUM, REGNO); \
2ee67fbb
JB
2077 else if (TARGET_THUMB1 \
2078 && (REGNO) == STATIC_CHAIN_REGNUM) \
2079 { \
2080 asm_fprintf (STREAM, "\tpush\t{r7}\n"); \
2081 asm_fprintf (STREAM, "\tmov\tr7, %r\n", REGNO);\
2082 asm_fprintf (STREAM, "\tpush\t{r7}\n"); \
2083 } \
8a81cc45
RE
2084 else \
2085 asm_fprintf (STREAM, "\tpush {%r}\n", REGNO); \
2086 } while (0)
d5b7b3ae
RE
2087
2088
2ee67fbb 2089/* See comment for ASM_OUTPUT_REG_PUSH concerning Thumb-1 issue. */
d5b7b3ae 2090#define ASM_OUTPUT_REG_POP(STREAM, REGNO) \
8a81cc45
RE
2091 do \
2092 { \
2093 if (TARGET_ARM) \
2094 asm_fprintf (STREAM, "\tldmfd\t%r!,{%r}\n", \
2095 STACK_POINTER_REGNUM, REGNO); \
2ee67fbb
JB
2096 else if (TARGET_THUMB1 \
2097 && (REGNO) == STATIC_CHAIN_REGNUM) \
2098 { \
2099 asm_fprintf (STREAM, "\tpop\t{r7}\n"); \
2100 asm_fprintf (STREAM, "\tmov\t%r, r7\n", REGNO);\
2101 asm_fprintf (STREAM, "\tpop\t{r7}\n"); \
2102 } \
8a81cc45
RE
2103 else \
2104 asm_fprintf (STREAM, "\tpop {%r}\n", REGNO); \
2105 } while (0)
d5b7b3ae 2106
5b3e6663
PB
2107/* Jump table alignment is explicit in ASM_OUTPUT_CASE_LABEL. */
2108#define ADDR_VEC_ALIGN(JUMPTABLE) 0
2109
d5b7b3ae
RE
2110/* This is how to output a label which precedes a jumptable. Since
2111 Thumb instructions are 2 bytes, we may need explicit alignment here. */
be393ecf 2112#undef ASM_OUTPUT_CASE_LABEL
5b3e6663
PB
2113#define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
2114 do \
2115 { \
2116 if (TARGET_THUMB && GET_MODE (PATTERN (JUMPTABLE)) == SImode) \
2117 ASM_OUTPUT_ALIGN (FILE, 2); \
2118 (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); \
2119 } \
2120 while (0)
2121
2122/* Make sure subsequent insns are aligned after a TBB. */
2123#define ASM_OUTPUT_CASE_END(FILE, NUM, JUMPTABLE) \
2124 do \
2125 { \
2126 if (GET_MODE (PATTERN (JUMPTABLE)) == QImode) \
2127 ASM_OUTPUT_ALIGN (FILE, 1); \
2128 } \
d5b7b3ae 2129 while (0)
35d965d5 2130
6cfc7210
NC
2131#define ARM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
2132 do \
2133 { \
d5b7b3ae
RE
2134 if (TARGET_THUMB) \
2135 { \
5b3e6663 2136 if (is_called_in_ARM_mode (DECL) \
bf98ec6c 2137 || (TARGET_THUMB1 && !TARGET_THUMB1_ONLY \
3c072c6b 2138 && cfun->is_thunk)) \
d5b7b3ae 2139 fprintf (STREAM, "\t.code 32\n") ; \
5b3e6663
PB
2140 else if (TARGET_THUMB1) \
2141 fprintf (STREAM, "\t.code\t16\n\t.thumb_func\n") ; \
d5b7b3ae 2142 else \
5b3e6663 2143 fprintf (STREAM, "\t.thumb\n\t.thumb_func\n") ; \
d5b7b3ae 2144 } \
6cfc7210 2145 if (TARGET_POKE_FUNCTION_NAME) \
586de218 2146 arm_poke_function_name (STREAM, (const char *) NAME); \
6cfc7210
NC
2147 } \
2148 while (0)
35d965d5 2149
d5b7b3ae
RE
2150/* For aliases of functions we use .thumb_set instead. */
2151#define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL1, DECL2) \
2152 do \
2153 { \
91ea4f8d
KG
2154 const char *const LABEL1 = XSTR (XEXP (DECL_RTL (decl), 0), 0); \
2155 const char *const LABEL2 = IDENTIFIER_POINTER (DECL2); \
d5b7b3ae
RE
2156 \
2157 if (TARGET_THUMB && TREE_CODE (DECL1) == FUNCTION_DECL) \
2158 { \
2159 fprintf (FILE, "\t.thumb_set "); \
2160 assemble_name (FILE, LABEL1); \
2161 fprintf (FILE, ","); \
2162 assemble_name (FILE, LABEL2); \
2163 fprintf (FILE, "\n"); \
2164 } \
2165 else \
2166 ASM_OUTPUT_DEF (FILE, LABEL1, LABEL2); \
2167 } \
2168 while (0)
2169
fdc2d3b0
NC
2170#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
2171/* To support -falign-* switches we need to use .p2align so
2172 that alignment directives in code sections will be padded
2173 with no-op instructions, rather than zeroes. */
5a9335ef 2174#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \
fdc2d3b0
NC
2175 if ((LOG) != 0) \
2176 { \
2177 if ((MAX_SKIP) == 0) \
5a9335ef 2178 fprintf ((FILE), "\t.p2align %d\n", (int) (LOG)); \
fdc2d3b0
NC
2179 else \
2180 fprintf ((FILE), "\t.p2align %d,,%d\n", \
5a9335ef 2181 (int) (LOG), (int) (MAX_SKIP)); \
fdc2d3b0
NC
2182 }
2183#endif
35d965d5 2184\f
5b3e6663
PB
2185/* Add two bytes to the length of conditionally executed Thumb-2
2186 instructions for the IT instruction. */
2187#define ADJUST_INSN_LENGTH(insn, length) \
2188 if (TARGET_THUMB2 && GET_CODE (PATTERN (insn)) == COND_EXEC) \
2189 length += 2;
2190
35d965d5 2191/* Only perform branch elimination (by making instructions conditional) if
5b3e6663
PB
2192 we're optimizing. For Thumb-2 check if any IT instructions need
2193 outputting. */
d5b7b3ae
RE
2194#define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
2195 if (TARGET_ARM && optimize) \
2196 arm_final_prescan_insn (INSN); \
5b3e6663
PB
2197 else if (TARGET_THUMB2) \
2198 thumb2_final_prescan_insn (INSN); \
2199 else if (TARGET_THUMB1) \
2200 thumb1_final_prescan_insn (INSN)
35d965d5 2201
7b8b8ade
NC
2202#define ARM_SIGN_EXTEND(x) ((HOST_WIDE_INT) \
2203 (HOST_BITS_PER_WIDE_INT <= 32 ? (unsigned HOST_WIDE_INT) (x) \
30cf4896
KG
2204 : ((((unsigned HOST_WIDE_INT)(x)) & (unsigned HOST_WIDE_INT) 0xffffffff) |\
2205 ((((unsigned HOST_WIDE_INT)(x)) & (unsigned HOST_WIDE_INT) 0x80000000) \
2206 ? ((~ (unsigned HOST_WIDE_INT) 0) \
2207 & ~ (unsigned HOST_WIDE_INT) 0xffffffff) \
7bc7696c 2208 : 0))))
35d965d5 2209
6a5d7526
MS
2210/* A C expression whose value is RTL representing the value of the return
2211 address for the frame COUNT steps up from the current frame. */
2212
d5b7b3ae
RE
2213#define RETURN_ADDR_RTX(COUNT, FRAME) \
2214 arm_return_addr (COUNT, FRAME)
2215
f676971a 2216/* Mask of the bits in the PC that contain the real return address
d5b7b3ae
RE
2217 when running in 26-bit mode. */
2218#define RETURN_ADDR_MASK26 (0x03fffffc)
6a5d7526 2219
2c849145
JM
2220/* Pick up the return address upon entry to a procedure. Used for
2221 dwarf2 unwind information. This also enables the table driven
2222 mechanism. */
2c849145
JM
2223#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LR_REGNUM)
2224#define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (LR_REGNUM)
2225
39950dff
MS
2226/* Used to mask out junk bits from the return address, such as
2227 processor state, interrupt status, condition codes and the like. */
2228#define MASK_RETURN_ADDR \
2229 /* If we are generating code for an ARM2/ARM3 machine or for an ARM6 \
2230 in 26 bit mode, the condition codes must be masked out of the \
2231 return address. This does not apply to ARM6 and later processors \
2232 when running in 32 bit mode. */ \
61f0ccff
RE
2233 ((arm_arch4 || TARGET_THUMB) \
2234 ? (gen_int_mode ((unsigned long)0xffffffff, Pmode)) \
fcd53748 2235 : arm_gen_return_addr_mask ())
d5b7b3ae
RE
2236
2237\f
978e411f
CD
2238/* Do not emit .note.GNU-stack by default. */
2239#ifndef NEED_INDICATE_EXEC_STACK
2240#define NEED_INDICATE_EXEC_STACK 0
2241#endif
2242
9e94a7fc
MGD
2243#define TARGET_ARM_ARCH \
2244 (arm_base_arch) \
2245
2246#define TARGET_ARM_V6M (!arm_arch_notm && !arm_arch_thumb2)
2247#define TARGET_ARM_V7M (!arm_arch_notm && arm_arch_thumb2)
2248
2249/* The highest Thumb instruction set version supported by the chip. */
2250#define TARGET_ARM_ARCH_ISA_THUMB \
2251 (arm_arch_thumb2 ? 2 \
2252 : ((TARGET_ARM_ARCH >= 5 || arm_arch4t) ? 1 : 0))
2253
2254/* Expands to an upper-case char of the target's architectural
2255 profile. */
2256#define TARGET_ARM_ARCH_PROFILE \
2257 (!arm_arch_notm \
2258 ? 'M' \
2259 : (arm_arch7 \
2260 ? (strlen (arm_arch_name) >=3 \
2261 ? (arm_arch_name[strlen (arm_arch_name) - 3]) \
2262 : 0) \
2263 : 0))
2264
2265/* Bit-field indicating what size LDREX/STREX loads/stores are available.
2266 Bit 0 for bytes, up to bit 3 for double-words. */
2267#define TARGET_ARM_FEATURE_LDREX \
2268 ((TARGET_HAVE_LDREX ? 4 : 0) \
2269 | (TARGET_HAVE_LDREXBH ? 3 : 0) \
2270 | (TARGET_HAVE_LDREXD ? 8 : 0))
2271
2272/* Set as a bit mask indicating the available widths of hardware floating
2273 point types. Where bit 1 indicates 16-bit support, bit 2 indicates
2274 32-bit support, bit 3 indicates 64-bit support. */
2275#define TARGET_ARM_FP \
2276 (TARGET_VFP_SINGLE ? 4 \
2277 : (TARGET_VFP_DOUBLE ? (TARGET_FP16 ? 14 : 12) : 0))
2278
2279
2280/* Set as a bit mask indicating the available widths of floating point
2281 types for hardware NEON floating point. This is the same as
2282 TARGET_ARM_FP without the 64-bit bit set. */
2283#ifdef TARGET_NEON
2284#define TARGET_NEON_FP \
2285 (TARGET_ARM_FP & (0xff ^ 0x08))
2286#endif
2287
93b338c3
BS
2288/* The maximum number of parallel loads or stores we support in an ldm/stm
2289 instruction. */
2290#define MAX_LDM_STM_OPS 4
2291
54e73f88
AS
2292#define ASM_CPU_SPEC \
2293 " %{mcpu=generic-*:-march=%*;" \
2294 " :%{mcpu=*:-mcpu=%*} %{march=*:-march=%*}}"
2295
33aa08b3
AS
2296/* -mcpu=native handling only makes sense with compiler running on
2297 an ARM chip. */
2298#if defined(__arm__)
2299extern const char *host_detect_local_cpu (int argc, const char **argv);
2300# define EXTRA_SPEC_FUNCTIONS \
2301 { "local_cpu_detect", host_detect_local_cpu },
2302
2303# define MCPU_MTUNE_NATIVE_SPECS \
2304 " %{march=native:%<march=native %:local_cpu_detect(arch)}" \
2305 " %{mcpu=native:%<mcpu=native %:local_cpu_detect(cpu)}" \
2306 " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}"
2307#else
2308# define MCPU_MTUNE_NATIVE_SPECS ""
2309#endif
2310
2311#define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS
2312
88657302 2313#endif /* ! GCC_ARM_H */