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