]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/arm/arm.h
arm.h (SECONDARY_INPUT_RELOAD_CLASS): Only need a secondary reload if reloading a...
[thirdparty/gcc.git] / gcc / config / arm / arm.h
CommitLineData
35d965d5 1/* Definitions of target machine for GNU compiler, for Acorn RISC Machine.
8625fab5 2 Copyright (C) 1991, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
35d965d5 3 Contributed by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl)
8b109b37 4 and Martin Simmons (@harleqn.co.uk).
ff9940b0
RE
5 More major hacks by Richard Earnshaw (rwe11@cl.cam.ac.uk)
6
35d965d5
RS
7This file is part of GNU CC.
8
9GNU CC is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2, or (at your option)
12any later version.
13
14GNU CC is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with GNU CC; see the file COPYING. If not, write to
8fb289e7
RK
21the Free Software Foundation, 59 Temple Place - Suite 330,
22Boston, MA 02111-1307, USA. */
35d965d5 23
52a02435 24/* Configuration triples for ARM ports work as follows:
9e7d0bcc 25 (This is a bit of a mess and needs some thought)
52a02435
DE
26 arm-*-*: little endian
27 armel-*-*: little endian
28 armeb-*-*: big endian
5da4dc2c
DE
29 If a non-embedded environment (ie: "real" OS) is specified, `arm'
30 should default to that used by the OS.
52a02435
DE
31*/
32
7a801826
RE
33#define TARGET_CPU_arm2 0x0000
34#define TARGET_CPU_arm250 0x0000
35#define TARGET_CPU_arm3 0x0000
36#define TARGET_CPU_arm6 0x0001
37#define TARGET_CPU_arm600 0x0001
38#define TARGET_CPU_arm610 0x0002
39#define TARGET_CPU_arm7 0x0001
40#define TARGET_CPU_arm7m 0x0004
41#define TARGET_CPU_arm7dm 0x0004
42#define TARGET_CPU_arm7dmi 0x0004
43#define TARGET_CPU_arm700 0x0001
44#define TARGET_CPU_arm710 0x0002
45#define TARGET_CPU_arm7100 0x0002
46#define TARGET_CPU_arm7500 0x0002
47#define TARGET_CPU_arm7500fe 0x1001
48#define TARGET_CPU_arm7tdmi 0x0008
49#define TARGET_CPU_arm8 0x0010
50#define TARGET_CPU_arm810 0x0020
51#define TARGET_CPU_strongarm 0x0040
52#define TARGET_CPU_strongarm110 0x0040
53/* Configure didn't specify */
54#define TARGET_CPU_generic 0x8000
ff9940b0 55
89c7ca52
RE
56enum arm_cond_code
57{
58 ARM_EQ = 0, ARM_NE, ARM_CS, ARM_CC, ARM_MI, ARM_PL, ARM_VS, ARM_VC,
59 ARM_HI, ARM_LS, ARM_GE, ARM_LT, ARM_GT, ARM_LE, ARM_AL, ARM_NV
60};
61extern enum arm_cond_code arm_current_cc;
ff9940b0
RE
62extern char *arm_condition_codes[];
63
89c7ca52
RE
64#define ARM_INVERSE_CONDITION_CODE(X) ((enum arm_cond_code) (((int)X) ^ 1))
65
ff9940b0
RE
66/* This is needed by the tail-calling peepholes */
67extern int frame_pointer_needed;
68
35d965d5 69\f
7a801826
RE
70/* Just in case configure has failed to define anything. */
71#ifndef TARGET_CPU_DEFAULT
72#define TARGET_CPU_DEFAULT TARGET_CPU_generic
73#endif
74
75/* If the configuration file doesn't specify the cpu, the subtarget may
76 override it. If it doesn't, then default to an ARM6. */
77#if TARGET_CPU_DEFAULT == TARGET_CPU_generic
78#undef TARGET_CPU_DEFAULT
79#ifdef SUBTARGET_CPU_DEFAULT
80#define TARGET_CPU_DEFAULT SUBTARGET_CPU_DEFAULT
81#else
82#define TARGET_CPU_DEFAULT TARGET_CPU_arm6
83#endif
84#endif
85
86#if TARGET_CPU_DEFAULT == TARGET_CPU_arm2
87#define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_2__"
88#else
18543a22 89#if TARGET_CPU_DEFAULT == TARGET_CPU_arm6 || TARGET_CPU_DEFAULT == TARGET_CPU_arm610 || TARGET_CPU_DEFAULT == TARGET_CPU_arm7500fe
7a801826
RE
90#define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_3__"
91#else
92#if TARGET_CPU_DEFAULT == TARGET_CPU_arm7m
93#define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_3M__"
94#else
95#if TARGET_CPU_DEFAULT == TARGET_CPU_arm7tdmi
96#define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_4T__"
97#else
98#if TARGET_CPU_DEFAULT == TARGET_CPU_arm8 || TARGET_CPU_DEFAULT == TARGET_CPU_arm810 || TARGET_CPU_DEFAULT == TARGET_CPU_strongarm
99#define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_4__"
100#else
101Unrecognized value in TARGET_CPU_DEFAULT.
102#endif
103#endif
104#endif
105#endif
106#endif
107
ff9940b0
RE
108#ifndef CPP_PREDEFINES
109#define CPP_PREDEFINES "-Darm -Acpu(arm) -Amachine(arm)"
110#endif
35d965d5 111
38fc909b
RE
112#define CPP_SPEC "\
113%(cpp_cpu_arch) %(cpp_apcs_pc) %(cpp_float) \
114%(cpp_endian) %(subtarget_cpp_spec)"
7a801826 115
71791e16
RE
116/* Set the architecture define -- if -march= is set, then it overrides
117 the -mcpu= setting. */
7a801826
RE
118#define CPP_CPU_ARCH_SPEC "\
119%{m2:-D__arm2__ -D__ARM_ARCH_2__} \
120%{m3:-D__arm2__ -D__ARM_ARCH_2__} \
121%{m6:-D__arm6__ -D__ARM_ARCH_3__} \
71791e16
RE
122%{march=arm2:-D__ARM_ARCH_2__} \
123%{march=arm250:-D__ARM_ARCH_2__} \
124%{march=arm3:-D__ARM_ARCH_2__} \
125%{march=arm6:-D__ARM_ARCH_3__} \
126%{march=arm600:-D__ARM_ARCH_3__} \
127%{march=arm610:-D__ARM_ARCH_3__} \
128%{march=arm7:-D__ARM_ARCH_3__} \
129%{march=arm700:-D__ARM_ARCH_3__} \
130%{march=arm710:-D__ARM_ARCH_3__} \
131%{march=arm7100:-D__ARM_ARCH_3__} \
132%{march=arm7500:-D__ARM_ARCH_3__} \
133%{march=arm7500fe:-D__ARM_ARCH_3__} \
134%{march=arm7m:-D__ARM_ARCH_3M__} \
135%{march=arm7dm:-D__ARM_ARCH_3M__} \
136%{march=arm7dmi:-D__ARM_ARCH_3M__} \
137%{march=arm7tdmi:-D__ARM_ARCH_4T__} \
138%{march=arm8:-D__ARM_ARCH_4__} \
139%{march=arm810:-D__ARM_ARCH_4__} \
140%{march=strongarm:-D__ARM_ARCH_4__} \
141%{march=strongarm110:-D__ARM_ARCH_4__} \
142%{march=armv2:-D__ARM_ARCH_2__} \
143%{march=armv2a:-D__ARM_ARCH_2__} \
144%{march=armv3:-D__ARM_ARCH_3__} \
145%{march=armv3m:-D__ARM_ARCH_3M__} \
146%{march=armv4:-D__ARM_ARCH_4__} \
147%{march=armv4t:-D__ARM_ARCH_4T__} \
148%{!march=*: \
149 %{mcpu=arm2:-D__ARM_ARCH_2__} \
150 %{mcpu=arm250:-D__ARM_ARCH_2__} \
151 %{mcpu=arm3:-D__ARM_ARCH_2__} \
152 %{mcpu=arm6:-D__ARM_ARCH_3__} \
153 %{mcpu=arm600:-D__ARM_ARCH_3__} \
154 %{mcpu=arm610:-D__ARM_ARCH_3__} \
155 %{mcpu=arm7:-D__ARM_ARCH_3__} \
156 %{mcpu=arm700:-D__ARM_ARCH_3__} \
157 %{mcpu=arm710:-D__ARM_ARCH_3__} \
158 %{mcpu=arm7100:-D__ARM_ARCH_3__} \
159 %{mcpu=arm7500:-D__ARM_ARCH_3__} \
160 %{mcpu=arm7500fe:-D__ARM_ARCH_3__} \
161 %{mcpu=arm7m:-D__ARM_ARCH_3M__} \
162 %{mcpu=arm7dm:-D__ARM_ARCH_3M__} \
163 %{mcpu=arm7dmi:-D__ARM_ARCH_3M__} \
164 %{mcpu=arm7tdmi:-D__ARM_ARCH_4T__} \
165 %{mcpu=arm8:-D__ARM_ARCH_4__} \
166 %{mcpu=arm810:-D__ARM_ARCH_4__} \
167 %{mcpu=strongarm:-D__ARM_ARCH_4__} \
168 %{mcpu=strongarm110:-D__ARM_ARCH_4__} \
169 %{!mcpu*:%{!m6:%{!m2:%{!m3:%(cpp_cpu_arch_default)}}}}} \
11c1a207 170"
7a801826
RE
171
172/* Define __APCS_26__ if the PC also contains the PSR */
173/* This also examines deprecated -m[236] if neither of -mapcs-{26,32} is set,
174 ??? Delete this for 2.9. */
175#define CPP_APCS_PC_SPEC "\
176%{mapcs-32:%{mapcs-26:%e-mapcs-26 and -mapcs-32 may not be used together} \
177 -D__APCS_32__} \
178%{mapcs-26:-D__APCS_26__} \
179%{!mapcs-32: %{!mapcs-26:%{m6:-D__APCS_32__} %{m2:-D__APCS_26__} \
180 %{m3:-D__APCS_26__} %{!m6:%{!m3:%{!m2:%(cpp_apcs_pc_default)}}}}} \
181"
182
183#define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_26__"
184
185#define CPP_FLOAT_SPEC "\
186%{msoft-float:\
187 %{mhard-float:%e-msoft-float and -mhard_float may not be used together} \
188 -D__SOFTFP__} \
189%{!mhard-float:%{!msoft-float:%(cpp_float_default)}} \
190"
191
192/* Default is hard float, which doesn't define anything */
193#define CPP_FLOAT_DEFAULT_SPEC ""
194
195#define CPP_ENDIAN_SPEC "\
196%{mbig-endian: \
197 %{mlittle-endian: \
198 %e-mbig-endian and -mlittle-endian may not be used together} \
7a801826 199 -D__ARMEB__ %{mwords-little-endian:-D__ARMWEL__}} \
9e7d0bcc 200%{!mlittle-endian:%{!mbig-endian:%(cpp_endian_default)}} \
7a801826
RE
201"
202
203/* Default is little endian, which doesn't define anything. */
204#define CPP_ENDIAN_DEFAULT_SPEC ""
205
206/* Translate (for now) the old -m[236] option into the appropriate -mcpu=...
207 and -mapcs-xx equivalents.
9e7d0bcc 208 ??? Remove support for this style in 2.9.*/
7a801826
RE
209#define CC1_SPEC "\
210%{m2:-mcpu=arm2 -mapcs-26} \
211%{m3:-mcpu=arm3 -mapcs-26} \
212%{m6:-mcpu=arm6 -mapcs-32} \
7a801826
RE
213"
214
215/* This macro defines names of additional specifications to put in the specs
216 that can be used in various specifications like CC1_SPEC. Its definition
217 is an initializer with a subgrouping for each command option.
218
219 Each subgrouping contains a string constant, that defines the
220 specification name, and a string constant that used by the GNU CC driver
221 program.
222
223 Do not define this macro if it does not need to do anything. */
224#define EXTRA_SPECS \
225 { "cpp_cpu_arch", CPP_CPU_ARCH_SPEC }, \
226 { "cpp_cpu_arch_default", CPP_ARCH_DEFAULT_SPEC }, \
227 { "cpp_apcs_pc", CPP_APCS_PC_SPEC }, \
228 { "cpp_apcs_pc_default", CPP_APCS_PC_DEFAULT_SPEC }, \
229 { "cpp_float", CPP_FLOAT_SPEC }, \
230 { "cpp_float_default", CPP_FLOAT_DEFAULT_SPEC }, \
231 { "cpp_endian", CPP_ENDIAN_SPEC }, \
232 { "cpp_endian_default", CPP_ENDIAN_DEFAULT_SPEC }, \
38fc909b 233 { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC }, \
7a801826
RE
234 SUBTARGET_EXTRA_SPECS
235
236#define SUBTARGET_EXTRA_SPECS
38fc909b 237#define SUBTARGET_CPP_SPEC ""
7a801826 238
35d965d5
RS
239\f
240/* Run-time Target Specification. */
ff9940b0 241#ifndef TARGET_VERSION
35d965d5 242#define TARGET_VERSION \
ff9940b0
RE
243 fputs (" (ARM/generic)", stderr);
244#endif
35d965d5 245
11c1a207 246/* Run-time compilation parameters selecting different hardware subsets. */
35d965d5
RS
247extern int target_flags;
248
71791e16
RE
249/* The floating point instruction architecture, can be 2 or 3 */
250extern char *target_fp_name;
11c1a207 251
35d965d5
RS
252/* Nonzero if the function prologue (and epilogue) should obey
253 the ARM Procedure Call Standard. */
11c1a207 254#define ARM_FLAG_APCS_FRAME (0x0001)
35d965d5
RS
255
256/* Nonzero if the function prologue should output the function name to enable
257 the post mortem debugger to print a backtrace (very useful on RISCOS,
11c1a207
RE
258 unused on RISCiX). Specifying this flag also enables
259 -fno-omit-frame-pointer.
35d965d5 260 XXX Must still be implemented in the prologue. */
11c1a207 261#define ARM_FLAG_POKE (0x0002)
35d965d5
RS
262
263/* Nonzero if floating point instructions are emulated by the FPE, in which
264 case instruction scheduling becomes very uninteresting. */
11c1a207 265#define ARM_FLAG_FPE (0x0004)
35d965d5 266
ff9940b0
RE
267/* Nonzero if destined for an ARM6xx. Takes out bits that assume restoration
268 of condition flags when returning from a branch & link (ie. a function) */
11c1a207
RE
269/* ********* DEPRECATED ******** */
270#define ARM_FLAG_ARM6 (0x0008)
271
272/* ********* DEPRECATED ******** */
273#define ARM_FLAG_ARM3 (0x0010)
274
275/* Nonzero if destined for a processor in 32-bit program mode. Takes out bit
276 that assume restoration of the condition flags when returning from a
277 branch and link (ie a function). */
278#define ARM_FLAG_APCS_32 (0x0020)
279
280/* Nonzero if stack checking should be performed on entry to each function
281 which allocates temporary variables on the stack. */
282#define ARM_FLAG_APCS_STACK (0x0040)
283
284/* Nonzero if floating point parameters should be passed to functions in
285 floating point registers. */
286#define ARM_FLAG_APCS_FLOAT (0x0080)
287
288/* Nonzero if re-entrant, position independent code should be generated.
289 This is equivalent to -fpic. */
290#define ARM_FLAG_APCS_REENT (0x0100)
291
292/* Nonzero if the MMU will trap unaligned word accesses, so shorts must be
293 loaded byte-at-a-time. */
294#define ARM_FLAG_SHORT_BYTE (0x0200)
295
296/* Nonzero if all floating point instructions are missing (and there is no
297 emulator either). Generate function calls for all ops in this case. */
298#define ARM_FLAG_SOFT_FLOAT (0x0400)
299
300/* Nonzero if we should compile with BYTES_BIG_ENDIAN set to 1. */
301#define ARM_FLAG_BIG_END (0x0800)
302
303/* Nonzero if we should compile for Thumb interworking. */
304#define ARM_FLAG_THUMB (0x1000)
305
ddee6aba
RE
306/* Nonzero if we should have little-endian words even when compiling for
307 big-endian (for backwards compatibility with older versions of GCC). */
308#define ARM_FLAG_LITTLE_WORDS (0x2000)
309
11c1a207
RE
310#define TARGET_APCS (target_flags & ARM_FLAG_APCS_FRAME)
311#define TARGET_POKE_FUNCTION_NAME (target_flags & ARM_FLAG_POKE)
312#define TARGET_FPE (target_flags & ARM_FLAG_FPE)
313#define TARGET_6 (target_flags & ARM_FLAG_ARM6)
314#define TARGET_3 (target_flags & ARM_FLAG_ARM3)
315#define TARGET_APCS_32 (target_flags & ARM_FLAG_APCS_32)
316#define TARGET_APCS_STACK (target_flags & ARM_FLAG_APCS_STACK)
317#define TARGET_APCS_FLOAT (target_flags & ARM_FLAG_APCS_FLOAT)
318#define TARGET_APCS_REENT (target_flags & ARM_FLAG_APCS_REENT)
319#define TARGET_SHORT_BY_BYTES (target_flags & ARM_FLAG_SHORT_BYTE)
320#define TARGET_SOFT_FLOAT (target_flags & ARM_FLAG_SOFT_FLOAT)
321#define TARGET_HARD_FLOAT (! TARGET_SOFT_FLOAT)
322#define TARGET_BIG_END (target_flags & ARM_FLAG_BIG_END)
323#define TARGET_THUMB_INTERWORK (target_flags & ARM_FLAG_THUMB)
ddee6aba 324#define TARGET_LITTLE_WORDS (target_flags & ARM_FLAG_LITTLE_WORDS)
3ada8e17
DE
325
326/* SUBTARGET_SWITCHES is used to add flags on a per-config basis.
327 Bit 31 is reserved. See riscix.h. */
328#ifndef SUBTARGET_SWITCHES
329#define SUBTARGET_SWITCHES
ff9940b0
RE
330#endif
331
2ce9c1b9
RE
332#define TARGET_SWITCHES \
333{ \
11c1a207
RE
334 {"apcs", ARM_FLAG_APCS_FRAME}, \
335 {"apcs-frame", ARM_FLAG_APCS_FRAME}, \
336 {"no-apcs-frame", -ARM_FLAG_APCS_FRAME}, \
337 {"poke-function-name", ARM_FLAG_POKE}, \
338 {"fpe", ARM_FLAG_FPE}, \
339 {"6", ARM_FLAG_ARM6}, \
340 {"2", ARM_FLAG_ARM3}, \
341 {"3", ARM_FLAG_ARM3}, \
342 {"apcs-32", ARM_FLAG_APCS_32}, \
343 {"apcs-26", -ARM_FLAG_APCS_32}, \
344 {"apcs-stack-check", ARM_FLAG_APCS_STACK}, \
345 {"no-apcs-stack-check", -ARM_FLAG_APCS_STACK}, \
346 {"apcs-float", ARM_FLAG_APCS_FLOAT}, \
347 {"no-apcs-float", -ARM_FLAG_APCS_FLOAT}, \
348 {"apcs-reentrant", ARM_FLAG_APCS_REENT}, \
18543a22 349 {"no-apcs-reentrant", -ARM_FLAG_APCS_REENT}, \
11c1a207
RE
350 {"short-load-bytes", ARM_FLAG_SHORT_BYTE}, \
351 {"no-short-load-bytes", -ARM_FLAG_SHORT_BYTE}, \
352 {"short-load-words", -ARM_FLAG_SHORT_BYTE}, \
353 {"no-short-load-words", ARM_FLAG_SHORT_BYTE}, \
354 {"soft-float", ARM_FLAG_SOFT_FLOAT}, \
355 {"hard-float", -ARM_FLAG_SOFT_FLOAT}, \
356 {"big-endian", ARM_FLAG_BIG_END}, \
11c1a207 357 {"little-endian", -ARM_FLAG_BIG_END}, \
11c1a207
RE
358 {"thumb-interwork", ARM_FLAG_THUMB}, \
359 {"no-thumb-interwork", -ARM_FLAG_THUMB}, \
ddee6aba 360 {"words-little-endian", ARM_FLAG_LITTLE_WORDS}, \
3ada8e17 361 SUBTARGET_SWITCHES \
11c1a207 362 {"", TARGET_DEFAULT } \
35d965d5
RS
363}
364
62dd06ea
RE
365#define TARGET_OPTIONS \
366{ \
367 {"cpu=", &arm_select[1].string}, \
71791e16
RE
368 {"arch=", &arm_select[2].string}, \
369 {"tune=", &arm_select[3].string}, \
370 {"fp=", &target_fp_name} \
11c1a207 371}
ff9940b0 372
62dd06ea
RE
373/* arm_select[0] is reserved for the default cpu. */
374struct arm_cpu_select
375{
376 char *string;
377 char *name;
378 int set_tune_p;
379 int set_arch_p;
380};
381
382extern struct arm_cpu_select arm_select[];
383
384#ifndef PROCESSOR_DEFAULT
385#define PROCESSOR_DEFAULT PROCESSOR_ARM2
386#endif
387
388#ifndef TARGET_CPU_DEFAULT
389#define TARGET_CPU_DEFAULT ((char *) 0)
390#endif
391
71791e16
RE
392/* Which processor we are running on, for instruction scheduling
393 purposes. */
ff9940b0
RE
394enum processor_type
395{
396 PROCESSOR_ARM2,
397 PROCESSOR_ARM3,
11c1a207 398 PROCESSOR_ARM6,
7a801826
RE
399 PROCESSOR_ARM7,
400 PROCESSOR_ARM8,
71791e16
RE
401 PROCESSOR_STARM,
402 PROCESSOR_NONE /* NOTE: This must be last, since it doesn't
403 appear in the attr_cpu list */
ff9940b0
RE
404};
405
ff9940b0
RE
406/* Recast the cpu class to be the cpu attribute. */
407#define arm_cpu_attr ((enum attr_cpu)arm_cpu)
408
409extern enum processor_type arm_cpu;
410
11c1a207
RE
411enum prog_mode_type
412{
413 prog_mode26,
414 prog_mode32
415};
416
417/* Recast the program mode class to be the prog_mode attribute */
418#define arm_prog_mode ((enum attr_prog_mode) arm_prgmode)
419
420extern enum prog_mode_type arm_prgmode;
421
422/* What sort of floating point unit do we have? Hardware or software.
423 If software, is it issue 2 or issue 3? */
24f0c1b4
RE
424enum floating_point_type
425{
426 FP_HARD,
11c1a207
RE
427 FP_SOFT2,
428 FP_SOFT3
24f0c1b4
RE
429};
430
431/* Recast the floating point class to be the floating point attribute. */
432#define arm_fpu_attr ((enum attr_fpu) arm_fpu)
433
71791e16 434/* What type of floating point to tune for */
24f0c1b4
RE
435extern enum floating_point_type arm_fpu;
436
71791e16
RE
437/* What type of floating point instructions are available */
438extern enum floating_point_type arm_fpu_arch;
439
18543a22 440/* Default floating point architecture. Override in sub-target if
71791e16
RE
441 necessary. */
442#define FP_DEFAULT FP_SOFT2
443
11c1a207
RE
444/* Nonzero if the processor has a fast multiply insn, and one that does
445 a 64-bit multiply of two 32-bit values. */
446extern int arm_fast_multiply;
447
71791e16 448/* Nonzero if this chip supports the ARM Architecture 4 extensions */
11c1a207
RE
449extern int arm_arch4;
450
2ce9c1b9 451#ifndef TARGET_DEFAULT
35d965d5 452#define TARGET_DEFAULT 0
2ce9c1b9 453#endif
35d965d5 454
11c1a207
RE
455/* The frame pointer register used in gcc has nothing to do with debugging;
456 that is controlled by the APCS-FRAME option. */
457/* Not fully implemented yet */
458/* #define CAN_DEBUG_WITHOUT_FP 1 */
35d965d5 459
11c1a207
RE
460#define TARGET_MEM_FUNCTIONS 1
461
462#define OVERRIDE_OPTIONS arm_override_options ()
35d965d5
RS
463\f
464/* Target machine storage Layout. */
465
ff9940b0
RE
466
467/* Define this macro if it is advisable to hold scalars in registers
468 in a wider mode than that declared by the program. In such cases,
469 the value is constrained to be within the bounds of the declared
470 type, but kept valid in the wider mode. The signedness of the
471 extension may differ from that of the type. */
472
473/* It is far faster to zero extend chars than to sign extend them */
474
475#define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
2ce9c1b9
RE
476 if (GET_MODE_CLASS (MODE) == MODE_INT \
477 && GET_MODE_SIZE (MODE) < 4) \
478 { \
479 if (MODE == QImode) \
480 UNSIGNEDP = 1; \
481 else if (MODE == HImode) \
482 UNSIGNEDP = TARGET_SHORT_BY_BYTES != 0; \
483 (MODE) = SImode; \
ff9940b0
RE
484 }
485
18543a22
ILT
486/* Define this macro if the promotion described by `PROMOTE_MODE'
487 should also be done for outgoing function arguments. */
488/* This is required to ensure that push insns always push a word. */
489#define PROMOTE_FUNCTION_ARGS
490
ff9940b0
RE
491/* Define for XFmode extended real floating point support.
492 This will automatically cause REAL_ARITHMETIC to be defined. */
493/* For the ARM:
494 I think I have added all the code to make this work. Unfortunately,
495 early releases of the floating point emulation code on RISCiX used a
496 different format for extended precision numbers. On my RISCiX box there
497 is a bug somewhere which causes the machine to lock up when running enquire
498 with long doubles. There is the additional aspect that Norcroft C
499 treats long doubles as doubles and we ought to remain compatible.
500 Perhaps someone with an FPA coprocessor and not running RISCiX would like
501 to try this someday. */
502/* #define LONG_DOUBLE_TYPE_SIZE 96 */
503
504/* Disable XFmode patterns in md file */
505#define ENABLE_XF_PATTERNS 0
506
507/* Define if you don't want extended real, but do want to use the
508 software floating point emulator for REAL_ARITHMETIC and
509 decimal <-> binary conversion. */
510/* See comment above */
511#define REAL_ARITHMETIC
512
35d965d5
RS
513/* Define this if most significant bit is lowest numbered
514 in instructions that operate on numbered bit-fields. */
515#define BITS_BIG_ENDIAN 0
516
9c872872 517/* Define this if most significant byte of a word is the lowest numbered.
3ada8e17
DE
518 Most ARM processors are run in little endian mode, so that is the default.
519 If you want to have it run-time selectable, change the definition in a
520 cover file to be TARGET_BIG_ENDIAN. */
11c1a207 521#define BYTES_BIG_ENDIAN (TARGET_BIG_END != 0)
35d965d5
RS
522
523/* Define this if most significant word of a multiword number is the lowest
11c1a207
RE
524 numbered.
525 This is always false, even when in big-endian mode. */
ddee6aba
RE
526#define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN && ! TARGET_LITTLE_WORDS)
527
528/* LIBGCC2_WORDS_BIG_ENDIAN has to be a constant, so we define this based
529 on processor pre-defineds when compiling libgcc2.c. */
530#if defined(__ARMEB__) && !defined(__ARMWEL__)
531#define LIBGCC2_WORDS_BIG_ENDIAN 1
532#else
533#define LIBGCC2_WORDS_BIG_ENDIAN 0
534#endif
35d965d5 535
11c1a207
RE
536/* Define this if most significant word of doubles is the lowest numbered.
537 This is always true, even when in little-endian mode. */
7fc6c9f0
RK
538#define FLOAT_WORDS_BIG_ENDIAN 1
539
b4ac57ab 540/* Number of bits in an addressable storage unit */
35d965d5
RS
541#define BITS_PER_UNIT 8
542
543#define BITS_PER_WORD 32
544
545#define UNITS_PER_WORD 4
546
547#define POINTER_SIZE 32
548
549#define PARM_BOUNDARY 32
550
551#define STACK_BOUNDARY 32
552
553#define FUNCTION_BOUNDARY 32
554
555#define EMPTY_FIELD_BOUNDARY 32
556
557#define BIGGEST_ALIGNMENT 32
558
ff9940b0
RE
559/* Make strings word-aligned so strcpy from constants will be faster. */
560#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
561 (TREE_CODE (EXP) == STRING_CST \
562 && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
563
b4ac57ab 564/* Every structures size must be a multiple of 32 bits. */
7d94bb81
DE
565/* This is for compatibility with ARMCC. ARM SDT Reference Manual
566 (ARM DUI 0020D) page 2-20 says "Structures are aligned on word
567 boundaries". */
b4ac57ab
RS
568#define STRUCTURE_SIZE_BOUNDARY 32
569
ff9940b0
RE
570/* Non-zero if move instructions will actually fail to work
571 when given unaligned data. */
35d965d5
RS
572#define STRICT_ALIGNMENT 1
573
ff9940b0
RE
574#define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
575
35d965d5
RS
576\f
577/* Standard register usage. */
578
579/* Register allocation in ARM Procedure Call Standard (as used on RISCiX):
580 (S - saved over call).
581
582 r0 * argument word/integer result
583 r1-r3 argument word
584
585 r4-r8 S register variable
586 r9 S (rfp) register variable (real frame pointer)
587
588 r10 F S (sl) stack limit (not currently used)
589 r11 F S (fp) argument pointer
590 r12 (ip) temp workspace
591 r13 F S (sp) lower end of current stack frame
592 r14 (lr) link address/workspace
593 r15 F (pc) program counter
594
595 f0 floating point result
596 f1-f3 floating point scratch
597
598 f4-f7 S floating point variable
599
ff9940b0
RE
600 cc This is NOT a real register, but is used internally
601 to represent things that use or set the condition
602 codes.
603 sfp This isn't either. It is used during rtl generation
604 since the offset between the frame pointer and the
605 auto's isn't known until after register allocation.
606 afp Nor this, we only need this because of non-local
607 goto. Without it fp appears to be used and the
608 elimination code won't get rid of sfp. It tracks
609 fp exactly at all times.
610
35d965d5
RS
611 *: See CONDITIONAL_REGISTER_USAGE */
612
ff9940b0
RE
613/* The stack backtrace structure is as follows:
614 fp points to here: | save code pointer | [fp]
615 | return link value | [fp, #-4]
616 | return sp value | [fp, #-8]
617 | return fp value | [fp, #-12]
618 [| saved r10 value |]
619 [| saved r9 value |]
620 [| saved r8 value |]
621 [| saved r7 value |]
622 [| saved r6 value |]
623 [| saved r5 value |]
624 [| saved r4 value |]
625 [| saved r3 value |]
626 [| saved r2 value |]
627 [| saved r1 value |]
628 [| saved r0 value |]
629 [| saved f7 value |] three words
630 [| saved f6 value |] three words
631 [| saved f5 value |] three words
632 [| saved f4 value |] three words
633 r0-r3 are not normally saved in a C function. */
634
635/* The number of hard registers is 16 ARM + 8 FPU + 1 CC + 1 SFP. */
636#define FIRST_PSEUDO_REGISTER 27
35d965d5
RS
637
638/* 1 for registers that have pervasive standard uses
639 and are not available for the register allocator. */
640#define FIXED_REGISTERS \
641{ \
642 0,0,0,0,0,0,0,0, \
643 0,0,1,1,0,1,0,1, \
ff9940b0
RE
644 0,0,0,0,0,0,0,0, \
645 1,1,1 \
35d965d5
RS
646}
647
648/* 1 for registers not available across function calls.
649 These must include the FIXED_REGISTERS and also any
650 registers that can be used without being saved.
651 The latter must include the registers where values are returned
652 and the register where structure-value addresses are passed.
ff9940b0
RE
653 Aside from that, you can include as many other registers as you like.
654 The CC is not preserved over function calls on the ARM 6, so it is
655 easier to assume this for all. SFP is preserved, since FP is. */
35d965d5
RS
656#define CALL_USED_REGISTERS \
657{ \
658 1,1,1,1,0,0,0,0, \
659 0,0,1,1,1,1,1,1, \
ff9940b0
RE
660 1,1,1,1,0,0,0,0, \
661 1,1,1 \
35d965d5
RS
662}
663
664/* If doing stupid life analysis, avoid a bug causing a return value r0 to be
665 trampled. This effectively reduces the number of available registers by 1.
666 XXX It is a hack, I know.
667 XXX Is this still needed? */
668#define CONDITIONAL_REGISTER_USAGE \
3ada8e17
DE
669{ \
670 if (obey_regdecls) \
671 fixed_regs[0] = 1; \
672 if (TARGET_SOFT_FLOAT) \
673 { \
674 int regno; \
675 for (regno = 16; regno < 24; ++regno) \
676 fixed_regs[regno] = call_used_regs[regno] = 1; \
677 } \
7a801826
RE
678 if (flag_pic) \
679 { \
680 fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
681 call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 0; \
682 } \
35d965d5
RS
683}
684
685/* Return number of consecutive hard regs needed starting at reg REGNO
686 to hold something of mode MODE.
687 This is ordinarily the length in words of a value of mode MODE
688 but can be less for certain modes in special long registers.
689
690 On the ARM regs are UNITS_PER_WORD bits wide; FPU regs can hold any FP
691 mode. */
ff9940b0
RE
692#define HARD_REGNO_NREGS(REGNO, MODE) \
693 (((REGNO) >= 16 && REGNO != FRAME_POINTER_REGNUM \
694 && (REGNO) != ARG_POINTER_REGNUM) ? 1 \
35d965d5
RS
695 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
696
697/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
698 This is TRUE for ARM regs since they can hold anything, and TRUE for FPU
699 regs holding FP. */
ff9940b0
RE
700#define HARD_REGNO_MODE_OK(REGNO, MODE) \
701 ((GET_MODE_CLASS (MODE) == MODE_CC) ? (REGNO == CC_REGNUM) : \
702 ((REGNO) < 16 || REGNO == FRAME_POINTER_REGNUM \
703 || REGNO == ARG_POINTER_REGNUM \
704 || GET_MODE_CLASS (MODE) == MODE_FLOAT))
35d965d5
RS
705
706/* Value is 1 if it is a good idea to tie two pseudo registers
707 when one has mode MODE1 and one has mode MODE2.
708 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
709 for any hard reg, then this must be 0 for correct output. */
710#define MODES_TIEABLE_P(MODE1, MODE2) \
3967692c 711 (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
35d965d5
RS
712
713/* Specify the registers used for certain standard purposes.
714 The values of these macros are register numbers. */
715
716/* Define this if the program counter is overloaded on a register. */
717#define PC_REGNUM 15
718
719/* Register to use for pushing function arguments. */
720#define STACK_POINTER_REGNUM 13
721
722/* Base register for access to local variables of the function. */
ff9940b0
RE
723#define FRAME_POINTER_REGNUM 25
724
725/* Define this to be where the real frame pointer is if it is not possible to
726 work out the offset between the frame pointer and the automatic variables
727 until after register allocation has taken place. FRAME_POINTER_REGNUM
728 should point to a special register that we will make sure is eliminated. */
729#define HARD_FRAME_POINTER_REGNUM 11
35d965d5
RS
730
731/* Value should be nonzero if functions must have frame pointers.
732 Zero means the frame pointer need not be set up (and parms may be accessed
ff9940b0
RE
733 via the stack pointer) in functions that seem suitable.
734 If we have to have a frame pointer we might as well make use of it.
735 APCS says that the frame pointer does not need to be pushed in leaf
736 functions. */
688743e7
RE
737#define FRAME_POINTER_REQUIRED \
738 (current_function_has_nonlocal_label || (TARGET_APCS && !leaf_function_p ()))
35d965d5
RS
739
740/* Base register for access to arguments of the function. */
ff9940b0 741#define ARG_POINTER_REGNUM 26
35d965d5
RS
742
743/* The native (Norcroft) Pascal compiler for the ARM passes the static chain
744 as an invisible last argument (possible since varargs don't exist in
745 Pascal), so the following is not true. */
746#define STATIC_CHAIN_REGNUM 8
747
748/* Register in which address to store a structure value
749 is passed to a function. */
750#define STRUCT_VALUE_REGNUM 0
751
ff9940b0
RE
752/* Internal, so that we don't need to refer to a raw number */
753#define CC_REGNUM 24
754
35d965d5 755/* The order in which register should be allocated. It is good to use ip
ff9940b0
RE
756 since no saving is required (though calls clobber it) and it never contains
757 function parameters. It is quite good to use lr since other calls may
758 clobber it anyway. Allocate r0 through r3 in reverse order since r3 is
759 least likely to contain a function parameter; in addition results are
760 returned in r0.
761 */
ff73fb53 762#define REG_ALLOC_ORDER \
35d965d5 763{ \
ff73fb53
NC
764 3, 2, 1, 0, 12, 14, 4, 5, \
765 6, 7, 8, 10, 9, 11, 13, 15, \
ff9940b0 766 16, 17, 18, 19, 20, 21, 22, 23, \
ff73fb53 767 24, 25, 26 \
35d965d5
RS
768}
769\f
770/* Register and constant classes. */
771
772/* Register classes: all ARM regs or all FPU regs---simple! */
773enum reg_class
774{
775 NO_REGS,
776 FPU_REGS,
777 GENERAL_REGS,
778 ALL_REGS,
779 LIM_REG_CLASSES
780};
781
782#define N_REG_CLASSES (int) LIM_REG_CLASSES
783
784/* Give names of register classes as strings for dump file. */
785#define REG_CLASS_NAMES \
786{ \
787 "NO_REGS", \
788 "FPU_REGS", \
789 "GENERAL_REGS", \
790 "ALL_REGS", \
791}
792
793/* Define which registers fit in which classes.
794 This is an initializer for a vector of HARD_REG_SET
795 of length N_REG_CLASSES. */
796#define REG_CLASS_CONTENTS \
797{ \
ff9940b0
RE
798 0x0000000, /* NO_REGS */ \
799 0x0FF0000, /* FPU_REGS */ \
800 0x200FFFF, /* GENERAL_REGS */ \
801 0x2FFFFFF /* ALL_REGS */ \
35d965d5
RS
802}
803
804/* The same information, inverted:
805 Return the class number of the smallest class containing
806 reg number REGNO. This could be a conditional expression
807 or could index an array. */
ff9940b0
RE
808#define REGNO_REG_CLASS(REGNO) \
809 (((REGNO) < 16 || REGNO == FRAME_POINTER_REGNUM \
810 || REGNO == ARG_POINTER_REGNUM) \
811 ? GENERAL_REGS : (REGNO) == CC_REGNUM \
812 ? NO_REGS : FPU_REGS)
35d965d5
RS
813
814/* The class value for index registers, and the one for base regs. */
815#define INDEX_REG_CLASS GENERAL_REGS
816#define BASE_REG_CLASS GENERAL_REGS
817
818/* Get reg_class from a letter such as appears in the machine description.
819 We only need constraint `f' for FPU_REGS (`r' == GENERAL_REGS). */
820#define REG_CLASS_FROM_LETTER(C) \
821 ((C)=='f' ? FPU_REGS : NO_REGS)
822
823/* The letters I, J, K, L and M in a register constraint string
824 can be used to stand for particular ranges of immediate operands.
825 This macro defines what the ranges are.
826 C is the letter, and VALUE is a constant value.
827 Return 1 if VALUE is in the range specified by C.
b4ac57ab 828 I: immediate arithmetic operand (i.e. 8 bits shifted as required).
ff9940b0 829 J: valid indexing constants.
aef1764c 830 K: ~value ok in rhs argument of data operand.
3967692c
RE
831 L: -value ok in rhs argument of data operand.
832 M: 0..32, or a power of 2 (for shifts, or mult done by shift). */
aef1764c
RE
833#define CONST_OK_FOR_LETTER_P(VALUE, C) \
834 ((C) == 'I' ? const_ok_for_arm (VALUE) : \
835 (C) == 'J' ? ((VALUE) < 4096 && (VALUE) > -4096) : \
836 (C) == 'K' ? (const_ok_for_arm (~(VALUE))) : \
3967692c
RE
837 (C) == 'L' ? (const_ok_for_arm (-(VALUE))) : \
838 (C) == 'M' ? (((VALUE >= 0 && VALUE <= 32)) \
839 || (((VALUE) & ((VALUE) - 1)) == 0)) \
840 : 0)
ff9940b0
RE
841
842/* For the ARM, `Q' means that this is a memory operand that is just
843 an offset from a register.
844 `S' means any symbol that has the SYMBOL_REF_FLAG set or a CONSTANT_POOL
845 address. This means that the symbol is in the text segment and can be
846 accessed without using a load. */
847
7a801826
RE
848#define EXTRA_CONSTRAINT(OP, C) \
849 ((C) == 'Q' ? GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG \
850 : (C) == 'R' ? (GET_CODE (OP) == MEM \
851 && GET_CODE (XEXP (OP, 0)) == SYMBOL_REF \
852 && CONSTANT_POOL_ADDRESS_P (XEXP (OP, 0))) \
853 : (C) == 'S' ? (optimize > 0 && CONSTANT_ADDRESS_P (OP)) \
854 : 0)
ff9940b0
RE
855
856/* Constant letter 'G' for the FPU immediate constants.
857 'H' means the same constant negated. */
858#define CONST_DOUBLE_OK_FOR_LETTER_P(X,C) \
859 ((C) == 'G' ? const_double_rtx_ok_for_fpu (X) \
860 : (C) == 'H' ? neg_const_double_rtx_ok_for_fpu (X) : 0)
35d965d5
RS
861
862/* Given an rtx X being reloaded into a reg required to be
863 in class CLASS, return the class of reg to actually use.
864 In general this is just CLASS; but on some machines
865 in some cases it is preferable to use a more restrictive class. */
866#define PREFERRED_RELOAD_CLASS(X, CLASS) (CLASS)
867
ff9940b0
RE
868/* Return the register class of a scratch register needed to copy IN into
869 or out of a register in CLASS in MODE. If it can be done directly,
870 NO_REGS is returned. */
11c1a207
RE
871#define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,X) \
872 (((MODE) == HImode && ! arm_arch4 && true_regnum (X) == -1) \
873 ? GENERAL_REGS : NO_REGS)
ff9940b0 874
2ce9c1b9 875/* If we need to load shorts byte-at-a-time, then we need a scratch. */
ed4c4348
RE
876#define SECONDARY_INPUT_RELOAD_CLASS(CLASS,MODE,X) \
877 (((MODE) == HImode && TARGET_SHORT_BY_BYTES \
878 && (GET_CODE (X) == MEM \
879 || ((GET_CODE (X) == REG || GET_CODE (X) == SUBREG) \
880 && true_regnum (X) == -1))) \
2ce9c1b9
RE
881 ? GENERAL_REGS : NO_REGS)
882
6f734908
RE
883/* Try a machine-dependent way of reloading an illegitimate address
884 operand. If we find one, push the reload and jump to WIN. This
885 macro is used in only one place: `find_reloads_address' in reload.c.
886
887 For the ARM, we wish to handle large displacements off a base
888 register by splitting the addend across a MOV and the mem insn.
889 This can cut the number of reloads needed. */
890#define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN) \
891do { \
892 if (GET_CODE (X) == PLUS \
893 && GET_CODE (XEXP (X, 0)) == REG \
894 && REGNO (XEXP (X, 0)) < FIRST_PSEUDO_REGISTER \
895 && REG_MODE_OK_FOR_BASE_P (XEXP (X, 0), MODE) \
896 && GET_CODE (XEXP (X, 1)) == CONST_INT) \
897 { \
898 HOST_WIDE_INT val = INTVAL (XEXP (X, 1)); \
899 HOST_WIDE_INT low, high; \
900 \
901 if (MODE == DImode || (TARGET_SOFT_FLOAT && MODE == DFmode)) \
902 low = ((val & 0xf) ^ 0x8) - 0x8; \
903 else if (MODE == SImode || MODE == QImode \
904 || (MODE == SFmode && TARGET_SOFT_FLOAT) \
905 || (MODE == HImode && ! arm_arch4)) \
906 /* Need to be careful, -4096 is not a valid offset */ \
907 low = val >= 0 ? (val & 0xfff) : -((-val) & 0xfff); \
908 else if (MODE == HImode && arm_arch4) \
909 /* Need to be careful, -256 is not a valid offset */ \
910 low = val >= 0 ? (val & 0xff) : -((-val) & 0xff); \
911 else if (GET_MODE_CLASS (MODE) == MODE_FLOAT \
912 && TARGET_HARD_FLOAT) \
913 /* Need to be careful, -1024 is not a valid offset */ \
914 low = val >= 0 ? (val & 0x3ff) : -((-val) & 0x3ff); \
915 else \
916 break; \
917 \
918 high = ((((val - low) & 0xffffffff) ^ 0x80000000) - 0x80000000); \
919 /* Check for overflow or zero */ \
920 if (low == 0 || high == 0 || (high + low != val)) \
921 break; \
922 \
923 /* Reload the high part into a base reg; leave the low part \
924 in the mem. */ \
925 X = gen_rtx_PLUS (GET_MODE (X), \
926 gen_rtx_PLUS (GET_MODE (X), XEXP (X, 0), \
927 GEN_INT (high)), \
928 GEN_INT (low)); \
929 push_reload (XEXP (X, 0), NULL_RTX, &XEXP (X, 0), NULL_PTR, \
930 BASE_REG_CLASS, GET_MODE (X), VOIDmode, 0, 0, \
931 OPNUM, TYPE); \
932 goto WIN; \
933 } \
934} while (0)
935
35d965d5
RS
936/* Return the maximum number of consecutive registers
937 needed to represent mode MODE in a register of class CLASS.
938 ARM regs are UNITS_PER_WORD bits while FPU regs can hold any FP mode */
939#define CLASS_MAX_NREGS(CLASS, MODE) \
940 ((CLASS) == FPU_REGS ? 1 \
941 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
942
ff9940b0 943/* Moves between FPU_REGS and GENERAL_REGS are two memory insns. */
35d965d5
RS
944#define REGISTER_MOVE_COST(CLASS1, CLASS2) \
945 ((((CLASS1) == FPU_REGS && (CLASS2) != FPU_REGS) \
946 || ((CLASS2) == FPU_REGS && (CLASS1) != FPU_REGS)) \
ff9940b0 947 ? 20 : 2)
35d965d5
RS
948\f
949/* Stack layout; function entry, exit and calling. */
950
951/* Define this if pushing a word on the stack
952 makes the stack pointer a smaller address. */
953#define STACK_GROWS_DOWNWARD 1
954
955/* Define this if the nominal address of the stack frame
956 is at the high-address end of the local variables;
957 that is, each additional local variable allocated
958 goes at a more negative offset in the frame. */
959#define FRAME_GROWS_DOWNWARD 1
960
961/* Offset within stack frame to start allocating local variables at.
962 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
963 first local allocated. Otherwise, it is the offset to the BEGINNING
964 of the first local allocated. */
965#define STARTING_FRAME_OFFSET 0
966
967/* If we generate an insn to push BYTES bytes,
968 this says how many the stack pointer really advances by. */
18543a22
ILT
969/* The push insns do not do this rounding implicitly. So don't define this. */
970/* #define PUSH_ROUNDING(NPUSHED) (((NPUSHED) + 3) & ~3) */
971
972/* Define this if the maximum size of all the outgoing args is to be
973 accumulated and pushed during the prologue. The amount can be
974 found in the variable current_function_outgoing_args_size. */
975#define ACCUMULATE_OUTGOING_ARGS
35d965d5
RS
976
977/* Offset of first parameter from the argument pointer register value. */
978#define FIRST_PARM_OFFSET(FNDECL) 4
979
980/* Value is the number of byte of arguments automatically
981 popped when returning from a subroutine call.
8b109b37 982 FUNDECL is the declaration node of the function (as a tree),
35d965d5
RS
983 FUNTYPE is the data type of the function (as a tree),
984 or for a library call it is an identifier node for the subroutine name.
985 SIZE is the number of bytes of arguments passed on the stack.
986
987 On the ARM, the caller does not pop any of its arguments that were passed
988 on the stack. */
8b109b37 989#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
35d965d5
RS
990
991/* Define how to find the value returned by a function.
992 VALTYPE is the data type of the value (as a tree).
993 If the precise function being called is known, FUNC is its FUNCTION_DECL;
994 otherwise, FUNC is 0. */
995#define FUNCTION_VALUE(VALTYPE, FUNC) \
3ada8e17
DE
996 (GET_MODE_CLASS (TYPE_MODE (VALTYPE)) == MODE_FLOAT && TARGET_HARD_FLOAT \
997 ? gen_rtx (REG, TYPE_MODE (VALTYPE), 16) \
35d965d5
RS
998 : gen_rtx (REG, TYPE_MODE (VALTYPE), 0))
999
1000/* Define how to find the value returned by a library function
1001 assuming the value has mode MODE. */
1002#define LIBCALL_VALUE(MODE) \
3ada8e17
DE
1003 (GET_MODE_CLASS (MODE) == MODE_FLOAT && TARGET_HARD_FLOAT \
1004 ? gen_rtx (REG, MODE, 16) \
35d965d5
RS
1005 : gen_rtx (REG, MODE, 0))
1006
1007/* 1 if N is a possible register number for a function value.
1008 On the ARM, only r0 and f0 can return results. */
1009#define FUNCTION_VALUE_REGNO_P(REGNO) \
3ada8e17 1010 ((REGNO) == 0 || ((REGNO) == 16) && TARGET_HARD_FLOAT)
35d965d5 1011
11c1a207
RE
1012/* How large values are returned */
1013/* A C expression which can inhibit the returning of certain function values
1014 in registers, based on the type of value. */
1015#define RETURN_IN_MEMORY(TYPE) \
1016 (TYPE_MODE ((TYPE)) == BLKmode || \
1017 (AGGREGATE_TYPE_P ((TYPE)) && arm_return_in_memory ((TYPE))))
1018
1019/* Define DEFAULT_PCC_STRUCT_RETURN to 1 if all structure and union return
1020 values must be in memory. On the ARM, they need only do so if larger
1021 than a word, or if they contain elements offset from zero in the struct. */
1022#define DEFAULT_PCC_STRUCT_RETURN 0
1023
35d965d5
RS
1024/* Define where to put the arguments to a function.
1025 Value is zero to push the argument on the stack,
1026 or a hard register in which to store the argument.
1027
1028 MODE is the argument's machine mode.
1029 TYPE is the data type of the argument (as a tree).
1030 This is null for libcalls where that information may
1031 not be available.
1032 CUM is a variable of type CUMULATIVE_ARGS which gives info about
1033 the preceding args and about the function being called.
1034 NAMED is nonzero if this argument is a named parameter
1035 (otherwise it is an extra parameter matching an ellipsis).
1036
1037 On the ARM, normally the first 16 bytes are passed in registers r0-r3; all
1038 other arguments are passed on the stack. If (NAMED == 0) (which happens
1039 only in assign_parms, since SETUP_INCOMING_VARARGS is defined), say it is
1040 passed in the stack (function_prologue will indeed make it pass in the
1041 stack if necessary). */
1042#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1043 ((NAMED) \
1044 ? ((CUM) >= 16 ? 0 : gen_rtx (REG, MODE, (CUM) / 4)) \
1045 : 0)
1046
1047/* For an arg passed partly in registers and partly in memory,
1048 this is the number of registers used.
1049 For args passed entirely in registers or entirely in memory, zero. */
1050#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
1051 ((CUM) < 16 && 16 < (CUM) + ((MODE) != BLKmode \
1052 ? GET_MODE_SIZE (MODE) \
1053 : int_size_in_bytes (TYPE)) \
1054 ? 4 - (CUM) / 4 : 0)
1055
1056/* A C type for declaring a variable that is used as the first argument of
1057 `FUNCTION_ARG' and other related values. For some target machines, the
1058 type `int' suffices and can hold the number of bytes of argument so far.
1059
1060 On the ARM, this is the number of bytes of arguments scanned so far. */
1061#define CUMULATIVE_ARGS int
1062
1063/* Initialize a variable CUM of type CUMULATIVE_ARGS
1064 for a call to a function whose data type is FNTYPE.
1065 For a library call, FNTYPE is 0.
1066 On the ARM, the offset starts at 0. */
2c7ee1a6 1067#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT) \
ff9940b0 1068 ((CUM) = (((FNTYPE) && aggregate_value_p (TREE_TYPE ((FNTYPE)))) ? 4 : 0))
35d965d5
RS
1069
1070/* Update the data in CUM to advance over an argument
1071 of mode MODE and data type TYPE.
1072 (TYPE is null for libcalls where that information may not be available.) */
1073#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
1074 (CUM) += ((MODE) != BLKmode \
1075 ? (GET_MODE_SIZE (MODE) + 3) & ~3 \
1076 : (int_size_in_bytes (TYPE) + 3) & ~3) \
1077
1078/* 1 if N is a possible register number for function argument passing.
1079 On the ARM, r0-r3 are used to pass args. */
1080#define FUNCTION_ARG_REGNO_P(REGNO) \
1081 ((REGNO) >= 0 && (REGNO) <= 3)
1082
1083/* Perform any actions needed for a function that is receiving a variable
1084 number of arguments. CUM is as above. MODE and TYPE are the mode and type
1085 of the current parameter. PRETEND_SIZE is a variable that should be set to
1086 the amount of stack that must be pushed by the prolog to pretend that our
1087 caller pushed it.
1088
1089 Normally, this macro will push all remaining incoming registers on the
1090 stack and set PRETEND_SIZE to the length of the registers pushed.
1091
1092 On the ARM, PRETEND_SIZE is set in order to have the prologue push the last
1093 named arg and all anonymous args onto the stack.
1094 XXX I know the prologue shouldn't be pushing registers, but it is faster
1095 that way. */
1096#define SETUP_INCOMING_VARARGS(CUM, MODE, TYPE, PRETEND_SIZE, NO_RTL) \
1097{ \
1098 extern int current_function_anonymous_args; \
1099 current_function_anonymous_args = 1; \
1100 if ((CUM) < 16) \
1101 (PRETEND_SIZE) = 16 - (CUM); \
1102}
1103
1104/* Generate assembly output for the start of a function. */
1105#define FUNCTION_PROLOGUE(STREAM, SIZE) \
008cf58a 1106 output_func_prologue ((STREAM), (SIZE))
35d965d5
RS
1107
1108/* Call the function profiler with a given profile label. The Acorn compiler
7a801826 1109 puts this BEFORE the prolog but gcc puts it afterwards. The ``mov ip,lr''
35d965d5
RS
1110 seems like a good idea to stick with cc convention. ``prof'' doesn't seem
1111 to mind about this! */
4eda77ec
RE
1112#define FUNCTION_PROFILER(STREAM,LABELNO) \
1113{ \
c383667d 1114 fprintf(STREAM, "\tmov\t%sip, %slr\n", REGISTER_PREFIX, REGISTER_PREFIX); \
4eda77ec
RE
1115 fprintf(STREAM, "\tbl\tmcount\n"); \
1116 fprintf(STREAM, "\t.word\tLP%d\n", (LABELNO)); \
35d965d5
RS
1117}
1118
1119/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1120 the stack pointer does not matter. The value is tested only in
1121 functions that have frame pointers.
1122 No definition is equivalent to always zero.
1123
1124 On the ARM, the function epilogue recovers the stack pointer from the
1125 frame. */
1126#define EXIT_IGNORE_STACK 1
1127
1128/* Generate the assembly code for function exit. */
1129#define FUNCTION_EPILOGUE(STREAM, SIZE) \
008cf58a 1130 output_func_epilogue ((STREAM), (SIZE))
35d965d5
RS
1131
1132/* Determine if the epilogue should be output as RTL.
1133 You should override this if you define FUNCTION_EXTRA_EPILOGUE. */
ff9940b0
RE
1134#define USE_RETURN_INSN use_return_insn ()
1135
1136/* Definitions for register eliminations.
1137
1138 This is an array of structures. Each structure initializes one pair
1139 of eliminable registers. The "from" register number is given first,
1140 followed by "to". Eliminations of the same "from" register are listed
1141 in order of preference.
1142
1143 We have two registers that can be eliminated on the ARM. First, the
1144 arg pointer register can often be eliminated in favor of the stack
1145 pointer register. Secondly, the pseudo frame pointer register can always
1146 be eliminated; it is replaced with either the stack or the real frame
1147 pointer. */
1148
1149#define ELIMINABLE_REGS \
1150{{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1151 {ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
1152 {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1153 {FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}
1154
1155/* Given FROM and TO register numbers, say whether this elimination is allowed.
1156 Frame pointer elimination is automatically handled.
1157
1158 All eliminations are permissible. Note that ARG_POINTER_REGNUM and
abc95ed3 1159 HARD_FRAME_POINTER_REGNUM are in fact the same thing. If we need a frame
ff9940b0
RE
1160 pointer, we must eliminate FRAME_POINTER_REGNUM into
1161 HARD_FRAME_POINTER_REGNUM and not into STACK_POINTER_REGNUM. */
1162#define CAN_ELIMINATE(FROM, TO) \
1163 (((TO) == STACK_POINTER_REGNUM && frame_pointer_needed) ? 0 : 1)
1164
1165/* Define the offset between two registers, one to be eliminated, and the other
1166 its replacement, at the start of a routine. */
1167#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1168{ \
3967692c 1169 int volatile_func = arm_volatile_func (); \
ff9940b0
RE
1170 if ((FROM) == ARG_POINTER_REGNUM && (TO) == HARD_FRAME_POINTER_REGNUM)\
1171 (OFFSET) = 0; \
18543a22
ILT
1172 else if ((FROM) == FRAME_POINTER_REGNUM \
1173 && (TO) == STACK_POINTER_REGNUM) \
1174 (OFFSET) = (current_function_outgoing_args_size \
1175 + (get_frame_size () + 3 & ~3)); \
ff9940b0
RE
1176 else \
1177 { \
1178 int regno; \
1179 int offset = 12; \
008cf58a 1180 int saved_hard_reg = 0; \
ff9940b0 1181 \
3967692c
RE
1182 if (! volatile_func) \
1183 { \
1184 for (regno = 0; regno <= 10; regno++) \
1185 if (regs_ever_live[regno] && ! call_used_regs[regno]) \
1186 saved_hard_reg = 1, offset += 4; \
1187 for (regno = 16; regno <=23; regno++) \
1188 if (regs_ever_live[regno] && ! call_used_regs[regno]) \
1189 offset += 12; \
1190 } \
ff9940b0
RE
1191 if ((FROM) == FRAME_POINTER_REGNUM) \
1192 (OFFSET) = -offset; \
1193 else \
1194 { \
bd4d60ce 1195 if (! frame_pointer_needed) \
ff9940b0 1196 offset -= 16; \
18543a22
ILT
1197 if (! volatile_func \
1198 && (regs_ever_live[14] || saved_hard_reg)) \
ff9940b0 1199 offset += 4; \
18543a22 1200 offset += current_function_outgoing_args_size; \
ff9940b0
RE
1201 (OFFSET) = (get_frame_size () + 3 & ~3) + offset; \
1202 } \
1203 } \
1204}
35d965d5 1205
35d965d5
RS
1206/* Output assembler code for a block containing the constant parts
1207 of a trampoline, leaving space for the variable parts.
1208
1209 On the ARM, (if r8 is the static chain regnum, and remembering that
1210 referencing pc adds an offset of 8) the trampoline looks like:
1211 ldr r8, [pc, #0]
1212 ldr pc, [pc]
1213 .word static chain value
11c1a207
RE
1214 .word function's address
1215 ??? FIXME: When the trampoline returns, r8 will be clobbered. */
4eda77ec
RE
1216#define TRAMPOLINE_TEMPLATE(FILE) \
1217{ \
c383667d
DE
1218 fprintf ((FILE), "\tldr\t%sr8, [%spc, #0]\n", \
1219 REGISTER_PREFIX, REGISTER_PREFIX); \
1220 fprintf ((FILE), "\tldr\t%spc, [%spc, #0]\n", \
1221 REGISTER_PREFIX, REGISTER_PREFIX); \
4eda77ec
RE
1222 fprintf ((FILE), "\t.word\t0\n"); \
1223 fprintf ((FILE), "\t.word\t0\n"); \
35d965d5
RS
1224}
1225
1226/* Length in units of the trampoline for entering a nested function. */
1227#define TRAMPOLINE_SIZE 16
1228
1229/* Alignment required for a trampoline in units. */
1230#define TRAMPOLINE_ALIGN 4
1231
1232/* Emit RTL insns to initialize the variable parts of a trampoline.
1233 FNADDR is an RTX for the address of the function's pure code.
1234 CXT is an RTX for the static chain value for the function. */
1235#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
1236{ \
1237 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 8)), \
1238 (CXT)); \
1239 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 12)), \
1240 (FNADDR)); \
1241}
1242
35d965d5
RS
1243\f
1244/* Addressing modes, and classification of registers for them. */
1245
1246#define HAVE_POST_INCREMENT 1
1247#define HAVE_PRE_INCREMENT 1
1248#define HAVE_POST_DECREMENT 1
1249#define HAVE_PRE_DECREMENT 1
1250
1251/* Macros to check register numbers against specific register classes. */
1252
1253/* These assume that REGNO is a hard or pseudo reg number.
1254 They give nonzero only if REGNO is a hard reg of the suitable class
1255 or a pseudo reg currently allocated to a suitable hard reg.
1256 Since they use reg_renumber, they are safe only once reg_renumber
1257 has been allocated, which happens in local-alloc.c.
1258
1259 On the ARM, don't allow the pc to be used. */
ff9940b0
RE
1260#define REGNO_OK_FOR_BASE_P(REGNO) \
1261 ((REGNO) < 15 || (REGNO) == FRAME_POINTER_REGNUM \
1262 || (REGNO) == ARG_POINTER_REGNUM \
1263 || (unsigned) reg_renumber[(REGNO)] < 15 \
1264 || (unsigned) reg_renumber[(REGNO)] == FRAME_POINTER_REGNUM \
1265 || (unsigned) reg_renumber[(REGNO)] == ARG_POINTER_REGNUM)
1266#define REGNO_OK_FOR_INDEX_P(REGNO) \
35d965d5
RS
1267 REGNO_OK_FOR_BASE_P(REGNO)
1268
1269/* Maximum number of registers that can appear in a valid memory address.
ff9940b0
RE
1270 Shifts in addresses can't be by a register. */
1271
1272#define MAX_REGS_PER_ADDRESS 2
35d965d5
RS
1273
1274/* Recognize any constant value that is a valid address. */
1275/* XXX We can address any constant, eventually... */
11c1a207
RE
1276
1277#ifdef AOF_ASSEMBLER
1278
1279#define CONSTANT_ADDRESS_P(X) \
1280 (GET_CODE (X) == SYMBOL_REF \
1281 && CONSTANT_POOL_ADDRESS_P (X))
1282
1283#else
35d965d5 1284
008cf58a
RE
1285#define CONSTANT_ADDRESS_P(X) \
1286 (GET_CODE (X) == SYMBOL_REF \
1287 && (CONSTANT_POOL_ADDRESS_P (X) \
1288 || (optimize > 0 && SYMBOL_REF_FLAG (X))))
35d965d5 1289
11c1a207
RE
1290#endif /* AOF_ASSEMBLER */
1291
35d965d5
RS
1292/* Nonzero if the constant value X is a legitimate general operand.
1293 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.
1294
1295 On the ARM, allow any integer (invalid ones are removed later by insn
1296 patterns), nice doubles and symbol_refs which refer to the function's
1297 constant pool XXX. */
11c1a207 1298#define LEGITIMATE_CONSTANT_P(X) (! label_mentioned_p (X))
ff9940b0
RE
1299
1300/* Symbols in the text segment can be accessed without indirecting via the
1301 constant pool; it may take an extra binary operation, but this is still
008cf58a
RE
1302 faster than indirecting via memory. Don't do this when not optimizing,
1303 since we won't be calculating al of the offsets necessary to do this
1304 simplification. */
11c1a207
RE
1305/* This doesn't work with AOF syntax, since the string table may be in
1306 a different AREA. */
1307#ifndef AOF_ASSEMBLER
ff9940b0
RE
1308#define ENCODE_SECTION_INFO(decl) \
1309{ \
008cf58a 1310 if (optimize > 0 && TREE_CONSTANT (decl) \
ff9940b0 1311 && (!flag_writable_strings || TREE_CODE (decl) != STRING_CST)) \
228b6a3f
RS
1312 { \
1313 rtx rtl = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd' \
1314 ? TREE_CST_RTL (decl) : DECL_RTL (decl)); \
1315 SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1; \
1316 } \
ff9940b0 1317}
11c1a207 1318#endif
7a801826 1319
35d965d5
RS
1320/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1321 and check its validity for a certain class.
1322 We have two alternate definitions for each of them.
1323 The usual definition accepts all pseudo regs; the other rejects
1324 them unless they have been allocated suitable hard regs.
1325 The symbol REG_OK_STRICT causes the latter definition to be used. */
1326#ifndef REG_OK_STRICT
ff9940b0 1327
35d965d5
RS
1328/* Nonzero if X is a hard reg that can be used as a base reg
1329 or if it is a pseudo reg. */
ff9940b0
RE
1330#define REG_OK_FOR_BASE_P(X) \
1331 (REGNO (X) < 16 || REGNO (X) >= FIRST_PSEUDO_REGISTER \
1332 || REGNO (X) == FRAME_POINTER_REGNUM || REGNO (X) == ARG_POINTER_REGNUM)
1333
35d965d5
RS
1334/* Nonzero if X is a hard reg that can be used as an index
1335 or if it is a pseudo reg. */
1336#define REG_OK_FOR_INDEX_P(X) \
1337 REG_OK_FOR_BASE_P(X)
ff9940b0
RE
1338
1339#define REG_OK_FOR_PRE_POST_P(X) \
1340 (REGNO (X) < 16 || REGNO (X) >= FIRST_PSEUDO_REGISTER \
1341 || REGNO (X) == FRAME_POINTER_REGNUM || REGNO (X) == ARG_POINTER_REGNUM)
1342
35d965d5 1343#else
ff9940b0 1344
35d965d5
RS
1345/* Nonzero if X is a hard reg that can be used as a base reg. */
1346#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
ff9940b0 1347
35d965d5
RS
1348/* Nonzero if X is a hard reg that can be used as an index. */
1349#define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
ff9940b0
RE
1350
1351#define REG_OK_FOR_PRE_POST_P(X) \
1352 (REGNO (X) < 16 || (unsigned) reg_renumber[REGNO (X)] < 16 \
1353 || REGNO (X) == FRAME_POINTER_REGNUM || REGNO (X) == ARG_POINTER_REGNUM \
1354 || (unsigned) reg_renumber[REGNO (X)] == FRAME_POINTER_REGNUM \
1355 || (unsigned) reg_renumber[REGNO (X)] == ARG_POINTER_REGNUM)
1356
35d965d5
RS
1357#endif
1358\f
1359/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1360 that is a valid memory address for an instruction.
1361 The MODE argument is the machine mode for the MEM expression
1362 that wants to use this address.
1363
1364 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS. */
1365#define BASE_REGISTER_RTX_P(X) \
1366 (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X))
1367
1368#define INDEX_REGISTER_RTX_P(X) \
1369 (GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X))
1370
1371/* A C statement (sans semicolon) to jump to LABEL for legitimate index RTXs
1372 used by the macro GO_IF_LEGITIMATE_ADDRESS. Floating point indices can
1373 only be small constants. */
ff9940b0 1374#define GO_IF_LEGITIMATE_INDEX(MODE, BASE_REGNO, INDEX, LABEL) \
4d01c30f
RS
1375do \
1376{ \
008cf58a
RE
1377 HOST_WIDE_INT range; \
1378 enum rtx_code code = GET_CODE (INDEX); \
4d01c30f 1379 \
11c1a207 1380 if (TARGET_HARD_FLOAT && GET_MODE_CLASS (MODE) == MODE_FLOAT) \
ff9940b0
RE
1381 { \
1382 if (code == CONST_INT && INTVAL (INDEX) < 1024 \
1383 && INTVAL (INDEX) > -1024 \
1384 && (INTVAL (INDEX) & 3) == 0) \
1385 goto LABEL; \
1386 } \
4d01c30f
RS
1387 else \
1388 { \
ff9940b0 1389 if (INDEX_REGISTER_RTX_P (INDEX) && GET_MODE_SIZE (MODE) <= 4) \
4d01c30f 1390 goto LABEL; \
11c1a207
RE
1391 if (GET_MODE_SIZE (MODE) <= 4 && code == MULT \
1392 && (! arm_arch4 || (MODE) != HImode)) \
4d01c30f
RS
1393 { \
1394 rtx xiop0 = XEXP (INDEX, 0); \
1395 rtx xiop1 = XEXP (INDEX, 1); \
1396 if (INDEX_REGISTER_RTX_P (xiop0) \
1397 && power_of_two_operand (xiop1, SImode)) \
1398 goto LABEL; \
1399 if (INDEX_REGISTER_RTX_P (xiop1) \
1400 && power_of_two_operand (xiop0, SImode)) \
1401 goto LABEL; \
1402 } \
ff9940b0 1403 if (GET_MODE_SIZE (MODE) <= 4 \
996a5f59 1404 && (code == LSHIFTRT || code == ASHIFTRT \
11c1a207
RE
1405 || code == ASHIFT || code == ROTATERT) \
1406 && (! arm_arch4 || (MODE) != HImode)) \
ff9940b0
RE
1407 { \
1408 rtx op = XEXP (INDEX, 1); \
1409 if (INDEX_REGISTER_RTX_P (XEXP (INDEX, 0)) \
1410 && GET_CODE (op) == CONST_INT && INTVAL (op) > 0 \
1411 && INTVAL (op) <= 31) \
1412 goto LABEL; \
1413 } \
ff73fb53
NC
1414 /* NASTY: Since this limits the addressing of unsigned byte loads */ \
1415 range = ((MODE) == HImode || (MODE) == QImode) \
1416 ? (arm_arch4 ? 256 : 4095) : 4096; \
ff9940b0
RE
1417 if (code == CONST_INT && INTVAL (INDEX) < range \
1418 && INTVAL (INDEX) > -range) \
1419 goto LABEL; \
4d01c30f 1420 } \
35d965d5
RS
1421} while (0)
1422
1423/* Jump to LABEL if X is a valid address RTX. This must also take
1424 REG_OK_STRICT into account when deciding about valid registers, but it uses
1425 the above macros so we are in luck. Allow REG, REG+REG, REG+INDEX,
1426 INDEX+REG, REG-INDEX, and non floating SYMBOL_REF to the constant pool.
ff9940b0
RE
1427 Allow REG-only and AUTINC-REG if handling TImode or HImode. Other symbol
1428 refs must be forced though a static cell to ensure addressability. */
11c1a207 1429#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
35d965d5
RS
1430{ \
1431 if (BASE_REGISTER_RTX_P (X)) \
1432 goto LABEL; \
1433 else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC) \
1434 && GET_CODE (XEXP (X, 0)) == REG \
1435 && REG_OK_FOR_PRE_POST_P (XEXP (X, 0))) \
1436 goto LABEL; \
11c1a207
RE
1437 else if (GET_MODE_SIZE (MODE) >= 4 && reload_completed \
1438 && (GET_CODE (X) == LABEL_REF \
1439 || (GET_CODE (X) == CONST \
1440 && GET_CODE (XEXP ((X), 0)) == PLUS \
1441 && GET_CODE (XEXP (XEXP ((X), 0), 0)) == LABEL_REF \
1442 && GET_CODE (XEXP (XEXP ((X), 0), 1)) == CONST_INT)))\
1443 goto LABEL; \
35d965d5
RS
1444 else if ((MODE) == TImode) \
1445 ; \
11c1a207
RE
1446 else if ((MODE) == DImode || (TARGET_SOFT_FLOAT && (MODE) == DFmode)) \
1447 { \
1448 if (GET_CODE (X) == PLUS && BASE_REGISTER_RTX_P (XEXP (X, 0)) \
1449 && GET_CODE (XEXP (X, 1)) == CONST_INT) \
1450 { \
1451 HOST_WIDE_INT val = INTVAL (XEXP (X, 1)); \
1452 if (val == 4 || val == -4 || val == -8) \
1453 goto LABEL; \
1454 } \
1455 } \
35d965d5
RS
1456 else if (GET_CODE (X) == PLUS) \
1457 { \
1458 rtx xop0 = XEXP(X,0); \
1459 rtx xop1 = XEXP(X,1); \
1460 \
1461 if (BASE_REGISTER_RTX_P (xop0)) \
1462 GO_IF_LEGITIMATE_INDEX (MODE, REGNO (xop0), xop1, LABEL); \
1463 else if (BASE_REGISTER_RTX_P (xop1)) \
1464 GO_IF_LEGITIMATE_INDEX (MODE, REGNO (xop1), xop0, LABEL); \
1465 } \
18543a22
ILT
1466 /* Reload currently can't handle MINUS, so disable this for now */ \
1467 /* else if (GET_CODE (X) == MINUS) \
35d965d5
RS
1468 { \
1469 rtx xop0 = XEXP (X,0); \
1470 rtx xop1 = XEXP (X,1); \
1471 \
1472 if (BASE_REGISTER_RTX_P (xop0)) \
1473 GO_IF_LEGITIMATE_INDEX (MODE, -1, xop1, LABEL); \
18543a22 1474 } */ \
35d965d5
RS
1475 else if (GET_MODE_CLASS (MODE) != MODE_FLOAT \
1476 && GET_CODE (X) == SYMBOL_REF \
1477 && CONSTANT_POOL_ADDRESS_P (X)) \
1478 goto LABEL; \
1479 else if ((GET_CODE (X) == PRE_INC || GET_CODE (X) == POST_DEC) \
11c1a207 1480 && (GET_MODE_SIZE (MODE) <= 4) \
35d965d5
RS
1481 && GET_CODE (XEXP (X, 0)) == REG \
1482 && REG_OK_FOR_PRE_POST_P (XEXP (X, 0))) \
1483 goto LABEL; \
1484}
1485\f
1486/* Try machine-dependent ways of modifying an illegitimate address
1487 to be legitimate. If we find one, return the new, valid address.
1488 This macro is used in only one place: `memory_address' in explow.c.
1489
1490 OLDX is the address as it was before break_out_memory_refs was called.
1491 In some cases it is useful to look at this to decide what needs to be done.
1492
1493 MODE and WIN are passed so that this macro can use
1494 GO_IF_LEGITIMATE_ADDRESS.
1495
1496 It is always safe for this macro to do nothing. It exists to recognize
1497 opportunities to optimize the output.
1498
1499 On the ARM, try to convert [REG, #BIGCONST]
1500 into ADD BASE, REG, #UPPERCONST and [BASE, #VALIDCONST],
1501 where VALIDCONST == 0 in case of TImode. */
7a801826 1502extern struct rtx_def *legitimize_pic_address ();
3967692c
RE
1503#define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
1504{ \
1505 if (GET_CODE (X) == PLUS) \
1506 { \
1507 rtx xop0 = XEXP (X, 0); \
1508 rtx xop1 = XEXP (X, 1); \
1509 \
11c1a207 1510 if (CONSTANT_P (xop0) && ! symbol_mentioned_p (xop0)) \
3967692c 1511 xop0 = force_reg (SImode, xop0); \
11c1a207 1512 if (CONSTANT_P (xop1) && ! symbol_mentioned_p (xop1)) \
3967692c
RE
1513 xop1 = force_reg (SImode, xop1); \
1514 if (BASE_REGISTER_RTX_P (xop0) && GET_CODE (xop1) == CONST_INT) \
1515 { \
1516 HOST_WIDE_INT n, low_n; \
1517 rtx base_reg, val; \
1518 n = INTVAL (xop1); \
1519 \
11c1a207 1520 if (MODE == DImode || (TARGET_SOFT_FLOAT && MODE == DFmode)) \
3967692c
RE
1521 { \
1522 low_n = n & 0x0f; \
1523 n &= ~0x0f; \
1524 if (low_n > 4) \
1525 { \
1526 n += 16; \
1527 low_n -= 16; \
1528 } \
1529 } \
1530 else \
1531 { \
1532 low_n = ((MODE) == TImode ? 0 \
1533 : n >= 0 ? (n & 0xfff) : -((-n) & 0xfff)); \
1534 n -= low_n; \
1535 } \
1536 base_reg = gen_reg_rtx (SImode); \
1537 val = force_operand (gen_rtx (PLUS, SImode, xop0, \
1538 GEN_INT (n)), NULL_RTX); \
1539 emit_move_insn (base_reg, val); \
1540 (X) = (low_n == 0 ? base_reg \
1541 : gen_rtx (PLUS, SImode, base_reg, GEN_INT (low_n))); \
1542 } \
1543 else if (xop0 != XEXP (X, 0) || xop1 != XEXP (x, 1)) \
1544 (X) = gen_rtx (PLUS, SImode, xop0, xop1); \
1545 } \
1546 else if (GET_CODE (X) == MINUS) \
1547 { \
1548 rtx xop0 = XEXP (X, 0); \
1549 rtx xop1 = XEXP (X, 1); \
1550 \
1551 if (CONSTANT_P (xop0)) \
1552 xop0 = force_reg (SImode, xop0); \
11c1a207 1553 if (CONSTANT_P (xop1) && ! symbol_mentioned_p (xop1)) \
3967692c
RE
1554 xop1 = force_reg (SImode, xop1); \
1555 if (xop0 != XEXP (X, 0) || xop1 != XEXP (X, 1)) \
1556 (X) = gen_rtx (MINUS, SImode, xop0, xop1); \
1557 } \
7a801826
RE
1558 if (flag_pic) \
1559 (X) = legitimize_pic_address (OLDX, MODE, NULL_RTX); \
3967692c
RE
1560 if (memory_address_p (MODE, X)) \
1561 goto WIN; \
35d965d5
RS
1562}
1563
1564/* Go to LABEL if ADDR (a legitimate address expression)
1565 has an effect that depends on the machine mode it is used for. */
1566#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1567{ \
1568 if (GET_CODE(ADDR) == PRE_DEC || GET_CODE(ADDR) == POST_DEC \
1569 || GET_CODE(ADDR) == PRE_INC || GET_CODE(ADDR) == POST_INC) \
1570 goto LABEL; \
1571}
1572\f
1573/* Specify the machine mode that this machine uses
1574 for the index in the tablejump instruction. */
1575#define CASE_VECTOR_MODE SImode
1576
18543a22
ILT
1577/* Define as C expression which evaluates to nonzero if the tablejump
1578 instruction expects the table to contain offsets from the address of the
1579 table.
1580 Do not define this if the table should contain absolute addresses. */
1581/* #define CASE_VECTOR_PC_RELATIVE 1 */
35d965d5
RS
1582
1583/* Specify the tree operation to be used to convert reals to integers. */
1584#define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1585
1586/* This is the kind of divide that is easiest to do in the general case. */
1587#define EASY_DIV_EXPR TRUNC_DIV_EXPR
1588
ff9940b0
RE
1589/* signed 'char' is most compatible, but RISC OS wants it unsigned.
1590 unsigned is probably best, but may break some code. */
1591#ifndef DEFAULT_SIGNED_CHAR
3967692c 1592#define DEFAULT_SIGNED_CHAR 0
35d965d5
RS
1593#endif
1594
1595/* Don't cse the address of the function being compiled. */
1596#define NO_RECURSIVE_FUNCTION_CSE 1
1597
1598/* Max number of bytes we can move from memory to memory
d17ce9af
TG
1599 in one reasonably fast instruction. */
1600#define MOVE_MAX 4
35d965d5 1601
ff9940b0
RE
1602/* Define if operations between registers always perform the operation
1603 on the full register even if a narrower mode is specified. */
1604#define WORD_REGISTER_OPERATIONS
1605
1606/* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1607 will either zero-extend or sign-extend. The value of this macro should
1608 be the code that says which one of the two operations is implicitly
1609 done, NIL if none. */
9c872872 1610#define LOAD_EXTEND_OP(MODE) \
11c1a207 1611 ((arm_arch4 || (MODE) == QImode) ? ZERO_EXTEND \
9c872872 1612 : ((BYTES_BIG_ENDIAN && (MODE) == HImode) ? SIGN_EXTEND : NIL))
ff9940b0 1613
35d965d5
RS
1614/* Define this if zero-extension is slow (more than one real instruction).
1615 On the ARM, it is more than one instruction only if not fetching from
1616 memory. */
1617/* #define SLOW_ZERO_EXTEND */
1618
1619/* Nonzero if access to memory by bytes is slow and undesirable. */
1620#define SLOW_BYTE_ACCESS 0
1621
1622/* Immediate shift counts are truncated by the output routines (or was it
1623 the assembler?). Shift counts in a register are truncated by ARM. Note
1624 that the native compiler puts too large (> 32) immediate shift counts
1625 into a register and shifts by the register, letting the ARM decide what
1626 to do instead of doing that itself. */
ff9940b0
RE
1627/* This is all wrong. Defining SHIFT_COUNT_TRUNCATED tells combine that
1628 code like (X << (Y % 32)) for register X, Y is equivalent to (X << Y).
1629 On the arm, Y in a register is used modulo 256 for the shift. Only for
1630 rotates is modulo 32 used. */
1631/* #define SHIFT_COUNT_TRUNCATED 1 */
35d965d5 1632
35d965d5
RS
1633/* All integers have the same format so truncation is easy. */
1634#define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) 1
1635
1636/* Calling from registers is a massive pain. */
1637#define NO_FUNCTION_CSE 1
1638
1639/* Chars and shorts should be passed as ints. */
1640#define PROMOTE_PROTOTYPES 1
1641
35d965d5
RS
1642/* The machine modes of pointers and functions */
1643#define Pmode SImode
1644#define FUNCTION_MODE Pmode
1645
1646/* The structure type of the machine dependent info field of insns
1647 No uses for this yet. */
1648/* #define INSN_MACHINE_INFO struct machine_info */
1649
1650/* The relative costs of various types of constants. Note that cse.c defines
1651 REG = 1, SUBREG = 2, any node = (2 + sum of subnodes). */
ff9940b0
RE
1652#define CONST_COSTS(RTX, CODE, OUTER_CODE) \
1653 case CONST_INT: \
1654 if (const_ok_for_arm (INTVAL (RTX))) \
1655 return (OUTER_CODE) == SET ? 2 : -1; \
1656 else if (OUTER_CODE == AND \
1657 && const_ok_for_arm (~INTVAL (RTX))) \
1658 return -1; \
1659 else if ((OUTER_CODE == COMPARE \
1660 || OUTER_CODE == PLUS || OUTER_CODE == MINUS) \
1661 && const_ok_for_arm (-INTVAL (RTX))) \
1662 return -1; \
1663 else \
1664 return 5; \
1665 case CONST: \
1666 case LABEL_REF: \
1667 case SYMBOL_REF: \
1668 return 6; \
1669 case CONST_DOUBLE: \
1670 if (const_double_rtx_ok_for_fpu (RTX)) \
1671 return (OUTER_CODE) == SET ? 2 : -1; \
1672 else if (((OUTER_CODE) == COMPARE || (OUTER_CODE) == PLUS) \
1673 && neg_const_double_rtx_ok_for_fpu (RTX)) \
1674 return -1; \
1675 return(7);
1676
3967692c
RE
1677#define ARM_FRAME_RTX(X) \
1678 ((X) == frame_pointer_rtx || (X) == stack_pointer_rtx \
1679 || (X) == arg_pointer_rtx)
1680
8625fab5 1681#define DEFAULT_RTX_COSTS(X,CODE,OUTER_CODE) \
3967692c 1682 return arm_rtx_costs (X, CODE, OUTER_CODE);
ff9940b0
RE
1683
1684/* Moves to and from memory are quite expensive */
cbd5b9a2 1685#define MEMORY_MOVE_COST(MODE,CLASS,IN) 10
ff9940b0 1686
3967692c 1687/* All address computations that can be done are free, but rtx cost returns
ddd5a7c1 1688 the same for practically all of them. So we weight the different types
3967692c
RE
1689 of address here in the order (most pref first):
1690 PRE/POST_INC/DEC, SHIFT or NON-INT sum, INT sum, REG, MEM or LABEL. */
1691#define ADDRESS_COST(X) \
1692 (10 - ((GET_CODE (X) == MEM || GET_CODE (X) == LABEL_REF \
1693 || GET_CODE (X) == SYMBOL_REF) \
1694 ? 0 \
1695 : ((GET_CODE (X) == PRE_INC || GET_CODE (X) == PRE_DEC \
1696 || GET_CODE (X) == POST_INC || GET_CODE (X) == POST_DEC) \
1697 ? 10 \
1698 : (((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS) \
1699 ? 6 + (GET_CODE (XEXP (X, 1)) == CONST_INT ? 2 \
1700 : ((GET_RTX_CLASS (GET_CODE (XEXP (X, 0))) == '2' \
1701 || GET_RTX_CLASS (GET_CODE (XEXP (X, 0))) == 'c' \
1702 || GET_RTX_CLASS (GET_CODE (XEXP (X, 1))) == '2' \
1703 || GET_RTX_CLASS (GET_CODE (XEXP (X, 1))) == 'c') \
1704 ? 1 : 0)) \
1705 : 4)))))
1706
1707
ff9940b0
RE
1708
1709/* Try to generate sequences that don't involve branches, we can then use
1710 conditional instructions */
1711#define BRANCH_COST 4
7a801826
RE
1712
1713/* A C statement to update the variable COST based on the relationship
1714 between INSN that is dependent on DEP through dependence LINK. */
1715#define ADJUST_COST(INSN,LINK,DEP,COST) \
1716 (COST) = arm_adjust_cost ((INSN), (LINK), (DEP), (COST))
1717\f
1718/* Position Independent Code. */
1719/* We decide which register to use based on the compilation options and
1720 the assembler in use; this is more general than the APCS restriction of
1721 using sb (r9) all the time. */
1722extern int arm_pic_register;
1723
1724/* The register number of the register used to address a table of static
1725 data addresses in memory. */
1726#define PIC_OFFSET_TABLE_REGNUM arm_pic_register
1727
1728#define FINALIZE_PIC arm_finalize_pic ()
1729
1730#define LEGITIMATE_PIC_OPERAND_P(X) (! symbol_mentioned_p (X))
1731
1732
35d965d5 1733\f
ff9940b0
RE
1734/* Condition code information. */
1735/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
1736 return the mode to be used for the comparison.
ddd5a7c1 1737 CCFPEmode should be used with floating inequalities,
ff9940b0 1738 CCFPmode should be used with floating equalities.
ddd5a7c1 1739 CC_NOOVmode should be used with SImode integer equalities.
69fcc21d 1740 CC_Zmode should be used if only the Z flag is set correctly
ff9940b0
RE
1741 CCmode should be used otherwise. */
1742
89c7ca52
RE
1743#define EXTRA_CC_MODES CC_NOOVmode, CC_Zmode, CC_SWPmode, \
1744 CCFPmode, CCFPEmode, CC_DNEmode, CC_DEQmode, CC_DLEmode, \
1745 CC_DLTmode, CC_DGEmode, CC_DGTmode, CC_DLEUmode, CC_DLTUmode, \
62dd06ea 1746 CC_DGEUmode, CC_DGTUmode, CC_Cmode
89c7ca52
RE
1747
1748#define EXTRA_CC_NAMES "CC_NOOV", "CC_Z", "CC_SWP", "CCFP", "CCFPE", \
1749 "CC_DNE", "CC_DEQ", "CC_DLE", "CC_DLT", "CC_DGE", "CC_DGT", "CC_DLEU", \
62dd06ea 1750 "CC_DLTU", "CC_DGEU", "CC_DGTU", "CC_C"
89c7ca52
RE
1751
1752enum machine_mode arm_select_cc_mode ();
1753#define SELECT_CC_MODE(OP,X,Y) arm_select_cc_mode ((OP), (X), (Y))
ff9940b0 1754
008cf58a
RE
1755#define REVERSIBLE_CC_MODE(MODE) ((MODE) != CCFPEmode)
1756
62dd06ea
RE
1757enum rtx_code arm_canonicalize_comparison ();
1758#define CANONICALIZE_COMPARISON(CODE,OP0,OP1) \
1759do \
1760{ \
1761 if (GET_CODE (OP1) == CONST_INT \
1762 && ! (const_ok_for_arm (INTVAL (OP1)) \
1763 || (const_ok_for_arm (- INTVAL (OP1))))) \
1764 { \
1765 rtx const_op = OP1; \
1766 CODE = arm_canonicalize_comparison ((CODE), &const_op); \
ad076f4e 1767 OP1 = const_op; \
62dd06ea
RE
1768 } \
1769} while (0)
1770
ff9940b0
RE
1771#define STORE_FLAG_VALUE 1
1772
1773/* Define the information needed to generate branch insns. This is
1774 stored from the compare operation. Note that we can't use "rtx" here
1775 since it hasn't been defined! */
1776
1777extern struct rtx_def *arm_compare_op0, *arm_compare_op1;
1778extern int arm_compare_fp;
1779
1780/* Define the codes that are matched by predicates in arm.c */
1781#define PREDICATE_CODES \
1782 {"s_register_operand", {SUBREG, REG}}, \
71791e16 1783 {"f_register_operand", {SUBREG, REG}}, \
ff9940b0
RE
1784 {"arm_add_operand", {SUBREG, REG, CONST_INT}}, \
1785 {"fpu_add_operand", {SUBREG, REG, CONST_DOUBLE}}, \
1786 {"arm_rhs_operand", {SUBREG, REG, CONST_INT}}, \
1787 {"fpu_rhs_operand", {SUBREG, REG, CONST_DOUBLE}}, \
1788 {"arm_not_operand", {SUBREG, REG, CONST_INT}}, \
69fcc21d 1789 {"offsettable_memory_operand", {MEM}}, \
4d818c85 1790 {"bad_signed_byte_operand", {MEM}}, \
69fcc21d 1791 {"alignable_memory_operand", {MEM}}, \
ff9940b0
RE
1792 {"shiftable_operator", {PLUS, MINUS, AND, IOR, XOR}}, \
1793 {"minmax_operator", {SMIN, SMAX, UMIN, UMAX}}, \
3967692c 1794 {"shift_operator", {ASHIFT, ASHIFTRT, LSHIFTRT, ROTATERT, MULT}}, \
ff9940b0 1795 {"di_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE, MEM}}, \
c383667d 1796 {"soft_df_operand", {SUBREG, REG, CONST_DOUBLE, MEM}}, \
ff9940b0
RE
1797 {"load_multiple_operation", {PARALLEL}}, \
1798 {"store_multiple_operation", {PARALLEL}}, \
1799 {"equality_operator", {EQ, NE}}, \
1800 {"arm_rhsm_operand", {SUBREG, REG, CONST_INT, MEM}}, \
1801 {"const_shift_operand", {CONST_INT}}, \
1802 {"index_operand", {SUBREG, REG, CONST_INT}}, \
3967692c
RE
1803 {"reg_or_int_operand", {SUBREG, REG, CONST_INT}}, \
1804 {"multi_register_push", {PARALLEL}}, \
31e6408a 1805 {"cc_register", {REG}}, \
89c7ca52 1806 {"dominant_cc_register", {REG}},
ff9940b0 1807
35d965d5 1808\f
35d965d5 1809
11c1a207
RE
1810/* Gcc puts the pool in the wrong place for ARM, since we can only
1811 load addresses a limited distance around the pc. We do some
1812 special munging to move the constant pool values to the correct
1813 point in the code. */
1814#define MACHINE_DEPENDENT_REORG(INSN) arm_reorg ((INSN))
35d965d5 1815
11c1a207
RE
1816/* The pool is empty, since we have moved everything into the code. */
1817#define ASM_OUTPUT_SPECIAL_POOL_ENTRY(FILE,X,MODE,ALIGN,LABELNO,JUMPTO) \
1818 goto JUMPTO
35d965d5
RS
1819
1820/* Output an internal label definition. */
18543a22
ILT
1821#define ASM_OUTPUT_INTERNAL_LABEL(STREAM, PREFIX, NUM) \
1822 do \
1823 { \
1824 char *s = (char *) alloca (40 + strlen (PREFIX)); \
1825 extern int arm_target_label, arm_ccfsm_state; \
1826 extern rtx arm_target_insn; \
1827 \
1828 if (arm_ccfsm_state == 3 && arm_target_label == (NUM) \
1829 && !strcmp (PREFIX, "L")) \
1830 { \
1831 arm_ccfsm_state = 0; \
1832 arm_target_insn = NULL; \
1833 } \
1834 ASM_GENERATE_INTERNAL_LABEL (s, (PREFIX), (NUM)); \
1835 ASM_OUTPUT_LABEL (STREAM, s); \
35d965d5
RS
1836 } while (0)
1837
35d965d5 1838/* Output a push or a pop instruction (only used when profiling). */
c383667d
DE
1839#define ASM_OUTPUT_REG_PUSH(STREAM,REGNO) \
1840 fprintf(STREAM,"\tstmfd\t%ssp!,{%s%s}\n", \
1841 REGISTER_PREFIX, REGISTER_PREFIX, reg_names[REGNO])
35d965d5 1842
c383667d
DE
1843#define ASM_OUTPUT_REG_POP(STREAM,REGNO) \
1844 fprintf(STREAM,"\tldmfd\t%ssp!,{%s%s}\n", \
1845 REGISTER_PREFIX, REGISTER_PREFIX, reg_names[REGNO])
35d965d5 1846
35d965d5
RS
1847/* Target characters. */
1848#define TARGET_BELL 007
1849#define TARGET_BS 010
1850#define TARGET_TAB 011
1851#define TARGET_NEWLINE 012
1852#define TARGET_VT 013
1853#define TARGET_FF 014
1854#define TARGET_CR 015
1855\f
35d965d5
RS
1856/* Only perform branch elimination (by making instructions conditional) if
1857 we're optimising. Otherwise it's of no use anyway. */
1858#define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
1859 if (optimize) \
1860 final_prescan_insn (INSN, OPVEC, NOPERANDS)
1861
7bc7696c
RE
1862#define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
1863 ((CODE) == '?' || (CODE) == '|' || (CODE) == '@')
1864/* Output an operand of an instruction. */
35d965d5 1865#define PRINT_OPERAND(STREAM, X, CODE) \
7bc7696c
RE
1866 arm_print_operand (STREAM, X, CODE)
1867
1868#define ARM_SIGN_EXTEND(x) ((HOST_WIDE_INT) \
1869 (HOST_BITS_PER_WIDE_INT <= 32 ? (x) \
1870 : (((x) & (unsigned HOST_WIDE_INT) 0xffffffff) | \
1871 (((x) & (unsigned HOST_WIDE_INT) 0x80000000) \
1872 ? ((~ (HOST_WIDE_INT) 0) \
1873 & ~ (unsigned HOST_WIDE_INT) 0xffffffff) \
1874 : 0))))
35d965d5
RS
1875
1876/* Output the address of an operand. */
1877#define PRINT_OPERAND_ADDRESS(STREAM,X) \
1878{ \
1879 int is_minus = GET_CODE (X) == MINUS; \
1880 \
1881 if (GET_CODE (X) == REG) \
c383667d 1882 fprintf (STREAM, "[%s%s, #0]", REGISTER_PREFIX, \
4eda77ec 1883 reg_names[REGNO (X)]); \
35d965d5
RS
1884 else if (GET_CODE (X) == PLUS || is_minus) \
1885 { \
1886 rtx base = XEXP (X, 0); \
1887 rtx index = XEXP (X, 1); \
1888 char *base_reg_name; \
7bc7696c 1889 HOST_WIDE_INT offset = 0; \
35d965d5
RS
1890 if (GET_CODE (base) != REG) \
1891 { \
1892 /* Ensure that BASE is a register (one of them must be). */ \
1893 rtx temp = base; \
1894 base = index; \
1895 index = temp; \
1896 } \
1897 base_reg_name = reg_names[REGNO (base)]; \
1898 switch (GET_CODE (index)) \
1899 { \
1900 case CONST_INT: \
1901 offset = INTVAL (index); \
1902 if (is_minus) \
1903 offset = -offset; \
c383667d 1904 fprintf (STREAM, "[%s%s, #%d]", REGISTER_PREFIX, \
4eda77ec 1905 base_reg_name, offset); \
35d965d5
RS
1906 break; \
1907 \
1908 case REG: \
c383667d 1909 fprintf (STREAM, "[%s%s, %s%s%s]", REGISTER_PREFIX, \
4eda77ec 1910 base_reg_name, is_minus ? "-" : "", \
c383667d 1911 REGISTER_PREFIX, reg_names[REGNO (index)] ); \
35d965d5
RS
1912 break; \
1913 \
1914 case MULT: \
ff9940b0
RE
1915 case ASHIFTRT: \
1916 case LSHIFTRT: \
1917 case ASHIFT: \
ff9940b0
RE
1918 case ROTATERT: \
1919 { \
c383667d
DE
1920 fprintf (STREAM, "[%s%s, %s%s%s", REGISTER_PREFIX, \
1921 base_reg_name, is_minus ? "-" : "", REGISTER_PREFIX,\
7bc7696c
RE
1922 reg_names[REGNO (XEXP (index, 0))]); \
1923 arm_print_operand (STREAM, index, 'S'); \
1924 fputs ("]", STREAM); \
ff9940b0
RE
1925 break; \
1926 } \
35d965d5
RS
1927 \
1928 default: \
1929 abort(); \
1930 } \
1931 } \
1932 else if (GET_CODE (X) == PRE_INC || GET_CODE (X) == POST_INC \
1933 || GET_CODE (X) == PRE_DEC || GET_CODE (X) == POST_DEC) \
1934 { \
1935 extern int output_memory_reference_mode; \
1936 \
1937 if (GET_CODE (XEXP (X, 0)) != REG) \
1938 abort (); \
1939 \
1940 if (GET_CODE (X) == PRE_DEC || GET_CODE (X) == PRE_INC) \
c383667d 1941 fprintf (STREAM, "[%s%s, #%s%d]!", REGISTER_PREFIX, \
4eda77ec 1942 reg_names[REGNO (XEXP (X, 0))], \
35d965d5
RS
1943 GET_CODE (X) == PRE_DEC ? "-" : "", \
1944 GET_MODE_SIZE (output_memory_reference_mode)); \
1945 else \
c383667d 1946 fprintf (STREAM, "[%s%s], #%s%d", REGISTER_PREFIX, \
4eda77ec 1947 reg_names[REGNO (XEXP (X, 0))], \
35d965d5
RS
1948 GET_CODE (X) == POST_DEC ? "-" : "", \
1949 GET_MODE_SIZE (output_memory_reference_mode)); \
1950 } \
1951 else output_addr_const(STREAM, X); \
1952}
62dd06ea 1953
7a801826
RE
1954/* Handles PIC addr specially */
1955#define OUTPUT_INT_ADDR_CONST(STREAM,X) \
1956 { \
1957 if (flag_pic && GET_CODE(X) == CONST && is_pic(X)) \
1958 { \
1959 output_addr_const(STREAM, XEXP (XEXP (XEXP (X, 0), 0), 0)); \
1960 fputs(" - (", STREAM); \
1961 output_addr_const(STREAM, XEXP (XEXP (XEXP (X, 0), 1), 0)); \
1962 fputs(")", STREAM); \
1963 } \
1964 else output_addr_const(STREAM, X); \
1965 }
1966
62dd06ea
RE
1967/* Output code to add DELTA to the first argument, and then jump to FUNCTION.
1968 Used for C++ multiple inheritance. */
1969#define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \
1970do { \
1971 int mi_delta = (DELTA); \
1972 char *mi_op = mi_delta < 0 ? "sub" : "add"; \
1973 int shift = 0; \
821581e4
DE
1974 int this_regno = (aggregate_value_p (TREE_TYPE (TREE_TYPE (FUNCTION))) \
1975 ? 1 : 0); \
62dd06ea
RE
1976 if (mi_delta < 0) mi_delta = -mi_delta; \
1977 while (mi_delta != 0) \
1978 { \
1979 if (mi_delta & (3 << shift) == 0) \
1980 shift += 2; \
1981 else \
1982 { \
1983 fprintf (FILE, "\t%s\t%s%s, %s%s, #%d\n", \
821581e4
DE
1984 mi_op, REGISTER_PREFIX, reg_names[this_regno], \
1985 REGISTER_PREFIX, reg_names[this_regno], \
62dd06ea 1986 mi_delta & (0xff << shift)); \
62dd06ea
RE
1987 mi_delta &= ~(0xff << shift); \
1988 shift += 8; \
1989 } \
1990 } \
18543a22 1991 fputs ("\tb\t", FILE); \
92d4501f 1992 assemble_name (FILE, XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0)); \
18543a22 1993 fputc ('\n', FILE); \
62dd06ea 1994} while (0)
39950dff 1995
6a5d7526
MS
1996/* A C expression whose value is RTL representing the value of the return
1997 address for the frame COUNT steps up from the current frame. */
1998
1999#define RETURN_ADDR_RTX(COUNT, FRAME) \
2000 ((COUNT == 0) \
2001 ? gen_rtx (MEM, Pmode, plus_constant (FRAME, -4)) \
18543a22 2002 : NULL_RTX)
6a5d7526 2003
39950dff
MS
2004/* Used to mask out junk bits from the return address, such as
2005 processor state, interrupt status, condition codes and the like. */
2006#define MASK_RETURN_ADDR \
2007 /* If we are generating code for an ARM2/ARM3 machine or for an ARM6 \
2008 in 26 bit mode, the condition codes must be masked out of the \
2009 return address. This does not apply to ARM6 and later processors \
2010 when running in 32 bit mode. */ \
7a801826 2011 ((!TARGET_APCS_32) ? (GEN_INT (0x03fffffc)) : (GEN_INT (0xffffffff)))
71791e16
RE
2012
2013/* Prototypes for arm.c -- actually, they aren't since the types aren't
2014 fully defined yet. */
2015
2016void arm_override_options (/* void */);
2017int use_return_insn (/* void */);
2018int const_ok_for_arm (/* HOST_WIDE_INT */);
2019int const_ok_for_op (/* HOST_WIDE_INT, enum rtx_code,
2020 enum machine_mode */);
2021int arm_split_constant (/* enum rtx_code, enum machine_mode,
2022 HOST_WIDE_INT, struct rtx_def *,
2023 struct rtx_def *, int */);
2024enum rtx_code arm_canonicalize_comparison (/* enum rtx_code,
2025 struct rtx_def ** */);
2026int arm_return_in_memory (/* union tree_node * */);
2027int legitimate_pic_operand_p (/* struct rtx_def * */);
2028struct rtx_def *legitimize_pic_address (/* struct rtx_def *,
2029 enum machine_mode,
2030 struct rtx_def * */);
2031int is_pic (/* struct rtx_def * */);
2032void arm_finalize_pic (/* void */);
2033int arm_rtx_costs (/* struct rtx_def *, enum rtx_code, enum rtx_code */);
ed4c4348 2034int arm_adjust_cost (/* struct rtx_def *, struct rtx_def *,
71791e16
RE
2035 struct rtx_def *, int */);
2036int const_double_rtx_ok_for_fpu (/* struct rtx_def * */);
2037int neg_const_double_rtx_ok_for_fpu (/* struct rtx_def * */);
2038int s_register_operand (/* struct rtx_def *, enum machine_mode */);
2039int f_register_operand (/* struct rtx_def *, enum machine_mode */);
2040int reg_or_int_operand (/* struct rtx_def *, enum machine_mode */);
2041int reload_memory_operand (/* struct rtx_def *, enum machine_mode */);
2042int arm_rhs_operand (/* struct rtx_def *, enum machine_mode */);
2043int arm_rhsm_operand (/* struct rtx_def *, enum machine_mode */);
2044int arm_add_operand (/* struct rtx_def *, enum machine_mode */);
2045int arm_not_operand (/* struct rtx_def *, enum machine_mode */);
2046int offsettable_memory_operand (/* struct rtx_def *, enum machine_mode */);
2047int alignable_memory_operand (/* struct rtx_def *, enum machine_mode */);
ed4c4348 2048int bad_signed_byte_operand (/* struct rtx_def *, enum machine_mode */);
71791e16
RE
2049int fpu_rhs_operand (/* struct rtx_def *, enum machine_mode */);
2050int fpu_add_operand (/* struct rtx_def *, enum machine_mode */);
2051int power_of_two_operand (/* struct rtx_def *, enum machine_mode */);
2052int di_operand (/* struct rtx_def *, enum machine_mode */);
2053int soft_df_operand (/* struct rtx_def *, enum machine_mode */);
2054int index_operand (/* struct rtx_def *, enum machine_mode */);
2055int const_shift_operand (/* struct rtx_def *, enum machine_mode */);
2056int shiftable_operator (/* struct rtx_def *, enum machine_mode */);
2057int shift_operator (/* struct rtx_def *, enum machine_mode */);
2058int equality_operator (/* struct rtx_def *, enum machine_mode */);
2059int minmax_operator (/* struct rtx_def *, enum machine_mode */);
2060int cc_register (/* struct rtx_def *, enum machine_mode */);
2061int dominant_cc_register (/* struct rtx_def *, enum machine_mode */);
2062int symbol_mentioned_p (/* struct rtx_def * */);
2063int label_mentioned_p (/* struct rtx_def * */);
2064enum rtx_code minmax_code (/* struct rtx_def * */);
2065int adjacent_mem_locations (/* struct rtx_def *, struct rtx_def * */);
2066int load_multiple_operation (/* struct rtx_def *, enum machine_mode */);
2067int store_multiple_operation (/* struct rtx_def *, enum machine_mode */);
2068int load_multiple_sequence (/* struct rtx_def **, int, int *, int *,
2069 HOST_WIDE_INT * */);
2070char *emit_ldm_seq (/* struct rtx_def **, int */);
2071int store_multiple_sequence (/* struct rtx_def **, int, int *, int *,
2072 HOST_WIDE_INT * */);
2073char *emit_stm_seq (/* struct rtx_def **, int */);
2074int multi_register_push (/* struct rtx_def *, enum machine_mode */);
2075int arm_valid_machine_decl_attribute (/* union tree_node *, union tree_node *,
2076 union tree_node *,
2077 union tree_node * */);
2078struct rtx_def *arm_gen_load_multiple (/* int, int, struct rtx_def *,
18543a22 2079 int, int, int, int */);
71791e16 2080struct rtx_def *arm_gen_store_multiple (/* int, int, struct rtx_def *,
18543a22 2081 int, int, int, int */);
71791e16
RE
2082int arm_gen_movstrqi (/* struct rtx_def ** */);
2083struct rtx_def *gen_rotated_half_load (/* struct rtx_def * */);
2084enum machine_mode arm_select_cc_mode (/* enum rtx_code, struct rtx_def *,
2085 struct rtx_def * */);
2086struct rtx_def *gen_compare_reg (/* enum rtx_code, struct rtx_def *,
2087 struct rtx_def * */);
2088void arm_reload_in_hi (/* struct rtx_def ** */);
2089void arm_reload_out_hi (/* struct rtx_def ** */);
2090void arm_reorg (/* struct rtx_def * */);
2091char *fp_immediate_constant (/* struct rtx_def * */);
2092void print_multi_reg (/* FILE *, char *, int, int */);
2093char *output_call (/* struct rtx_def ** */);
2094char *output_call_mem (/* struct rtx_def ** */);
2095char *output_mov_long_double_fpu_from_arm (/* struct rtx_def ** */);
2096char *output_mov_long_double_arm_from_fpu (/* struct rtx_def ** */);
2097char *output_mov_long_double_arm_from_arm (/* struct rtx_def ** */);
2098char *output_mov_double_fpu_from_arm (/* struct rtx_def ** */);
2099char *output_mov_double_arm_from_fpu (/* struct rtx_def ** */);
18543a22 2100char *output_move_double (/* struct rtx_def ** */);
71791e16
RE
2101char *output_mov_immediate (/* struct rtx_def ** */);
2102char *output_add_immediate (/* struct rtx_def ** */);
2103char *arithmetic_instr (/* struct rtx_def *, int */);
2104void output_ascii_pseudo_op (/* FILE *, unsigned char *, int */);
2105char *output_return_instruction (/* struct rtx_def *, int, int */);
2106int arm_volatile_func (/* void */);
2107void output_func_prologue (/* FILE *, int */);
2108void output_func_epilogue (/* FILE *, int */);
2109void arm_expand_prologue (/* void */);
2110void arm_print_operand (/* FILE *, struct rtx_def *, int */);
71791e16
RE
2111void final_prescan_insn (/* struct rtx_def *, struct rtx_def **, int */);
2112#ifdef AOF_ASSEMBLER
2113struct rtx_def *aof_pic_entry (/* struct rtx_def * */);
2114void aof_dump_pic_table (/* FILE * */);
2115char *aof_text_section (/* void */);
2116char *aof_data_section (/* void */);
2117void aof_add_import (/* char * */);
2118void aof_delete_import (/* char * */);
2119void aof_dump_imports (/* FILE * */);
2120#endif