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