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)
10 This file is part of GCC.
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.
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.
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/>. */
29 #include "config/vxworks-dummy.h"
31 /* The architecture define. */
32 extern char arm_arch_name
[];
34 /* Target CPU builtins. */
35 #define TARGET_CPU_CPP_BUILTINS() \
38 /* Define __arm__ even when in thumb mode, for \
39 consistency with armcc. */ \
40 builtin_define ("__arm__"); \
41 builtin_define ("__APCS_32__"); \
43 builtin_define ("__thumb__"); \
45 builtin_define ("__thumb2__"); \
49 builtin_define ("__ARMEB__"); \
51 builtin_define ("__THUMBEB__"); \
52 if (TARGET_LITTLE_WORDS) \
53 builtin_define ("__ARMWEL__"); \
57 builtin_define ("__ARMEL__"); \
59 builtin_define ("__THUMBEL__"); \
62 if (TARGET_SOFT_FLOAT) \
63 builtin_define ("__SOFTFP__"); \
66 builtin_define ("__VFP_FP__"); \
69 builtin_define ("__ARM_NEON__"); \
71 /* Add a define for interworking. \
72 Needed when building libgcc.a. */ \
73 if (arm_cpp_interwork) \
74 builtin_define ("__THUMB_INTERWORK__"); \
76 builtin_assert ("cpu=arm"); \
77 builtin_assert ("machine=arm"); \
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__"); \
90 /* The various ARM cores. */
93 #define ARM_CORE(NAME, IDENT, ARCH, FLAGS, COSTS) \
95 #include "arm-cores.def"
97 /* Used to indicate that no processor has been specified. */
103 #define ARM_CORE(NAME, IDENT, ARCH, FLAGS, COSTS) \
105 #include "arm-cores.def"
110 /* The processor for which instructions should be scheduled. */
111 extern enum processor_type arm_tune
;
113 typedef enum arm_cond_code
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
120 extern arm_cc arm_current_cc
;
122 #define ARM_INVERSE_CONDITION_CODE(X) ((arm_cc) (((int)X) ^ 1))
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
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);
135 /* Just in case configure has failed to define anything. */
136 #ifndef TARGET_CPU_DEFAULT
137 #define TARGET_CPU_DEFAULT TARGET_CPU_generic
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}}"
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.
156 Each subgrouping contains a string constant, that defines the
157 specification name, and a string constant that used by the GCC driver
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
165 #ifndef SUBTARGET_EXTRA_SPECS
166 #define SUBTARGET_EXTRA_SPECS
169 #ifndef SUBTARGET_CPP_SPEC
170 #define SUBTARGET_CPP_SPEC ""
173 /* Run-time Target Specification. */
174 #ifndef TARGET_VERSION
175 #define TARGET_VERSION fputs (" (ARM/generic)", stderr);
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 \
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)
198 #define TARGET_HARD_TP (target_thread_pointer == TP_CP15)
199 #define TARGET_SOFT_TP (target_thread_pointer == TP_SOFT)
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)
208 #define TARGET_THUMB1_ONLY (TARGET_THUMB1 && !arm_arch_notm)
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. */
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))
221 /* FPU supports VFPv3 instructions. */
222 #define TARGET_VFP3 (arm_fp_model == ARM_FP_MODEL_VFP \
223 && (arm_fpu_arch == FPUTYPE_VFP3D16 \
226 /* FPU supports NEON/VFP half-precision floating-point. */
227 #define TARGET_NEON_FP16 (arm_fpu_arch == FPUTYPE_NEON_FP16)
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
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))
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)
245 /* Should MOVW/MOVT be used in preference to a constant pool. */
246 #define TARGET_USE_MOVT (arm_arch_thumb2 && !optimize_size)
248 /* We could use unified syntax for arm mode, but for now we just use it
250 #define TARGET_UNIFIED_ASM TARGET_THUMB2
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. */
258 #define TARGET_BPABI false
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
265 --with-tune is ignored if -mtune or -mcpu are specified (but not affected
267 --with-float is ignored if -mhard-float, -msoft-float or -mfloat-abi are
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)}}" }, \
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)}}"},
281 /* Which floating point model to use. */
284 ARM_FP_MODEL_UNKNOWN
,
285 /* FPA model (Hardware or software). */
287 /* Cirrus Maverick floating point model. */
288 ARM_FP_MODEL_MAVERICK
,
289 /* VFP floating point model. */
293 extern enum arm_fp_model arm_fp_model
;
295 /* Which floating point hardware is available. Also update
296 fp_model_for_fpu in arm.c when adding entries to this list. */
299 /* No FP hardware. */
301 /* Full FPA support. */
303 /* Emulated FPA hardware, Issue 2 emulator (no LFM/SFM). */
305 /* Emulated FPA hardware, Issue 3 emulator. */
307 /* Cirrus Maverick floating point co-processor. */
317 /* Neon with half-precision float extensions. */
321 /* Recast the floating point class to be the floating point attribute. */
322 #define arm_fpu_attr ((enum attr_fpu) arm_fpu_tune)
324 /* What type of floating point to tune for */
325 extern enum fputype arm_fpu_tune
;
327 /* What type of floating point instructions are available */
328 extern enum fputype arm_fpu_arch
;
333 ARM_FLOAT_ABI_SOFTFP
,
337 extern enum float_abi_type arm_float_abi
;
339 #ifndef TARGET_DEFAULT_FLOAT_ABI
340 #define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
343 /* Which __fp16 format to use.
344 The enumeration values correspond to the numbering for the
345 Tag_ABI_FP_16bit_format attribute.
347 enum arm_fp16_format_type
349 ARM_FP16_FORMAT_NONE
= 0,
350 ARM_FP16_FORMAT_IEEE
= 1,
351 ARM_FP16_FORMAT_ALTERNATIVE
= 2
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)
358 /* Which ABI to use. */
368 extern enum arm_abi_type arm_abi
;
370 #ifndef ARM_DEFAULT_ABI
371 #define ARM_DEFAULT_ABI ARM_ABI_APCS
374 /* Which thread pointer access sequence to use. */
381 extern enum arm_tp_type target_thread_pointer
;
383 /* Nonzero if this chip supports the ARM Architecture 3M extensions. */
384 extern int arm_arch3m
;
386 /* Nonzero if this chip supports the ARM Architecture 4 extensions. */
387 extern int arm_arch4
;
389 /* Nonzero if this chip supports the ARM Architecture 4T extensions. */
390 extern int arm_arch4t
;
392 /* Nonzero if this chip supports the ARM Architecture 5 extensions. */
393 extern int arm_arch5
;
395 /* Nonzero if this chip supports the ARM Architecture 5E extensions. */
396 extern int arm_arch5e
;
398 /* Nonzero if this chip supports the ARM Architecture 6 extensions. */
399 extern int arm_arch6
;
401 /* Nonzero if instructions not present in the 'M' profile can be used. */
402 extern int arm_arch_notm
;
404 /* Nonzero if this chip can benefit from load scheduling. */
405 extern int arm_ld_sched
;
407 /* Nonzero if generating thumb code. */
408 extern int thumb_code
;
410 /* Nonzero if this chip is a StrongARM. */
411 extern int arm_tune_strongarm
;
413 /* Nonzero if this chip is a Cirrus variant. */
414 extern int arm_arch_cirrus
;
416 /* Nonzero if this chip supports Intel XScale with Wireless MMX technology. */
417 extern int arm_arch_iwmmxt
;
419 /* Nonzero if this chip is an XScale. */
420 extern int arm_arch_xscale
;
422 /* Nonzero if tuning for XScale. */
423 extern int arm_tune_xscale
;
425 /* Nonzero if tuning for stores via the write buffer. */
426 extern int arm_tune_wbuf
;
428 /* Nonzero if tuning for Cortex-A9. */
429 extern int arm_tune_cortex_a9
;
431 /* Nonzero if we should define __THUMB_INTERWORK__ in the
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
;
438 /* Nonzero if chip supports Thumb 2. */
439 extern int arm_arch_thumb2
;
441 /* Nonzero if chip supports integer division instruction. */
442 extern int arm_arch_hwdiv
;
444 #ifndef TARGET_DEFAULT
445 #define TARGET_DEFAULT (MASK_APCS_FRAME)
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
452 #define OVERRIDE_OPTIONS arm_override_options ()
454 #define OPTIMIZATION_OPTIONS(LEVEL,SIZE) \
455 arm_optimization_options ((LEVEL), (SIZE))
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
463 #ifndef NEED_PLT_RELOC
464 #define NEED_PLT_RELOC 0
467 /* Nonzero if we need to refer to the GOT with a PC-relative
468 offset. In other words, generate
470 .word _GLOBAL_OFFSET_TABLE_ - [. - (.Lxx + 8)]
474 .word _GLOBAL_OFFSET_TABLE_ - (.Lxx + 8)
476 The default is true, which matches NetBSD. Subtargets can
477 override this if required. */
482 /* Target machine storage Layout. */
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. */
491 /* It is far faster to zero extend chars than to sign extend them */
493 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
494 if (GET_MODE_CLASS (MODE) == MODE_INT \
495 && GET_MODE_SIZE (MODE) < 4) \
497 if (MODE == QImode) \
499 else if (MODE == HImode) \
504 #define PROMOTE_FUNCTION_MODE(MODE, UNSIGNEDP, TYPE) \
505 if (GET_MODE_CLASS (MODE) == MODE_INT \
506 && GET_MODE_SIZE (MODE) < 4) \
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
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)
519 /* Define this if most significant word of a multiword number is the lowest
521 This is always false, even when in big-endian mode. */
522 #define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN && ! TARGET_LITTLE_WORDS)
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
529 #define LIBGCC2_WORDS_BIG_ENDIAN 0
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 ())
537 #define UNITS_PER_WORD 4
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)
545 /* True if natural alignment is used for doubleword types. */
546 #define ARM_DOUBLEWORD_ALIGN TARGET_AAPCS_BASED
548 #define DOUBLEWORD_ALIGNMENT 64
550 #define PARM_BOUNDARY 32
552 #define STACK_BOUNDARY (ARM_DOUBLEWORD_ALIGN ? DOUBLEWORD_ALIGNMENT : 32)
554 #define PREFERRED_STACK_BOUNDARY \
555 (arm_abi == ARM_ABI_ATPCS ? 64 : STACK_BOUNDARY)
557 #define FUNCTION_BOUNDARY ((TARGET_THUMB && optimize_size) ? 16 : 32)
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
562 #define TARGET_PTRMEMFUNC_VBIT_LOCATION ptrmemfunc_vbit_in_delta
564 #define EMPTY_FIELD_BOUNDARY 32
566 #define BIGGEST_ALIGNMENT (ARM_DOUBLEWORD_ALIGN ? DOUBLEWORD_ALIGNMENT : 32)
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
575 /* Make strings word-aligned so strcpy from constants will be faster. */
576 #define CONSTANT_ALIGNMENT_FACTOR (TARGET_THUMB || ! arm_tune_xscale ? 1 : 2)
578 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
579 ((TREE_CODE (EXP) == STRING_CST \
581 && (ALIGN) < BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR) \
582 ? BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR : (ALIGN))
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
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))
594 /* Similarly, make sure that objects on the stack are sensibly aligned. */
595 #define LOCAL_ALIGNMENT(EXP, ALIGN) DATA_ALIGNMENT(EXP, ALIGN)
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
;
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
615 /* Nonzero if move instructions will actually fail to work
616 when given unaligned data. */
617 #define STRICT_ALIGNMENT 1
619 /* wchar_t is unsigned under the AAPCS. */
621 #define WCHAR_TYPE (TARGET_AAPCS_BASED ? "unsigned int" : "int")
623 #define WCHAR_TYPE_SIZE BITS_PER_WORD
627 #define SIZE_TYPE (TARGET_AAPCS_BASED ? "unsigned int" : "long unsigned int")
631 #define PTRDIFF_TYPE (TARGET_AAPCS_BASED ? "int" : "long int")
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
640 /* Standard register usage. */
642 /* Register allocation in ARM Procedure Call Standard (as used on RISCiX):
643 (S - saved over call).
645 r0 * argument word/integer result
648 r4-r8 S register variable
649 r9 S (rfp) register variable (real frame pointer)
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
658 f0 floating point result
659 f1-f3 floating point scratch
661 f4-f7 S floating point variable
663 cc This is NOT a real register, but is used internally
664 to represent things that use or set the condition
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.
674 *: See CONDITIONAL_REGISTER_USAGE */
677 mvf0 Cirrus floating point result
678 mvf1-mvf3 Cirrus floating point scratch
679 mvf4-mvf15 S Cirrus floating point variable. */
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
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 |]
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. */
708 /* 1 for registers that have pervasive standard uses
709 and are not available for the register allocator. */
710 #define FIXED_REGISTERS \
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 \
762 #ifndef SUBTARGET_CONDITIONAL_REGISTER_USAGE
763 #define SUBTARGET_CONDITIONAL_REGISTER_USAGE
766 #define CONDITIONAL_REGISTER_USAGE \
770 if (TARGET_SOFT_FLOAT || TARGET_THUMB1 || !TARGET_FPA) \
772 for (regno = FIRST_FPA_REGNUM; \
773 regno <= LAST_FPA_REGNUM; ++regno) \
774 fixed_regs[regno] = call_used_regs[regno] = 1; \
777 if (TARGET_THUMB && optimize_size) \
779 /* When optimizing for size, it's better not to use \
780 the HI regs, because of the overhead of stacking \
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; \
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. */ \
792 fixed_regs[LR_REGNUM] = call_used_regs[LR_REGNUM] = 1; \
794 if (TARGET_32BIT && TARGET_HARD_FLOAT) \
796 if (TARGET_MAVERICK) \
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) \
804 fixed_regs[regno] = 0; \
805 call_used_regs[regno] = regno < FIRST_CIRRUS_FP_REGNUM + 4; \
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) \
816 fixed_regs[regno] = 0; \
817 call_used_regs[regno] = regno < FIRST_VFP_REGNUM + 16 \
818 || regno >= FIRST_VFP_REGNUM + 32; \
823 if (TARGET_REALLY_IWMMXT) \
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) \
838 fixed_regs[regno] = 0; \
839 call_used_regs[regno] = regno < FIRST_IWMMXT_REGNUM + 10; \
843 if ((unsigned) PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) \
845 fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
846 call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
848 else if (TARGET_APCS_STACK) \
850 fixed_regs[10] = 1; \
851 call_used_regs[10] = 1; \
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 \
857 if (TARGET_APCS_FRAME || TARGET_CALLER_INTERWORKING \
858 || TARGET_TPCS_FRAME || TARGET_TPCS_LEAF_FRAME) \
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; \
865 SUBTARGET_CONDITIONAL_REGISTER_USAGE \
868 /* These are a couple of extensions to the formats accepted
870 %@ prints out ASM_COMMENT_START
871 %r prints out REGISTER_PREFIX reg_names[arg] */
872 #define ASM_FPRINTF_EXTENSIONS(FILE, ARGS, P) \
874 fputs (ASM_COMMENT_START, FILE); \
878 fputs (REGISTER_PREFIX, FILE); \
879 fputs (reg_names [va_arg (ARGS, int)], FILE); \
882 /* Round X up to the nearest word. */
883 #define ROUND_UP_WORD(X) (((X) + 3) & ~3)
885 /* Convert fron bytes to ints. */
886 #define ARM_NUM_INTS(X) (((X) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
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))
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))
898 /* The number of (integer) argument register available. */
899 #define NUM_ARG_REGS 4
901 /* Return the register number of the N'th (integer) argument. */
902 #define ARG_REGISTER(N) (N - 1)
904 /* Specify the registers used for certain standard purposes.
905 The values of these macros are register numbers. */
907 /* The number of the last argument register. */
908 #define LAST_ARG_REGNUM ARG_REGISTER (NUM_ARG_REGS)
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
916 #ifndef TARGET_UNWIND_INFO
917 /* We use sjlj exceptions for backwards compatibility. */
918 #define MUST_USE_SJLJ_EXCEPTIONS 1
921 /* We can generate DWARF2 Unwind info, even though we don't use it. */
922 #define DWARF2_UNWIND_INFO 1
924 /* Use r0 and r1 to pass exception handling information. */
925 #define EH_RETURN_DATA_REGNO(N) (((N) < 2) ? N : INVALID_REGNUM)
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)
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
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.
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.
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
952 #define ARM_HARD_FRAME_POINTER_REGNUM 11
953 #define THUMB_HARD_FRAME_POINTER_REGNUM 7
955 #define HARD_FRAME_POINTER_REGNUM \
957 ? ARM_HARD_FRAME_POINTER_REGNUM \
958 : THUMB_HARD_FRAME_POINTER_REGNUM)
960 #define FP_REGNUM HARD_FRAME_POINTER_REGNUM
962 /* Register to use for pushing function arguments. */
963 #define STACK_POINTER_REGNUM SP_REGNUM
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))
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))
980 /* Base register for access to local variables of the function. */
981 #define FRAME_POINTER_REGNUM 25
983 /* Base register for access to arguments of the function. */
984 #define ARG_POINTER_REGNUM 26
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))
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)
996 #define IS_VFP_REGNUM(REGNUM) \
997 (((REGNUM) >= FIRST_VFP_REGNUM) && ((REGNUM) <= LAST_VFP_REGNUM))
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
1009 #define VFP_REGNO_OK_FOR_SINGLE(REGNUM) \
1010 ((REGNUM) <= LAST_LO_VFP_REGNUM)
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)
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)
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
1024 #define NEON_REGNO_OK_FOR_NREGS(REGNUM, N) \
1025 ((((REGNUM) - FIRST_VFP_REGNUM) & 3) == 0 \
1026 && (LAST_VFP_REGNUM - (REGNUM) >= 2 * (N) - 1))
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
1034 #define DBX_REGISTER_NUMBER(REGNO) arm_dbx_register_number (REGNO)
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. */
1043 #ifndef SUBTARGET_FRAME_POINTER_REQUIRED
1044 #define SUBTARGET_FRAME_POINTER_REQUIRED 0
1047 #define FRAME_POINTER_REQUIRED \
1048 (cfun->has_nonlocal_label \
1049 || SUBTARGET_FRAME_POINTER_REQUIRED \
1050 || (TARGET_ARM && TARGET_APCS_FRAME && ! leaf_function_p ()))
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.
1057 On the ARM regs are UNITS_PER_WORD bits wide; FPA regs can hold any FP
1059 #define HARD_REGNO_NREGS(REGNO, MODE) \
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))
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))
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))
1078 #define VALID_IWMMXT_REG_MODE(MODE) \
1079 (arm_vector_mode_supported_p (MODE) || (MODE) == DImode)
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)
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)
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)
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
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
1107 #define REG_ALLOC_ORDER \
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, \
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, \
1129 /* Use different register alloc ordering for Thumb. */
1130 #define ORDER_REGS_FOR_LOCAL_ALLOC arm_order_regs_for_local_alloc ()
1132 /* Interrupt functions can only use registers that have already been
1133 saved by the prologue, even if they would normally be
1135 #define HARD_REGNO_RENAME_OK(SRC, DST) \
1136 (! IS_INTERRUPT (cfun->machine->func_type) || \
1137 df_regs_ever_live_p (DST))
1139 /* Register and constant classes. */
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. */
1166 #define N_REG_CLASSES (int) LIM_REG_CLASSES
1168 /* Give names of register classes as strings for dump file. */
1169 #define REG_CLASS_NAMES \
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 \
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 */ \
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)
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)
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
1235 #define IRA_COVER_CLASSES \
1237 GENERAL_REGS, FPA_REGS, CIRRUS_REGS, VFP_REGS, IWMMXT_GR_REGS, IWMMXT_REGS,\
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
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)) \
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)
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)
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))
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
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
1276 #define SMALL_REGISTER_CLASSES TARGET_THUMB1
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)))
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 \
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 \
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) \
1314 ? (((MODE) == HImode && ! arm_arch4 && true_regnum (X) == -1) \
1315 ? GENERAL_REGS : NO_REGS) \
1316 : THUMB_SECONDARY_OUTPUT_RELOAD_CLASS (CLASS, MODE, X))
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)) \
1332 (((CLASS) == IWMMXT_REGS || (CLASS) == IWMMXT_GR_REGS) \
1333 && CONSTANT_P (X)) \
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)))
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.
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) \
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) \
1358 HOST_WIDE_INT val = INTVAL (XEXP (X, 1)); \
1359 HOST_WIDE_INT low, high; \
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); \
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)) \
1388 /* Reload the high part into a base reg; leave the low part \
1390 X = gen_rtx_PLUS (GET_MODE (X), \
1391 gen_rtx_PLUS (GET_MODE (X), XEXP (X, 0), \
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); \
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) \
1413 rtx new_x = thumb_legitimize_reload_address (&X, MODE, OPNUM, TYPE, IND_L); \
1421 #define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_LEVELS, WIN) \
1423 ARM_LEGITIMIZE_RELOAD_ADDRESS (X, MODE, OPNUM, TYPE, IND_LEVELS, WIN); \
1425 THUMB_LEGITIMIZE_RELOAD_ADDRESS (X, MODE, OPNUM, TYPE, IND_LEVELS, WIN)
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))
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. */
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) \
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 : \
1454 ((FROM) == HI_REGS || (TO) == HI_REGS) ? 4 : 2)
1456 /* Stack layout; function entry, exit and calling. */
1458 /* Define this if pushing a word on the stack
1459 makes the stack pointer a smaller address. */
1460 #define STACK_GROWS_DOWNWARD 1
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
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.
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)
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
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) */
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
1499 /* Offset of first parameter from the argument pointer register value. */
1500 #define FIRST_PARM_OFFSET(FNDECL) (TARGET_ARM ? 4 : 0)
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.
1509 On the ARM, the caller does not pop any of its arguments that were passed
1511 #define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, SIZE) 0
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)))
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);
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))
1544 /* Amount of memory needed for an untyped call to save all possible return
1546 #define APPLY_RESULT_SIZE arm_apply_result_size()
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
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
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). */
1571 #define ARM_FT_TYPE_MASK ((1 << 3) - 1)
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. */
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)
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. */
1595 typedef struct GTY(()) arm_stack_offsets
1597 int saved_args
; /* ARG_POINTER_REGNUM. */
1598 int frame
; /* ARM_HARD_FRAME_POINTER_REGNUM. */
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
;
1607 /* A C structure for machine-specific, per-function data.
1608 This is added to the cfun structure. */
1609 typedef struct GTY(()) machine_function
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. */
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. */
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. */
1634 /* Set to 1 when a return insn is output, this means that the epilogue
1636 int return_used_this_function
;
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];
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. */
1649 /* This is the number of registers of arguments scanned so far. */
1651 /* This is the number of iWMMXt register arguments scanned so far. */
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.
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
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).
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))
1679 #define FUNCTION_ARG_PADDING(MODE, TYPE) \
1680 (arm_pad_arg_upward (MODE, TYPE) ? upward : downward)
1682 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
1683 (arm_pad_reg_upward (MODE, TYPE, FIRST) ? upward : downward)
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)
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))
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) \
1702 if (arm_vector_mode_supported_p (MODE) \
1703 && (CUM).named_count > (CUM).nargs \
1704 && TARGET_IWMMXT_ABI) \
1705 (CUM).iwmmxt_nregs += 1; \
1707 (CUM).nregs += ARM_NUM_REGS2 (MODE, TYPE)
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 \
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)))
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"
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:
1742 profile_function() in final.c outputs the .data section, FUNCTION_PROFILER
1743 will output the .text section.
1745 The ``mov ip,lr'' seems like a good idea to stick with cc convention.
1746 ``prof'' doesn't seem to mind about this!
1748 Note - this version of the code is designed to work in both ARM and
1750 #ifndef ARM_FUNCTION_PROFILER
1751 #define ARM_FUNCTION_PROFILER(STREAM, LABELNO) \
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); \
1766 #ifdef THUMB_FUNCTION_PROFILER
1767 #define FUNCTION_PROFILER(STREAM, LABELNO) \
1769 ARM_FUNCTION_PROFILER (STREAM, LABELNO) \
1771 THUMB_FUNCTION_PROFILER (STREAM, LABELNO)
1773 #define FUNCTION_PROFILER(STREAM, LABELNO) \
1774 ARM_FUNCTION_PROFILER (STREAM, LABELNO)
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.
1782 On the ARM, the function epilogue recovers the stack pointer from the
1784 #define EXIT_IGNORE_STACK 1
1786 #define EPILOGUE_USES(REGNO) ((REGNO) == LR_REGNUM)
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)
1795 /* Definitions for register eliminations.
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.
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. */
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 }}
1818 /* Given FROM and TO register numbers, say whether this elimination is
1819 allowed. Frame pointer elimination is automatically handled.
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 : \
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) \
1837 (OFFSET) = arm_compute_initial_elimination_offset (FROM, TO); \
1839 (OFFSET) = thumb_compute_initial_elimination_offset (FROM, TO)
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)
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 ()
1848 /* Output assembler code for a block containing the constant parts
1849 of a trampoline, leaving space for the variable parts.
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:
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) \
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); \
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) \
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); \
1880 #define THUMB1_TRAMPOLINE_TEMPLATE(FILE) \
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", \
1888 asm_fprintf (FILE, "\tmov\t%r, r0\n", \
1889 STATIC_CHAIN_REGNUM); \
1890 asm_fprintf (FILE, "\tldr\tr0, [%r, #8]\n", \
1892 asm_fprintf (FILE, "\tstr\tr0, [%r, #4]\n", \
1894 asm_fprintf (FILE, "\tpop\t{r0, %r}\n", \
1896 assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \
1897 assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \
1900 #define TRAMPOLINE_TEMPLATE(FILE) \
1902 ARM_TRAMPOLINE_TEMPLATE (FILE) \
1903 else if (TARGET_THUMB2) \
1904 THUMB2_TRAMPOLINE_TEMPLATE (FILE) \
1906 THUMB1_TRAMPOLINE_TEMPLATE (FILE)
1908 /* Thumb trampolines should be entered in thumb mode, so set the bottom bit
1910 #define TRAMPOLINE_ADJUST_ADDRESS(ADDR) do \
1913 (ADDR) = expand_simple_binop (Pmode, IOR, (ADDR), GEN_INT(1), \
1914 gen_reg_rtx (Pmode), 0, OPTAB_LIB_WIDEN); \
1917 /* Length in units of the trampoline for entering a nested function. */
1918 #define TRAMPOLINE_SIZE (TARGET_32BIT ? 16 : 20)
1920 /* Alignment required for a trampoline in bits. */
1921 #define TRAMPOLINE_ALIGNMENT 32
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) \
1930 emit_move_insn (gen_rtx_MEM (SImode, \
1931 plus_constant (TRAMP, \
1932 TARGET_32BIT ? 8 : 12)), \
1934 emit_move_insn (gen_rtx_MEM (SImode, \
1935 plus_constant (TRAMP, \
1936 TARGET_32BIT ? 12 : 16)), \
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); \
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
1955 /* Macros to check register numbers against specific register classes. */
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))
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))
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)))
1976 #define REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) \
1978 ? THUMB1_REGNO_MODE_OK_FOR_BASE_P (REGNO, MODE) \
1979 : ARM_REGNO_OK_FOR_BASE_P (REGNO))
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)
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))
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
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))))
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
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
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.
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
2020 When generating pic allow anything. */
2021 #define ARM_LEGITIMATE_CONSTANT_P(X) (flag_pic || ! label_mentioned_p (X))
2023 #define THUMB_LEGITIMATE_CONSTANT_P(X) \
2024 ( GET_CODE (X) == CONST_INT \
2025 || GET_CODE (X) == CONST_DOUBLE \
2026 || CONSTANT_ADDRESS_P (X) \
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)))
2034 #ifndef SUBTARGET_NAME_ENCODING_LENGTHS
2035 #define SUBTARGET_NAME_ENCODING_LENGTHS
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
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)
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);
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"
2063 #ifndef ARM_EABI_DTORS_SECTION_OP
2064 #define ARM_EABI_DTORS_SECTION_OP \
2065 "\t.section\t.fini_array,\"aw\",%fini_array"
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"
2072 /* Define CTORS_SECTION_ASM_OP. */
2073 #undef CTORS_SECTION_ASM_OP
2074 #undef DTORS_SECTION_ASM_OP
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) */
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
2109 #define ARM_OUTPUT_FN_UNWIND(F, PROLOGUE) arm_output_fn_unwind (F, PROLOGUE)
2111 #ifdef TARGET_UNWIND_INFO
2112 #define ARM_EABI_UNWIND_TABLES \
2113 ((!USING_SJLJ_EXCEPTIONS && flag_exceptions) || flag_unwind_tables)
2115 #define ARM_EABI_UNWIND_TABLES 0
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
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)
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)
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)))
2148 #define REG_STRICT_P 0
2150 #else /* REG_OK_STRICT */
2152 #define ARM_REG_OK_FOR_BASE_P(X) \
2153 ARM_REGNO_OK_FOR_BASE_P (REGNO (X))
2155 #define ARM_REG_OK_FOR_INDEX_P(X) \
2156 ARM_REGNO_OK_FOR_INDEX_P (REGNO (X))
2158 #define THUMB1_REG_MODE_OK_FOR_BASE_P(X, MODE) \
2159 THUMB1_REGNO_MODE_OK_FOR_BASE_P (REGNO (X), MODE)
2161 #define REG_STRICT_P 1
2163 #endif /* REG_OK_STRICT */
2165 /* Now define some helpers in terms of the above. */
2167 #define REG_MODE_OK_FOR_BASE_P(X, MODE) \
2169 ? THUMB1_REG_MODE_OK_FOR_BASE_P (X, MODE) \
2170 : ARM_REG_OK_FOR_BASE_P (X))
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)
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
2180 #define REG_OK_FOR_INDEX_P(X) \
2182 ? THUMB1_REG_OK_FOR_INDEX_P (X) \
2183 : ARM_REG_OK_FOR_INDEX_P (X))
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)
2190 #define ARM_BASE_REGISTER_RTX_P(X) \
2191 (GET_CODE (X) == REG && ARM_REG_OK_FOR_BASE_P (X))
2193 #define ARM_INDEX_REGISTER_RTX_P(X) \
2194 (GET_CODE (X) == REG && ARM_REG_OK_FOR_INDEX_P (X))
2196 /* Define this for compatibility reasons. */
2197 #define HANDLE_PRAGMA_PACK_PUSH_POP
2199 /* Specify the machine mode that this machine uses
2200 for the index in the tablejump instruction. */
2201 #define CASE_VECTOR_MODE Pmode
2203 #define CASE_VECTOR_PC_RELATIVE (TARGET_THUMB2 \
2205 && (optimize_size || flag_pic)))
2207 #define CASE_VECTOR_SHORTEN_MODE(min, max, body) \
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) \
2218 : ((min < 0 || max >= 0x2000 || !TARGET_THUMB2) ? SImode \
2219 : (max >= 0x200) ? HImode \
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
2228 /* Max number of bytes we can move from memory to memory
2229 in one reasonably fast instruction. */
2233 #define MOVE_RATIO(speed) (arm_tune_xscale ? 4 : 2)
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
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)))
2248 /* Nonzero if access to memory by bytes is slow and undesirable. */
2249 #define SLOW_BYTE_ACCESS 0
2251 #define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) 1
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 */
2264 /* All integers have the same format so truncation is easy. */
2265 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
2267 /* Calling from registers is a massive pain. */
2268 #define NO_FUNCTION_CSE 1
2270 /* The machine modes of pointers and functions */
2271 #define Pmode SImode
2272 #define FUNCTION_MODE Pmode
2274 #define ARM_FRAME_RTX(X) \
2275 ( (X) == frame_pointer_rtx || (X) == stack_pointer_rtx \
2276 || (X) == arg_pointer_rtx)
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)))
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))
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
;
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
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))
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
2314 extern int making_const_table
;
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(); \
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. */
2329 #define SELECT_CC_MODE(OP, X, Y) arm_select_cc_mode (OP, X, Y)
2331 #define REVERSIBLE_CC_MODE(MODE) 1
2333 #define REVERSE_CONDITION(CODE,MODE) \
2334 (((MODE) == CCFPmode || (MODE) == CCFPEmode) \
2335 ? reverse_condition_maybe_unordered (code) \
2336 : reverse_condition (code))
2338 #define CANONICALIZE_COMPARISON(CODE, OP0, OP1) \
2341 if (GET_CODE (OP1) == CONST_INT \
2342 && ! (const_ok_for_arm (INTVAL (OP1)) \
2343 || (const_ok_for_arm (- INTVAL (OP1))))) \
2345 rtx const_op = OP1; \
2346 CODE = arm_canonicalize_comparison ((CODE), GET_MODE (OP0), \
2353 /* The arm5 clz instruction returns 32. */
2354 #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 32, 1)
2357 #define ASM_APP_OFF (TARGET_THUMB1 ? "\t.code\t16\n" : \
2358 TARGET_THUMB2 ? "\t.thumb\n" : "")
2360 /* Output a push or a pop instruction (only used when profiling). */
2361 #define ASM_OUTPUT_REG_PUSH(STREAM, REGNO) \
2365 asm_fprintf (STREAM,"\tstmfd\t%r!,{%r}\n", \
2366 STACK_POINTER_REGNUM, REGNO); \
2368 asm_fprintf (STREAM, "\tpush {%r}\n", REGNO); \
2372 #define ASM_OUTPUT_REG_POP(STREAM, REGNO) \
2376 asm_fprintf (STREAM, "\tldmfd\t%r!,{%r}\n", \
2377 STACK_POINTER_REGNUM, REGNO); \
2379 asm_fprintf (STREAM, "\tpop {%r}\n", REGNO); \
2382 /* Jump table alignment is explicit in ASM_OUTPUT_CASE_LABEL. */
2383 #define ADDR_VEC_ALIGN(JUMPTABLE) 0
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) \
2391 if (TARGET_THUMB && GET_MODE (PATTERN (JUMPTABLE)) == SImode) \
2392 ASM_OUTPUT_ALIGN (FILE, 2); \
2393 (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); \
2397 /* Make sure subsequent insns are aligned after a TBB. */
2398 #define ASM_OUTPUT_CASE_END(FILE, NUM, JUMPTABLE) \
2401 if (GET_MODE (PATTERN (JUMPTABLE)) == QImode) \
2402 ASM_OUTPUT_ALIGN (FILE, 1); \
2406 #define ARM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
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") ; \
2418 fprintf (STREAM, "\t.thumb\n\t.thumb_func\n") ; \
2420 if (TARGET_POKE_FUNCTION_NAME) \
2421 arm_poke_function_name (STREAM, (const char *) NAME); \
2425 /* For aliases of functions we use .thumb_set instead. */
2426 #define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL1, DECL2) \
2429 const char *const LABEL1 = XSTR (XEXP (DECL_RTL (decl), 0), 0); \
2430 const char *const LABEL2 = IDENTIFIER_POINTER (DECL2); \
2432 if (TARGET_THUMB && TREE_CODE (DECL1) == FUNCTION_DECL) \
2434 fprintf (FILE, "\t.thumb_set "); \
2435 assemble_name (FILE, LABEL1); \
2436 fprintf (FILE, ","); \
2437 assemble_name (FILE, LABEL2); \
2438 fprintf (FILE, "\n"); \
2441 ASM_OUTPUT_DEF (FILE, LABEL1, LABEL2); \
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) \
2452 if ((MAX_SKIP) == 0) \
2453 fprintf ((FILE), "\t.p2align %d\n", (int) (LOG)); \
2455 fprintf ((FILE), "\t.p2align %d,,%d\n", \
2456 (int) (LOG), (int) (MAX_SKIP)); \
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) \
2466 /* Only perform branch elimination (by making instructions conditional) if
2467 we're optimizing. For Thumb-2 check if any IT instructions need
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)
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 == '_')))
2484 /* Output an operand of an instruction. */
2485 #define PRINT_OPERAND(STREAM, X, CODE) \
2486 arm_print_operand (STREAM, X, CODE)
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) \
2496 /* Output the address of an operand. */
2497 #define ARM_PRINT_OPERAND_ADDRESS(STREAM, X) \
2499 int is_minus = GET_CODE (X) == MINUS; \
2501 if (GET_CODE (X) == REG) \
2502 asm_fprintf (STREAM, "[%r, #0]", REGNO (X)); \
2503 else if (GET_CODE (X) == PLUS || is_minus) \
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)) \
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. */ \
2518 switch (GET_CODE (index)) \
2521 offset = INTVAL (index); \
2524 asm_fprintf (STREAM, "[%r, #%wd]", \
2525 REGNO (base), offset); \
2529 asm_fprintf (STREAM, "[%r, %s%r]", \
2530 REGNO (base), is_minus ? "-" : "", \
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); \
2549 gcc_unreachable (); \
2552 else if (GET_CODE (X) == PRE_INC || GET_CODE (X) == POST_INC \
2553 || GET_CODE (X) == PRE_DEC || GET_CODE (X) == POST_DEC) \
2555 extern enum machine_mode output_memory_reference_mode; \
2557 gcc_assert (GET_CODE (XEXP (X, 0)) == REG); \
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)); \
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)); \
2570 else if (GET_CODE (X) == PRE_MODIFY) \
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))); \
2577 asm_fprintf (STREAM, "%r]!", \
2578 REGNO (XEXP (XEXP (X, 1), 1))); \
2580 else if (GET_CODE (X) == POST_MODIFY) \
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))); \
2587 asm_fprintf (STREAM, "%r", \
2588 REGNO (XEXP (XEXP (X, 1), 1))); \
2590 else output_addr_const (STREAM, X); \
2593 #define THUMB_PRINT_OPERAND_ADDRESS(STREAM, X) \
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) \
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))); \
2607 asm_fprintf (STREAM, "[%r, %r]", \
2608 REGNO (XEXP (X, 0)), \
2609 REGNO (XEXP (X, 1))); \
2612 output_addr_const (STREAM, X); \
2615 #define PRINT_OPERAND_ADDRESS(STREAM, X) \
2617 ARM_PRINT_OPERAND_ADDRESS (STREAM, X) \
2619 THUMB_PRINT_OPERAND_ADDRESS (STREAM, X)
2621 #define OUTPUT_ADDR_CONST_EXTRA(file, x, fail) \
2622 if (arm_output_addr_const_extra (file, x) == FALSE) \
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. */
2628 #define RETURN_ADDR_RTX(COUNT, FRAME) \
2629 arm_return_addr (COUNT, FRAME)
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)
2635 /* Pick up the return address upon entry to a procedure. Used for
2636 dwarf2 unwind information. This also enables the table driven
2638 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LR_REGNUM)
2639 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (LR_REGNUM)
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 ())
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).
2663 ARM_BUILTIN_WAVG2BR
,
2664 ARM_BUILTIN_WAVG2HR
,
2691 ARM_BUILTIN_TMOVMSKB
,
2692 ARM_BUILTIN_TMOVMSKH
,
2693 ARM_BUILTIN_TMOVMSKW
,
2702 ARM_BUILTIN_WPACKHSS
,
2703 ARM_BUILTIN_WPACKWSS
,
2704 ARM_BUILTIN_WPACKDSS
,
2705 ARM_BUILTIN_WPACKHUS
,
2706 ARM_BUILTIN_WPACKWUS
,
2707 ARM_BUILTIN_WPACKDUS
,
2712 ARM_BUILTIN_WADDSSB
,
2713 ARM_BUILTIN_WADDSSH
,
2714 ARM_BUILTIN_WADDSSW
,
2715 ARM_BUILTIN_WADDUSB
,
2716 ARM_BUILTIN_WADDUSH
,
2717 ARM_BUILTIN_WADDUSW
,
2721 ARM_BUILTIN_WSUBSSB
,
2722 ARM_BUILTIN_WSUBSSH
,
2723 ARM_BUILTIN_WSUBSSW
,
2724 ARM_BUILTIN_WSUBUSB
,
2725 ARM_BUILTIN_WSUBUSH
,
2726 ARM_BUILTIN_WSUBUSW
,
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
,
2743 ARM_BUILTIN_TEXTRMSB
,
2744 ARM_BUILTIN_TEXTRMSH
,
2745 ARM_BUILTIN_TEXTRMSW
,
2746 ARM_BUILTIN_TEXTRMUB
,
2747 ARM_BUILTIN_TEXTRMUH
,
2748 ARM_BUILTIN_TEXTRMUW
,
2798 ARM_BUILTIN_WUNPCKIHB
,
2799 ARM_BUILTIN_WUNPCKIHH
,
2800 ARM_BUILTIN_WUNPCKIHW
,
2801 ARM_BUILTIN_WUNPCKILB
,
2802 ARM_BUILTIN_WUNPCKILH
,
2803 ARM_BUILTIN_WUNPCKILW
,
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
,
2818 ARM_BUILTIN_THREAD_POINTER
,
2820 ARM_BUILTIN_NEON_BASE
,
2822 ARM_BUILTIN_MAX
= ARM_BUILTIN_NEON_BASE
/* FIXME: Wrong! */
2825 /* Do not emit .note.GNU-stack by default. */
2826 #ifndef NEED_INDICATE_EXEC_STACK
2827 #define NEED_INDICATE_EXEC_STACK 0
2830 #endif /* ! GCC_ARM_H */