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