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