]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/arm/arm.h
jvm.h (MAYBE_UNUSED): New macro tp mark probably unused arguments.
[thirdparty/gcc.git] / gcc / config / arm / arm.h
CommitLineData
f5a1b0d2 1/* Definitions of target machine for GNU compiler, for ARM.
cf011243 2 Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
f9ba5949 3 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
35d965d5 4 Contributed by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl)
8b109b37 5 and Martin Simmons (@harleqn.co.uk).
949d79eb 6 More major hacks by Richard Earnshaw (rearnsha@arm.com)
6cfc7210
NC
7 Minor hacks by Nick Clifton (nickc@cygnus.com)
8
4f448245 9 This file is part of GCC.
35d965d5 10
4f448245
NC
11 GCC is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published
13 by the Free Software Foundation; either version 2, or (at your
14 option) any later version.
35d965d5 15
4f448245
NC
16 GCC is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 License for more details.
35d965d5 20
4f448245
NC
21 You should have received a copy of the GNU General Public License
22 along with GCC; see the file COPYING. If not, write to
23 the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
24 MA 02111-1307, USA. */
35d965d5 25
88657302
RH
26#ifndef GCC_ARM_H
27#define GCC_ARM_H
b355a481 28
e6471be6
NB
29/* Target CPU builtins. */
30#define TARGET_CPU_CPP_BUILTINS() \
31 do \
32 { \
48f6efae 33 if (TARGET_ARM) \
e6471be6
NB
34 builtin_define ("__arm__"); \
35 else \
36 builtin_define ("__thumb__"); \
37 \
38 if (TARGET_BIG_END) \
39 { \
40 builtin_define ("__ARMEB__"); \
41 if (TARGET_THUMB) \
42 builtin_define ("__THUMBEB__"); \
43 if (TARGET_LITTLE_WORDS) \
44 builtin_define ("__ARMWEL__"); \
45 } \
46 else \
47 { \
48 builtin_define ("__ARMEL__"); \
49 if (TARGET_THUMB) \
50 builtin_define ("__THUMBEL__"); \
51 } \
52 \
53 if (TARGET_APCS_32) \
54 builtin_define ("__APCS_32__"); \
55 else \
56 builtin_define ("__APCS_26__"); \
57 \
58 if (TARGET_SOFT_FLOAT) \
59 builtin_define ("__SOFTFP__"); \
60 \
b5b620a4
JT
61 /* FIXME: TARGET_HARD_FLOAT currently implies \
62 FPA. */ \
63 if (TARGET_VFP && !TARGET_HARD_FLOAT) \
64 builtin_define ("__VFP_FP__"); \
65 \
e6471be6
NB
66 /* Add a define for interworking. \
67 Needed when building libgcc.a. */ \
68 if (TARGET_INTERWORK) \
69 builtin_define ("__THUMB_INTERWORK__"); \
70 \
71 builtin_assert ("cpu=arm"); \
72 builtin_assert ("machine=arm"); \
73 } while (0)
74
7a801826
RE
75#define TARGET_CPU_arm2 0x0000
76#define TARGET_CPU_arm250 0x0000
77#define TARGET_CPU_arm3 0x0000
78#define TARGET_CPU_arm6 0x0001
79#define TARGET_CPU_arm600 0x0001
80#define TARGET_CPU_arm610 0x0002
81#define TARGET_CPU_arm7 0x0001
82#define TARGET_CPU_arm7m 0x0004
83#define TARGET_CPU_arm7dm 0x0004
84#define TARGET_CPU_arm7dmi 0x0004
85#define TARGET_CPU_arm700 0x0001
86#define TARGET_CPU_arm710 0x0002
87#define TARGET_CPU_arm7100 0x0002
88#define TARGET_CPU_arm7500 0x0002
89#define TARGET_CPU_arm7500fe 0x1001
90#define TARGET_CPU_arm7tdmi 0x0008
91#define TARGET_CPU_arm8 0x0010
92#define TARGET_CPU_arm810 0x0020
93#define TARGET_CPU_strongarm 0x0040
94#define TARGET_CPU_strongarm110 0x0040
f5a1b0d2 95#define TARGET_CPU_strongarm1100 0x0040
b36ba79f
RE
96#define TARGET_CPU_arm9 0x0080
97#define TARGET_CPU_arm9tdmi 0x0080
d19fb8e3 98#define TARGET_CPU_xscale 0x0100
9b6b54e2 99#define TARGET_CPU_ep9312 0x0200
5a9335ef 100#define TARGET_CPU_iwmmxt 0x0400
81f9037c
MM
101#define TARGET_CPU_arm926ej_s 0x0800
102#define TARGET_CPU_arm1026ej_s 0x1000
103#define TARGET_CPU_arm1136j_s 0x2000
104#define TARGET_CPU_arm1136jf_s 0x4000
82e9d970 105/* Configure didn't specify. */
7a801826 106#define TARGET_CPU_generic 0x8000
ff9940b0 107
d5b7b3ae 108typedef enum arm_cond_code
89c7ca52
RE
109{
110 ARM_EQ = 0, ARM_NE, ARM_CS, ARM_CC, ARM_MI, ARM_PL, ARM_VS, ARM_VC,
111 ARM_HI, ARM_LS, ARM_GE, ARM_LT, ARM_GT, ARM_LE, ARM_AL, ARM_NV
d5b7b3ae
RE
112}
113arm_cc;
6cfc7210 114
d5b7b3ae 115extern arm_cc arm_current_cc;
ff9940b0 116
d5b7b3ae 117#define ARM_INVERSE_CONDITION_CODE(X) ((arm_cc) (((int)X) ^ 1))
89c7ca52 118
6cfc7210
NC
119extern int arm_target_label;
120extern int arm_ccfsm_state;
e2500fed 121extern GTY(()) rtx arm_target_insn;
6cfc7210
NC
122/* Run-time compilation parameters selecting different hardware subsets. */
123extern int target_flags;
124/* The floating point instruction architecture, can be 2 or 3 */
125extern const char * target_fp_name;
d5b7b3ae 126/* Define the information needed to generate branch insns. This is
e2500fed
GK
127 stored from the compare operation. */
128extern GTY(()) rtx arm_compare_op0;
129extern GTY(()) rtx arm_compare_op1;
d5b7b3ae 130/* The label of the current constant pool. */
e2500fed 131extern rtx pool_vector_label;
d5b7b3ae 132/* Set to 1 when a return insn is output, this means that the epilogue
d6b4baa4 133 is not needed. */
d5b7b3ae 134extern int return_used_this_function;
e2500fed
GK
135/* Used to produce AOF syntax assembler. */
136extern GTY(()) rtx aof_pic_label;
35d965d5 137\f
d6b4baa4 138/* Just in case configure has failed to define anything. */
7a801826
RE
139#ifndef TARGET_CPU_DEFAULT
140#define TARGET_CPU_DEFAULT TARGET_CPU_generic
141#endif
142
143/* If the configuration file doesn't specify the cpu, the subtarget may
70f24e49 144 override it. If it doesn't, then default to an ARM6. */
7a801826
RE
145#if TARGET_CPU_DEFAULT == TARGET_CPU_generic
146#undef TARGET_CPU_DEFAULT
70f24e49 147
7a801826
RE
148#ifdef SUBTARGET_CPU_DEFAULT
149#define TARGET_CPU_DEFAULT SUBTARGET_CPU_DEFAULT
150#else
151#define TARGET_CPU_DEFAULT TARGET_CPU_arm6
152#endif
153#endif
154
155#if TARGET_CPU_DEFAULT == TARGET_CPU_arm2
156#define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_2__"
157#else
18543a22 158#if TARGET_CPU_DEFAULT == TARGET_CPU_arm6 || TARGET_CPU_DEFAULT == TARGET_CPU_arm610 || TARGET_CPU_DEFAULT == TARGET_CPU_arm7500fe
7a801826
RE
159#define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_3__"
160#else
161#if TARGET_CPU_DEFAULT == TARGET_CPU_arm7m
162#define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_3M__"
163#else
70f24e49 164#if TARGET_CPU_DEFAULT == TARGET_CPU_arm7tdmi || TARGET_CPU_DEFAULT == TARGET_CPU_arm9 || TARGET_CPU_DEFAULT == TARGET_CPU_arm9tdmi
7a801826
RE
165#define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_4T__"
166#else
dc60a41b 167#if TARGET_CPU_DEFAULT == TARGET_CPU_arm8 || TARGET_CPU_DEFAULT == TARGET_CPU_arm810 || TARGET_CPU_DEFAULT == TARGET_CPU_strongarm || TARGET_CPU_DEFAULT == TARGET_CPU_strongarm110 || TARGET_CPU_DEFAULT == TARGET_CPU_strongarm1100
7a801826
RE
168#define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_4__"
169#else
d19fb8e3
NC
170#if TARGET_CPU_DEFAULT == TARGET_CPU_xscale
171#define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_5TE__ -D__XSCALE__"
172#else
9b6b54e2
NC
173#if TARGET_CPU_DEFAULT == TARGET_CPU_ep9312
174#define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_4T__ -D__MAVERICK__"
175/* Set TARGET_DEFAULT to the default, but without soft-float. */
176#ifdef TARGET_DEFAULT
177#undef TARGET_DEFAULT
178#define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_APCS_FRAME)
de1f0668
NC
179#endif
180#else
877bcd2d
NC
181#if TARGET_CPU_DEFAULT == TARGET_CPU_iwmmxt
182#define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_5TE__ -D__XSCALE__ -D__IWMMXT__"
9b6b54e2 183#else
877bcd2d
NC
184#error Unrecognized value in TARGET_CPU_DEFAULT.
185#endif
7a801826
RE
186#endif
187#endif
188#endif
189#endif
190#endif
d19fb8e3 191#endif
9b6b54e2 192#endif
7a801826 193
5742588d 194#undef CPP_SPEC
e6471be6
NB
195#define CPP_SPEC "%(cpp_cpu_arch) %(subtarget_cpp_spec) \
196%{mapcs-32:%{mapcs-26: \
197 %e-mapcs-26 and -mapcs-32 may not be used together}} \
198%{msoft-float:%{mhard-float: \
199 %e-msoft-float and -mhard_float may not be used together}} \
200%{mbig-endian:%{mlittle-endian: \
201 %e-mbig-endian and -mlittle-endian may not be used together}}"
7a801826 202
71791e16
RE
203/* Set the architecture define -- if -march= is set, then it overrides
204 the -mcpu= setting. */
7a801826 205#define CPP_CPU_ARCH_SPEC "\
71791e16
RE
206%{march=arm2:-D__ARM_ARCH_2__} \
207%{march=arm250:-D__ARM_ARCH_2__} \
208%{march=arm3:-D__ARM_ARCH_2__} \
209%{march=arm6:-D__ARM_ARCH_3__} \
210%{march=arm600:-D__ARM_ARCH_3__} \
211%{march=arm610:-D__ARM_ARCH_3__} \
212%{march=arm7:-D__ARM_ARCH_3__} \
213%{march=arm700:-D__ARM_ARCH_3__} \
214%{march=arm710:-D__ARM_ARCH_3__} \
a120a3bd 215%{march=arm720:-D__ARM_ARCH_3__} \
71791e16
RE
216%{march=arm7100:-D__ARM_ARCH_3__} \
217%{march=arm7500:-D__ARM_ARCH_3__} \
218%{march=arm7500fe:-D__ARM_ARCH_3__} \
219%{march=arm7m:-D__ARM_ARCH_3M__} \
220%{march=arm7dm:-D__ARM_ARCH_3M__} \
221%{march=arm7dmi:-D__ARM_ARCH_3M__} \
222%{march=arm7tdmi:-D__ARM_ARCH_4T__} \
223%{march=arm8:-D__ARM_ARCH_4__} \
224%{march=arm810:-D__ARM_ARCH_4__} \
b36ba79f 225%{march=arm9:-D__ARM_ARCH_4T__} \
60d0536b
NC
226%{march=arm920:-D__ARM_ARCH_4__} \
227%{march=arm920t:-D__ARM_ARCH_4T__} \
b36ba79f 228%{march=arm9tdmi:-D__ARM_ARCH_4T__} \
71791e16
RE
229%{march=strongarm:-D__ARM_ARCH_4__} \
230%{march=strongarm110:-D__ARM_ARCH_4__} \
f5a1b0d2 231%{march=strongarm1100:-D__ARM_ARCH_4__} \
d19fb8e3
NC
232%{march=xscale:-D__ARM_ARCH_5TE__} \
233%{march=xscale:-D__XSCALE__} \
9b6b54e2
NC
234%{march=ep9312:-D__ARM_ARCH_4T__} \
235%{march=ep9312:-D__MAVERICK__} \
71791e16
RE
236%{march=armv2:-D__ARM_ARCH_2__} \
237%{march=armv2a:-D__ARM_ARCH_2__} \
238%{march=armv3:-D__ARM_ARCH_3__} \
239%{march=armv3m:-D__ARM_ARCH_3M__} \
240%{march=armv4:-D__ARM_ARCH_4__} \
241%{march=armv4t:-D__ARM_ARCH_4T__} \
62b10bbc 242%{march=armv5:-D__ARM_ARCH_5__} \
d5b7b3ae
RE
243%{march=armv5t:-D__ARM_ARCH_5T__} \
244%{march=armv5e:-D__ARM_ARCH_5E__} \
245%{march=armv5te:-D__ARM_ARCH_5TE__} \
71791e16
RE
246%{!march=*: \
247 %{mcpu=arm2:-D__ARM_ARCH_2__} \
248 %{mcpu=arm250:-D__ARM_ARCH_2__} \
249 %{mcpu=arm3:-D__ARM_ARCH_2__} \
250 %{mcpu=arm6:-D__ARM_ARCH_3__} \
251 %{mcpu=arm600:-D__ARM_ARCH_3__} \
252 %{mcpu=arm610:-D__ARM_ARCH_3__} \
253 %{mcpu=arm7:-D__ARM_ARCH_3__} \
254 %{mcpu=arm700:-D__ARM_ARCH_3__} \
255 %{mcpu=arm710:-D__ARM_ARCH_3__} \
a120a3bd 256 %{mcpu=arm720:-D__ARM_ARCH_3__} \
71791e16
RE
257 %{mcpu=arm7100:-D__ARM_ARCH_3__} \
258 %{mcpu=arm7500:-D__ARM_ARCH_3__} \
259 %{mcpu=arm7500fe:-D__ARM_ARCH_3__} \
260 %{mcpu=arm7m:-D__ARM_ARCH_3M__} \
261 %{mcpu=arm7dm:-D__ARM_ARCH_3M__} \
262 %{mcpu=arm7dmi:-D__ARM_ARCH_3M__} \
263 %{mcpu=arm7tdmi:-D__ARM_ARCH_4T__} \
264 %{mcpu=arm8:-D__ARM_ARCH_4__} \
265 %{mcpu=arm810:-D__ARM_ARCH_4__} \
b36ba79f 266 %{mcpu=arm9:-D__ARM_ARCH_4T__} \
60d0536b
NC
267 %{mcpu=arm920:-D__ARM_ARCH_4__} \
268 %{mcpu=arm920t:-D__ARM_ARCH_4T__} \
b36ba79f 269 %{mcpu=arm9tdmi:-D__ARM_ARCH_4T__} \
71791e16
RE
270 %{mcpu=strongarm:-D__ARM_ARCH_4__} \
271 %{mcpu=strongarm110:-D__ARM_ARCH_4__} \
f5a1b0d2 272 %{mcpu=strongarm1100:-D__ARM_ARCH_4__} \
d19fb8e3
NC
273 %{mcpu=xscale:-D__ARM_ARCH_5TE__} \
274 %{mcpu=xscale:-D__XSCALE__} \
9b6b54e2
NC
275 %{mcpu=ep9312:-D__ARM_ARCH_4T__} \
276 %{mcpu=ep9312:-D__MAVERICK__} \
5a9335ef
NC
277 %{mcpu=iwmmxt:-D__ARM_ARCH_5TE__} \
278 %{mcpu=iwmmxt:-D__XSCALE__} \
279 %{mcpu=iwmmxt:-D__IWMMXT__} \
dfa08768 280 %{!mcpu*:%(cpp_cpu_arch_default)}} \
11c1a207 281"
7a801826 282
be393ecf 283#ifndef CC1_SPEC
dfa08768 284#define CC1_SPEC ""
be393ecf 285#endif
7a801826
RE
286
287/* This macro defines names of additional specifications to put in the specs
288 that can be used in various specifications like CC1_SPEC. Its definition
289 is an initializer with a subgrouping for each command option.
290
291 Each subgrouping contains a string constant, that defines the
4f448245 292 specification name, and a string constant that used by the GCC driver
7a801826
RE
293 program.
294
295 Do not define this macro if it does not need to do anything. */
296#define EXTRA_SPECS \
297 { "cpp_cpu_arch", CPP_CPU_ARCH_SPEC }, \
298 { "cpp_cpu_arch_default", CPP_ARCH_DEFAULT_SPEC }, \
38fc909b 299 { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC }, \
7a801826
RE
300 SUBTARGET_EXTRA_SPECS
301
914a3b8c 302#ifndef SUBTARGET_EXTRA_SPECS
7a801826 303#define SUBTARGET_EXTRA_SPECS
914a3b8c
DM
304#endif
305
6cfc7210 306#ifndef SUBTARGET_CPP_SPEC
38fc909b 307#define SUBTARGET_CPP_SPEC ""
6cfc7210 308#endif
35d965d5
RS
309\f
310/* Run-time Target Specification. */
ff9940b0 311#ifndef TARGET_VERSION
6cfc7210 312#define TARGET_VERSION fputs (" (ARM/generic)", stderr);
ff9940b0 313#endif
35d965d5 314
35d965d5
RS
315/* Nonzero if the function prologue (and epilogue) should obey
316 the ARM Procedure Call Standard. */
6cfc7210 317#define ARM_FLAG_APCS_FRAME (1 << 0)
35d965d5
RS
318
319/* Nonzero if the function prologue should output the function name to enable
320 the post mortem debugger to print a backtrace (very useful on RISCOS,
11c1a207
RE
321 unused on RISCiX). Specifying this flag also enables
322 -fno-omit-frame-pointer.
35d965d5 323 XXX Must still be implemented in the prologue. */
6cfc7210 324#define ARM_FLAG_POKE (1 << 1)
35d965d5
RS
325
326/* Nonzero if floating point instructions are emulated by the FPE, in which
327 case instruction scheduling becomes very uninteresting. */
6cfc7210 328#define ARM_FLAG_FPE (1 << 2)
35d965d5 329
11c1a207
RE
330/* Nonzero if destined for a processor in 32-bit program mode. Takes out bit
331 that assume restoration of the condition flags when returning from a
332 branch and link (ie a function). */
6cfc7210 333#define ARM_FLAG_APCS_32 (1 << 3)
11c1a207 334
dfa08768
RE
335/* FLAGS 0x0008 and 0x0010 are now spare (used to be arm3/6 selection). */
336
11c1a207
RE
337/* Nonzero if stack checking should be performed on entry to each function
338 which allocates temporary variables on the stack. */
6cfc7210 339#define ARM_FLAG_APCS_STACK (1 << 4)
11c1a207
RE
340
341/* Nonzero if floating point parameters should be passed to functions in
342 floating point registers. */
6cfc7210 343#define ARM_FLAG_APCS_FLOAT (1 << 5)
11c1a207
RE
344
345/* Nonzero if re-entrant, position independent code should be generated.
346 This is equivalent to -fpic. */
6cfc7210 347#define ARM_FLAG_APCS_REENT (1 << 6)
11c1a207 348
5f1e6755
NC
349/* Nonzero if the MMU will trap unaligned word accesses, so shorts must
350 be loaded using either LDRH or LDRB instructions. */
351#define ARM_FLAG_MMU_TRAPS (1 << 7)
11c1a207
RE
352
353/* Nonzero if all floating point instructions are missing (and there is no
354 emulator either). Generate function calls for all ops in this case. */
6cfc7210 355#define ARM_FLAG_SOFT_FLOAT (1 << 8)
11c1a207
RE
356
357/* Nonzero if we should compile with BYTES_BIG_ENDIAN set to 1. */
6cfc7210 358#define ARM_FLAG_BIG_END (1 << 9)
11c1a207
RE
359
360/* Nonzero if we should compile for Thumb interworking. */
6cfc7210 361#define ARM_FLAG_INTERWORK (1 << 10)
11c1a207 362
ddee6aba
RE
363/* Nonzero if we should have little-endian words even when compiling for
364 big-endian (for backwards compatibility with older versions of GCC). */
6cfc7210 365#define ARM_FLAG_LITTLE_WORDS (1 << 11)
ddee6aba 366
f5a1b0d2 367/* Nonzero if we need to protect the prolog from scheduling */
6cfc7210 368#define ARM_FLAG_NO_SCHED_PRO (1 << 12)
f5a1b0d2 369
c11145f6 370/* Nonzero if a call to abort should be generated if a noreturn
dd18ae56 371 function tries to return. */
6cfc7210 372#define ARM_FLAG_ABORT_NORETURN (1 << 13)
c11145f6 373
d6b4baa4 374/* Nonzero if function prologues should not load the PIC register. */
dd18ae56 375#define ARM_FLAG_SINGLE_PIC_BASE (1 << 14)
ed0e6530 376
b020fd92
NC
377/* Nonzero if all call instructions should be indirect. */
378#define ARM_FLAG_LONG_CALLS (1 << 15)
d5b7b3ae
RE
379
380/* Nonzero means that the target ISA is the THUMB, not the ARM. */
381#define ARM_FLAG_THUMB (1 << 16)
382
383/* Set if a TPCS style stack frame should be generated, for non-leaf
384 functions, even if they do not need one. */
385#define THUMB_FLAG_BACKTRACE (1 << 17)
b020fd92 386
d5b7b3ae
RE
387/* Set if a TPCS style stack frame should be generated, for leaf
388 functions, even if they do not need one. */
389#define THUMB_FLAG_LEAF_BACKTRACE (1 << 18)
390
391/* Set if externally visible functions should assume that they
392 might be called in ARM mode, from a non-thumb aware code. */
393#define THUMB_FLAG_CALLEE_SUPER_INTERWORKING (1 << 19)
394
395/* Set if calls via function pointers should assume that their
396 destination is non-Thumb aware. */
397#define THUMB_FLAG_CALLER_SUPER_INTERWORKING (1 << 20)
398
b5b620a4
JT
399/* Nonzero means target uses VFP FP. */
400#define ARM_FLAG_VFP (1 << 21)
401
dc0ba55a
JT
402/* Nonzero means to use ARM/Thumb Procedure Call Standard conventions. */
403#define ARM_FLAG_ATPCS (1 << 22)
404
9b6b54e2
NC
405/* Fix invalid Cirrus instruction combinations by inserting NOPs. */
406#define CIRRUS_FIX_INVALID_INSNS (1 << 23)
407
d5b7b3ae 408#define TARGET_APCS_FRAME (target_flags & ARM_FLAG_APCS_FRAME)
11c1a207
RE
409#define TARGET_POKE_FUNCTION_NAME (target_flags & ARM_FLAG_POKE)
410#define TARGET_FPE (target_flags & ARM_FLAG_FPE)
11c1a207
RE
411#define TARGET_APCS_32 (target_flags & ARM_FLAG_APCS_32)
412#define TARGET_APCS_STACK (target_flags & ARM_FLAG_APCS_STACK)
413#define TARGET_APCS_FLOAT (target_flags & ARM_FLAG_APCS_FLOAT)
414#define TARGET_APCS_REENT (target_flags & ARM_FLAG_APCS_REENT)
dc0ba55a 415#define TARGET_ATPCS (target_flags & ARM_FLAG_ATPCS)
5f1e6755 416#define TARGET_MMU_TRAPS (target_flags & ARM_FLAG_MMU_TRAPS)
11c1a207
RE
417#define TARGET_SOFT_FLOAT (target_flags & ARM_FLAG_SOFT_FLOAT)
418#define TARGET_HARD_FLOAT (! TARGET_SOFT_FLOAT)
9b6b54e2
NC
419#define TARGET_CIRRUS (arm_is_cirrus)
420#define TARGET_ANY_HARD_FLOAT (TARGET_HARD_FLOAT || TARGET_CIRRUS)
5a9335ef
NC
421#define TARGET_IWMMXT (arm_arch_iwmmxt)
422#define TARGET_REALLY_IWMMXT (TARGET_IWMMXT && TARGET_ARM)
b5b620a4 423#define TARGET_VFP (target_flags & ARM_FLAG_VFP)
11c1a207 424#define TARGET_BIG_END (target_flags & ARM_FLAG_BIG_END)
6cfc7210 425#define TARGET_INTERWORK (target_flags & ARM_FLAG_INTERWORK)
ddee6aba 426#define TARGET_LITTLE_WORDS (target_flags & ARM_FLAG_LITTLE_WORDS)
f5a1b0d2 427#define TARGET_NO_SCHED_PRO (target_flags & ARM_FLAG_NO_SCHED_PRO)
dd18ae56 428#define TARGET_ABORT_NORETURN (target_flags & ARM_FLAG_ABORT_NORETURN)
ed0e6530 429#define TARGET_SINGLE_PIC_BASE (target_flags & ARM_FLAG_SINGLE_PIC_BASE)
b020fd92 430#define TARGET_LONG_CALLS (target_flags & ARM_FLAG_LONG_CALLS)
d5b7b3ae
RE
431#define TARGET_THUMB (target_flags & ARM_FLAG_THUMB)
432#define TARGET_ARM (! TARGET_THUMB)
433#define TARGET_EITHER 1 /* (TARGET_ARM | TARGET_THUMB) */
434#define TARGET_CALLEE_INTERWORKING (target_flags & THUMB_FLAG_CALLEE_SUPER_INTERWORKING)
435#define TARGET_CALLER_INTERWORKING (target_flags & THUMB_FLAG_CALLER_SUPER_INTERWORKING)
436#define TARGET_BACKTRACE (leaf_function_p () \
437 ? (target_flags & THUMB_FLAG_LEAF_BACKTRACE) \
438 : (target_flags & THUMB_FLAG_BACKTRACE))
9b6b54e2 439#define TARGET_CIRRUS_FIX_INVALID_INSNS (target_flags & CIRRUS_FIX_INVALID_INSNS)
3ada8e17 440
c7bdf0a6 441/* SUBTARGET_SWITCHES is used to add flags on a per-config basis. */
3ada8e17
DE
442#ifndef SUBTARGET_SWITCHES
443#define SUBTARGET_SWITCHES
ff9940b0
RE
444#endif
445
047142d3
PT
446#define TARGET_SWITCHES \
447{ \
448 {"apcs", ARM_FLAG_APCS_FRAME, "" }, \
449 {"apcs-frame", ARM_FLAG_APCS_FRAME, \
450 N_("Generate APCS conformant stack frames") }, \
451 {"no-apcs-frame", -ARM_FLAG_APCS_FRAME, "" }, \
452 {"poke-function-name", ARM_FLAG_POKE, \
453 N_("Store function names in object code") }, \
454 {"no-poke-function-name", -ARM_FLAG_POKE, "" }, \
455 {"fpe", ARM_FLAG_FPE, "" }, \
456 {"apcs-32", ARM_FLAG_APCS_32, \
b605cfa8 457 N_("Use the 32-bit version of the APCS") }, \
047142d3 458 {"apcs-26", -ARM_FLAG_APCS_32, \
b605cfa8 459 N_("Use the 26-bit version of the APCS") }, \
047142d3
PT
460 {"apcs-stack-check", ARM_FLAG_APCS_STACK, "" }, \
461 {"no-apcs-stack-check", -ARM_FLAG_APCS_STACK, "" }, \
462 {"apcs-float", ARM_FLAG_APCS_FLOAT, \
463 N_("Pass FP arguments in FP registers") }, \
464 {"no-apcs-float", -ARM_FLAG_APCS_FLOAT, "" }, \
465 {"apcs-reentrant", ARM_FLAG_APCS_REENT, \
466 N_("Generate re-entrant, PIC code") }, \
467 {"no-apcs-reentrant", -ARM_FLAG_APCS_REENT, "" }, \
468 {"alignment-traps", ARM_FLAG_MMU_TRAPS, \
469 N_("The MMU will trap on unaligned accesses") }, \
470 {"no-alignment-traps", -ARM_FLAG_MMU_TRAPS, "" }, \
471 {"short-load-bytes", ARM_FLAG_MMU_TRAPS, "" }, \
472 {"no-short-load-bytes", -ARM_FLAG_MMU_TRAPS, "" }, \
473 {"short-load-words", -ARM_FLAG_MMU_TRAPS, "" }, \
474 {"no-short-load-words", ARM_FLAG_MMU_TRAPS, "" }, \
475 {"soft-float", ARM_FLAG_SOFT_FLOAT, \
476 N_("Use library calls to perform FP operations") }, \
477 {"hard-float", -ARM_FLAG_SOFT_FLOAT, \
478 N_("Use hardware floating point instructions") }, \
479 {"big-endian", ARM_FLAG_BIG_END, \
480 N_("Assume target CPU is configured as big endian") }, \
481 {"little-endian", -ARM_FLAG_BIG_END, \
482 N_("Assume target CPU is configured as little endian") }, \
483 {"words-little-endian", ARM_FLAG_LITTLE_WORDS, \
484 N_("Assume big endian bytes, little endian words") }, \
485 {"thumb-interwork", ARM_FLAG_INTERWORK, \
b605cfa8 486 N_("Support calls between Thumb and ARM instruction sets") }, \
047142d3
PT
487 {"no-thumb-interwork", -ARM_FLAG_INTERWORK, "" }, \
488 {"abort-on-noreturn", ARM_FLAG_ABORT_NORETURN, \
489 N_("Generate a call to abort if a noreturn function returns")}, \
490 {"no-abort-on-noreturn", -ARM_FLAG_ABORT_NORETURN, "" }, \
b605cfa8 491 {"no-sched-prolog", ARM_FLAG_NO_SCHED_PRO, \
047142d3 492 N_("Do not move instructions into a function's prologue") }, \
b605cfa8 493 {"sched-prolog", -ARM_FLAG_NO_SCHED_PRO, "" }, \
047142d3
PT
494 {"single-pic-base", ARM_FLAG_SINGLE_PIC_BASE, \
495 N_("Do not load the PIC register in function prologues") }, \
496 {"no-single-pic-base", -ARM_FLAG_SINGLE_PIC_BASE, "" }, \
497 {"long-calls", ARM_FLAG_LONG_CALLS, \
498 N_("Generate call insns as indirect calls, if necessary") }, \
499 {"no-long-calls", -ARM_FLAG_LONG_CALLS, "" }, \
500 {"thumb", ARM_FLAG_THUMB, \
501 N_("Compile for the Thumb not the ARM") }, \
502 {"no-thumb", -ARM_FLAG_THUMB, "" }, \
503 {"arm", -ARM_FLAG_THUMB, "" }, \
504 {"tpcs-frame", THUMB_FLAG_BACKTRACE, \
505 N_("Thumb: Generate (non-leaf) stack frames even if not needed") }, \
506 {"no-tpcs-frame", -THUMB_FLAG_BACKTRACE, "" }, \
507 {"tpcs-leaf-frame", THUMB_FLAG_LEAF_BACKTRACE, \
508 N_("Thumb: Generate (leaf) stack frames even if not needed") }, \
509 {"no-tpcs-leaf-frame", -THUMB_FLAG_LEAF_BACKTRACE, "" }, \
510 {"callee-super-interworking", THUMB_FLAG_CALLEE_SUPER_INTERWORKING, \
511 N_("Thumb: Assume non-static functions may be called from ARM code") }, \
512 {"no-callee-super-interworking", -THUMB_FLAG_CALLEE_SUPER_INTERWORKING, \
513 "" }, \
514 {"caller-super-interworking", THUMB_FLAG_CALLER_SUPER_INTERWORKING, \
515 N_("Thumb: Assume function pointers may go to non-Thumb aware code") }, \
516 {"no-caller-super-interworking", -THUMB_FLAG_CALLER_SUPER_INTERWORKING, \
517 "" }, \
9b6b54e2
NC
518 {"cirrus-fix-invalid-insns", CIRRUS_FIX_INVALID_INSNS, \
519 N_("Cirrus: Place NOPs to avoid invalid instruction combinations") }, \
520 {"no-cirrus-fix-invalid-insns", -CIRRUS_FIX_INVALID_INSNS, \
521 N_("Cirrus: Do not break up invalid instruction combinations with NOPs") },\
047142d3
PT
522 SUBTARGET_SWITCHES \
523 {"", TARGET_DEFAULT, "" } \
35d965d5
RS
524}
525
43cffd11
RE
526#define TARGET_OPTIONS \
527{ \
f5a1b0d2 528 {"cpu=", & arm_select[0].string, \
7052a099 529 N_("Specify the name of the target CPU"), 0}, \
f5a1b0d2 530 {"arch=", & arm_select[1].string, \
7052a099
RE
531 N_("Specify the name of the target architecture"), 0}, \
532 {"tune=", & arm_select[2].string, "", 0}, \
533 {"fpe=", & target_fp_name, "" , 0}, \
f5a1b0d2 534 {"fp=", & target_fp_name, \
7052a099 535 N_("Specify the version of the floating point emulator"), 0},\
047142d3 536 {"structure-size-boundary=", & structure_size_string, \
7052a099 537 N_("Specify the minimum bit alignment of structures"), 0}, \
047142d3 538 {"pic-register=", & arm_pic_register_string, \
7052a099 539 N_("Specify the register to be used for PIC addressing"), 0} \
11c1a207 540}
ff9940b0 541
7816bea0
DJ
542/* Support for a compile-time default CPU, et cetera. The rules are:
543 --with-arch is ignored if -march or -mcpu are specified.
544 --with-cpu is ignored if -march or -mcpu are specified, and is overridden
545 by --with-arch.
546 --with-tune is ignored if -mtune or -mcpu are specified (but not affected
547 by -march).
548 --with-float is ignored if -mhard-float or -msoft-float are
549 specified. */
550#define OPTION_DEFAULT_SPECS \
551 {"arch", "%{!march=*:%{!mcpu=*:-march=%(VALUE)}}" }, \
552 {"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
553 {"tune", "%{!mcpu=*:%{!mtune=*:-mtune=%(VALUE)}}" }, \
554 {"float", "%{!msoft-float:%{!mhard-float:-m%(VALUE)-float}}" }
555
62dd06ea
RE
556struct arm_cpu_select
557{
f9cc092a
RE
558 const char * string;
559 const char * name;
560 const struct processors * processors;
62dd06ea
RE
561};
562
f5a1b0d2
NC
563/* This is a magic array. If the user specifies a command line switch
564 which matches one of the entries in TARGET_OPTIONS then the corresponding
565 string pointer will be set to the value specified by the user. */
62dd06ea
RE
566extern struct arm_cpu_select arm_select[];
567
11c1a207
RE
568enum prog_mode_type
569{
570 prog_mode26,
571 prog_mode32
572};
573
d6b4baa4 574/* Recast the program mode class to be the prog_mode attribute. */
11c1a207
RE
575#define arm_prog_mode ((enum attr_prog_mode) arm_prgmode)
576
577extern enum prog_mode_type arm_prgmode;
578
579/* What sort of floating point unit do we have? Hardware or software.
580 If software, is it issue 2 or issue 3? */
29ad9694 581enum fputype
24f0c1b4 582{
29ad9694
RE
583 /* Software floating point, FPA style double fmt. */
584 FPUTYPE_SOFT_FPA,
585 /* Full FPA support. */
586 FPUTYPE_FPA,
587 /* Emulated FPA hardware, Issue 2 emulator (no LFM/SFM). */
588 FPUTYPE_FPA_EMU2,
589 /* Emulated FPA hardware, Issue 3 emulator. */
590 FPUTYPE_FPA_EMU3,
591 /* Cirrus Maverick floating point co-processor. */
592 FPUTYPE_MAVERICK
24f0c1b4
RE
593};
594
595/* Recast the floating point class to be the floating point attribute. */
29ad9694 596#define arm_fpu_attr ((enum attr_fpu) arm_fpu_tune)
24f0c1b4 597
71791e16 598/* What type of floating point to tune for */
29ad9694 599extern enum fputype arm_fpu_tune;
24f0c1b4 600
71791e16 601/* What type of floating point instructions are available */
29ad9694 602extern enum fputype arm_fpu_arch;
71791e16 603
18543a22 604/* Default floating point architecture. Override in sub-target if
71791e16 605 necessary. */
29ad9694
RE
606#ifndef FPUTYPE_DEFAULT
607#define FPUTYPE_DEFAULT FPUTYPE_FPA_EMU2
be393ecf 608#endif
71791e16 609
9b6b54e2 610#if TARGET_CPU_DEFAULT == TARGET_CPU_ep9312
29ad9694
RE
611#undef FPUTYPE_DEFAULT
612#define FPUTYPE_DEFAULT FPUTYPE_MAVERICK
9b6b54e2
NC
613#endif
614
11c1a207
RE
615/* Nonzero if the processor has a fast multiply insn, and one that does
616 a 64-bit multiply of two 32-bit values. */
617extern int arm_fast_multiply;
618
71791e16 619/* Nonzero if this chip supports the ARM Architecture 4 extensions */
11c1a207
RE
620extern int arm_arch4;
621
62b10bbc
NC
622/* Nonzero if this chip supports the ARM Architecture 5 extensions */
623extern int arm_arch5;
624
b15bca31
RE
625/* Nonzero if this chip supports the ARM Architecture 5E extensions */
626extern int arm_arch5e;
627
f5a1b0d2
NC
628/* Nonzero if this chip can benefit from load scheduling. */
629extern int arm_ld_sched;
630
0616531f
RE
631/* Nonzero if generating thumb code. */
632extern int thumb_code;
633
f5a1b0d2
NC
634/* Nonzero if this chip is a StrongARM. */
635extern int arm_is_strong;
636
9b6b54e2
NC
637/* Nonzero if this chip is a Cirrus variant. */
638extern int arm_is_cirrus;
639
5a9335ef
NC
640/* Nonzero if this chip supports Intel XScale with Wireless MMX technology. */
641extern int arm_arch_iwmmxt;
642
d19fb8e3 643/* Nonzero if this chip is an XScale. */
4b3c2e48
PB
644extern int arm_arch_xscale;
645
646/* Nonzero if tuning for XScale */
647extern int arm_tune_xscale;
d19fb8e3 648
3569057d 649/* Nonzero if this chip is an ARM6 or an ARM7. */
f5a1b0d2
NC
650extern int arm_is_6_or_7;
651
2ce9c1b9 652#ifndef TARGET_DEFAULT
d5b7b3ae 653#define TARGET_DEFAULT (ARM_FLAG_APCS_FRAME)
2ce9c1b9 654#endif
35d965d5 655
11c1a207
RE
656/* The frame pointer register used in gcc has nothing to do with debugging;
657 that is controlled by the APCS-FRAME option. */
d5b7b3ae 658#define CAN_DEBUG_WITHOUT_FP
35d965d5 659
be393ecf 660#undef TARGET_MEM_FUNCTIONS
11c1a207
RE
661#define TARGET_MEM_FUNCTIONS 1
662
663#define OVERRIDE_OPTIONS arm_override_options ()
86efdc8e
PB
664
665/* Nonzero if PIC code requires explicit qualifiers to generate
666 PLT and GOT relocs rather than the assembler doing so implicitly.
ed0e6530
PB
667 Subtargets can override these if required. */
668#ifndef NEED_GOT_RELOC
669#define NEED_GOT_RELOC 0
670#endif
671#ifndef NEED_PLT_RELOC
672#define NEED_PLT_RELOC 0
e2723c62 673#endif
84306176
PB
674
675/* Nonzero if we need to refer to the GOT with a PC-relative
676 offset. In other words, generate
677
678 .word _GLOBAL_OFFSET_TABLE_ - [. - (.Lxx + 8)]
679
680 rather than
681
682 .word _GLOBAL_OFFSET_TABLE_ - (.Lxx + 8)
683
684 The default is true, which matches NetBSD. Subtargets can
685 override this if required. */
686#ifndef GOT_PCREL
687#define GOT_PCREL 1
688#endif
35d965d5
RS
689\f
690/* Target machine storage Layout. */
691
ff9940b0
RE
692
693/* Define this macro if it is advisable to hold scalars in registers
694 in a wider mode than that declared by the program. In such cases,
695 the value is constrained to be within the bounds of the declared
696 type, but kept valid in the wider mode. The signedness of the
697 extension may differ from that of the type. */
698
699/* It is far faster to zero extend chars than to sign extend them */
700
6cfc7210 701#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
2ce9c1b9
RE
702 if (GET_MODE_CLASS (MODE) == MODE_INT \
703 && GET_MODE_SIZE (MODE) < 4) \
704 { \
705 if (MODE == QImode) \
706 UNSIGNEDP = 1; \
707 else if (MODE == HImode) \
5f1e6755 708 UNSIGNEDP = TARGET_MMU_TRAPS != 0; \
2ce9c1b9 709 (MODE) = SImode; \
ff9940b0
RE
710 }
711
35d965d5
RS
712/* Define this if most significant bit is lowest numbered
713 in instructions that operate on numbered bit-fields. */
714#define BITS_BIG_ENDIAN 0
715
9c872872 716/* Define this if most significant byte of a word is the lowest numbered.
3ada8e17
DE
717 Most ARM processors are run in little endian mode, so that is the default.
718 If you want to have it run-time selectable, change the definition in a
719 cover file to be TARGET_BIG_ENDIAN. */
11c1a207 720#define BYTES_BIG_ENDIAN (TARGET_BIG_END != 0)
35d965d5
RS
721
722/* Define this if most significant word of a multiword number is the lowest
11c1a207
RE
723 numbered.
724 This is always false, even when in big-endian mode. */
ddee6aba
RE
725#define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN && ! TARGET_LITTLE_WORDS)
726
727/* LIBGCC2_WORDS_BIG_ENDIAN has to be a constant, so we define this based
728 on processor pre-defineds when compiling libgcc2.c. */
729#if defined(__ARMEB__) && !defined(__ARMWEL__)
730#define LIBGCC2_WORDS_BIG_ENDIAN 1
731#else
732#define LIBGCC2_WORDS_BIG_ENDIAN 0
733#endif
35d965d5 734
11c1a207 735/* Define this if most significant word of doubles is the lowest numbered.
f0375c66
NC
736 The rules are different based on whether or not we use FPA-format,
737 VFP-format or some other floating point co-processor's format doubles. */
b5b620a4 738#define FLOAT_WORDS_BIG_ENDIAN (arm_float_words_big_endian ())
7fc6c9f0 739
35d965d5
RS
740#define UNITS_PER_WORD 4
741
35d965d5
RS
742#define PARM_BOUNDARY 32
743
5a9335ef
NC
744#define IWMMXT_ALIGNMENT 64
745
35d965d5
RS
746#define STACK_BOUNDARY 32
747
0977774b
JT
748#define PREFERRED_STACK_BOUNDARY (TARGET_ATPCS ? 64 : 32)
749
35d965d5
RS
750#define FUNCTION_BOUNDARY 32
751
92928d71
AO
752/* The lowest bit is used to indicate Thumb-mode functions, so the
753 vbit must go into the delta field of pointers to member
754 functions. */
755#define TARGET_PTRMEMFUNC_VBIT_LOCATION ptrmemfunc_vbit_in_delta
756
35d965d5
RS
757#define EMPTY_FIELD_BOUNDARY 32
758
84edd42c 759#define BIGGEST_ALIGNMENT (TARGET_REALLY_IWMMXT ? 64 : 32)
5a9335ef
NC
760
761#define TYPE_NEEDS_IWMMXT_ALIGNMENT(TYPE) \
762 (TARGET_REALLY_IWMMXT \
763 && ((TREE_CODE (TYPE) == VECTOR_TYPE) || (TYPE_MODE (TYPE) == DImode) || (TYPE_MODE (TYPE) == DFmode)))
764
27847754
NC
765/* XXX Blah -- this macro is used directly by libobjc. Since it
766 supports no vector modes, cut out the complexity and fall back
767 on BIGGEST_FIELD_ALIGNMENT. */
768#ifdef IN_TARGET_LIBS
8fca31a2 769#define BIGGEST_FIELD_ALIGNMENT 64
27847754 770#else
5a9335ef
NC
771/* An expression for the alignment of a structure field FIELD if the
772 alignment computed in the usual way is COMPUTED. GCC uses this
773 value instead of the value in `BIGGEST_ALIGNMENT' or
774 `BIGGEST_FIELD_ALIGNMENT', if defined, for structure fields only. */
775#define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
776 (TYPE_NEEDS_IWMMXT_ALIGNMENT (TREE_TYPE (FIELD)) \
777 ? IWMMXT_ALIGNMENT \
778 : (COMPUTED))
27847754 779#endif
5a9335ef
NC
780
781/* If defined, a C expression to compute the alignment for a static variable.
782 TYPE is the data type, and ALIGN is the alignment that the object
783 would ordinarily have. The value of this macro is used instead of that
784 alignment to align the object.
785
786 If this macro is not defined, then ALIGN is used. */
787#define DATA_ALIGNMENT(TYPE, ALIGN) \
788 (TYPE_NEEDS_IWMMXT_ALIGNMENT (TYPE) ? IWMMXT_ALIGNMENT : ALIGN)
789
790/* If defined, a C expression to compute the alignment for a
791 variables in the local store. TYPE is the data type, and
792 BASIC-ALIGN is the alignment that the object would ordinarily
793 have. The value of this macro is used instead of that alignment
794 to align the object.
795
796 If this macro is not defined, then BASIC-ALIGN is used. */
797#define LOCAL_ALIGNMENT(TYPE, ALIGN) \
798 (TYPE_NEEDS_IWMMXT_ALIGNMENT (TYPE) ? IWMMXT_ALIGNMENT : ALIGN)
35d965d5 799
ff9940b0 800/* Make strings word-aligned so strcpy from constants will be faster. */
591af218 801#define CONSTANT_ALIGNMENT_FACTOR (TARGET_THUMB || ! arm_tune_xscale ? 1 : 2)
d19fb8e3
NC
802
803#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
5a9335ef
NC
804 ((TARGET_REALLY_IWMMXT && TREE_CODE (EXP) == VECTOR_TYPE) ? IWMMXT_ALIGNMENT : \
805 (TREE_CODE (EXP) == STRING_CST \
d19fb8e3
NC
806 && (ALIGN) < BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR) \
807 ? BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR : (ALIGN))
ff9940b0 808
723ae7c1
NC
809/* Setting STRUCTURE_SIZE_BOUNDARY to 32 produces more efficient code, but the
810 value set in previous versions of this toolchain was 8, which produces more
811 compact structures. The command line option -mstructure_size_boundary=<n>
f710504c 812 can be used to change this value. For compatibility with the ARM SDK
723ae7c1
NC
813 however the value should be left at 32. ARM SDT Reference Manual (ARM DUI
814 0020D) page 2-20 says "Structures are aligned on word boundaries". */
6ead9ba5
NC
815#define STRUCTURE_SIZE_BOUNDARY arm_structure_size_boundary
816extern int arm_structure_size_boundary;
723ae7c1 817
4912a07c 818/* This is the value used to initialize arm_structure_size_boundary. If a
723ae7c1 819 particular arm target wants to change the default value it should change
6bc82793 820 the definition of this macro, not STRUCTURE_SIZE_BOUNDARY. See netbsd.h
723ae7c1
NC
821 for an example of this. */
822#ifndef DEFAULT_STRUCTURE_SIZE_BOUNDARY
823#define DEFAULT_STRUCTURE_SIZE_BOUNDARY 32
b355a481 824#endif
2a5307b1 825
b355a481 826/* Used when parsing command line option -mstructure_size_boundary. */
f9cc092a 827extern const char * structure_size_string;
b4ac57ab 828
825dda42 829/* Nonzero if move instructions will actually fail to work
ff9940b0 830 when given unaligned data. */
35d965d5 831#define STRICT_ALIGNMENT 1
35d965d5
RS
832\f
833/* Standard register usage. */
834
835/* Register allocation in ARM Procedure Call Standard (as used on RISCiX):
836 (S - saved over call).
837
838 r0 * argument word/integer result
839 r1-r3 argument word
840
841 r4-r8 S register variable
842 r9 S (rfp) register variable (real frame pointer)
f5a1b0d2
NC
843
844 r10 F S (sl) stack limit (used by -mapcs-stack-check)
35d965d5
RS
845 r11 F S (fp) argument pointer
846 r12 (ip) temp workspace
847 r13 F S (sp) lower end of current stack frame
848 r14 (lr) link address/workspace
849 r15 F (pc) program counter
850
851 f0 floating point result
852 f1-f3 floating point scratch
853
854 f4-f7 S floating point variable
855
ff9940b0
RE
856 cc This is NOT a real register, but is used internally
857 to represent things that use or set the condition
858 codes.
859 sfp This isn't either. It is used during rtl generation
860 since the offset between the frame pointer and the
861 auto's isn't known until after register allocation.
862 afp Nor this, we only need this because of non-local
863 goto. Without it fp appears to be used and the
864 elimination code won't get rid of sfp. It tracks
865 fp exactly at all times.
866
35d965d5
RS
867 *: See CONDITIONAL_REGISTER_USAGE */
868
9b6b54e2
NC
869/*
870 mvf0 Cirrus floating point result
871 mvf1-mvf3 Cirrus floating point scratch
872 mvf4-mvf15 S Cirrus floating point variable. */
873
ff9940b0
RE
874/* The stack backtrace structure is as follows:
875 fp points to here: | save code pointer | [fp]
876 | return link value | [fp, #-4]
877 | return sp value | [fp, #-8]
878 | return fp value | [fp, #-12]
879 [| saved r10 value |]
880 [| saved r9 value |]
881 [| saved r8 value |]
882 [| saved r7 value |]
883 [| saved r6 value |]
884 [| saved r5 value |]
885 [| saved r4 value |]
886 [| saved r3 value |]
887 [| saved r2 value |]
888 [| saved r1 value |]
889 [| saved r0 value |]
890 [| saved f7 value |] three words
891 [| saved f6 value |] three words
892 [| saved f5 value |] three words
893 [| saved f4 value |] three words
894 r0-r3 are not normally saved in a C function. */
895
35d965d5
RS
896/* 1 for registers that have pervasive standard uses
897 and are not available for the register allocator. */
898#define FIXED_REGISTERS \
899{ \
900 0,0,0,0,0,0,0,0, \
d5b7b3ae 901 0,0,0,0,0,1,0,1, \
ff9940b0 902 0,0,0,0,0,0,0,0, \
9b6b54e2
NC
903 1,1,1, \
904 1,1,1,1,1,1,1,1, \
5a9335ef
NC
905 1,1,1,1,1,1,1,1, \
906 1,1,1,1,1,1,1,1, \
907 1,1,1,1,1,1,1,1, \
908 1,1,1,1 \
35d965d5
RS
909}
910
911/* 1 for registers not available across function calls.
912 These must include the FIXED_REGISTERS and also any
913 registers that can be used without being saved.
914 The latter must include the registers where values are returned
915 and the register where structure-value addresses are passed.
ff9940b0
RE
916 Aside from that, you can include as many other registers as you like.
917 The CC is not preserved over function calls on the ARM 6, so it is
d6b4baa4 918 easier to assume this for all. SFP is preserved, since FP is. */
35d965d5
RS
919#define CALL_USED_REGISTERS \
920{ \
921 1,1,1,1,0,0,0,0, \
d5b7b3ae 922 0,0,0,0,1,1,1,1, \
ff9940b0 923 1,1,1,1,0,0,0,0, \
9b6b54e2
NC
924 1,1,1, \
925 1,1,1,1,1,1,1,1, \
5a9335ef
NC
926 1,1,1,1,1,1,1,1, \
927 1,1,1,1,1,1,1,1, \
928 1,1,1,1,1,1,1,1, \
929 1,1,1,1 \
35d965d5
RS
930}
931
6cc8c0b3
NC
932#ifndef SUBTARGET_CONDITIONAL_REGISTER_USAGE
933#define SUBTARGET_CONDITIONAL_REGISTER_USAGE
934#endif
935
d5b7b3ae
RE
936#define CONDITIONAL_REGISTER_USAGE \
937{ \
4b02997f
NC
938 int regno; \
939 \
d5b7b3ae
RE
940 if (TARGET_SOFT_FLOAT || TARGET_THUMB) \
941 { \
d5b7b3ae
RE
942 for (regno = FIRST_ARM_FP_REGNUM; \
943 regno <= LAST_ARM_FP_REGNUM; ++regno) \
944 fixed_regs[regno] = call_used_regs[regno] = 1; \
945 } \
9b6b54e2 946 \
c769a35d
RE
947 if (TARGET_THUMB && optimize_size) \
948 { \
949 /* When optimizing for size, it's better not to use \
950 the HI regs, because of the overhead of stacking \
d6b4baa4 951 them. */ \
c769a35d
RE
952 for (regno = FIRST_HI_REGNUM; \
953 regno <= LAST_HI_REGNUM; ++regno) \
954 fixed_regs[regno] = call_used_regs[regno] = 1; \
955 } \
956 \
fb14bc89
RE
957 /* The link register can be clobbered by any branch insn, \
958 but we have no way to track that at present, so mark \
959 it as unavailable. */ \
960 if (TARGET_THUMB) \
961 fixed_regs[LR_REGNUM] = call_used_regs[LR_REGNUM] = 1; \
962 \
9b6b54e2
NC
963 if (TARGET_CIRRUS) \
964 { \
965 for (regno = FIRST_ARM_FP_REGNUM; \
966 regno <= LAST_ARM_FP_REGNUM; ++ regno) \
967 fixed_regs[regno] = call_used_regs[regno] = 1; \
968 for (regno = FIRST_CIRRUS_FP_REGNUM; \
969 regno <= LAST_CIRRUS_FP_REGNUM; ++ regno) \
970 { \
971 fixed_regs[regno] = 0; \
972 call_used_regs[regno] = regno < FIRST_CIRRUS_FP_REGNUM + 4; \
973 } \
974 } \
975 \
5a9335ef
NC
976 if (TARGET_REALLY_IWMMXT) \
977 { \
978 regno = FIRST_IWMMXT_GR_REGNUM; \
979 /* The 2002/10/09 revision of the XScale ABI has wCG0 \
980 and wCG1 as call-preserved registers. The 2002/11/21 \
981 revision changed this so that all wCG registers are \
982 scratch registers. */ \
983 for (regno = FIRST_IWMMXT_GR_REGNUM; \
984 regno <= LAST_IWMMXT_GR_REGNUM; ++ regno) \
985 fixed_regs[regno] = call_used_regs[regno] = 0; \
986 /* The XScale ABI has wR0 - wR9 as scratch registers, \
987 the rest as call-preserved registers. */ \
988 for (regno = FIRST_IWMMXT_REGNUM; \
989 regno <= LAST_IWMMXT_REGNUM; ++ regno) \
990 { \
991 fixed_regs[regno] = 0; \
992 call_used_regs[regno] = regno < FIRST_IWMMXT_REGNUM + 10; \
993 } \
994 } \
995 \
fc555370 996 if ((unsigned) PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) \
d5b7b3ae
RE
997 { \
998 fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
999 call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
1000 } \
1001 else if (TARGET_APCS_STACK) \
1002 { \
1003 fixed_regs[10] = 1; \
1004 call_used_regs[10] = 1; \
1005 } \
1006 if (TARGET_APCS_FRAME) \
1007 { \
1008 fixed_regs[ARM_HARD_FRAME_POINTER_REGNUM] = 1; \
1009 call_used_regs[ARM_HARD_FRAME_POINTER_REGNUM] = 1; \
1010 } \
1011 SUBTARGET_CONDITIONAL_REGISTER_USAGE \
35d965d5 1012}
d5b7b3ae 1013
6bc82793 1014/* These are a couple of extensions to the formats accepted
dd18ae56
NC
1015 by asm_fprintf:
1016 %@ prints out ASM_COMMENT_START
1017 %r prints out REGISTER_PREFIX reg_names[arg] */
1018#define ASM_FPRINTF_EXTENSIONS(FILE, ARGS, P) \
1019 case '@': \
1020 fputs (ASM_COMMENT_START, FILE); \
1021 break; \
1022 \
1023 case 'r': \
1024 fputs (REGISTER_PREFIX, FILE); \
1025 fputs (reg_names [va_arg (ARGS, int)], FILE); \
1026 break;
1027
d5b7b3ae 1028/* Round X up to the nearest word. */
0c2ca901 1029#define ROUND_UP_WORD(X) (((X) + 3) & ~3)
d5b7b3ae 1030
6cfc7210 1031/* Convert fron bytes to ints. */
e9d7b180 1032#define ARM_NUM_INTS(X) (((X) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
6cfc7210
NC
1033
1034/* The number of (integer) registers required to hold a quantity of type MODE. */
e9d7b180
JD
1035#define ARM_NUM_REGS(MODE) \
1036 ARM_NUM_INTS (GET_MODE_SIZE (MODE))
6cfc7210
NC
1037
1038/* The number of (integer) registers required to hold a quantity of TYPE MODE. */
e9d7b180
JD
1039#define ARM_NUM_REGS2(MODE, TYPE) \
1040 ARM_NUM_INTS ((MODE) == BLKmode ? \
d5b7b3ae 1041 int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE))
6cfc7210
NC
1042
1043/* The number of (integer) argument register available. */
d5b7b3ae 1044#define NUM_ARG_REGS 4
6cfc7210 1045
093354e0 1046/* Return the register number of the N'th (integer) argument. */
d5b7b3ae 1047#define ARG_REGISTER(N) (N - 1)
6cfc7210 1048
d5b7b3ae
RE
1049/* Specify the registers used for certain standard purposes.
1050 The values of these macros are register numbers. */
35d965d5 1051
d5b7b3ae
RE
1052/* The number of the last argument register. */
1053#define LAST_ARG_REGNUM ARG_REGISTER (NUM_ARG_REGS)
35d965d5 1054
c769a35d
RE
1055/* The numbers of the Thumb register ranges. */
1056#define FIRST_LO_REGNUM 0
6d3d9133 1057#define LAST_LO_REGNUM 7
c769a35d
RE
1058#define FIRST_HI_REGNUM 8
1059#define LAST_HI_REGNUM 11
6d3d9133
NC
1060
1061/* The register that holds the return address in exception handlers. */
1062#define EXCEPTION_LR_REGNUM 2
35d965d5 1063
d5b7b3ae
RE
1064/* The native (Norcroft) Pascal compiler for the ARM passes the static chain
1065 as an invisible last argument (possible since varargs don't exist in
1066 Pascal), so the following is not true. */
68dfd979 1067#define STATIC_CHAIN_REGNUM (TARGET_ARM ? 12 : 9)
35d965d5 1068
d5b7b3ae
RE
1069/* Define this to be where the real frame pointer is if it is not possible to
1070 work out the offset between the frame pointer and the automatic variables
1071 until after register allocation has taken place. FRAME_POINTER_REGNUM
1072 should point to a special register that we will make sure is eliminated.
1073
1074 For the Thumb we have another problem. The TPCS defines the frame pointer
6bc82793 1075 as r11, and GCC believes that it is always possible to use the frame pointer
d5b7b3ae
RE
1076 as base register for addressing purposes. (See comments in
1077 find_reloads_address()). But - the Thumb does not allow high registers,
1078 including r11, to be used as base address registers. Hence our problem.
1079
1080 The solution used here, and in the old thumb port is to use r7 instead of
1081 r11 as the hard frame pointer and to have special code to generate
1082 backtrace structures on the stack (if required to do so via a command line
6bc82793 1083 option) using r11. This is the only 'user visible' use of r11 as a frame
d5b7b3ae
RE
1084 pointer. */
1085#define ARM_HARD_FRAME_POINTER_REGNUM 11
1086#define THUMB_HARD_FRAME_POINTER_REGNUM 7
35d965d5 1087
b15bca31
RE
1088#define HARD_FRAME_POINTER_REGNUM \
1089 (TARGET_ARM \
1090 ? ARM_HARD_FRAME_POINTER_REGNUM \
1091 : THUMB_HARD_FRAME_POINTER_REGNUM)
d5b7b3ae 1092
b15bca31 1093#define FP_REGNUM HARD_FRAME_POINTER_REGNUM
d5b7b3ae 1094
b15bca31
RE
1095/* Register to use for pushing function arguments. */
1096#define STACK_POINTER_REGNUM SP_REGNUM
d5b7b3ae
RE
1097
1098/* ARM floating pointer registers. */
1099#define FIRST_ARM_FP_REGNUM 16
1100#define LAST_ARM_FP_REGNUM 23
1101
5a9335ef
NC
1102#define FIRST_IWMMXT_GR_REGNUM 43
1103#define LAST_IWMMXT_GR_REGNUM 46
1104#define FIRST_IWMMXT_REGNUM 47
1105#define LAST_IWMMXT_REGNUM 62
1106#define IS_IWMMXT_REGNUM(REGNUM) \
1107 (((REGNUM) >= FIRST_IWMMXT_REGNUM) && ((REGNUM) <= LAST_IWMMXT_REGNUM))
1108#define IS_IWMMXT_GR_REGNUM(REGNUM) \
1109 (((REGNUM) >= FIRST_IWMMXT_GR_REGNUM) && ((REGNUM) <= LAST_IWMMXT_GR_REGNUM))
1110
35d965d5 1111/* Base register for access to local variables of the function. */
ff9940b0
RE
1112#define FRAME_POINTER_REGNUM 25
1113
d5b7b3ae
RE
1114/* Base register for access to arguments of the function. */
1115#define ARG_POINTER_REGNUM 26
62b10bbc 1116
9b6b54e2
NC
1117#define FIRST_CIRRUS_FP_REGNUM 27
1118#define LAST_CIRRUS_FP_REGNUM 42
1119#define IS_CIRRUS_REGNUM(REGNUM) \
1120 (((REGNUM) >= FIRST_CIRRUS_FP_REGNUM) && ((REGNUM) <= LAST_CIRRUS_FP_REGNUM))
1121
6f8c9bd1
NC
1122/* The number of hard registers is 16 ARM + 8 FPA + 1 CC + 1 SFP + 1 AFP. */
1123/* + 16 Cirrus registers take us up to 43. */
5a9335ef
NC
1124/* Intel Wireless MMX Technology registers add 16 + 4 more. */
1125#define FIRST_PSEUDO_REGISTER 63
62b10bbc 1126
35d965d5
RS
1127/* Value should be nonzero if functions must have frame pointers.
1128 Zero means the frame pointer need not be set up (and parms may be accessed
ff9940b0
RE
1129 via the stack pointer) in functions that seem suitable.
1130 If we have to have a frame pointer we might as well make use of it.
1131 APCS says that the frame pointer does not need to be pushed in leaf
2a5307b1 1132 functions, or simple tail call functions. */
7b8b8ade
NC
1133#define FRAME_POINTER_REQUIRED \
1134 (current_function_has_nonlocal_label \
d5b7b3ae 1135 || (TARGET_ARM && TARGET_APCS_FRAME && ! leaf_function_p ()))
35d965d5 1136
d5b7b3ae
RE
1137/* Return number of consecutive hard regs needed starting at reg REGNO
1138 to hold something of mode MODE.
1139 This is ordinarily the length in words of a value of mode MODE
1140 but can be less for certain modes in special long registers.
35d965d5 1141
3b684012 1142 On the ARM regs are UNITS_PER_WORD bits wide; FPA regs can hold any FP
d5b7b3ae
RE
1143 mode. */
1144#define HARD_REGNO_NREGS(REGNO, MODE) \
1145 ((TARGET_ARM \
1146 && REGNO >= FIRST_ARM_FP_REGNUM \
1147 && REGNO != FRAME_POINTER_REGNUM \
1148 && REGNO != ARG_POINTER_REGNUM) \
e9d7b180 1149 ? 1 : ARM_NUM_REGS (MODE))
35d965d5 1150
4b02997f 1151/* Return true if REGNO is suitable for holding a quantity of type MODE. */
d5b7b3ae 1152#define HARD_REGNO_MODE_OK(REGNO, MODE) \
4b02997f 1153 arm_hard_regno_mode_ok ((REGNO), (MODE))
35d965d5 1154
d5b7b3ae
RE
1155/* Value is 1 if it is a good idea to tie two pseudo registers
1156 when one has mode MODE1 and one has mode MODE2.
1157 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
1158 for any hard reg, then this must be 0 for correct output. */
1159#define MODES_TIEABLE_P(MODE1, MODE2) \
1160 (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
ff9940b0 1161
5a9335ef
NC
1162#define VECTOR_MODE_SUPPORTED_P(MODE) \
1163 ((MODE) == V2SImode || (MODE) == V4HImode || (MODE) == V8QImode)
1164
1165#define VALID_IWMMXT_REG_MODE(MODE) \
1166 (VECTOR_MODE_SUPPORTED_P (MODE) || (MODE) == DImode)
1167
35d965d5 1168/* The order in which register should be allocated. It is good to use ip
ff9940b0
RE
1169 since no saving is required (though calls clobber it) and it never contains
1170 function parameters. It is quite good to use lr since other calls may
1171 clobber it anyway. Allocate r0 through r3 in reverse order since r3 is
1172 least likely to contain a function parameter; in addition results are
d5b7b3ae 1173 returned in r0. */
ff73fb53 1174#define REG_ALLOC_ORDER \
35d965d5 1175{ \
ff73fb53
NC
1176 3, 2, 1, 0, 12, 14, 4, 5, \
1177 6, 7, 8, 10, 9, 11, 13, 15, \
ff9940b0 1178 16, 17, 18, 19, 20, 21, 22, 23, \
9b6b54e2
NC
1179 27, 28, 29, 30, 31, 32, 33, 34, \
1180 35, 36, 37, 38, 39, 40, 41, 42, \
5a9335ef
NC
1181 43, 44, 45, 46, 47, 48, 49, 50, \
1182 51, 52, 53, 54, 55, 56, 57, 58, \
1183 59, 60, 61, 62, \
ff73fb53 1184 24, 25, 26 \
35d965d5 1185}
9338ffe6
PB
1186
1187/* Interrupt functions can only use registers that have already been
1188 saved by the prologue, even if they would normally be
1189 call-clobbered. */
1190#define HARD_REGNO_RENAME_OK(SRC, DST) \
1191 (! IS_INTERRUPT (cfun->machine->func_type) || \
1192 regs_ever_live[DST])
35d965d5
RS
1193\f
1194/* Register and constant classes. */
1195
3b684012 1196/* Register classes: used to be simple, just all ARM regs or all FPA regs
d6a7951f 1197 Now that the Thumb is involved it has become more complicated. */
35d965d5
RS
1198enum reg_class
1199{
1200 NO_REGS,
3b684012 1201 FPA_REGS,
9b6b54e2 1202 CIRRUS_REGS,
5a9335ef
NC
1203 IWMMXT_GR_REGS,
1204 IWMMXT_REGS,
d5b7b3ae
RE
1205 LO_REGS,
1206 STACK_REG,
1207 BASE_REGS,
1208 HI_REGS,
1209 CC_REG,
35d965d5
RS
1210 GENERAL_REGS,
1211 ALL_REGS,
1212 LIM_REG_CLASSES
1213};
1214
1215#define N_REG_CLASSES (int) LIM_REG_CLASSES
1216
d6b4baa4 1217/* Give names of register classes as strings for dump file. */
35d965d5
RS
1218#define REG_CLASS_NAMES \
1219{ \
1220 "NO_REGS", \
3b684012 1221 "FPA_REGS", \
9b6b54e2 1222 "CIRRUS_REGS", \
5a9335ef
NC
1223 "IWMMXT_GR_REGS", \
1224 "IWMMXT_REGS", \
d5b7b3ae
RE
1225 "LO_REGS", \
1226 "STACK_REG", \
1227 "BASE_REGS", \
1228 "HI_REGS", \
1229 "CC_REG", \
35d965d5
RS
1230 "GENERAL_REGS", \
1231 "ALL_REGS", \
1232}
1233
1234/* Define which registers fit in which classes.
1235 This is an initializer for a vector of HARD_REG_SET
1236 of length N_REG_CLASSES. */
aec3cfba
NC
1237#define REG_CLASS_CONTENTS \
1238{ \
9b6b54e2 1239 { 0x00000000, 0x0 }, /* NO_REGS */ \
3b684012 1240 { 0x00FF0000, 0x0 }, /* FPA_REGS */ \
9b6b54e2 1241 { 0xF8000000, 0x000007FF }, /* CIRRUS_REGS */ \
5a9335ef
NC
1242 { 0x00000000, 0x00007800 }, /* IWMMXT_GR_REGS */\
1243 { 0x00000000, 0x7FFF8000 }, /* IWMMXT_REGS */ \
9b6b54e2
NC
1244 { 0x000000FF, 0x0 }, /* LO_REGS */ \
1245 { 0x00002000, 0x0 }, /* STACK_REG */ \
1246 { 0x000020FF, 0x0 }, /* BASE_REGS */ \
1247 { 0x0000FF00, 0x0 }, /* HI_REGS */ \
1248 { 0x01000000, 0x0 }, /* CC_REG */ \
1249 { 0x0200FFFF, 0x0 }, /* GENERAL_REGS */\
5a9335ef 1250 { 0xFAFFFFFF, 0x7FFFFFFF } /* ALL_REGS */ \
35d965d5 1251}
4b02997f 1252
35d965d5
RS
1253/* The same information, inverted:
1254 Return the class number of the smallest class containing
1255 reg number REGNO. This could be a conditional expression
1256 or could index an array. */
d5b7b3ae 1257#define REGNO_REG_CLASS(REGNO) arm_regno_class (REGNO)
35d965d5 1258
75d2580c
RE
1259/* FPA registers can't do dubreg as all values are reformatted to internal
1260 precision. */
1261#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
1262 (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
1263 ? reg_classes_intersect_p (FPA_REGS, (CLASS)) : 0)
1264
35d965d5 1265/* The class value for index registers, and the one for base regs. */
d5b7b3ae 1266#define INDEX_REG_CLASS (TARGET_THUMB ? LO_REGS : GENERAL_REGS)
b93a0fe6 1267#define BASE_REG_CLASS (TARGET_THUMB ? LO_REGS : GENERAL_REGS)
d5b7b3ae 1268
b93a0fe6 1269/* For the Thumb the high registers cannot be used as base registers
6bc82793 1270 when addressing quantities in QI or HI mode; if we don't know the
b93a0fe6
RE
1271 mode, then we must be conservative. After reload we must also be
1272 conservative, since we can't support SP+reg addressing, and we
1273 can't fix up any bad substitutions. */
3dcc68a4 1274#define MODE_BASE_REG_CLASS(MODE) \
b93a0fe6
RE
1275 (TARGET_ARM ? GENERAL_REGS : \
1276 (((MODE) == SImode && !reload_completed) ? BASE_REGS : LO_REGS))
3dcc68a4 1277
d5b7b3ae
RE
1278/* When SMALL_REGISTER_CLASSES is nonzero, the compiler allows
1279 registers explicitly used in the rtl to be used as spill registers
1280 but prevents the compiler from extending the lifetime of these
d6b4baa4 1281 registers. */
d5b7b3ae 1282#define SMALL_REGISTER_CLASSES TARGET_THUMB
35d965d5
RS
1283
1284/* Get reg_class from a letter such as appears in the machine description.
3b684012 1285 We only need constraint `f' for FPA_REGS (`r' == GENERAL_REGS) for the
d5b7b3ae
RE
1286 ARM, but several more letters for the Thumb. */
1287#define REG_CLASS_FROM_LETTER(C) \
3b684012 1288 ( (C) == 'f' ? FPA_REGS \
9b6b54e2 1289 : (C) == 'v' ? CIRRUS_REGS \
5a9335ef
NC
1290 : (C) == 'y' ? IWMMXT_REGS \
1291 : (C) == 'z' ? IWMMXT_GR_REGS \
d5b7b3ae
RE
1292 : (C) == 'l' ? (TARGET_ARM ? GENERAL_REGS : LO_REGS) \
1293 : TARGET_ARM ? NO_REGS \
1294 : (C) == 'h' ? HI_REGS \
1295 : (C) == 'b' ? BASE_REGS \
1296 : (C) == 'k' ? STACK_REG \
1297 : (C) == 'c' ? CC_REG \
1298 : NO_REGS)
35d965d5
RS
1299
1300/* The letters I, J, K, L and M in a register constraint string
1301 can be used to stand for particular ranges of immediate operands.
1302 This macro defines what the ranges are.
1303 C is the letter, and VALUE is a constant value.
1304 Return 1 if VALUE is in the range specified by C.
b4ac57ab 1305 I: immediate arithmetic operand (i.e. 8 bits shifted as required).
ff9940b0 1306 J: valid indexing constants.
aef1764c 1307 K: ~value ok in rhs argument of data operand.
3967692c
RE
1308 L: -value ok in rhs argument of data operand.
1309 M: 0..32, or a power of 2 (for shifts, or mult done by shift). */
d5b7b3ae 1310#define CONST_OK_FOR_ARM_LETTER(VALUE, C) \
aef1764c
RE
1311 ((C) == 'I' ? const_ok_for_arm (VALUE) : \
1312 (C) == 'J' ? ((VALUE) < 4096 && (VALUE) > -4096) : \
1313 (C) == 'K' ? (const_ok_for_arm (~(VALUE))) : \
3967692c
RE
1314 (C) == 'L' ? (const_ok_for_arm (-(VALUE))) : \
1315 (C) == 'M' ? (((VALUE >= 0 && VALUE <= 32)) \
1316 || (((VALUE) & ((VALUE) - 1)) == 0)) \
1317 : 0)
ff9940b0 1318
d5b7b3ae
RE
1319#define CONST_OK_FOR_THUMB_LETTER(VAL, C) \
1320 ((C) == 'I' ? (unsigned HOST_WIDE_INT) (VAL) < 256 : \
1321 (C) == 'J' ? (VAL) > -256 && (VAL) < 0 : \
1322 (C) == 'K' ? thumb_shiftable_const (VAL) : \
1323 (C) == 'L' ? (VAL) > -8 && (VAL) < 8 : \
1324 (C) == 'M' ? ((unsigned HOST_WIDE_INT) (VAL) < 1024 \
1325 && ((VAL) & 3) == 0) : \
1326 (C) == 'N' ? ((unsigned HOST_WIDE_INT) (VAL) < 32) : \
1327 (C) == 'O' ? ((VAL) >= -508 && (VAL) <= 508) \
1328 : 0)
1329
1330#define CONST_OK_FOR_LETTER_P(VALUE, C) \
1331 (TARGET_ARM ? \
1332 CONST_OK_FOR_ARM_LETTER (VALUE, C) : CONST_OK_FOR_THUMB_LETTER (VALUE, C))
1333
3b684012 1334/* Constant letter 'G' for the FPA immediate constants.
d5b7b3ae
RE
1335 'H' means the same constant negated. */
1336#define CONST_DOUBLE_OK_FOR_ARM_LETTER(X, C) \
3b684012
RE
1337 ((C) == 'G' ? const_double_rtx_ok_for_fpa (X) : \
1338 (C) == 'H' ? neg_const_double_rtx_ok_for_fpa (X) : 0)
d5b7b3ae
RE
1339
1340#define CONST_DOUBLE_OK_FOR_LETTER_P(X, C) \
1341 (TARGET_ARM ? \
1342 CONST_DOUBLE_OK_FOR_ARM_LETTER (X, C) : 0)
1343
ff9940b0
RE
1344/* For the ARM, `Q' means that this is a memory operand that is just
1345 an offset from a register.
1346 `S' means any symbol that has the SYMBOL_REF_FLAG set or a CONSTANT_POOL
1347 address. This means that the symbol is in the text segment and can be
d6b4baa4 1348 accessed without using a load. */
ff9940b0 1349
d5b7b3ae
RE
1350#define EXTRA_CONSTRAINT_ARM(OP, C) \
1351 ((C) == 'Q' ? GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG : \
1352 (C) == 'R' ? (GET_CODE (OP) == MEM \
1353 && GET_CODE (XEXP (OP, 0)) == SYMBOL_REF \
1354 && CONSTANT_POOL_ADDRESS_P (XEXP (OP, 0))) : \
9b6b54e2
NC
1355 (C) == 'S' ? (optimize > 0 && CONSTANT_ADDRESS_P (OP)) : \
1356 (C) == 'T' ? cirrus_memory_offset (OP) : \
1357 0)
ff9940b0 1358
d5b7b3ae
RE
1359#define EXTRA_CONSTRAINT_THUMB(X, C) \
1360 ((C) == 'Q' ? (GET_CODE (X) == MEM \
1361 && GET_CODE (XEXP (X, 0)) == LABEL_REF) : 0)
1362
1363#define EXTRA_CONSTRAINT(X, C) \
1364 (TARGET_ARM ? \
1365 EXTRA_CONSTRAINT_ARM (X, C) : EXTRA_CONSTRAINT_THUMB (X, C))
35d965d5
RS
1366
1367/* Given an rtx X being reloaded into a reg required to be
1368 in class CLASS, return the class of reg to actually use.
d5b7b3ae
RE
1369 In general this is just CLASS, but for the Thumb we prefer
1370 a LO_REGS class or a subset. */
1371#define PREFERRED_RELOAD_CLASS(X, CLASS) \
1372 (TARGET_ARM ? (CLASS) : \
1373 ((CLASS) == BASE_REGS ? (CLASS) : LO_REGS))
1374
1375/* Must leave BASE_REGS reloads alone */
1376#define THUMB_SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \
1377 ((CLASS) != LO_REGS && (CLASS) != BASE_REGS \
1378 ? ((true_regnum (X) == -1 ? LO_REGS \
1379 : (true_regnum (X) + HARD_REGNO_NREGS (0, MODE) > 8) ? LO_REGS \
1380 : NO_REGS)) \
1381 : NO_REGS)
1382
1383#define THUMB_SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \
1384 ((CLASS) != LO_REGS \
1385 ? ((true_regnum (X) == -1 ? LO_REGS \
1386 : (true_regnum (X) + HARD_REGNO_NREGS (0, MODE) > 8) ? LO_REGS \
1387 : NO_REGS)) \
1388 : NO_REGS)
35d965d5 1389
ff9940b0
RE
1390/* Return the register class of a scratch register needed to copy IN into
1391 or out of a register in CLASS in MODE. If it can be done directly,
1392 NO_REGS is returned. */
d5b7b3ae
RE
1393#define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \
1394 (TARGET_ARM ? \
1395 (((MODE) == HImode && ! arm_arch4 && true_regnum (X) == -1) \
1396 ? GENERAL_REGS : NO_REGS) \
1397 : THUMB_SECONDARY_OUTPUT_RELOAD_CLASS (CLASS, MODE, X))
1398
d6b4baa4 1399/* If we need to load shorts byte-at-a-time, then we need a scratch. */
d5b7b3ae 1400#define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \
9b6b54e2
NC
1401 /* Cannot load constants into Cirrus registers. */ \
1402 ((TARGET_CIRRUS \
1403 && (CLASS) == CIRRUS_REGS \
1404 && (CONSTANT_P (X) || GET_CODE (X) == SYMBOL_REF)) \
1405 ? GENERAL_REGS : \
d5b7b3ae 1406 (TARGET_ARM ? \
5a9335ef
NC
1407 (((CLASS) == IWMMXT_REGS || (CLASS) == IWMMXT_GR_REGS) \
1408 && CONSTANT_P (X)) \
1409 ? GENERAL_REGS : \
d5b7b3ae
RE
1410 (((MODE) == HImode && ! arm_arch4 && TARGET_MMU_TRAPS \
1411 && (GET_CODE (X) == MEM \
1412 || ((GET_CODE (X) == REG || GET_CODE (X) == SUBREG) \
1413 && true_regnum (X) == -1))) \
1414 ? GENERAL_REGS : NO_REGS) \
9b6b54e2 1415 : THUMB_SECONDARY_INPUT_RELOAD_CLASS (CLASS, MODE, X)))
2ce9c1b9 1416
6f734908
RE
1417/* Try a machine-dependent way of reloading an illegitimate address
1418 operand. If we find one, push the reload and jump to WIN. This
1419 macro is used in only one place: `find_reloads_address' in reload.c.
1420
1421 For the ARM, we wish to handle large displacements off a base
1422 register by splitting the addend across a MOV and the mem insn.
d5b7b3ae
RE
1423 This can cut the number of reloads needed. */
1424#define ARM_LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND, WIN) \
1425 do \
1426 { \
1427 if (GET_CODE (X) == PLUS \
1428 && GET_CODE (XEXP (X, 0)) == REG \
1429 && REGNO (XEXP (X, 0)) < FIRST_PSEUDO_REGISTER \
1430 && REG_MODE_OK_FOR_BASE_P (XEXP (X, 0), MODE) \
1431 && GET_CODE (XEXP (X, 1)) == CONST_INT) \
1432 { \
1433 HOST_WIDE_INT val = INTVAL (XEXP (X, 1)); \
1434 HOST_WIDE_INT low, high; \
1435 \
1436 if (MODE == DImode || (TARGET_SOFT_FLOAT && MODE == DFmode)) \
1437 low = ((val & 0xf) ^ 0x8) - 0x8; \
9b6b54e2
NC
1438 else if (TARGET_CIRRUS) \
1439 /* Need to be careful, -256 is not a valid offset. */ \
1440 low = val >= 0 ? (val & 0xff) : -((-val) & 0xff); \
d5b7b3ae
RE
1441 else if (MODE == SImode \
1442 || (MODE == SFmode && TARGET_SOFT_FLOAT) \
1443 || ((MODE == HImode || MODE == QImode) && ! arm_arch4)) \
1444 /* Need to be careful, -4096 is not a valid offset. */ \
1445 low = val >= 0 ? (val & 0xfff) : -((-val) & 0xfff); \
1446 else if ((MODE == HImode || MODE == QImode) && arm_arch4) \
1447 /* Need to be careful, -256 is not a valid offset. */ \
1448 low = val >= 0 ? (val & 0xff) : -((-val) & 0xff); \
1449 else if (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1450 && TARGET_HARD_FLOAT) \
1451 /* Need to be careful, -1024 is not a valid offset. */ \
1452 low = val >= 0 ? (val & 0x3ff) : -((-val) & 0x3ff); \
1453 else \
1454 break; \
1455 \
30cf4896
KG
1456 high = ((((val - low) & (unsigned HOST_WIDE_INT) 0xffffffff) \
1457 ^ (unsigned HOST_WIDE_INT) 0x80000000) \
1458 - (unsigned HOST_WIDE_INT) 0x80000000); \
d5b7b3ae
RE
1459 /* Check for overflow or zero */ \
1460 if (low == 0 || high == 0 || (high + low != val)) \
1461 break; \
1462 \
1463 /* Reload the high part into a base reg; leave the low part \
1464 in the mem. */ \
1465 X = gen_rtx_PLUS (GET_MODE (X), \
1466 gen_rtx_PLUS (GET_MODE (X), XEXP (X, 0), \
1467 GEN_INT (high)), \
1468 GEN_INT (low)); \
df4ae160 1469 push_reload (XEXP (X, 0), NULL_RTX, &XEXP (X, 0), NULL, \
4a692617
NC
1470 MODE_BASE_REG_CLASS (MODE), GET_MODE (X), \
1471 VOIDmode, 0, 0, OPNUM, TYPE); \
d5b7b3ae
RE
1472 goto WIN; \
1473 } \
1474 } \
62b10bbc 1475 while (0)
6f734908 1476
27847754 1477/* XXX If an HImode FP+large_offset address is converted to an HImode
d5b7b3ae
RE
1478 SP+large_offset address, then reload won't know how to fix it. It sees
1479 only that SP isn't valid for HImode, and so reloads the SP into an index
1480 register, but the resulting address is still invalid because the offset
1481 is too big. We fix it here instead by reloading the entire address. */
1482/* We could probably achieve better results by defining PROMOTE_MODE to help
1483 cope with the variances between the Thumb's signed and unsigned byte and
1484 halfword load instructions. */
1485#define THUMB_LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_LEVELS, WIN) \
1486{ \
1487 if (GET_CODE (X) == PLUS \
1488 && GET_MODE_SIZE (MODE) < 4 \
1489 && GET_CODE (XEXP (X, 0)) == REG \
1490 && XEXP (X, 0) == stack_pointer_rtx \
1491 && GET_CODE (XEXP (X, 1)) == CONST_INT \
76a318e9 1492 && ! thumb_legitimate_offset_p (MODE, INTVAL (XEXP (X, 1)))) \
d5b7b3ae
RE
1493 { \
1494 rtx orig_X = X; \
1495 X = copy_rtx (X); \
df4ae160 1496 push_reload (orig_X, NULL_RTX, &X, NULL, \
4a692617 1497 MODE_BASE_REG_CLASS (MODE), \
d5b7b3ae
RE
1498 Pmode, VOIDmode, 0, 0, OPNUM, TYPE); \
1499 goto WIN; \
1500 } \
1501}
1502
1503#define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_LEVELS, WIN) \
1504 if (TARGET_ARM) \
1505 ARM_LEGITIMIZE_RELOAD_ADDRESS (X, MODE, OPNUM, TYPE, IND_LEVELS, WIN); \
1506 else \
1507 THUMB_LEGITIMIZE_RELOAD_ADDRESS (X, MODE, OPNUM, TYPE, IND_LEVELS, WIN)
1508
35d965d5
RS
1509/* Return the maximum number of consecutive registers
1510 needed to represent mode MODE in a register of class CLASS.
3b684012 1511 ARM regs are UNITS_PER_WORD bits while FPA regs can hold any FP mode */
35d965d5 1512#define CLASS_MAX_NREGS(CLASS, MODE) \
3b684012 1513 (((CLASS) == FPA_REGS || (CLASS) == CIRRUS_REGS) ? 1 : ARM_NUM_REGS (MODE))
9b6b54e2
NC
1514
1515/* If defined, gives a class of registers that cannot be used as the
1516 operand of a SUBREG that changes the mode of the object illegally. */
35d965d5 1517
3b684012 1518/* Moves between FPA_REGS and GENERAL_REGS are two memory insns. */
cf011243 1519#define REGISTER_MOVE_COST(MODE, FROM, TO) \
d5b7b3ae 1520 (TARGET_ARM ? \
3b684012
RE
1521 ((FROM) == FPA_REGS && (TO) != FPA_REGS ? 20 : \
1522 (FROM) != FPA_REGS && (TO) == FPA_REGS ? 20 : \
5a9335ef
NC
1523 (FROM) == IWMMXT_REGS && (TO) != IWMMXT_REGS ? 4 : \
1524 (FROM) != IWMMXT_REGS && (TO) == IWMMXT_REGS ? 4 : \
1525 (FROM) == IWMMXT_GR_REGS || (TO) == IWMMXT_GR_REGS ? 20 : \
9b6b54e2
NC
1526 (FROM) == CIRRUS_REGS && (TO) != CIRRUS_REGS ? 20 : \
1527 (FROM) != CIRRUS_REGS && (TO) == CIRRUS_REGS ? 20 : \
1528 2) \
d5b7b3ae
RE
1529 : \
1530 ((FROM) == HI_REGS || (TO) == HI_REGS) ? 4 : 2)
35d965d5
RS
1531\f
1532/* Stack layout; function entry, exit and calling. */
1533
1534/* Define this if pushing a word on the stack
1535 makes the stack pointer a smaller address. */
1536#define STACK_GROWS_DOWNWARD 1
1537
1538/* Define this if the nominal address of the stack frame
1539 is at the high-address end of the local variables;
1540 that is, each additional local variable allocated
1541 goes at a more negative offset in the frame. */
1542#define FRAME_GROWS_DOWNWARD 1
1543
1544/* Offset within stack frame to start allocating local variables at.
1545 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
1546 first local allocated. Otherwise, it is the offset to the BEGINNING
1547 of the first local allocated. */
1548#define STARTING_FRAME_OFFSET 0
1549
1550/* If we generate an insn to push BYTES bytes,
1551 this says how many the stack pointer really advances by. */
d5b7b3ae 1552/* The push insns do not do this rounding implicitly.
d6b4baa4 1553 So don't define this. */
0c2ca901 1554/* #define PUSH_ROUNDING(NPUSHED) ROUND_UP_WORD (NPUSHED) */
18543a22
ILT
1555
1556/* Define this if the maximum size of all the outgoing args is to be
1557 accumulated and pushed during the prologue. The amount can be
1558 found in the variable current_function_outgoing_args_size. */
6cfc7210 1559#define ACCUMULATE_OUTGOING_ARGS 1
35d965d5
RS
1560
1561/* Offset of first parameter from the argument pointer register value. */
d5b7b3ae 1562#define FIRST_PARM_OFFSET(FNDECL) (TARGET_ARM ? 4 : 0)
35d965d5
RS
1563
1564/* Value is the number of byte of arguments automatically
1565 popped when returning from a subroutine call.
8b109b37 1566 FUNDECL is the declaration node of the function (as a tree),
35d965d5
RS
1567 FUNTYPE is the data type of the function (as a tree),
1568 or for a library call it is an identifier node for the subroutine name.
1569 SIZE is the number of bytes of arguments passed on the stack.
1570
1571 On the ARM, the caller does not pop any of its arguments that were passed
1572 on the stack. */
6cfc7210 1573#define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, SIZE) 0
35d965d5
RS
1574
1575/* Define how to find the value returned by a library function
1576 assuming the value has mode MODE. */
1577#define LIBCALL_VALUE(MODE) \
d5b7b3ae
RE
1578 (TARGET_ARM && TARGET_HARD_FLOAT && GET_MODE_CLASS (MODE) == MODE_FLOAT \
1579 ? gen_rtx_REG (MODE, FIRST_ARM_FP_REGNUM) \
9b6b54e2
NC
1580 : TARGET_ARM && TARGET_CIRRUS && GET_MODE_CLASS (MODE) == MODE_FLOAT \
1581 ? gen_rtx_REG (MODE, FIRST_CIRRUS_FP_REGNUM) \
5a9335ef
NC
1582 : TARGET_REALLY_IWMMXT && VECTOR_MODE_SUPPORTED_P (MODE) \
1583 ? gen_rtx_REG (MODE, FIRST_IWMMXT_REGNUM) \
d5b7b3ae 1584 : gen_rtx_REG (MODE, ARG_REGISTER (1)))
35d965d5 1585
6cfc7210
NC
1586/* Define how to find the value returned by a function.
1587 VALTYPE is the data type of the value (as a tree).
1588 If the precise function being called is known, FUNC is its FUNCTION_DECL;
1589 otherwise, FUNC is 0. */
d5b7b3ae 1590#define FUNCTION_VALUE(VALTYPE, FUNC) \
6cfc7210
NC
1591 LIBCALL_VALUE (TYPE_MODE (VALTYPE))
1592
35d965d5
RS
1593/* 1 if N is a possible register number for a function value.
1594 On the ARM, only r0 and f0 can return results. */
9b6b54e2 1595/* On a Cirrus chip, mvf0 can return results. */
35d965d5 1596#define FUNCTION_VALUE_REGNO_P(REGNO) \
d5b7b3ae 1597 ((REGNO) == ARG_REGISTER (1) \
9b6b54e2 1598 || (TARGET_ARM && ((REGNO) == FIRST_CIRRUS_FP_REGNUM) && TARGET_CIRRUS) \
5a9335ef 1599 || (TARGET_ARM && ((REGNO) == FIRST_IWMMXT_REGNUM) && TARGET_IWMMXT) \
d5b7b3ae 1600 || (TARGET_ARM && ((REGNO) == FIRST_ARM_FP_REGNUM) && TARGET_HARD_FLOAT))
35d965d5 1601
11c1a207
RE
1602/* How large values are returned */
1603/* A C expression which can inhibit the returning of certain function values
d6b4baa4 1604 in registers, based on the type of value. */
f5a1b0d2 1605#define RETURN_IN_MEMORY(TYPE) arm_return_in_memory (TYPE)
11c1a207
RE
1606
1607/* Define DEFAULT_PCC_STRUCT_RETURN to 1 if all structure and union return
1608 values must be in memory. On the ARM, they need only do so if larger
d6b4baa4 1609 than a word, or if they contain elements offset from zero in the struct. */
11c1a207
RE
1610#define DEFAULT_PCC_STRUCT_RETURN 0
1611
d5b7b3ae
RE
1612/* Flags for the call/call_value rtl operations set up by function_arg. */
1613#define CALL_NORMAL 0x00000000 /* No special processing. */
1614#define CALL_LONG 0x00000001 /* Always call indirect. */
1615#define CALL_SHORT 0x00000002 /* Never call indirect. */
1616
6d3d9133
NC
1617/* These bits describe the different types of function supported
1618 by the ARM backend. They are exclusive. ie a function cannot be both a
1619 normal function and an interworked function, for example. Knowing the
1620 type of a function is important for determining its prologue and
1621 epilogue sequences.
1622 Note value 7 is currently unassigned. Also note that the interrupt
1623 function types all have bit 2 set, so that they can be tested for easily.
1624 Note that 0 is deliberately chosen for ARM_FT_UNKNOWN so that when the
4912a07c 1625 machine_function structure is initialized (to zero) func_type will
6d3d9133
NC
1626 default to unknown. This will force the first use of arm_current_func_type
1627 to call arm_compute_func_type. */
1628#define ARM_FT_UNKNOWN 0 /* Type has not yet been determined. */
1629#define ARM_FT_NORMAL 1 /* Your normal, straightforward function. */
1630#define ARM_FT_INTERWORKED 2 /* A function that supports interworking. */
1631#define ARM_FT_EXCEPTION_HANDLER 3 /* A C++ exception handler. */
1632#define ARM_FT_ISR 4 /* An interrupt service routine. */
1633#define ARM_FT_FIQ 5 /* A fast interrupt service routine. */
1634#define ARM_FT_EXCEPTION 6 /* An ARM exception handler (subcase of ISR). */
1635
1636#define ARM_FT_TYPE_MASK ((1 << 3) - 1)
1637
1638/* In addition functions can have several type modifiers,
1639 outlined by these bit masks: */
1640#define ARM_FT_INTERRUPT (1 << 2) /* Note overlap with FT_ISR and above. */
1641#define ARM_FT_NAKED (1 << 3) /* No prologue or epilogue. */
1642#define ARM_FT_VOLATILE (1 << 4) /* Does not return. */
d6b4baa4 1643#define ARM_FT_NESTED (1 << 5) /* Embedded inside another func. */
6d3d9133
NC
1644
1645/* Some macros to test these flags. */
1646#define ARM_FUNC_TYPE(t) (t & ARM_FT_TYPE_MASK)
1647#define IS_INTERRUPT(t) (t & ARM_FT_INTERRUPT)
1648#define IS_VOLATILE(t) (t & ARM_FT_VOLATILE)
1649#define IS_NAKED(t) (t & ARM_FT_NAKED)
1650#define IS_NESTED(t) (t & ARM_FT_NESTED)
1651
1652/* A C structure for machine-specific, per-function data.
1653 This is added to the cfun structure. */
e2500fed 1654typedef struct machine_function GTY(())
d5b7b3ae 1655{
6bc82793 1656 /* Additional stack adjustment in __builtin_eh_throw. */
e2500fed 1657 rtx eh_epilogue_sp_ofs;
d5b7b3ae
RE
1658 /* Records if LR has to be saved for far jumps. */
1659 int far_jump_used;
1660 /* Records if ARG_POINTER was ever live. */
1661 int arg_pointer_live;
6f7ebcbb
NC
1662 /* Records if the save of LR has been eliminated. */
1663 int lr_save_eliminated;
0977774b
JT
1664 /* The size of the stack frame. Only valid after reload. */
1665 int frame_size;
6d3d9133
NC
1666 /* Records the type of the current function. */
1667 unsigned long func_type;
3cb66fd7
NC
1668 /* Record if the function has a variable argument list. */
1669 int uses_anonymous_args;
5a9335ef
NC
1670 /* Records if sibcalls are blocked because an argument
1671 register is needed to preserve stack alignment. */
1672 int sibcall_blocked;
6d3d9133
NC
1673}
1674machine_function;
d5b7b3ae 1675
82e9d970
PB
1676/* A C type for declaring a variable that is used as the first argument of
1677 `FUNCTION_ARG' and other related values. For some target machines, the
1678 type `int' suffices and can hold the number of bytes of argument so far. */
1679typedef struct
1680{
d5b7b3ae 1681 /* This is the number of registers of arguments scanned so far. */
82e9d970 1682 int nregs;
5a9335ef
NC
1683 /* This is the number of iWMMXt register arguments scanned so far. */
1684 int iwmmxt_nregs;
1685 int named_count;
1686 int nargs;
d6b4baa4 1687 /* One of CALL_NORMAL, CALL_LONG or CALL_SHORT. */
82e9d970 1688 int call_cookie;
d5b7b3ae 1689} CUMULATIVE_ARGS;
82e9d970 1690
35d965d5
RS
1691/* Define where to put the arguments to a function.
1692 Value is zero to push the argument on the stack,
1693 or a hard register in which to store the argument.
1694
1695 MODE is the argument's machine mode.
1696 TYPE is the data type of the argument (as a tree).
1697 This is null for libcalls where that information may
1698 not be available.
1699 CUM is a variable of type CUMULATIVE_ARGS which gives info about
1700 the preceding args and about the function being called.
1701 NAMED is nonzero if this argument is a named parameter
1702 (otherwise it is an extra parameter matching an ellipsis).
1703
1704 On the ARM, normally the first 16 bytes are passed in registers r0-r3; all
1705 other arguments are passed on the stack. If (NAMED == 0) (which happens
1cc9f5f5
KH
1706 only in assign_parms, since TARGET_SETUP_INCOMING_VARARGS is
1707 defined), say it is passed in the stack (function_prologue will
1708 indeed make it pass in the stack if necessary). */
82e9d970
PB
1709#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1710 arm_function_arg (&(CUM), (MODE), (TYPE), (NAMED))
35d965d5
RS
1711
1712/* For an arg passed partly in registers and partly in memory,
1713 this is the number of registers used.
1714 For args passed entirely in registers or entirely in memory, zero. */
6cfc7210 1715#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
5a9335ef
NC
1716 (VECTOR_MODE_SUPPORTED_P (MODE) ? 0 : \
1717 NUM_ARG_REGS > (CUM).nregs \
e9d7b180 1718 && (NUM_ARG_REGS < ((CUM).nregs + ARM_NUM_REGS2 (MODE, TYPE))) \
82e9d970 1719 ? NUM_ARG_REGS - (CUM).nregs : 0)
35d965d5 1720
1741620c
JD
1721/* A C expression that indicates when an argument must be passed by
1722 reference. If nonzero for an argument, a copy of that argument is
1723 made in memory and a pointer to the argument is passed instead of
1724 the argument itself. The pointer is passed in whatever way is
1725 appropriate for passing a pointer to that type. */
1726#define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
1727 arm_function_arg_pass_by_reference (&CUM, MODE, TYPE, NAMED)
1728
35d965d5
RS
1729/* Initialize a variable CUM of type CUMULATIVE_ARGS
1730 for a call to a function whose data type is FNTYPE.
1731 For a library call, FNTYPE is 0.
1732 On the ARM, the offset starts at 0. */
563a317a
JH
1733#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL) \
1734 arm_init_cumulative_args (&(CUM), (FNTYPE), (LIBNAME), (FNDECL))
35d965d5
RS
1735
1736/* Update the data in CUM to advance over an argument
1737 of mode MODE and data type TYPE.
1738 (TYPE is null for libcalls where that information may not be available.) */
6cfc7210 1739#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
5a9335ef
NC
1740 (CUM).nargs += 1; \
1741 if (VECTOR_MODE_SUPPORTED_P (MODE)) \
1742 if ((CUM).named_count <= (CUM).nargs) \
1743 (CUM).nregs += 2; \
1744 else \
1745 (CUM).iwmmxt_nregs += 1; \
1746 else \
e9d7b180 1747 (CUM).nregs += ARM_NUM_REGS2 (MODE, TYPE)
35d965d5 1748
5a9335ef
NC
1749/* If defined, a C expression that gives the alignment boundary, in bits, of an
1750 argument with the specified mode and type. If it is not defined,
1751 `PARM_BOUNDARY' is used for all arguments. */
1752#define FUNCTION_ARG_BOUNDARY(MODE,TYPE) \
1753 (TARGET_REALLY_IWMMXT && (VALID_IWMMXT_REG_MODE (MODE) || ((MODE) == DFmode)) \
1754 ? IWMMXT_ALIGNMENT : PARM_BOUNDARY)
1755
35d965d5
RS
1756/* 1 if N is a possible register number for function argument passing.
1757 On the ARM, r0-r3 are used to pass args. */
5a9335ef
NC
1758#define FUNCTION_ARG_REGNO_P(REGNO) \
1759 (IN_RANGE ((REGNO), 0, 3) \
1760 || (TARGET_REALLY_IWMMXT && IN_RANGE ((REGNO), FIRST_IWMMXT_REGNUM, FIRST_IWMMXT_REGNUM + 9)))
35d965d5 1761
1741620c
JD
1762/* Implement `va_arg'. */
1763#define EXPAND_BUILTIN_VA_ARG(valist, type) \
1764 arm_va_arg (valist, type)
1765
f99fce0c 1766\f
afef3d7a
NC
1767/* If your target environment doesn't prefix user functions with an
1768 underscore, you may wish to re-define this to prevent any conflicts.
1769 e.g. AOF may prefix mcount with an underscore. */
1770#ifndef ARM_MCOUNT_NAME
1771#define ARM_MCOUNT_NAME "*mcount"
1772#endif
1773
1774/* Call the function profiler with a given profile label. The Acorn
1775 compiler puts this BEFORE the prolog but gcc puts it afterwards.
1776 On the ARM the full profile code will look like:
1777 .data
1778 LP1
1779 .word 0
1780 .text
1781 mov ip, lr
1782 bl mcount
1783 .word LP1
1784
1785 profile_function() in final.c outputs the .data section, FUNCTION_PROFILER
1786 will output the .text section.
1787
1788 The ``mov ip,lr'' seems like a good idea to stick with cc convention.
59be6073
AN
1789 ``prof'' doesn't seem to mind about this!
1790
1791 Note - this version of the code is designed to work in both ARM and
1792 Thumb modes. */
be393ecf 1793#ifndef ARM_FUNCTION_PROFILER
d5b7b3ae 1794#define ARM_FUNCTION_PROFILER(STREAM, LABELNO) \
6cfc7210
NC
1795{ \
1796 char temp[20]; \
1797 rtx sym; \
1798 \
dd18ae56 1799 asm_fprintf (STREAM, "\tmov\t%r, %r\n\tbl\t", \
d5b7b3ae 1800 IP_REGNUM, LR_REGNUM); \
6cfc7210
NC
1801 assemble_name (STREAM, ARM_MCOUNT_NAME); \
1802 fputc ('\n', STREAM); \
1803 ASM_GENERATE_INTERNAL_LABEL (temp, "LP", LABELNO); \
1804 sym = gen_rtx (SYMBOL_REF, Pmode, temp); \
301d03af 1805 assemble_aligned_integer (UNITS_PER_WORD, sym); \
35d965d5 1806}
be393ecf 1807#endif
35d965d5 1808
59be6073 1809#ifdef THUMB_FUNCTION_PROFILER
d5b7b3ae
RE
1810#define FUNCTION_PROFILER(STREAM, LABELNO) \
1811 if (TARGET_ARM) \
1812 ARM_FUNCTION_PROFILER (STREAM, LABELNO) \
1813 else \
1814 THUMB_FUNCTION_PROFILER (STREAM, LABELNO)
59be6073
AN
1815#else
1816#define FUNCTION_PROFILER(STREAM, LABELNO) \
1817 ARM_FUNCTION_PROFILER (STREAM, LABELNO)
1818#endif
d5b7b3ae 1819
35d965d5
RS
1820/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1821 the stack pointer does not matter. The value is tested only in
1822 functions that have frame pointers.
1823 No definition is equivalent to always zero.
1824
1825 On the ARM, the function epilogue recovers the stack pointer from the
1826 frame. */
1827#define EXIT_IGNORE_STACK 1
1828
c7861455
RE
1829#define EPILOGUE_USES(REGNO) (reload_completed && (REGNO) == LR_REGNUM)
1830
35d965d5
RS
1831/* Determine if the epilogue should be output as RTL.
1832 You should override this if you define FUNCTION_EXTRA_EPILOGUE. */
d5b7b3ae 1833#define USE_RETURN_INSN(ISCOND) \
a72d4945 1834 (TARGET_ARM ? use_return_insn (ISCOND, NULL) : 0)
ff9940b0
RE
1835
1836/* Definitions for register eliminations.
1837
1838 This is an array of structures. Each structure initializes one pair
1839 of eliminable registers. The "from" register number is given first,
1840 followed by "to". Eliminations of the same "from" register are listed
1841 in order of preference.
1842
1843 We have two registers that can be eliminated on the ARM. First, the
1844 arg pointer register can often be eliminated in favor of the stack
1845 pointer register. Secondly, the pseudo frame pointer register can always
1846 be eliminated; it is replaced with either the stack or the real frame
d5b7b3ae 1847 pointer. Note we have to use {ARM|THUMB}_HARD_FRAME_POINTER_REGNUM
d6a7951f 1848 because the definition of HARD_FRAME_POINTER_REGNUM is not a constant. */
ff9940b0 1849
d5b7b3ae
RE
1850#define ELIMINABLE_REGS \
1851{{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM },\
1852 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM },\
1853 { ARG_POINTER_REGNUM, ARM_HARD_FRAME_POINTER_REGNUM },\
1854 { ARG_POINTER_REGNUM, THUMB_HARD_FRAME_POINTER_REGNUM },\
1855 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM },\
1856 { FRAME_POINTER_REGNUM, ARM_HARD_FRAME_POINTER_REGNUM },\
1857 { FRAME_POINTER_REGNUM, THUMB_HARD_FRAME_POINTER_REGNUM }}
ff9940b0 1858
d5b7b3ae
RE
1859/* Given FROM and TO register numbers, say whether this elimination is
1860 allowed. Frame pointer elimination is automatically handled.
ff9940b0
RE
1861
1862 All eliminations are permissible. Note that ARG_POINTER_REGNUM and
abc95ed3 1863 HARD_FRAME_POINTER_REGNUM are in fact the same thing. If we need a frame
ff9940b0 1864 pointer, we must eliminate FRAME_POINTER_REGNUM into
d5b7b3ae
RE
1865 HARD_FRAME_POINTER_REGNUM and not into STACK_POINTER_REGNUM or
1866 ARG_POINTER_REGNUM. */
1867#define CAN_ELIMINATE(FROM, TO) \
1868 (((TO) == FRAME_POINTER_REGNUM && (FROM) == ARG_POINTER_REGNUM) ? 0 : \
1869 ((TO) == STACK_POINTER_REGNUM && frame_pointer_needed) ? 0 : \
1870 ((TO) == ARM_HARD_FRAME_POINTER_REGNUM && TARGET_THUMB) ? 0 : \
1871 ((TO) == THUMB_HARD_FRAME_POINTER_REGNUM && TARGET_ARM) ? 0 : \
1872 1)
aeaf4d25
AN
1873
1874#define THUMB_REG_PUSHED_P(reg) \
1875 (regs_ever_live [reg] \
1876 && (! call_used_regs [reg] \
1877 || (flag_pic && (reg) == PIC_OFFSET_TABLE_REGNUM)) \
1878 && !(TARGET_SINGLE_PIC_BASE && ((reg) == arm_pic_register)))
1879
d5b7b3ae
RE
1880/* Define the offset between two registers, one to be eliminated, and the
1881 other its replacement, at the start of a routine. */
1882#define ARM_INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
095bb276 1883 do \
ff9940b0 1884 { \
095bb276 1885 (OFFSET) = arm_compute_initial_elimination_offset (FROM, TO); \
ff9940b0 1886 } \
095bb276 1887 while (0)
35d965d5 1888
d5b7b3ae
RE
1889/* Note: This macro must match the code in thumb_function_prologue(). */
1890#define THUMB_INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1891{ \
1892 (OFFSET) = 0; \
1893 if ((FROM) == ARG_POINTER_REGNUM) \
1894 { \
1895 int count_regs = 0; \
1896 int regno; \
1897 for (regno = 8; regno < 13; regno ++) \
aeaf4d25
AN
1898 if (THUMB_REG_PUSHED_P (regno)) \
1899 count_regs ++; \
d5b7b3ae
RE
1900 if (count_regs) \
1901 (OFFSET) += 4 * count_regs; \
1902 count_regs = 0; \
1903 for (regno = 0; regno <= LAST_LO_REGNUM; regno ++) \
aeaf4d25 1904 if (THUMB_REG_PUSHED_P (regno)) \
d5b7b3ae
RE
1905 count_regs ++; \
1906 if (count_regs || ! leaf_function_p () || thumb_far_jump_used_p (0))\
1907 (OFFSET) += 4 * (count_regs + 1); \
1908 if (TARGET_BACKTRACE) \
1909 { \
1910 if ((count_regs & 0xFF) == 0 && (regs_ever_live[3] != 0)) \
1911 (OFFSET) += 20; \
1912 else \
1913 (OFFSET) += 16; \
1914 } \
1915 } \
1916 if ((TO) == STACK_POINTER_REGNUM) \
1917 { \
1918 (OFFSET) += current_function_outgoing_args_size; \
0977774b 1919 (OFFSET) += thumb_get_frame_size (); \
d5b7b3ae
RE
1920 } \
1921}
1922
1923#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1924 if (TARGET_ARM) \
095bb276 1925 ARM_INITIAL_ELIMINATION_OFFSET (FROM, TO, OFFSET); \
d5b7b3ae
RE
1926 else \
1927 THUMB_INITIAL_ELIMINATION_OFFSET (FROM, TO, OFFSET)
1928
1929/* Special case handling of the location of arguments passed on the stack. */
1930#define DEBUGGER_ARG_OFFSET(value, addr) value ? value : arm_debugger_arg_offset (value, addr)
1931
1932/* Initialize data used by insn expanders. This is called from insn_emit,
1933 once for every function before code is generated. */
1934#define INIT_EXPANDERS arm_init_expanders ()
1935
35d965d5
RS
1936/* Output assembler code for a block containing the constant parts
1937 of a trampoline, leaving space for the variable parts.
1938
1939 On the ARM, (if r8 is the static chain regnum, and remembering that
1940 referencing pc adds an offset of 8) the trampoline looks like:
1941 ldr r8, [pc, #0]
1942 ldr pc, [pc]
1943 .word static chain value
11c1a207 1944 .word function's address
27847754 1945 XXX FIXME: When the trampoline returns, r8 will be clobbered. */
301d03af
RS
1946#define ARM_TRAMPOLINE_TEMPLATE(FILE) \
1947{ \
1948 asm_fprintf (FILE, "\tldr\t%r, [%r, #0]\n", \
1949 STATIC_CHAIN_REGNUM, PC_REGNUM); \
1950 asm_fprintf (FILE, "\tldr\t%r, [%r, #0]\n", \
1951 PC_REGNUM, PC_REGNUM); \
1952 assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \
1953 assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \
d5b7b3ae
RE
1954}
1955
1956/* On the Thumb we always switch into ARM mode to execute the trampoline.
1957 Why - because it is easier. This code will always be branched to via
1958 a BX instruction and since the compiler magically generates the address
1959 of the function the linker has no opportunity to ensure that the
1960 bottom bit is set. Thus the processor will be in ARM mode when it
1961 reaches this code. So we duplicate the ARM trampoline code and add
1962 a switch into Thumb mode as well. */
1963#define THUMB_TRAMPOLINE_TEMPLATE(FILE) \
1964{ \
1965 fprintf (FILE, "\t.code 32\n"); \
1966 fprintf (FILE, ".Ltrampoline_start:\n"); \
1967 asm_fprintf (FILE, "\tldr\t%r, [%r, #8]\n", \
1968 STATIC_CHAIN_REGNUM, PC_REGNUM); \
1969 asm_fprintf (FILE, "\tldr\t%r, [%r, #8]\n", \
1970 IP_REGNUM, PC_REGNUM); \
1971 asm_fprintf (FILE, "\torr\t%r, %r, #1\n", \
1972 IP_REGNUM, IP_REGNUM); \
1973 asm_fprintf (FILE, "\tbx\t%r\n", IP_REGNUM); \
1974 fprintf (FILE, "\t.word\t0\n"); \
1975 fprintf (FILE, "\t.word\t0\n"); \
1976 fprintf (FILE, "\t.code 16\n"); \
35d965d5
RS
1977}
1978
d5b7b3ae
RE
1979#define TRAMPOLINE_TEMPLATE(FILE) \
1980 if (TARGET_ARM) \
1981 ARM_TRAMPOLINE_TEMPLATE (FILE) \
1982 else \
1983 THUMB_TRAMPOLINE_TEMPLATE (FILE)
1984
35d965d5 1985/* Length in units of the trampoline for entering a nested function. */
d5b7b3ae 1986#define TRAMPOLINE_SIZE (TARGET_ARM ? 16 : 24)
35d965d5 1987
006946e4
JM
1988/* Alignment required for a trampoline in bits. */
1989#define TRAMPOLINE_ALIGNMENT 32
35d965d5
RS
1990
1991/* Emit RTL insns to initialize the variable parts of a trampoline.
1992 FNADDR is an RTX for the address of the function's pure code.
1993 CXT is an RTX for the static chain value for the function. */
192c8d78
RE
1994#ifndef INITIALIZE_TRAMPOLINE
1995#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
1996{ \
1997 emit_move_insn (gen_rtx_MEM (SImode, \
1998 plus_constant (TRAMP, \
1999 TARGET_ARM ? 8 : 16)), \
2000 CXT); \
2001 emit_move_insn (gen_rtx_MEM (SImode, \
2002 plus_constant (TRAMP, \
2003 TARGET_ARM ? 12 : 20)), \
2004 FNADDR); \
35d965d5 2005}
192c8d78 2006#endif
35d965d5 2007
35d965d5
RS
2008\f
2009/* Addressing modes, and classification of registers for them. */
3cd45774
RE
2010#define HAVE_POST_INCREMENT 1
2011#define HAVE_PRE_INCREMENT TARGET_ARM
2012#define HAVE_POST_DECREMENT TARGET_ARM
2013#define HAVE_PRE_DECREMENT TARGET_ARM
2014#define HAVE_PRE_MODIFY_DISP TARGET_ARM
2015#define HAVE_POST_MODIFY_DISP TARGET_ARM
2016#define HAVE_PRE_MODIFY_REG TARGET_ARM
2017#define HAVE_POST_MODIFY_REG TARGET_ARM
35d965d5
RS
2018
2019/* Macros to check register numbers against specific register classes. */
2020
2021/* These assume that REGNO is a hard or pseudo reg number.
2022 They give nonzero only if REGNO is a hard reg of the suitable class
2023 or a pseudo reg currently allocated to a suitable hard reg.
2024 Since they use reg_renumber, they are safe only once reg_renumber
d6b4baa4 2025 has been allocated, which happens in local-alloc.c. */
d5b7b3ae
RE
2026#define TEST_REGNO(R, TEST, VALUE) \
2027 ((R TEST VALUE) || ((unsigned) reg_renumber[R] TEST VALUE))
2028
2029/* On the ARM, don't allow the pc to be used. */
f1008e52
RE
2030#define ARM_REGNO_OK_FOR_BASE_P(REGNO) \
2031 (TEST_REGNO (REGNO, <, PC_REGNUM) \
2032 || TEST_REGNO (REGNO, ==, FRAME_POINTER_REGNUM) \
2033 || TEST_REGNO (REGNO, ==, ARG_POINTER_REGNUM))
2034
2035#define THUMB_REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) \
2036 (TEST_REGNO (REGNO, <=, LAST_LO_REGNUM) \
2037 || (GET_MODE_SIZE (MODE) >= 4 \
2038 && TEST_REGNO (REGNO, ==, STACK_POINTER_REGNUM)))
2039
2040#define REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) \
2041 (TARGET_THUMB \
2042 ? THUMB_REGNO_MODE_OK_FOR_BASE_P (REGNO, MODE) \
2043 : ARM_REGNO_OK_FOR_BASE_P (REGNO))
2044
2045/* For ARM code, we don't care about the mode, but for Thumb, the index
2046 must be suitable for use in a QImode load. */
d5b7b3ae
RE
2047#define REGNO_OK_FOR_INDEX_P(REGNO) \
2048 REGNO_MODE_OK_FOR_BASE_P (REGNO, QImode)
35d965d5
RS
2049
2050/* Maximum number of registers that can appear in a valid memory address.
d6b4baa4 2051 Shifts in addresses can't be by a register. */
ff9940b0 2052#define MAX_REGS_PER_ADDRESS 2
35d965d5
RS
2053
2054/* Recognize any constant value that is a valid address. */
2055/* XXX We can address any constant, eventually... */
11c1a207
RE
2056
2057#ifdef AOF_ASSEMBLER
2058
2059#define CONSTANT_ADDRESS_P(X) \
d5b7b3ae 2060 (GET_CODE (X) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (X))
11c1a207
RE
2061
2062#else
35d965d5 2063
008cf58a
RE
2064#define CONSTANT_ADDRESS_P(X) \
2065 (GET_CODE (X) == SYMBOL_REF \
2066 && (CONSTANT_POOL_ADDRESS_P (X) \
d5b7b3ae 2067 || (TARGET_ARM && optimize > 0 && SYMBOL_REF_FLAG (X))))
35d965d5 2068
11c1a207
RE
2069#endif /* AOF_ASSEMBLER */
2070
35d965d5
RS
2071/* Nonzero if the constant value X is a legitimate general operand.
2072 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.
2073
2074 On the ARM, allow any integer (invalid ones are removed later by insn
2075 patterns), nice doubles and symbol_refs which refer to the function's
d5b7b3ae 2076 constant pool XXX.
82e9d970
PB
2077
2078 When generating pic allow anything. */
d5b7b3ae
RE
2079#define ARM_LEGITIMATE_CONSTANT_P(X) (flag_pic || ! label_mentioned_p (X))
2080
2081#define THUMB_LEGITIMATE_CONSTANT_P(X) \
2082 ( GET_CODE (X) == CONST_INT \
2083 || GET_CODE (X) == CONST_DOUBLE \
7b8781c8
PB
2084 || CONSTANT_ADDRESS_P (X) \
2085 || flag_pic)
d5b7b3ae
RE
2086
2087#define LEGITIMATE_CONSTANT_P(X) \
2088 (TARGET_ARM ? ARM_LEGITIMATE_CONSTANT_P (X) : THUMB_LEGITIMATE_CONSTANT_P (X))
2089
c27ba912
DM
2090/* Special characters prefixed to function names
2091 in order to encode attribute like information.
2092 Note, '@' and '*' have already been taken. */
2093#define SHORT_CALL_FLAG_CHAR '^'
2094#define LONG_CALL_FLAG_CHAR '#'
2095
2096#define ENCODED_SHORT_CALL_ATTR_P(SYMBOL_NAME) \
2097 (*(SYMBOL_NAME) == SHORT_CALL_FLAG_CHAR)
2098
2099#define ENCODED_LONG_CALL_ATTR_P(SYMBOL_NAME) \
2100 (*(SYMBOL_NAME) == LONG_CALL_FLAG_CHAR)
2101
2102#ifndef SUBTARGET_NAME_ENCODING_LENGTHS
2103#define SUBTARGET_NAME_ENCODING_LENGTHS
2104#endif
2105
6bc82793 2106/* This is a C fragment for the inside of a switch statement.
c27ba912
DM
2107 Each case label should return the number of characters to
2108 be stripped from the start of a function's name, if that
2109 name starts with the indicated character. */
2110#define ARM_NAME_ENCODING_LENGTHS \
2111 case SHORT_CALL_FLAG_CHAR: return 1; \
2112 case LONG_CALL_FLAG_CHAR: return 1; \
00fdafef 2113 case '*': return 1; \
c27ba912
DM
2114 SUBTARGET_NAME_ENCODING_LENGTHS
2115
c27ba912
DM
2116/* This is how to output a reference to a user-level label named NAME.
2117 `assemble_name' uses this. */
e5951263 2118#undef ASM_OUTPUT_LABELREF
c27ba912 2119#define ASM_OUTPUT_LABELREF(FILE, NAME) \
e1944073 2120 arm_asm_output_labelref (FILE, NAME)
c27ba912 2121
c27ba912
DM
2122#define ARM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL) \
2123 arm_encode_call_attribute (DECL, SHORT_CALL_FLAG_CHAR)
2124
35d965d5
RS
2125/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
2126 and check its validity for a certain class.
2127 We have two alternate definitions for each of them.
2128 The usual definition accepts all pseudo regs; the other rejects
2129 them unless they have been allocated suitable hard regs.
2130 The symbol REG_OK_STRICT causes the latter definition to be used. */
2131#ifndef REG_OK_STRICT
ff9940b0 2132
f1008e52
RE
2133#define ARM_REG_OK_FOR_BASE_P(X) \
2134 (REGNO (X) <= LAST_ARM_REGNUM \
2135 || REGNO (X) >= FIRST_PSEUDO_REGISTER \
2136 || REGNO (X) == FRAME_POINTER_REGNUM \
2137 || REGNO (X) == ARG_POINTER_REGNUM)
ff9940b0 2138
f1008e52
RE
2139#define THUMB_REG_MODE_OK_FOR_BASE_P(X, MODE) \
2140 (REGNO (X) <= LAST_LO_REGNUM \
2141 || REGNO (X) >= FIRST_PSEUDO_REGISTER \
2142 || (GET_MODE_SIZE (MODE) >= 4 \
2143 && (REGNO (X) == STACK_POINTER_REGNUM \
2144 || (X) == hard_frame_pointer_rtx \
2145 || (X) == arg_pointer_rtx)))
ff9940b0 2146
76a318e9
RE
2147#define REG_STRICT_P 0
2148
d5b7b3ae 2149#else /* REG_OK_STRICT */
ff9940b0 2150
f1008e52
RE
2151#define ARM_REG_OK_FOR_BASE_P(X) \
2152 ARM_REGNO_OK_FOR_BASE_P (REGNO (X))
ff9940b0 2153
f1008e52
RE
2154#define THUMB_REG_MODE_OK_FOR_BASE_P(X, MODE) \
2155 THUMB_REGNO_MODE_OK_FOR_BASE_P (REGNO (X), MODE)
ff9940b0 2156
76a318e9
RE
2157#define REG_STRICT_P 1
2158
d5b7b3ae 2159#endif /* REG_OK_STRICT */
f1008e52
RE
2160
2161/* Now define some helpers in terms of the above. */
2162
2163#define REG_MODE_OK_FOR_BASE_P(X, MODE) \
2164 (TARGET_THUMB \
2165 ? THUMB_REG_MODE_OK_FOR_BASE_P (X, MODE) \
2166 : ARM_REG_OK_FOR_BASE_P (X))
2167
2168#define ARM_REG_OK_FOR_INDEX_P(X) ARM_REG_OK_FOR_BASE_P (X)
2169
2170/* For Thumb, a valid index register is anything that can be used in
2171 a byte load instruction. */
2172#define THUMB_REG_OK_FOR_INDEX_P(X) THUMB_REG_MODE_OK_FOR_BASE_P (X, QImode)
2173
2174/* Nonzero if X is a hard reg that can be used as an index
2175 or if it is a pseudo reg. On the Thumb, the stack pointer
2176 is not suitable. */
2177#define REG_OK_FOR_INDEX_P(X) \
2178 (TARGET_THUMB \
2179 ? THUMB_REG_OK_FOR_INDEX_P (X) \
2180 : ARM_REG_OK_FOR_INDEX_P (X))
2181
35d965d5
RS
2182\f
2183/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
2184 that is a valid memory address for an instruction.
2185 The MODE argument is the machine mode for the MEM expression
76a318e9 2186 that wants to use this address. */
d5b7b3ae 2187
f1008e52
RE
2188#define ARM_BASE_REGISTER_RTX_P(X) \
2189 (GET_CODE (X) == REG && ARM_REG_OK_FOR_BASE_P (X))
35d965d5 2190
f1008e52
RE
2191#define ARM_INDEX_REGISTER_RTX_P(X) \
2192 (GET_CODE (X) == REG && ARM_REG_OK_FOR_INDEX_P (X))
35d965d5 2193
76a318e9
RE
2194#define ARM_GO_IF_LEGITIMATE_ADDRESS(MODE,X,WIN) \
2195 { \
2196 if (arm_legitimate_address_p (MODE, X, REG_STRICT_P)) \
2197 goto WIN; \
6b990f6b 2198 }
d5b7b3ae 2199
76a318e9
RE
2200#define THUMB_GO_IF_LEGITIMATE_ADDRESS(MODE,X,WIN) \
2201 { \
2202 if (thumb_legitimate_address_p (MODE, X, REG_STRICT_P)) \
2203 goto WIN; \
2204 }
d5b7b3ae 2205
d5b7b3ae
RE
2206#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, WIN) \
2207 if (TARGET_ARM) \
2208 ARM_GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN) \
2209 else /* if (TARGET_THUMB) */ \
2210 THUMB_GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN)
76a318e9 2211
35d965d5
RS
2212\f
2213/* Try machine-dependent ways of modifying an illegitimate address
ccf4d512
RE
2214 to be legitimate. If we find one, return the new, valid address. */
2215#define ARM_LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
2216do { \
2217 X = arm_legitimize_address (X, OLDX, MODE); \
2218 \
2219 if (memory_address_p (MODE, X)) \
2220 goto WIN; \
2221} while (0)
2222
2223#define THUMB_LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
2224do { \
2225 if (flag_pic) \
2226 (X) = legitimize_pic_address (OLDX, MODE, NULL_RTX); \
2227} while (0)
2228
2229#define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
2230do { \
2231 if (TARGET_ARM) \
2232 ARM_LEGITIMIZE_ADDRESS (X, OLDX, MODE, WIN); \
2233 else \
2234 THUMB_LEGITIMIZE_ADDRESS (X, OLDX, MODE, WIN); \
2235} while (0)
d5b7b3ae 2236
35d965d5
RS
2237/* Go to LABEL if ADDR (a legitimate address expression)
2238 has an effect that depends on the machine mode it is used for. */
d5b7b3ae 2239#define ARM_GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) \
35d965d5 2240{ \
d5b7b3ae
RE
2241 if ( GET_CODE (ADDR) == PRE_DEC || GET_CODE (ADDR) == POST_DEC \
2242 || GET_CODE (ADDR) == PRE_INC || GET_CODE (ADDR) == POST_INC) \
35d965d5
RS
2243 goto LABEL; \
2244}
d5b7b3ae
RE
2245
2246/* Nothing helpful to do for the Thumb */
2247#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) \
2248 if (TARGET_ARM) \
2249 ARM_GO_IF_MODE_DEPENDENT_ADDRESS (ADDR, LABEL)
35d965d5 2250\f
d5b7b3ae 2251
35d965d5
RS
2252/* Specify the machine mode that this machine uses
2253 for the index in the tablejump instruction. */
d5b7b3ae 2254#define CASE_VECTOR_MODE Pmode
35d965d5 2255
18543a22
ILT
2256/* Define as C expression which evaluates to nonzero if the tablejump
2257 instruction expects the table to contain offsets from the address of the
2258 table.
d6b4baa4 2259 Do not define this if the table should contain absolute addresses. */
18543a22 2260/* #define CASE_VECTOR_PC_RELATIVE 1 */
35d965d5 2261
ff9940b0
RE
2262/* signed 'char' is most compatible, but RISC OS wants it unsigned.
2263 unsigned is probably best, but may break some code. */
2264#ifndef DEFAULT_SIGNED_CHAR
3967692c 2265#define DEFAULT_SIGNED_CHAR 0
35d965d5
RS
2266#endif
2267
2268/* Don't cse the address of the function being compiled. */
2269#define NO_RECURSIVE_FUNCTION_CSE 1
2270
2271/* Max number of bytes we can move from memory to memory
d17ce9af
TG
2272 in one reasonably fast instruction. */
2273#define MOVE_MAX 4
35d965d5 2274
d19fb8e3 2275#undef MOVE_RATIO
591af218 2276#define MOVE_RATIO (arm_tune_xscale ? 4 : 2)
d19fb8e3 2277
ff9940b0
RE
2278/* Define if operations between registers always perform the operation
2279 on the full register even if a narrower mode is specified. */
2280#define WORD_REGISTER_OPERATIONS
2281
2282/* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
2283 will either zero-extend or sign-extend. The value of this macro should
2284 be the code that says which one of the two operations is implicitly
2285 done, NIL if none. */
9c872872 2286#define LOAD_EXTEND_OP(MODE) \
d5b7b3ae
RE
2287 (TARGET_THUMB ? ZERO_EXTEND : \
2288 ((arm_arch4 || (MODE) == QImode) ? ZERO_EXTEND \
2289 : ((BYTES_BIG_ENDIAN && (MODE) == HImode) ? SIGN_EXTEND : NIL)))
ff9940b0 2290
35d965d5
RS
2291/* Nonzero if access to memory by bytes is slow and undesirable. */
2292#define SLOW_BYTE_ACCESS 0
2293
d5b7b3ae
RE
2294#define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) 1
2295
35d965d5
RS
2296/* Immediate shift counts are truncated by the output routines (or was it
2297 the assembler?). Shift counts in a register are truncated by ARM. Note
2298 that the native compiler puts too large (> 32) immediate shift counts
2299 into a register and shifts by the register, letting the ARM decide what
2300 to do instead of doing that itself. */
ff9940b0
RE
2301/* This is all wrong. Defining SHIFT_COUNT_TRUNCATED tells combine that
2302 code like (X << (Y % 32)) for register X, Y is equivalent to (X << Y).
2303 On the arm, Y in a register is used modulo 256 for the shift. Only for
d6b4baa4 2304 rotates is modulo 32 used. */
ff9940b0 2305/* #define SHIFT_COUNT_TRUNCATED 1 */
35d965d5 2306
35d965d5 2307/* All integers have the same format so truncation is easy. */
d5b7b3ae 2308#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
35d965d5
RS
2309
2310/* Calling from registers is a massive pain. */
2311#define NO_FUNCTION_CSE 1
2312
35d965d5
RS
2313/* The machine modes of pointers and functions */
2314#define Pmode SImode
2315#define FUNCTION_MODE Pmode
2316
d5b7b3ae
RE
2317#define ARM_FRAME_RTX(X) \
2318 ( (X) == frame_pointer_rtx || (X) == stack_pointer_rtx \
3967692c
RE
2319 || (X) == arg_pointer_rtx)
2320
ff9940b0 2321/* Moves to and from memory are quite expensive */
d5b7b3ae
RE
2322#define MEMORY_MOVE_COST(M, CLASS, IN) \
2323 (TARGET_ARM ? 10 : \
2324 ((GET_MODE_SIZE (M) < 4 ? 8 : 2 * GET_MODE_SIZE (M)) \
2325 * (CLASS == LO_REGS ? 1 : 2)))
2326
ff9940b0
RE
2327/* Try to generate sequences that don't involve branches, we can then use
2328 conditional instructions */
d5b7b3ae
RE
2329#define BRANCH_COST \
2330 (TARGET_ARM ? 4 : (optimize > 1 ? 1 : 0))
7a801826
RE
2331\f
2332/* Position Independent Code. */
2333/* We decide which register to use based on the compilation options and
2334 the assembler in use; this is more general than the APCS restriction of
2335 using sb (r9) all the time. */
2336extern int arm_pic_register;
2337
ed0e6530
PB
2338/* Used when parsing command line option -mpic-register=. */
2339extern const char * arm_pic_register_string;
2340
7a801826
RE
2341/* The register number of the register used to address a table of static
2342 data addresses in memory. */
2343#define PIC_OFFSET_TABLE_REGNUM arm_pic_register
2344
c1163e75 2345#define FINALIZE_PIC arm_finalize_pic (1)
7a801826 2346
f5a1b0d2
NC
2347/* We can't directly access anything that contains a symbol,
2348 nor can we indirect via the constant pool. */
82e9d970 2349#define LEGITIMATE_PIC_OPERAND_P(X) \
1575c31e
JD
2350 (!(symbol_mentioned_p (X) \
2351 || label_mentioned_p (X) \
2352 || (GET_CODE (X) == SYMBOL_REF \
2353 && CONSTANT_POOL_ADDRESS_P (X) \
2354 && (symbol_mentioned_p (get_pool_constant (X)) \
2355 || label_mentioned_p (get_pool_constant (X))))))
2356
13bd191d
PB
2357/* We need to know when we are making a constant pool; this determines
2358 whether data needs to be in the GOT or can be referenced via a GOT
2359 offset. */
2360extern int making_const_table;
82e9d970 2361\f
c27ba912 2362/* Handle pragmas for compatibility with Intel's compilers. */
c58b209a
NB
2363#define REGISTER_TARGET_PRAGMAS() do { \
2364 c_register_pragma (0, "long_calls", arm_pr_long_calls); \
2365 c_register_pragma (0, "no_long_calls", arm_pr_no_long_calls); \
2366 c_register_pragma (0, "long_calls_off", arm_pr_long_calls_off); \
8b97c5f8
ZW
2367} while (0)
2368
d6b4baa4 2369/* Condition code information. */
ff9940b0 2370/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
a5381466 2371 return the mode to be used for the comparison. */
d5b7b3ae
RE
2372
2373#define SELECT_CC_MODE(OP, X, Y) arm_select_cc_mode (OP, X, Y)
ff9940b0 2374
008cf58a
RE
2375#define REVERSIBLE_CC_MODE(MODE) ((MODE) != CCFPEmode)
2376
62b10bbc
NC
2377#define CANONICALIZE_COMPARISON(CODE, OP0, OP1) \
2378 do \
2379 { \
2380 if (GET_CODE (OP1) == CONST_INT \
2381 && ! (const_ok_for_arm (INTVAL (OP1)) \
2382 || (const_ok_for_arm (- INTVAL (OP1))))) \
2383 { \
2384 rtx const_op = OP1; \
2385 CODE = arm_canonicalize_comparison ((CODE), &const_op); \
2386 OP1 = const_op; \
2387 } \
2388 } \
2389 while (0)
62dd06ea 2390
7dba8395
RH
2391/* The arm5 clz instruction returns 32. */
2392#define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 32, 1)
35d965d5 2393\f
d5b7b3ae
RE
2394#undef ASM_APP_OFF
2395#define ASM_APP_OFF (TARGET_THUMB ? "\t.code\t16\n" : "")
35d965d5 2396
35d965d5 2397/* Output a push or a pop instruction (only used when profiling). */
d5b7b3ae 2398#define ASM_OUTPUT_REG_PUSH(STREAM, REGNO) \
8a81cc45
RE
2399 do \
2400 { \
2401 if (TARGET_ARM) \
2402 asm_fprintf (STREAM,"\tstmfd\t%r!,{%r}\n", \
2403 STACK_POINTER_REGNUM, REGNO); \
2404 else \
2405 asm_fprintf (STREAM, "\tpush {%r}\n", REGNO); \
2406 } while (0)
d5b7b3ae
RE
2407
2408
2409#define ASM_OUTPUT_REG_POP(STREAM, REGNO) \
8a81cc45
RE
2410 do \
2411 { \
2412 if (TARGET_ARM) \
2413 asm_fprintf (STREAM, "\tldmfd\t%r!,{%r}\n", \
2414 STACK_POINTER_REGNUM, REGNO); \
2415 else \
2416 asm_fprintf (STREAM, "\tpop {%r}\n", REGNO); \
2417 } while (0)
d5b7b3ae
RE
2418
2419/* This is how to output a label which precedes a jumptable. Since
2420 Thumb instructions are 2 bytes, we may need explicit alignment here. */
be393ecf 2421#undef ASM_OUTPUT_CASE_LABEL
d5b7b3ae
RE
2422#define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
2423 do \
2424 { \
2425 if (TARGET_THUMB) \
2426 ASM_OUTPUT_ALIGN (FILE, 2); \
8a81cc45 2427 (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); \
d5b7b3ae
RE
2428 } \
2429 while (0)
35d965d5 2430
6cfc7210
NC
2431#define ARM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
2432 do \
2433 { \
d5b7b3ae
RE
2434 if (TARGET_THUMB) \
2435 { \
2436 if (is_called_in_ARM_mode (DECL)) \
2437 fprintf (STREAM, "\t.code 32\n") ; \
2438 else \
2439 fprintf (STREAM, "\t.thumb_func\n") ; \
2440 } \
6cfc7210 2441 if (TARGET_POKE_FUNCTION_NAME) \
6354dc9b 2442 arm_poke_function_name (STREAM, (char *) NAME); \
6cfc7210
NC
2443 } \
2444 while (0)
35d965d5 2445
d5b7b3ae
RE
2446/* For aliases of functions we use .thumb_set instead. */
2447#define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL1, DECL2) \
2448 do \
2449 { \
91ea4f8d
KG
2450 const char *const LABEL1 = XSTR (XEXP (DECL_RTL (decl), 0), 0); \
2451 const char *const LABEL2 = IDENTIFIER_POINTER (DECL2); \
d5b7b3ae
RE
2452 \
2453 if (TARGET_THUMB && TREE_CODE (DECL1) == FUNCTION_DECL) \
2454 { \
2455 fprintf (FILE, "\t.thumb_set "); \
2456 assemble_name (FILE, LABEL1); \
2457 fprintf (FILE, ","); \
2458 assemble_name (FILE, LABEL2); \
2459 fprintf (FILE, "\n"); \
2460 } \
2461 else \
2462 ASM_OUTPUT_DEF (FILE, LABEL1, LABEL2); \
2463 } \
2464 while (0)
2465
fdc2d3b0
NC
2466#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
2467/* To support -falign-* switches we need to use .p2align so
2468 that alignment directives in code sections will be padded
2469 with no-op instructions, rather than zeroes. */
5a9335ef 2470#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \
fdc2d3b0
NC
2471 if ((LOG) != 0) \
2472 { \
2473 if ((MAX_SKIP) == 0) \
5a9335ef 2474 fprintf ((FILE), "\t.p2align %d\n", (int) (LOG)); \
fdc2d3b0
NC
2475 else \
2476 fprintf ((FILE), "\t.p2align %d,,%d\n", \
5a9335ef 2477 (int) (LOG), (int) (MAX_SKIP)); \
fdc2d3b0
NC
2478 }
2479#endif
35d965d5 2480\f
35d965d5 2481/* Only perform branch elimination (by making instructions conditional) if
72ac76be 2482 we're optimizing. Otherwise it's of no use anyway. */
d5b7b3ae
RE
2483#define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
2484 if (TARGET_ARM && optimize) \
2485 arm_final_prescan_insn (INSN); \
2486 else if (TARGET_THUMB) \
2487 thumb_final_prescan_insn (INSN)
35d965d5 2488
7bc7696c 2489#define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
d5b7b3ae
RE
2490 (CODE == '@' || CODE == '|' \
2491 || (TARGET_ARM && (CODE == '?')) \
2492 || (TARGET_THUMB && (CODE == '_')))
6cfc7210 2493
7bc7696c 2494/* Output an operand of an instruction. */
35d965d5 2495#define PRINT_OPERAND(STREAM, X, CODE) \
7bc7696c
RE
2496 arm_print_operand (STREAM, X, CODE)
2497
7b8b8ade
NC
2498#define ARM_SIGN_EXTEND(x) ((HOST_WIDE_INT) \
2499 (HOST_BITS_PER_WIDE_INT <= 32 ? (unsigned HOST_WIDE_INT) (x) \
30cf4896
KG
2500 : ((((unsigned HOST_WIDE_INT)(x)) & (unsigned HOST_WIDE_INT) 0xffffffff) |\
2501 ((((unsigned HOST_WIDE_INT)(x)) & (unsigned HOST_WIDE_INT) 0x80000000) \
2502 ? ((~ (unsigned HOST_WIDE_INT) 0) \
2503 & ~ (unsigned HOST_WIDE_INT) 0xffffffff) \
7bc7696c 2504 : 0))))
35d965d5
RS
2505
2506/* Output the address of an operand. */
3cd45774
RE
2507#define ARM_PRINT_OPERAND_ADDRESS(STREAM, X) \
2508{ \
2509 int is_minus = GET_CODE (X) == MINUS; \
2510 \
2511 if (GET_CODE (X) == REG) \
2512 asm_fprintf (STREAM, "[%r, #0]", REGNO (X)); \
2513 else if (GET_CODE (X) == PLUS || is_minus) \
2514 { \
2515 rtx base = XEXP (X, 0); \
2516 rtx index = XEXP (X, 1); \
2517 HOST_WIDE_INT offset = 0; \
2518 if (GET_CODE (base) != REG) \
2519 { \
d6b4baa4
KH
2520 /* Ensure that BASE is a register. */ \
2521 /* (one of them must be). */ \
3cd45774
RE
2522 rtx temp = base; \
2523 base = index; \
2524 index = temp; \
2525 } \
2526 switch (GET_CODE (index)) \
2527 { \
2528 case CONST_INT: \
2529 offset = INTVAL (index); \
2530 if (is_minus) \
2531 offset = -offset; \
c53dddc2 2532 asm_fprintf (STREAM, "[%r, #%wd]", \
3cd45774
RE
2533 REGNO (base), offset); \
2534 break; \
2535 \
2536 case REG: \
2537 asm_fprintf (STREAM, "[%r, %s%r]", \
2538 REGNO (base), is_minus ? "-" : "", \
2539 REGNO (index)); \
2540 break; \
2541 \
2542 case MULT: \
2543 case ASHIFTRT: \
2544 case LSHIFTRT: \
2545 case ASHIFT: \
2546 case ROTATERT: \
2547 { \
2548 asm_fprintf (STREAM, "[%r, %s%r", \
2549 REGNO (base), is_minus ? "-" : "", \
2550 REGNO (XEXP (index, 0))); \
2551 arm_print_operand (STREAM, index, 'S'); \
2552 fputs ("]", STREAM); \
2553 break; \
2554 } \
2555 \
2556 default: \
2557 abort(); \
2558 } \
2559 } \
2560 else if (GET_CODE (X) == PRE_INC || GET_CODE (X) == POST_INC \
2561 || GET_CODE (X) == PRE_DEC || GET_CODE (X) == POST_DEC) \
2562 { \
2563 extern enum machine_mode output_memory_reference_mode; \
2564 \
2565 if (GET_CODE (XEXP (X, 0)) != REG) \
2566 abort (); \
2567 \
2568 if (GET_CODE (X) == PRE_DEC || GET_CODE (X) == PRE_INC) \
2569 asm_fprintf (STREAM, "[%r, #%s%d]!", \
2570 REGNO (XEXP (X, 0)), \
2571 GET_CODE (X) == PRE_DEC ? "-" : "", \
2572 GET_MODE_SIZE (output_memory_reference_mode)); \
2573 else \
2574 asm_fprintf (STREAM, "[%r], #%s%d", \
2575 REGNO (XEXP (X, 0)), \
2576 GET_CODE (X) == POST_DEC ? "-" : "", \
2577 GET_MODE_SIZE (output_memory_reference_mode)); \
2578 } \
2579 else if (GET_CODE (X) == PRE_MODIFY) \
2580 { \
2581 asm_fprintf (STREAM, "[%r, ", REGNO (XEXP (X, 0))); \
2582 if (GET_CODE (XEXP (XEXP (X, 1), 1)) == CONST_INT) \
c53dddc2 2583 asm_fprintf (STREAM, "#%wd]!", \
3cd45774
RE
2584 INTVAL (XEXP (XEXP (X, 1), 1))); \
2585 else \
2586 asm_fprintf (STREAM, "%r]!", \
2587 REGNO (XEXP (XEXP (X, 1), 1))); \
2588 } \
2589 else if (GET_CODE (X) == POST_MODIFY) \
2590 { \
2591 asm_fprintf (STREAM, "[%r], ", REGNO (XEXP (X, 0))); \
2592 if (GET_CODE (XEXP (XEXP (X, 1), 1)) == CONST_INT) \
c53dddc2 2593 asm_fprintf (STREAM, "#%wd", \
3cd45774
RE
2594 INTVAL (XEXP (XEXP (X, 1), 1))); \
2595 else \
2596 asm_fprintf (STREAM, "%r", \
2597 REGNO (XEXP (XEXP (X, 1), 1))); \
2598 } \
2599 else output_addr_const (STREAM, X); \
35d965d5 2600}
62dd06ea 2601
d5b7b3ae
RE
2602#define THUMB_PRINT_OPERAND_ADDRESS(STREAM, X) \
2603{ \
2604 if (GET_CODE (X) == REG) \
2605 asm_fprintf (STREAM, "[%r]", REGNO (X)); \
2606 else if (GET_CODE (X) == POST_INC) \
2607 asm_fprintf (STREAM, "%r!", REGNO (XEXP (X, 0))); \
2608 else if (GET_CODE (X) == PLUS) \
2609 { \
27847754
NC
2610 if (GET_CODE (XEXP (X, 0)) != REG) \
2611 abort (); \
d5b7b3ae 2612 if (GET_CODE (XEXP (X, 1)) == CONST_INT) \
659bdc68 2613 asm_fprintf (STREAM, "[%r, #%wd]", \
d5b7b3ae 2614 REGNO (XEXP (X, 0)), \
659bdc68 2615 INTVAL (XEXP (X, 1))); \
d5b7b3ae
RE
2616 else \
2617 asm_fprintf (STREAM, "[%r, %r]", \
2618 REGNO (XEXP (X, 0)), \
2619 REGNO (XEXP (X, 1))); \
2620 } \
2621 else \
2622 output_addr_const (STREAM, X); \
2623}
2624
2625#define PRINT_OPERAND_ADDRESS(STREAM, X) \
2626 if (TARGET_ARM) \
2627 ARM_PRINT_OPERAND_ADDRESS (STREAM, X) \
2628 else \
2629 THUMB_PRINT_OPERAND_ADDRESS (STREAM, X)
5a9335ef
NC
2630
2631#define OUTPUT_ADDR_CONST_EXTRA(FILE, X, FAIL) \
2632 if (GET_CODE (X) != CONST_VECTOR \
2633 || ! arm_emit_vector_const (FILE, X)) \
2634 goto FAIL;
2635
6a5d7526
MS
2636/* A C expression whose value is RTL representing the value of the return
2637 address for the frame COUNT steps up from the current frame. */
2638
d5b7b3ae
RE
2639#define RETURN_ADDR_RTX(COUNT, FRAME) \
2640 arm_return_addr (COUNT, FRAME)
2641
2642/* Mask of the bits in the PC that contain the real return address
2643 when running in 26-bit mode. */
2644#define RETURN_ADDR_MASK26 (0x03fffffc)
6a5d7526 2645
2c849145
JM
2646/* Pick up the return address upon entry to a procedure. Used for
2647 dwarf2 unwind information. This also enables the table driven
2648 mechanism. */
2c849145
JM
2649#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LR_REGNUM)
2650#define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (LR_REGNUM)
2651
39950dff
MS
2652/* Used to mask out junk bits from the return address, such as
2653 processor state, interrupt status, condition codes and the like. */
2654#define MASK_RETURN_ADDR \
2655 /* If we are generating code for an ARM2/ARM3 machine or for an ARM6 \
2656 in 26 bit mode, the condition codes must be masked out of the \
2657 return address. This does not apply to ARM6 and later processors \
2658 when running in 32 bit mode. */ \
fcd53748
JT
2659 ((!TARGET_APCS_32) ? (gen_int_mode (RETURN_ADDR_MASK26, Pmode)) \
2660 : (arm_arch4 || TARGET_THUMB) ? \
2661 (gen_int_mode ((unsigned long)0xffffffff, Pmode)) \
2662 : arm_gen_return_addr_mask ())
d5b7b3ae
RE
2663
2664\f
2665/* Define the codes that are matched by predicates in arm.c */
2666#define PREDICATE_CODES \
2667 {"s_register_operand", {SUBREG, REG}}, \
b15bca31 2668 {"arm_hard_register_operand", {REG}}, \
d5b7b3ae
RE
2669 {"f_register_operand", {SUBREG, REG}}, \
2670 {"arm_add_operand", {SUBREG, REG, CONST_INT}}, \
f9b9980e 2671 {"arm_addimm_operand", {CONST_INT}}, \
3b684012
RE
2672 {"fpa_add_operand", {SUBREG, REG, CONST_DOUBLE}}, \
2673 {"fpa_rhs_operand", {SUBREG, REG, CONST_DOUBLE}}, \
d5b7b3ae
RE
2674 {"arm_rhs_operand", {SUBREG, REG, CONST_INT}}, \
2675 {"arm_not_operand", {SUBREG, REG, CONST_INT}}, \
2676 {"reg_or_int_operand", {SUBREG, REG, CONST_INT}}, \
2677 {"index_operand", {SUBREG, REG, CONST_INT}}, \
2678 {"thumb_cmp_operand", {SUBREG, REG, CONST_INT}}, \
c769a35d 2679 {"thumb_cmpneg_operand", {CONST_INT}}, \
defc0463 2680 {"thumb_cbrch_target_operand", {SUBREG, REG, MEM}}, \
d5b7b3ae
RE
2681 {"offsettable_memory_operand", {MEM}}, \
2682 {"bad_signed_byte_operand", {MEM}}, \
2683 {"alignable_memory_operand", {MEM}}, \
2684 {"shiftable_operator", {PLUS, MINUS, AND, IOR, XOR}}, \
2685 {"minmax_operator", {SMIN, SMAX, UMIN, UMAX}}, \
2686 {"shift_operator", {ASHIFT, ASHIFTRT, LSHIFTRT, ROTATERT, MULT}}, \
2687 {"di_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE, MEM}}, \
2688 {"nonimmediate_di_operand", {SUBREG, REG, MEM}}, \
2689 {"soft_df_operand", {SUBREG, REG, CONST_DOUBLE, MEM}}, \
2690 {"nonimmediate_soft_df_operand", {SUBREG, REG, MEM}}, \
2691 {"load_multiple_operation", {PARALLEL}}, \
2692 {"store_multiple_operation", {PARALLEL}}, \
2693 {"equality_operator", {EQ, NE}}, \
e45b72c4
RE
2694 {"arm_comparison_operator", {EQ, NE, LE, LT, GE, GT, GEU, GTU, LEU, \
2695 LTU, UNORDERED, ORDERED, UNLT, UNLE, \
2696 UNGE, UNGT}}, \
d5b7b3ae
RE
2697 {"arm_rhsm_operand", {SUBREG, REG, CONST_INT, MEM}}, \
2698 {"const_shift_operand", {CONST_INT}}, \
2699 {"multi_register_push", {PARALLEL}}, \
2700 {"cc_register", {REG}}, \
2701 {"logical_binary_operator", {AND, IOR, XOR}}, \
9b6b54e2
NC
2702 {"cirrus_register_operand", {REG}}, \
2703 {"cirrus_fp_register", {REG}}, \
2704 {"cirrus_shift_const", {CONST_INT}}, \
d5b7b3ae 2705 {"dominant_cc_register", {REG}},
71791e16 2706
ad027eae
RE
2707/* Define this if you have special predicates that know special things
2708 about modes. Genrecog will warn about certain forms of
2709 match_operand without a mode; if the operand predicate is listed in
d6b4baa4 2710 SPECIAL_MODE_PREDICATES, the warning will be suppressed. */
ad027eae
RE
2711#define SPECIAL_MODE_PREDICATES \
2712 "cc_register", "dominant_cc_register",
2713
5a9335ef
NC
2714enum arm_builtins
2715{
2716 ARM_BUILTIN_GETWCX,
2717 ARM_BUILTIN_SETWCX,
2718
2719 ARM_BUILTIN_WZERO,
2720
2721 ARM_BUILTIN_WAVG2BR,
2722 ARM_BUILTIN_WAVG2HR,
2723 ARM_BUILTIN_WAVG2B,
2724 ARM_BUILTIN_WAVG2H,
2725
2726 ARM_BUILTIN_WACCB,
2727 ARM_BUILTIN_WACCH,
2728 ARM_BUILTIN_WACCW,
2729
2730 ARM_BUILTIN_WMACS,
2731 ARM_BUILTIN_WMACSZ,
2732 ARM_BUILTIN_WMACU,
2733 ARM_BUILTIN_WMACUZ,
2734
2735 ARM_BUILTIN_WSADB,
2736 ARM_BUILTIN_WSADBZ,
2737 ARM_BUILTIN_WSADH,
2738 ARM_BUILTIN_WSADHZ,
2739
2740 ARM_BUILTIN_WALIGN,
2741
2742 ARM_BUILTIN_TMIA,
2743 ARM_BUILTIN_TMIAPH,
2744 ARM_BUILTIN_TMIABB,
2745 ARM_BUILTIN_TMIABT,
2746 ARM_BUILTIN_TMIATB,
2747 ARM_BUILTIN_TMIATT,
2748
2749 ARM_BUILTIN_TMOVMSKB,
2750 ARM_BUILTIN_TMOVMSKH,
2751 ARM_BUILTIN_TMOVMSKW,
2752
2753 ARM_BUILTIN_TBCSTB,
2754 ARM_BUILTIN_TBCSTH,
2755 ARM_BUILTIN_TBCSTW,
2756
2757 ARM_BUILTIN_WMADDS,
2758 ARM_BUILTIN_WMADDU,
2759
2760 ARM_BUILTIN_WPACKHSS,
2761 ARM_BUILTIN_WPACKWSS,
2762 ARM_BUILTIN_WPACKDSS,
2763 ARM_BUILTIN_WPACKHUS,
2764 ARM_BUILTIN_WPACKWUS,
2765 ARM_BUILTIN_WPACKDUS,
2766
2767 ARM_BUILTIN_WADDB,
2768 ARM_BUILTIN_WADDH,
2769 ARM_BUILTIN_WADDW,
2770 ARM_BUILTIN_WADDSSB,
2771 ARM_BUILTIN_WADDSSH,
2772 ARM_BUILTIN_WADDSSW,
2773 ARM_BUILTIN_WADDUSB,
2774 ARM_BUILTIN_WADDUSH,
2775 ARM_BUILTIN_WADDUSW,
2776 ARM_BUILTIN_WSUBB,
2777 ARM_BUILTIN_WSUBH,
2778 ARM_BUILTIN_WSUBW,
2779 ARM_BUILTIN_WSUBSSB,
2780 ARM_BUILTIN_WSUBSSH,
2781 ARM_BUILTIN_WSUBSSW,
2782 ARM_BUILTIN_WSUBUSB,
2783 ARM_BUILTIN_WSUBUSH,
2784 ARM_BUILTIN_WSUBUSW,
2785
2786 ARM_BUILTIN_WAND,
2787 ARM_BUILTIN_WANDN,
2788 ARM_BUILTIN_WOR,
2789 ARM_BUILTIN_WXOR,
2790
2791 ARM_BUILTIN_WCMPEQB,
2792 ARM_BUILTIN_WCMPEQH,
2793 ARM_BUILTIN_WCMPEQW,
2794 ARM_BUILTIN_WCMPGTUB,
2795 ARM_BUILTIN_WCMPGTUH,
2796 ARM_BUILTIN_WCMPGTUW,
2797 ARM_BUILTIN_WCMPGTSB,
2798 ARM_BUILTIN_WCMPGTSH,
2799 ARM_BUILTIN_WCMPGTSW,
2800
2801 ARM_BUILTIN_TEXTRMSB,
2802 ARM_BUILTIN_TEXTRMSH,
2803 ARM_BUILTIN_TEXTRMSW,
2804 ARM_BUILTIN_TEXTRMUB,
2805 ARM_BUILTIN_TEXTRMUH,
2806 ARM_BUILTIN_TEXTRMUW,
2807 ARM_BUILTIN_TINSRB,
2808 ARM_BUILTIN_TINSRH,
2809 ARM_BUILTIN_TINSRW,
2810
2811 ARM_BUILTIN_WMAXSW,
2812 ARM_BUILTIN_WMAXSH,
2813 ARM_BUILTIN_WMAXSB,
2814 ARM_BUILTIN_WMAXUW,
2815 ARM_BUILTIN_WMAXUH,
2816 ARM_BUILTIN_WMAXUB,
2817 ARM_BUILTIN_WMINSW,
2818 ARM_BUILTIN_WMINSH,
2819 ARM_BUILTIN_WMINSB,
2820 ARM_BUILTIN_WMINUW,
2821 ARM_BUILTIN_WMINUH,
2822 ARM_BUILTIN_WMINUB,
2823
2824 ARM_BUILTIN_WMULUH,
2825 ARM_BUILTIN_WMULSH,
2826 ARM_BUILTIN_WMULUL,
2827
2828 ARM_BUILTIN_PSADBH,
2829 ARM_BUILTIN_WSHUFH,
2830
2831 ARM_BUILTIN_WSLLH,
2832 ARM_BUILTIN_WSLLW,
2833 ARM_BUILTIN_WSLLD,
2834 ARM_BUILTIN_WSRAH,
2835 ARM_BUILTIN_WSRAW,
2836 ARM_BUILTIN_WSRAD,
2837 ARM_BUILTIN_WSRLH,
2838 ARM_BUILTIN_WSRLW,
2839 ARM_BUILTIN_WSRLD,
2840 ARM_BUILTIN_WRORH,
2841 ARM_BUILTIN_WRORW,
2842 ARM_BUILTIN_WRORD,
2843 ARM_BUILTIN_WSLLHI,
2844 ARM_BUILTIN_WSLLWI,
2845 ARM_BUILTIN_WSLLDI,
2846 ARM_BUILTIN_WSRAHI,
2847 ARM_BUILTIN_WSRAWI,
2848 ARM_BUILTIN_WSRADI,
2849 ARM_BUILTIN_WSRLHI,
2850 ARM_BUILTIN_WSRLWI,
2851 ARM_BUILTIN_WSRLDI,
2852 ARM_BUILTIN_WRORHI,
2853 ARM_BUILTIN_WRORWI,
2854 ARM_BUILTIN_WRORDI,
2855
2856 ARM_BUILTIN_WUNPCKIHB,
2857 ARM_BUILTIN_WUNPCKIHH,
2858 ARM_BUILTIN_WUNPCKIHW,
2859 ARM_BUILTIN_WUNPCKILB,
2860 ARM_BUILTIN_WUNPCKILH,
2861 ARM_BUILTIN_WUNPCKILW,
2862
2863 ARM_BUILTIN_WUNPCKEHSB,
2864 ARM_BUILTIN_WUNPCKEHSH,
2865 ARM_BUILTIN_WUNPCKEHSW,
2866 ARM_BUILTIN_WUNPCKEHUB,
2867 ARM_BUILTIN_WUNPCKEHUH,
2868 ARM_BUILTIN_WUNPCKEHUW,
2869 ARM_BUILTIN_WUNPCKELSB,
2870 ARM_BUILTIN_WUNPCKELSH,
2871 ARM_BUILTIN_WUNPCKELSW,
2872 ARM_BUILTIN_WUNPCKELUB,
2873 ARM_BUILTIN_WUNPCKELUH,
2874 ARM_BUILTIN_WUNPCKELUW,
2875
2876 ARM_BUILTIN_MAX
2877};
88657302 2878#endif /* ! GCC_ARM_H */