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