1 /* Definitions of target machine for GNU compiler, for ARM.
2 Copyright (C) 1991, 93-98, 1999 Free Software Foundation, Inc.
3 Contributed by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl)
4 and Martin Simmons (@harleqn.co.uk).
5 More major hacks by Richard Earnshaw (rearnsha@arm.com)
6 Minor hacks by Nick Clifton (nickc@cygnus.com)
8 This file is part of GNU CC.
10 GNU CC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
15 GNU CC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GNU CC; see the file COPYING. If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
28 #define TARGET_CPU_arm2 0x0000
29 #define TARGET_CPU_arm250 0x0000
30 #define TARGET_CPU_arm3 0x0000
31 #define TARGET_CPU_arm6 0x0001
32 #define TARGET_CPU_arm600 0x0001
33 #define TARGET_CPU_arm610 0x0002
34 #define TARGET_CPU_arm7 0x0001
35 #define TARGET_CPU_arm7m 0x0004
36 #define TARGET_CPU_arm7dm 0x0004
37 #define TARGET_CPU_arm7dmi 0x0004
38 #define TARGET_CPU_arm700 0x0001
39 #define TARGET_CPU_arm710 0x0002
40 #define TARGET_CPU_arm7100 0x0002
41 #define TARGET_CPU_arm7500 0x0002
42 #define TARGET_CPU_arm7500fe 0x1001
43 #define TARGET_CPU_arm7tdmi 0x0008
44 #define TARGET_CPU_arm8 0x0010
45 #define TARGET_CPU_arm810 0x0020
46 #define TARGET_CPU_strongarm 0x0040
47 #define TARGET_CPU_strongarm110 0x0040
48 #define TARGET_CPU_strongarm1100 0x0040
49 #define TARGET_CPU_arm9 0x0080
50 #define TARGET_CPU_arm9tdmi 0x0080
51 /* Configure didn't specify */
52 #define TARGET_CPU_generic 0x8000
56 ARM_EQ = 0, ARM_NE, ARM_CS, ARM_CC, ARM_MI, ARM_PL, ARM_VS, ARM_VC,
57 ARM_HI, ARM_LS, ARM_GE, ARM_LT, ARM_GT, ARM_LE, ARM_AL, ARM_NV
60 extern enum arm_cond_code arm_current_cc;
61 extern char * arm_condition_codes[];
63 #define ARM_INVERSE_CONDITION_CODE(X) ((enum arm_cond_code) (((int)X) ^ 1))
65 extern int arm_target_label;
66 extern int arm_ccfsm_state;
67 extern struct rtx_def * arm_target_insn;
68 extern int lr_save_eliminated;
69 /* This is needed by the tail-calling peepholes */
70 extern int frame_pointer_needed;
71 /* Run-time compilation parameters selecting different hardware subsets. */
72 extern int target_flags;
73 /* The floating point instruction architecture, can be 2 or 3 */
74 extern const char * target_fp_name;
77 /* Just in case configure has failed to define anything. */
78 #ifndef TARGET_CPU_DEFAULT
79 #define TARGET_CPU_DEFAULT TARGET_CPU_generic
82 /* If the configuration file doesn't specify the cpu, the subtarget may
83 override it. If it doesn't, then default to an ARM6. */
84 #if TARGET_CPU_DEFAULT == TARGET_CPU_generic
85 #undef TARGET_CPU_DEFAULT
86 #ifdef SUBTARGET_CPU_DEFAULT
87 #define TARGET_CPU_DEFAULT SUBTARGET_CPU_DEFAULT
89 #define TARGET_CPU_DEFAULT TARGET_CPU_arm6
93 #if TARGET_CPU_DEFAULT == TARGET_CPU_arm2
94 #define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_2__"
96 #if TARGET_CPU_DEFAULT == TARGET_CPU_arm6 || TARGET_CPU_DEFAULT == TARGET_CPU_arm610 || TARGET_CPU_DEFAULT == TARGET_CPU_arm7500fe
97 #define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_3__"
99 #if TARGET_CPU_DEFAULT == TARGET_CPU_arm7m
100 #define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_3M__"
102 #if TARGET_CPU_DEFAULT == TARGET_CPU_arm7tdmi || TARGET_CPU_DEFAULT == TARGET_CPU_arm9
103 #define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_4T__"
105 #if TARGET_CPU_DEFAULT == TARGET_CPU_arm8 || TARGET_CPU_DEFAULT == TARGET_CPU_arm810 || TARGET_CPU_DEFAULT == TARGET_CPU_strongarm
106 #define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_4__"
108 Unrecognized value in TARGET_CPU_DEFAULT.
115 #ifndef CPP_PREDEFINES
116 #define CPP_PREDEFINES "-Darm -Acpu(arm) -Amachine(arm)"
120 %(cpp_cpu_arch) %(cpp_apcs_pc) %(cpp_float) \
121 %(cpp_endian) %(subtarget_cpp_spec)"
123 /* Set the architecture define -- if -march= is set, then it overrides
124 the -mcpu= setting. */
125 #define CPP_CPU_ARCH_SPEC "\
126 %{march=arm2:-D__ARM_ARCH_2__} \
127 %{march=arm250:-D__ARM_ARCH_2__} \
128 %{march=arm3:-D__ARM_ARCH_2__} \
129 %{march=arm6:-D__ARM_ARCH_3__} \
130 %{march=arm600:-D__ARM_ARCH_3__} \
131 %{march=arm610:-D__ARM_ARCH_3__} \
132 %{march=arm7:-D__ARM_ARCH_3__} \
133 %{march=arm700:-D__ARM_ARCH_3__} \
134 %{march=arm710:-D__ARM_ARCH_3__} \
135 %{march=arm7100:-D__ARM_ARCH_3__} \
136 %{march=arm7500:-D__ARM_ARCH_3__} \
137 %{march=arm7500fe:-D__ARM_ARCH_3__} \
138 %{march=arm7m:-D__ARM_ARCH_3M__} \
139 %{march=arm7dm:-D__ARM_ARCH_3M__} \
140 %{march=arm7dmi:-D__ARM_ARCH_3M__} \
141 %{march=arm7tdmi:-D__ARM_ARCH_4T__} \
142 %{march=arm8:-D__ARM_ARCH_4__} \
143 %{march=arm810:-D__ARM_ARCH_4__} \
144 %{march=arm9:-D__ARM_ARCH_4T__} \
145 %{march=arm920:-D__ARM_ARCH_4__} \
146 %{march=arm920t:-D__ARM_ARCH_4T__} \
147 %{march=arm9tdmi:-D__ARM_ARCH_4T__} \
148 %{march=strongarm:-D__ARM_ARCH_4__} \
149 %{march=strongarm110:-D__ARM_ARCH_4__} \
150 %{march=strongarm1100:-D__ARM_ARCH_4__} \
151 %{march=armv2:-D__ARM_ARCH_2__} \
152 %{march=armv2a:-D__ARM_ARCH_2__} \
153 %{march=armv3:-D__ARM_ARCH_3__} \
154 %{march=armv3m:-D__ARM_ARCH_3M__} \
155 %{march=armv4:-D__ARM_ARCH_4__} \
156 %{march=armv4t:-D__ARM_ARCH_4T__} \
157 %{march=armv5:-D__ARM_ARCH_5__} \
159 %{mcpu=arm2:-D__ARM_ARCH_2__} \
160 %{mcpu=arm250:-D__ARM_ARCH_2__} \
161 %{mcpu=arm3:-D__ARM_ARCH_2__} \
162 %{mcpu=arm6:-D__ARM_ARCH_3__} \
163 %{mcpu=arm600:-D__ARM_ARCH_3__} \
164 %{mcpu=arm610:-D__ARM_ARCH_3__} \
165 %{mcpu=arm7:-D__ARM_ARCH_3__} \
166 %{mcpu=arm700:-D__ARM_ARCH_3__} \
167 %{mcpu=arm710:-D__ARM_ARCH_3__} \
168 %{mcpu=arm7100:-D__ARM_ARCH_3__} \
169 %{mcpu=arm7500:-D__ARM_ARCH_3__} \
170 %{mcpu=arm7500fe:-D__ARM_ARCH_3__} \
171 %{mcpu=arm7m:-D__ARM_ARCH_3M__} \
172 %{mcpu=arm7dm:-D__ARM_ARCH_3M__} \
173 %{mcpu=arm7dmi:-D__ARM_ARCH_3M__} \
174 %{mcpu=arm7tdmi:-D__ARM_ARCH_4T__} \
175 %{mcpu=arm8:-D__ARM_ARCH_4__} \
176 %{mcpu=arm810:-D__ARM_ARCH_4__} \
177 %{mcpu=arm9:-D__ARM_ARCH_4T__} \
178 %{mcpu=arm920:-D__ARM_ARCH_4__} \
179 %{mcpu=arm920t:-D__ARM_ARCH_4T__} \
180 %{mcpu=arm9tdmi:-D__ARM_ARCH_4T__} \
181 %{mcpu=strongarm:-D__ARM_ARCH_4__} \
182 %{mcpu=strongarm110:-D__ARM_ARCH_4__} \
183 %{mcpu=strongarm1100:-D__ARM_ARCH_4__} \
184 %{!mcpu*:%(cpp_cpu_arch_default)}} \
187 /* Define __APCS_26__ if the PC also contains the PSR */
188 #define CPP_APCS_PC_SPEC "\
189 %{mapcs-32:%{mapcs-26:%e-mapcs-26 and -mapcs-32 may not be used together} \
191 %{mapcs-26:-D__APCS_26__} \
192 %{!mapcs-32: %{!mapcs-26:%(cpp_apcs_pc_default)}} \
195 #ifndef CPP_APCS_PC_DEFAULT_SPEC
196 #define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_26__"
199 #define CPP_FLOAT_SPEC "\
201 %{mhard-float:%e-msoft-float and -mhard_float may not be used together} \
203 %{!mhard-float:%{!msoft-float:%(cpp_float_default)}} \
206 /* Default is hard float, which doesn't define anything */
207 #define CPP_FLOAT_DEFAULT_SPEC ""
209 #define CPP_ENDIAN_SPEC "\
212 %e-mbig-endian and -mlittle-endian may not be used together} \
213 -D__ARMEB__ %{mwords-little-endian:-D__ARMWEL__}} \
214 %{!mlittle-endian:%{!mbig-endian:%(cpp_endian_default)}} \
217 /* Default is little endian, which doesn't define anything. */
218 #define CPP_ENDIAN_DEFAULT_SPEC "-D__ARMEL__"
222 /* This macro defines names of additional specifications to put in the specs
223 that can be used in various specifications like CC1_SPEC. Its definition
224 is an initializer with a subgrouping for each command option.
226 Each subgrouping contains a string constant, that defines the
227 specification name, and a string constant that used by the GNU CC driver
230 Do not define this macro if it does not need to do anything. */
231 #define EXTRA_SPECS \
232 { "cpp_cpu_arch", CPP_CPU_ARCH_SPEC }, \
233 { "cpp_cpu_arch_default", CPP_ARCH_DEFAULT_SPEC }, \
234 { "cpp_apcs_pc", CPP_APCS_PC_SPEC }, \
235 { "cpp_apcs_pc_default", CPP_APCS_PC_DEFAULT_SPEC }, \
236 { "cpp_float", CPP_FLOAT_SPEC }, \
237 { "cpp_float_default", CPP_FLOAT_DEFAULT_SPEC }, \
238 { "cpp_endian", CPP_ENDIAN_SPEC }, \
239 { "cpp_endian_default", CPP_ENDIAN_DEFAULT_SPEC }, \
240 { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC }, \
241 SUBTARGET_EXTRA_SPECS
243 #define SUBTARGET_EXTRA_SPECS
244 #ifndef SUBTARGET_CPP_SPEC
245 #define SUBTARGET_CPP_SPEC ""
249 /* Run-time Target Specification. */
250 #ifndef TARGET_VERSION
251 #define TARGET_VERSION fputs (" (ARM/generic)", stderr);
254 /* Nonzero if the function prologue (and epilogue) should obey
255 the ARM Procedure Call Standard. */
256 #define ARM_FLAG_APCS_FRAME (1 << 0)
258 /* Nonzero if the function prologue should output the function name to enable
259 the post mortem debugger to print a backtrace (very useful on RISCOS,
260 unused on RISCiX). Specifying this flag also enables
261 -fno-omit-frame-pointer.
262 XXX Must still be implemented in the prologue. */
263 #define ARM_FLAG_POKE (1 << 1)
265 /* Nonzero if floating point instructions are emulated by the FPE, in which
266 case instruction scheduling becomes very uninteresting. */
267 #define ARM_FLAG_FPE (1 << 2)
269 /* Nonzero if destined for a processor in 32-bit program mode. Takes out bit
270 that assume restoration of the condition flags when returning from a
271 branch and link (ie a function). */
272 #define ARM_FLAG_APCS_32 (1 << 3)
274 /* FLAGS 0x0008 and 0x0010 are now spare (used to be arm3/6 selection). */
276 /* Nonzero if stack checking should be performed on entry to each function
277 which allocates temporary variables on the stack. */
278 #define ARM_FLAG_APCS_STACK (1 << 4)
280 /* Nonzero if floating point parameters should be passed to functions in
281 floating point registers. */
282 #define ARM_FLAG_APCS_FLOAT (1 << 5)
284 /* Nonzero if re-entrant, position independent code should be generated.
285 This is equivalent to -fpic. */
286 #define ARM_FLAG_APCS_REENT (1 << 6)
288 /* Nonzero if the MMU will trap unaligned word accesses, so shorts must be
289 loaded byte-at-a-time. */
290 #define ARM_FLAG_SHORT_BYTE (1 << 7)
292 /* Nonzero if all floating point instructions are missing (and there is no
293 emulator either). Generate function calls for all ops in this case. */
294 #define ARM_FLAG_SOFT_FLOAT (1 << 8)
296 /* Nonzero if we should compile with BYTES_BIG_ENDIAN set to 1. */
297 #define ARM_FLAG_BIG_END (1 << 9)
299 /* Nonzero if we should compile for Thumb interworking. */
300 #define ARM_FLAG_INTERWORK (1 << 10)
302 /* Nonzero if we should have little-endian words even when compiling for
303 big-endian (for backwards compatibility with older versions of GCC). */
304 #define ARM_FLAG_LITTLE_WORDS (1 << 11)
306 /* Nonzero if we need to protect the prolog from scheduling */
307 #define ARM_FLAG_NO_SCHED_PRO (1 << 12)
309 /* Nonzero if a call to abort should be generated if a noreturn
310 function tries to return. */
311 #define ARM_FLAG_ABORT_NORETURN (1 << 13)
313 /* Nonzero if function prologues should not load the PIC register. */
314 #define ARM_FLAG_SINGLE_PIC_BASE (1 << 14)
316 /* Nonzero if all call instructions should be indirect. */
317 #define ARM_FLAG_LONG_CALLS (1 << 15)
319 #define TARGET_APCS (target_flags & ARM_FLAG_APCS_FRAME)
320 #define TARGET_POKE_FUNCTION_NAME (target_flags & ARM_FLAG_POKE)
321 #define TARGET_FPE (target_flags & ARM_FLAG_FPE)
322 #define TARGET_APCS_32 (target_flags & ARM_FLAG_APCS_32)
323 #define TARGET_APCS_STACK (target_flags & ARM_FLAG_APCS_STACK)
324 #define TARGET_APCS_FLOAT (target_flags & ARM_FLAG_APCS_FLOAT)
325 #define TARGET_APCS_REENT (target_flags & ARM_FLAG_APCS_REENT)
326 /* Note: TARGET_SHORT_BY_BYTES is really a misnomer. What it means is
327 that short values should not be accessed using word load instructions
328 as there is a possibility that they may not be word aligned and this
329 would generate an MMU fault. On processors which do not have a 16 bit
330 load instruction therefore, short values must be loaded by individual
331 byte accesses rather than loading a word and then shifting the desired
333 #define TARGET_SHORT_BY_BYTES (target_flags & ARM_FLAG_SHORT_BYTE)
334 #define TARGET_SOFT_FLOAT (target_flags & ARM_FLAG_SOFT_FLOAT)
335 #define TARGET_HARD_FLOAT (! TARGET_SOFT_FLOAT)
336 #define TARGET_BIG_END (target_flags & ARM_FLAG_BIG_END)
337 #define TARGET_INTERWORK (target_flags & ARM_FLAG_INTERWORK)
338 #define TARGET_LITTLE_WORDS (target_flags & ARM_FLAG_LITTLE_WORDS)
339 #define TARGET_NO_SCHED_PRO (target_flags & ARM_FLAG_NO_SCHED_PRO)
340 #define TARGET_ABORT_NORETURN (target_flags & ARM_FLAG_ABORT_NORETURN)
341 #define TARGET_SINGLE_PIC_BASE (target_flags & ARM_FLAG_SINGLE_PIC_BASE)
342 #define TARGET_LONG_CALLS (target_flags & ARM_FLAG_LONG_CALLS)
344 /* SUBTARGET_SWITCHES is used to add flags on a per-config basis.
345 Bit 31 is reserved. See riscix.h. */
346 #ifndef SUBTARGET_SWITCHES
347 #define SUBTARGET_SWITCHES
350 #define TARGET_SWITCHES \
352 {"apcs", ARM_FLAG_APCS_FRAME, "" }, \
353 {"apcs-frame", ARM_FLAG_APCS_FRAME, \
354 "Generate APCS conformant stack frames" }, \
355 {"no-apcs-frame", -ARM_FLAG_APCS_FRAME, "" }, \
356 {"poke-function-name", ARM_FLAG_POKE, \
357 "Store function names in object code" }, \
358 {"no-poke-function-name", -ARM_FLAG_POKE, "" }, \
359 {"fpe", ARM_FLAG_FPE, "" }, \
360 {"apcs-32", ARM_FLAG_APCS_32, \
361 "Use the 32bit version of the APCS" }, \
362 {"apcs-26", -ARM_FLAG_APCS_32, \
363 "Use the 26bit version of the APCS" }, \
364 {"apcs-stack-check", ARM_FLAG_APCS_STACK, "" }, \
365 {"no-apcs-stack-check", -ARM_FLAG_APCS_STACK, "" }, \
366 {"apcs-float", ARM_FLAG_APCS_FLOAT, \
367 "Pass FP arguments in FP registers" }, \
368 {"no-apcs-float", -ARM_FLAG_APCS_FLOAT, "" }, \
369 {"apcs-reentrant", ARM_FLAG_APCS_REENT, \
370 "Generate re-entrant, PIC code" }, \
371 {"no-apcs-reentrant", -ARM_FLAG_APCS_REENT, "" }, \
372 {"short-load-bytes", ARM_FLAG_SHORT_BYTE, \
373 "Load shorts a byte at a time" }, \
374 {"no-short-load-bytes", -ARM_FLAG_SHORT_BYTE, "" }, \
375 {"short-load-words", -ARM_FLAG_SHORT_BYTE, \
376 "Load words a byte at a time" }, \
377 {"no-short-load-words", ARM_FLAG_SHORT_BYTE, "" }, \
378 {"soft-float", ARM_FLAG_SOFT_FLOAT, \
379 "Use library calls to perform FP operations" }, \
380 {"hard-float", -ARM_FLAG_SOFT_FLOAT, \
381 "Use hardware floating point instructions" }, \
382 {"big-endian", ARM_FLAG_BIG_END, \
383 "Assume target CPU is configured as big endian" }, \
384 {"little-endian", -ARM_FLAG_BIG_END, \
385 "Assume target CPU is configured as little endian" }, \
386 {"words-little-endian", ARM_FLAG_LITTLE_WORDS, \
387 "Assume big endian bytes, little endian words" }, \
388 {"thumb-interwork", ARM_FLAG_INTERWORK, \
389 "Support calls between THUMB and ARM instructions sets" }, \
390 {"no-thumb-interwork", -ARM_FLAG_INTERWORK, "" }, \
391 {"abort-on-noreturn", ARM_FLAG_ABORT_NORETURN, \
392 "Generate a call to abort if a noreturn function returns"}, \
393 {"no-abort-on-noreturn", -ARM_FLAG_ABORT_NORETURN, ""}, \
394 {"sched-prolog", -ARM_FLAG_NO_SCHED_PRO, \
395 "Do not move instructions into a function's prologue" }, \
396 {"no-sched-prolog", ARM_FLAG_NO_SCHED_PRO, "" }, \
397 {"single-pic-base", ARM_FLAG_SINGLE_PIC_BASE, \
398 "Do not load the PIC register in function prologues" }, \
399 {"no-single-pic-base", -ARM_FLAG_SINGLE_PIC_BASE, "" }, \
400 {"long-calls", ARM_FLAG_LONG_CALLS, \
401 "Generate all call instructions as indirect calls"}, \
402 {"no-long-calls", -ARM_FLAG_LONG_CALLS, ""}, \
404 {"", TARGET_DEFAULT, "" } \
407 #define TARGET_OPTIONS \
409 {"cpu=", & arm_select[0].string, \
410 "Specify the name of the target CPU" }, \
411 {"arch=", & arm_select[1].string, \
412 "Specify the name of the target architecture" }, \
413 {"tune=", & arm_select[2].string, "" }, \
414 {"fpe=", & target_fp_name, "" }, \
415 {"fp=", & target_fp_name, \
416 "Specify the version of the floating point emulator" }, \
417 { "structure-size-boundary=", & structure_size_string, \
418 "Specify the minumum bit alignment of structures" }, \
419 { "pic-register=", & arm_pic_register_string, \
420 "Specify the register to be used for PIC addressing" } \
423 struct arm_cpu_select
427 const struct processors * processors;
430 /* This is a magic array. If the user specifies a command line switch
431 which matches one of the entries in TARGET_OPTIONS then the corresponding
432 string pointer will be set to the value specified by the user. */
433 extern struct arm_cpu_select arm_select[];
441 /* Recast the program mode class to be the prog_mode attribute */
442 #define arm_prog_mode ((enum attr_prog_mode) arm_prgmode)
444 extern enum prog_mode_type arm_prgmode;
446 /* What sort of floating point unit do we have? Hardware or software.
447 If software, is it issue 2 or issue 3? */
448 enum floating_point_type
455 /* Recast the floating point class to be the floating point attribute. */
456 #define arm_fpu_attr ((enum attr_fpu) arm_fpu)
458 /* What type of floating point to tune for */
459 extern enum floating_point_type arm_fpu;
461 /* What type of floating point instructions are available */
462 extern enum floating_point_type arm_fpu_arch;
464 /* Default floating point architecture. Override in sub-target if
466 #define FP_DEFAULT FP_SOFT2
468 /* Nonzero if the processor has a fast multiply insn, and one that does
469 a 64-bit multiply of two 32-bit values. */
470 extern int arm_fast_multiply;
472 /* Nonzero if this chip supports the ARM Architecture 4 extensions */
473 extern int arm_arch4;
475 /* Nonzero if this chip supports the ARM Architecture 5 extensions */
476 extern int arm_arch5;
478 /* Nonzero if this chip can benefit from load scheduling. */
479 extern int arm_ld_sched;
481 /* Nonzero if this chip is a StrongARM. */
482 extern int arm_is_strong;
484 /* Nonzero if this chip is a an ARM6 or an ARM7. */
485 extern int arm_is_6_or_7;
487 #ifndef TARGET_DEFAULT
488 #define TARGET_DEFAULT 0
491 /* The frame pointer register used in gcc has nothing to do with debugging;
492 that is controlled by the APCS-FRAME option. */
493 /* Not fully implemented yet */
494 /* #define CAN_DEBUG_WITHOUT_FP 1 */
496 #define TARGET_MEM_FUNCTIONS 1
498 #define OVERRIDE_OPTIONS arm_override_options ()
500 /* Nonzero if PIC code requires explicit qualifiers to generate
501 PLT and GOT relocs rather than the assembler doing so implicitly.
502 Subtargets can override these if required. */
503 #ifndef NEED_GOT_RELOC
504 #define NEED_GOT_RELOC 0
506 #ifndef NEED_PLT_RELOC
507 #define NEED_PLT_RELOC 0
510 /* Nonzero if we need to refer to the GOT with a PC-relative
511 offset. In other words, generate
513 .word _GLOBAL_OFFSET_TABLE_ - [. - (.Lxx + 8)]
517 .word _GLOBAL_OFFSET_TABLE_ - (.Lxx + 8)
519 The default is true, which matches NetBSD. Subtargets can
520 override this if required. */
525 /* Target machine storage Layout. */
528 /* Define this macro if it is advisable to hold scalars in registers
529 in a wider mode than that declared by the program. In such cases,
530 the value is constrained to be within the bounds of the declared
531 type, but kept valid in the wider mode. The signedness of the
532 extension may differ from that of the type. */
534 /* It is far faster to zero extend chars than to sign extend them */
536 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
537 if (GET_MODE_CLASS (MODE) == MODE_INT \
538 && GET_MODE_SIZE (MODE) < 4) \
540 if (MODE == QImode) \
542 else if (MODE == HImode) \
543 UNSIGNEDP = TARGET_SHORT_BY_BYTES != 0; \
547 /* Define this macro if the promotion described by `PROMOTE_MODE'
548 should also be done for outgoing function arguments. */
549 /* This is required to ensure that push insns always push a word. */
550 #define PROMOTE_FUNCTION_ARGS
552 /* Define for XFmode extended real floating point support.
553 This will automatically cause REAL_ARITHMETIC to be defined. */
555 I think I have added all the code to make this work. Unfortunately,
556 early releases of the floating point emulation code on RISCiX used a
557 different format for extended precision numbers. On my RISCiX box there
558 is a bug somewhere which causes the machine to lock up when running enquire
559 with long doubles. There is the additional aspect that Norcroft C
560 treats long doubles as doubles and we ought to remain compatible.
561 Perhaps someone with an FPA coprocessor and not running RISCiX would like
562 to try this someday. */
563 /* #define LONG_DOUBLE_TYPE_SIZE 96 */
565 /* Disable XFmode patterns in md file */
566 #define ENABLE_XF_PATTERNS 0
568 /* Define if you don't want extended real, but do want to use the
569 software floating point emulator for REAL_ARITHMETIC and
570 decimal <-> binary conversion. */
571 /* See comment above */
572 #define REAL_ARITHMETIC
574 /* Define this if most significant bit is lowest numbered
575 in instructions that operate on numbered bit-fields. */
576 #define BITS_BIG_ENDIAN 0
578 /* Define this if most significant byte of a word is the lowest numbered.
579 Most ARM processors are run in little endian mode, so that is the default.
580 If you want to have it run-time selectable, change the definition in a
581 cover file to be TARGET_BIG_ENDIAN. */
582 #define BYTES_BIG_ENDIAN (TARGET_BIG_END != 0)
584 /* Define this if most significant word of a multiword number is the lowest
586 This is always false, even when in big-endian mode. */
587 #define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN && ! TARGET_LITTLE_WORDS)
589 /* LIBGCC2_WORDS_BIG_ENDIAN has to be a constant, so we define this based
590 on processor pre-defineds when compiling libgcc2.c. */
591 #if defined(__ARMEB__) && !defined(__ARMWEL__)
592 #define LIBGCC2_WORDS_BIG_ENDIAN 1
594 #define LIBGCC2_WORDS_BIG_ENDIAN 0
597 /* Define this if most significant word of doubles is the lowest numbered.
598 This is always true, even when in little-endian mode. */
599 #define FLOAT_WORDS_BIG_ENDIAN 1
601 /* Number of bits in an addressable storage unit */
602 #define BITS_PER_UNIT 8
604 #define BITS_PER_WORD 32
606 #define UNITS_PER_WORD 4
608 #define POINTER_SIZE 32
610 #define PARM_BOUNDARY 32
612 #define STACK_BOUNDARY 32
614 #define FUNCTION_BOUNDARY 32
616 #define EMPTY_FIELD_BOUNDARY 32
618 #define BIGGEST_ALIGNMENT 32
620 /* Make strings word-aligned so strcpy from constants will be faster. */
621 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
622 (TREE_CODE (EXP) == STRING_CST \
623 && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
625 /* Setting STRUCTURE_SIZE_BOUNDARY to 32 produces more efficient code, but the
626 value set in previous versions of this toolchain was 8, which produces more
627 compact structures. The command line option -mstructure_size_boundary=<n>
628 can be used to change this value. For compatability with the ARM SDK
629 however the value should be left at 32. ARM SDT Reference Manual (ARM DUI
630 0020D) page 2-20 says "Structures are aligned on word boundaries". */
631 #define STRUCTURE_SIZE_BOUNDARY arm_structure_size_boundary
632 extern int arm_structure_size_boundary;
634 /* This is the value used to initialise arm_structure_size_boundary. If a
635 particular arm target wants to change the default value it should change
636 the definition of this macro, not STRUCTRUE_SIZE_BOUNDARY. See netbsd.h
637 for an example of this. */
638 #ifndef DEFAULT_STRUCTURE_SIZE_BOUNDARY
639 #define DEFAULT_STRUCTURE_SIZE_BOUNDARY 32
642 /* Used when parsing command line option -mstructure_size_boundary. */
643 extern const char * structure_size_string;
645 /* Non-zero if move instructions will actually fail to work
646 when given unaligned data. */
647 #define STRICT_ALIGNMENT 1
649 #define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
652 /* Standard register usage. */
654 /* Register allocation in ARM Procedure Call Standard (as used on RISCiX):
655 (S - saved over call).
657 r0 * argument word/integer result
660 r4-r8 S register variable
661 r9 S (rfp) register variable (real frame pointer)
663 r10 F S (sl) stack limit (used by -mapcs-stack-check)
664 r11 F S (fp) argument pointer
665 r12 (ip) temp workspace
666 r13 F S (sp) lower end of current stack frame
667 r14 (lr) link address/workspace
668 r15 F (pc) program counter
670 f0 floating point result
671 f1-f3 floating point scratch
673 f4-f7 S floating point variable
675 cc This is NOT a real register, but is used internally
676 to represent things that use or set the condition
678 sfp This isn't either. It is used during rtl generation
679 since the offset between the frame pointer and the
680 auto's isn't known until after register allocation.
681 afp Nor this, we only need this because of non-local
682 goto. Without it fp appears to be used and the
683 elimination code won't get rid of sfp. It tracks
684 fp exactly at all times.
686 *: See CONDITIONAL_REGISTER_USAGE */
688 /* The stack backtrace structure is as follows:
689 fp points to here: | save code pointer | [fp]
690 | return link value | [fp, #-4]
691 | return sp value | [fp, #-8]
692 | return fp value | [fp, #-12]
693 [| saved r10 value |]
704 [| saved f7 value |] three words
705 [| saved f6 value |] three words
706 [| saved f5 value |] three words
707 [| saved f4 value |] three words
708 r0-r3 are not normally saved in a C function. */
710 /* The number of hard registers is 16 ARM + 8 FPU + 1 CC + 1 SFP. */
711 #define FIRST_PSEUDO_REGISTER 27
713 /* 1 for registers that have pervasive standard uses
714 and are not available for the register allocator. */
715 #define FIXED_REGISTERS \
723 /* 1 for registers not available across function calls.
724 These must include the FIXED_REGISTERS and also any
725 registers that can be used without being saved.
726 The latter must include the registers where values are returned
727 and the register where structure-value addresses are passed.
728 Aside from that, you can include as many other registers as you like.
729 The CC is not preserved over function calls on the ARM 6, so it is
730 easier to assume this for all. SFP is preserved, since FP is. */
731 #define CALL_USED_REGISTERS \
739 #ifndef SUBTARGET_CONDITIONAL_REGISTER_USAGE
740 #define SUBTARGET_CONDITIONAL_REGISTER_USAGE
743 /* If doing stupid life analysis, avoid a bug causing a return value r0 to be
744 trampled. This effectively reduces the number of available registers by 1.
745 XXX It is a hack, I know.
746 XXX Is this still needed? */
747 #define CONDITIONAL_REGISTER_USAGE \
751 if (TARGET_SOFT_FLOAT) \
754 for (regno = 16; regno < 24; ++regno) \
755 fixed_regs[regno] = call_used_regs[regno] = 1; \
759 fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
760 call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
762 else if (TARGET_APCS_STACK) \
764 fixed_regs[10] = 1; \
765 call_used_regs[10] = 1; \
767 SUBTARGET_CONDITIONAL_REGISTER_USAGE \
770 /* These are a couple of extensions to the formats accecpted
772 %@ prints out ASM_COMMENT_START
773 %r prints out REGISTER_PREFIX reg_names[arg] */
774 #define ASM_FPRINTF_EXTENSIONS(FILE, ARGS, P) \
776 fputs (ASM_COMMENT_START, FILE); \
780 fputs (REGISTER_PREFIX, FILE); \
781 fputs (reg_names [va_arg (ARGS, int)], FILE); \
784 /* Convert fron bytes to ints. */
785 #define NUM_INTS(X) (((X) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
787 /* The number of (integer) registers required to hold a quantity of type MODE. */
788 #define NUM_REGS(MODE) \
789 NUM_INTS (GET_MODE_SIZE (MODE))
791 /* The number of (integer) registers required to hold a quantity of TYPE MODE. */
792 #define NUM_REGS2(MODE, TYPE) \
793 NUM_INTS ((MODE) == BLKmode ? int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE))
795 /* The number of (integer) argument register available. */
796 #define NUM_ARG_REGS 4
798 /* Return the regiser number of the N'th (integer) argument. */
799 #define ARG_REGISTER(N) (N - 1)
801 /* The number of the last argument register. */
802 #define LAST_ARG_REGNUM ARG_REGISTER (NUM_ARG_REGS)
804 /* Return number of consecutive hard regs needed starting at reg REGNO
805 to hold something of mode MODE.
806 This is ordinarily the length in words of a value of mode MODE
807 but can be less for certain modes in special long registers.
809 On the ARM regs are UNITS_PER_WORD bits wide; FPU regs can hold any FP
811 #define HARD_REGNO_NREGS(REGNO, MODE) \
813 && REGNO != FRAME_POINTER_REGNUM \
814 && REGNO != ARG_POINTER_REGNUM) \
815 ? 1 : NUM_REGS (MODE))
817 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
818 This is TRUE for ARM regs since they can hold anything, and TRUE for FPU
820 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
821 ((GET_MODE_CLASS (MODE) == MODE_CC) ? (REGNO == CC_REGNUM) : \
822 ((REGNO) < 16 || REGNO == FRAME_POINTER_REGNUM \
823 || REGNO == ARG_POINTER_REGNUM \
824 || GET_MODE_CLASS (MODE) == MODE_FLOAT))
826 /* Value is 1 if it is a good idea to tie two pseudo registers
827 when one has mode MODE1 and one has mode MODE2.
828 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
829 for any hard reg, then this must be 0 for correct output. */
830 #define MODES_TIEABLE_P(MODE1, MODE2) \
831 (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
833 /* Specify the registers used for certain standard purposes.
834 The values of these macros are register numbers. */
836 /* Define this if the program counter is overloaded on a register. */
839 /* Register to use for pushing function arguments. */
840 #define STACK_POINTER_REGNUM 13
841 #define SP_REGNUM STACK_POINTER_REGNUM
843 /* Base register for access to local variables of the function. */
844 #define FRAME_POINTER_REGNUM 25
846 /* Define this to be where the real frame pointer is if it is not possible to
847 work out the offset between the frame pointer and the automatic variables
848 until after register allocation has taken place. FRAME_POINTER_REGNUM
849 should point to a special register that we will make sure is eliminated. */
850 #define HARD_FRAME_POINTER_REGNUM 11
851 #define FP_REGNUM HARD_FRAME_POINTER_REGNUM
853 /* Register which holds return address from a subroutine call. */
856 /* Scratch register - used in all kinds of places, eg trampolines. */
859 /* Value should be nonzero if functions must have frame pointers.
860 Zero means the frame pointer need not be set up (and parms may be accessed
861 via the stack pointer) in functions that seem suitable.
862 If we have to have a frame pointer we might as well make use of it.
863 APCS says that the frame pointer does not need to be pushed in leaf
864 functions, or simple tail call functions. */
865 #define FRAME_POINTER_REQUIRED \
866 (current_function_has_nonlocal_label || (TARGET_APCS && !leaf_function_p ()))
868 /* Base register for access to arguments of the function. */
869 #define ARG_POINTER_REGNUM 26
871 /* The native (Norcroft) Pascal compiler for the ARM passes the static chain
872 as an invisible last argument (possible since varargs don't exist in
873 Pascal), so the following is not true. */
874 #define STATIC_CHAIN_REGNUM 8
876 /* Register in which address to store a structure value
877 is passed to a function. */
878 #define STRUCT_VALUE_REGNUM 0
880 /* Internal, so that we don't need to refer to a raw number */
883 /* The order in which register should be allocated. It is good to use ip
884 since no saving is required (though calls clobber it) and it never contains
885 function parameters. It is quite good to use lr since other calls may
886 clobber it anyway. Allocate r0 through r3 in reverse order since r3 is
887 least likely to contain a function parameter; in addition results are
890 #define REG_ALLOC_ORDER \
892 3, 2, 1, 0, 12, 14, 4, 5, \
893 6, 7, 8, 10, 9, 11, 13, 15, \
894 16, 17, 18, 19, 20, 21, 22, 23, \
898 /* Register and constant classes. */
900 /* Register classes: all ARM regs or all FPU regs---simple! */
910 #define N_REG_CLASSES (int) LIM_REG_CLASSES
912 /* Give names of register classes as strings for dump file. */
913 #define REG_CLASS_NAMES \
921 /* Define which registers fit in which classes.
922 This is an initializer for a vector of HARD_REG_SET
923 of length N_REG_CLASSES. */
924 #define REG_CLASS_CONTENTS \
926 { 0x0000000 }, /* NO_REGS */ \
927 { 0x0FF0000 }, /* FPU_REGS */ \
928 { 0x200FFFF }, /* GENERAL_REGS */ \
929 { 0x2FFFFFF } /* ALL_REGS */ \
932 /* The same information, inverted:
933 Return the class number of the smallest class containing
934 reg number REGNO. This could be a conditional expression
935 or could index an array. */
936 #define REGNO_REG_CLASS(REGNO) \
937 (((REGNO) < 16 || REGNO == FRAME_POINTER_REGNUM \
938 || REGNO == ARG_POINTER_REGNUM) \
939 ? GENERAL_REGS : (REGNO) == CC_REGNUM \
940 ? NO_REGS : FPU_REGS)
942 /* The class value for index registers, and the one for base regs. */
943 #define INDEX_REG_CLASS GENERAL_REGS
944 #define BASE_REG_CLASS GENERAL_REGS
946 /* Get reg_class from a letter such as appears in the machine description.
947 We only need constraint `f' for FPU_REGS (`r' == GENERAL_REGS). */
948 #define REG_CLASS_FROM_LETTER(C) \
949 ((C)=='f' ? FPU_REGS : NO_REGS)
951 /* The letters I, J, K, L and M in a register constraint string
952 can be used to stand for particular ranges of immediate operands.
953 This macro defines what the ranges are.
954 C is the letter, and VALUE is a constant value.
955 Return 1 if VALUE is in the range specified by C.
956 I: immediate arithmetic operand (i.e. 8 bits shifted as required).
957 J: valid indexing constants.
958 K: ~value ok in rhs argument of data operand.
959 L: -value ok in rhs argument of data operand.
960 M: 0..32, or a power of 2 (for shifts, or mult done by shift). */
961 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
962 ((C) == 'I' ? const_ok_for_arm (VALUE) : \
963 (C) == 'J' ? ((VALUE) < 4096 && (VALUE) > -4096) : \
964 (C) == 'K' ? (const_ok_for_arm (~(VALUE))) : \
965 (C) == 'L' ? (const_ok_for_arm (-(VALUE))) : \
966 (C) == 'M' ? (((VALUE >= 0 && VALUE <= 32)) \
967 || (((VALUE) & ((VALUE) - 1)) == 0)) \
970 /* For the ARM, `Q' means that this is a memory operand that is just
971 an offset from a register.
972 `S' means any symbol that has the SYMBOL_REF_FLAG set or a CONSTANT_POOL
973 address. This means that the symbol is in the text segment and can be
974 accessed without using a load. */
976 #define EXTRA_CONSTRAINT(OP, C) \
977 ((C) == 'Q' ? GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG \
978 : (C) == 'R' ? (GET_CODE (OP) == MEM \
979 && GET_CODE (XEXP (OP, 0)) == SYMBOL_REF \
980 && CONSTANT_POOL_ADDRESS_P (XEXP (OP, 0))) \
981 : (C) == 'S' ? (optimize > 0 && CONSTANT_ADDRESS_P (OP)) \
984 /* Constant letter 'G' for the FPU immediate constants.
985 'H' means the same constant negated. */
986 #define CONST_DOUBLE_OK_FOR_LETTER_P(X,C) \
987 ((C) == 'G' ? const_double_rtx_ok_for_fpu (X) \
988 : (C) == 'H' ? neg_const_double_rtx_ok_for_fpu (X) : 0)
990 /* Given an rtx X being reloaded into a reg required to be
991 in class CLASS, return the class of reg to actually use.
992 In general this is just CLASS; but on some machines
993 in some cases it is preferable to use a more restrictive class. */
994 #define PREFERRED_RELOAD_CLASS(X, CLASS) (CLASS)
996 /* Return the register class of a scratch register needed to copy IN into
997 or out of a register in CLASS in MODE. If it can be done directly,
998 NO_REGS is returned. */
999 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,X) \
1000 (((MODE) == HImode && ! arm_arch4 && true_regnum (X) == -1) \
1001 ? GENERAL_REGS : NO_REGS)
1003 /* If we need to load shorts byte-at-a-time, then we need a scratch. */
1004 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS,MODE,X) \
1005 (((MODE) == HImode && ! arm_arch4 && TARGET_SHORT_BY_BYTES \
1006 && (GET_CODE (X) == MEM \
1007 || ((GET_CODE (X) == REG || GET_CODE (X) == SUBREG) \
1008 && true_regnum (X) == -1))) \
1009 ? GENERAL_REGS : NO_REGS)
1011 /* Try a machine-dependent way of reloading an illegitimate address
1012 operand. If we find one, push the reload and jump to WIN. This
1013 macro is used in only one place: `find_reloads_address' in reload.c.
1015 For the ARM, we wish to handle large displacements off a base
1016 register by splitting the addend across a MOV and the mem insn.
1017 This can cut the number of reloads needed. */
1018 #define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_LEVELS, WIN) \
1021 if (GET_CODE (X) == PLUS \
1022 && GET_CODE (XEXP (X, 0)) == REG \
1023 && REGNO (XEXP (X, 0)) < FIRST_PSEUDO_REGISTER \
1024 && REG_MODE_OK_FOR_BASE_P (XEXP (X, 0), MODE) \
1025 && GET_CODE (XEXP (X, 1)) == CONST_INT) \
1027 HOST_WIDE_INT val = INTVAL (XEXP (X, 1)); \
1028 HOST_WIDE_INT low, high; \
1030 if (MODE == DImode || (TARGET_SOFT_FLOAT && MODE == DFmode)) \
1031 low = ((val & 0xf) ^ 0x8) - 0x8; \
1032 else if (MODE == SImode \
1033 || (MODE == SFmode && TARGET_SOFT_FLOAT) \
1034 || ((MODE == HImode || MODE == QImode) && ! arm_arch4)) \
1035 /* Need to be careful, -4096 is not a valid offset */ \
1036 low = val >= 0 ? (val & 0xfff) : -((-val) & 0xfff); \
1037 else if ((MODE == HImode || MODE == QImode) && arm_arch4) \
1038 /* Need to be careful, -256 is not a valid offset */ \
1039 low = val >= 0 ? (val & 0xff) : -((-val) & 0xff); \
1040 else if (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1041 && TARGET_HARD_FLOAT) \
1042 /* Need to be careful, -1024 is not a valid offset */ \
1043 low = val >= 0 ? (val & 0x3ff) : -((-val) & 0x3ff); \
1047 high = ((((val - low) & 0xffffffff) ^ 0x80000000) - 0x80000000); \
1048 /* Check for overflow or zero */ \
1049 if (low == 0 || high == 0 || (high + low != val)) \
1052 /* Reload the high part into a base reg; leave the low part \
1054 X = gen_rtx_PLUS (GET_MODE (X), \
1055 gen_rtx_PLUS (GET_MODE (X), XEXP (X, 0), \
1058 push_reload (XEXP (X, 0), NULL_RTX, &XEXP (X, 0), NULL_PTR, \
1059 BASE_REG_CLASS, GET_MODE (X), VOIDmode, 0, 0, \
1066 /* Return the maximum number of consecutive registers
1067 needed to represent mode MODE in a register of class CLASS.
1068 ARM regs are UNITS_PER_WORD bits while FPU regs can hold any FP mode */
1069 #define CLASS_MAX_NREGS(CLASS, MODE) \
1070 ((CLASS) == FPU_REGS ? 1 : NUM_REGS (MODE))
1072 /* Moves between FPU_REGS and GENERAL_REGS are two memory insns. */
1073 #define REGISTER_MOVE_COST(CLASS1, CLASS2) \
1074 ((((CLASS1) == FPU_REGS && (CLASS2) != FPU_REGS) \
1075 || ((CLASS2) == FPU_REGS && (CLASS1) != FPU_REGS)) \
1078 /* Stack layout; function entry, exit and calling. */
1080 /* Define this if pushing a word on the stack
1081 makes the stack pointer a smaller address. */
1082 #define STACK_GROWS_DOWNWARD 1
1084 /* Define this if the nominal address of the stack frame
1085 is at the high-address end of the local variables;
1086 that is, each additional local variable allocated
1087 goes at a more negative offset in the frame. */
1088 #define FRAME_GROWS_DOWNWARD 1
1090 /* Offset within stack frame to start allocating local variables at.
1091 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
1092 first local allocated. Otherwise, it is the offset to the BEGINNING
1093 of the first local allocated. */
1094 #define STARTING_FRAME_OFFSET 0
1096 /* If we generate an insn to push BYTES bytes,
1097 this says how many the stack pointer really advances by. */
1098 /* The push insns do not do this rounding implicitly. So don't define this. */
1099 /* #define PUSH_ROUNDING(NPUSHED) (((NPUSHED) + 3) & ~3) */
1101 /* Define this if the maximum size of all the outgoing args is to be
1102 accumulated and pushed during the prologue. The amount can be
1103 found in the variable current_function_outgoing_args_size. */
1104 #define ACCUMULATE_OUTGOING_ARGS 1
1106 /* Offset of first parameter from the argument pointer register value. */
1107 #define FIRST_PARM_OFFSET(FNDECL) 4
1109 /* Value is the number of byte of arguments automatically
1110 popped when returning from a subroutine call.
1111 FUNDECL is the declaration node of the function (as a tree),
1112 FUNTYPE is the data type of the function (as a tree),
1113 or for a library call it is an identifier node for the subroutine name.
1114 SIZE is the number of bytes of arguments passed on the stack.
1116 On the ARM, the caller does not pop any of its arguments that were passed
1118 #define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, SIZE) 0
1120 /* Define how to find the value returned by a library function
1121 assuming the value has mode MODE. */
1122 #define LIBCALL_VALUE(MODE) \
1123 (GET_MODE_CLASS (MODE) == MODE_FLOAT && TARGET_HARD_FLOAT \
1124 ? gen_rtx_REG (MODE, 16) \
1125 : gen_rtx_REG (MODE, 0))
1127 /* Define how to find the value returned by a function.
1128 VALTYPE is the data type of the value (as a tree).
1129 If the precise function being called is known, FUNC is its FUNCTION_DECL;
1130 otherwise, FUNC is 0. */
1131 #define FUNCTION_VALUE(VALTYPE, FUNC) \
1132 LIBCALL_VALUE (TYPE_MODE (VALTYPE))
1134 /* 1 if N is a possible register number for a function value.
1135 On the ARM, only r0 and f0 can return results. */
1136 #define FUNCTION_VALUE_REGNO_P(REGNO) \
1137 ((REGNO) == 0 || (((REGNO) == 16) && TARGET_HARD_FLOAT))
1139 /* How large values are returned */
1140 /* A C expression which can inhibit the returning of certain function values
1141 in registers, based on the type of value. */
1142 #define RETURN_IN_MEMORY(TYPE) arm_return_in_memory (TYPE)
1144 /* Define DEFAULT_PCC_STRUCT_RETURN to 1 if all structure and union return
1145 values must be in memory. On the ARM, they need only do so if larger
1146 than a word, or if they contain elements offset from zero in the struct. */
1147 #define DEFAULT_PCC_STRUCT_RETURN 0
1149 /* Define where to put the arguments to a function.
1150 Value is zero to push the argument on the stack,
1151 or a hard register in which to store the argument.
1153 MODE is the argument's machine mode.
1154 TYPE is the data type of the argument (as a tree).
1155 This is null for libcalls where that information may
1157 CUM is a variable of type CUMULATIVE_ARGS which gives info about
1158 the preceding args and about the function being called.
1159 NAMED is nonzero if this argument is a named parameter
1160 (otherwise it is an extra parameter matching an ellipsis).
1162 On the ARM, normally the first 16 bytes are passed in registers r0-r3; all
1163 other arguments are passed on the stack. If (NAMED == 0) (which happens
1164 only in assign_parms, since SETUP_INCOMING_VARARGS is defined), say it is
1165 passed in the stack (function_prologue will indeed make it pass in the
1166 stack if necessary). */
1167 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1169 ? ((CUM) >= NUM_ARG_REGS ? 0 : gen_rtx_REG (MODE, CUM))\
1172 /* For an arg passed partly in registers and partly in memory,
1173 this is the number of registers used.
1174 For args passed entirely in registers or entirely in memory, zero. */
1175 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
1176 ( NUM_ARG_REGS > (CUM) \
1177 && (NUM_ARG_REGS < ((CUM) + NUM_REGS2 (MODE, TYPE))) \
1178 ? NUM_ARG_REGS - (CUM) : 0)
1180 /* A C type for declaring a variable that is used as the first argument of
1181 `FUNCTION_ARG' and other related values. For some target machines, the
1182 type `int' suffices and can hold the number of bytes of argument so far.
1184 On the ARM, this is the number of bytes of arguments scanned so far. */
1185 #define CUMULATIVE_ARGS int
1187 /* Initialize a variable CUM of type CUMULATIVE_ARGS
1188 for a call to a function whose data type is FNTYPE.
1189 For a library call, FNTYPE is 0.
1190 On the ARM, the offset starts at 0. */
1191 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT) \
1192 ((CUM) = (((FNTYPE) && aggregate_value_p (TREE_TYPE ((FNTYPE)))) ? 1 : 0))
1194 /* Update the data in CUM to advance over an argument
1195 of mode MODE and data type TYPE.
1196 (TYPE is null for libcalls where that information may not be available.) */
1197 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
1198 (CUM) += NUM_REGS2 (MODE, TYPE)
1200 /* 1 if N is a possible register number for function argument passing.
1201 On the ARM, r0-r3 are used to pass args. */
1202 #define FUNCTION_ARG_REGNO_P(REGNO) \
1203 ((REGNO) >= 0 && (REGNO) <= 3)
1205 /* Perform any actions needed for a function that is receiving a variable
1206 number of arguments. CUM is as above. MODE and TYPE are the mode and type
1207 of the current parameter. PRETEND_SIZE is a variable that should be set to
1208 the amount of stack that must be pushed by the prolog to pretend that our
1211 Normally, this macro will push all remaining incoming registers on the
1212 stack and set PRETEND_SIZE to the length of the registers pushed.
1214 On the ARM, PRETEND_SIZE is set in order to have the prologue push the last
1215 named arg and all anonymous args onto the stack.
1216 XXX I know the prologue shouldn't be pushing registers, but it is faster
1218 #define SETUP_INCOMING_VARARGS(CUM, MODE, TYPE, PRETEND_SIZE, NO_RTL) \
1220 extern int current_function_anonymous_args; \
1221 current_function_anonymous_args = 1; \
1222 if ((CUM) < NUM_ARG_REGS) \
1223 (PRETEND_SIZE) = (NUM_ARG_REGS - (CUM)) * UNITS_PER_WORD; \
1226 /* Generate assembly output for the start of a function. */
1227 #define FUNCTION_PROLOGUE(STREAM, SIZE) \
1228 output_func_prologue ((STREAM), (SIZE))
1230 /* If your target environment doesn't prefix user functions with an
1231 underscore, you may wish to re-define this to prevent any conflicts.
1232 e.g. AOF may prefix mcount with an underscore. */
1233 #ifndef ARM_MCOUNT_NAME
1234 #define ARM_MCOUNT_NAME "*mcount"
1237 /* Call the function profiler with a given profile label. The Acorn
1238 compiler puts this BEFORE the prolog but gcc puts it afterwards.
1239 On the ARM the full profile code will look like:
1248 profile_function() in final.c outputs the .data section, FUNCTION_PROFILER
1249 will output the .text section.
1251 The ``mov ip,lr'' seems like a good idea to stick with cc convention.
1252 ``prof'' doesn't seem to mind about this! */
1253 #define FUNCTION_PROFILER(STREAM, LABELNO) \
1258 asm_fprintf (STREAM, "\tmov\t%r, %r\n\tbl\t", \
1259 IP_REGNUM, LR_REGNUM); \
1260 assemble_name (STREAM, ARM_MCOUNT_NAME); \
1261 fputc ('\n', STREAM); \
1262 ASM_GENERATE_INTERNAL_LABEL (temp, "LP", LABELNO); \
1263 sym = gen_rtx (SYMBOL_REF, Pmode, temp); \
1264 ASM_OUTPUT_INT (STREAM, sym); \
1267 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1268 the stack pointer does not matter. The value is tested only in
1269 functions that have frame pointers.
1270 No definition is equivalent to always zero.
1272 On the ARM, the function epilogue recovers the stack pointer from the
1274 #define EXIT_IGNORE_STACK 1
1276 /* Generate the assembly code for function exit. */
1277 #define FUNCTION_EPILOGUE(STREAM, SIZE) \
1278 output_func_epilogue (SIZE)
1280 /* Determine if the epilogue should be output as RTL.
1281 You should override this if you define FUNCTION_EXTRA_EPILOGUE. */
1282 #define USE_RETURN_INSN(ISCOND) use_return_insn (ISCOND)
1284 /* Definitions for register eliminations.
1286 This is an array of structures. Each structure initializes one pair
1287 of eliminable registers. The "from" register number is given first,
1288 followed by "to". Eliminations of the same "from" register are listed
1289 in order of preference.
1291 We have two registers that can be eliminated on the ARM. First, the
1292 arg pointer register can often be eliminated in favor of the stack
1293 pointer register. Secondly, the pseudo frame pointer register can always
1294 be eliminated; it is replaced with either the stack or the real frame
1297 #define ELIMINABLE_REGS \
1298 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
1299 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
1300 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
1301 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }}
1303 /* Given FROM and TO register numbers, say whether this elimination is allowed.
1304 Frame pointer elimination is automatically handled.
1306 All eliminations are permissible. Note that ARG_POINTER_REGNUM and
1307 HARD_FRAME_POINTER_REGNUM are in fact the same thing. If we need a frame
1308 pointer, we must eliminate FRAME_POINTER_REGNUM into
1309 HARD_FRAME_POINTER_REGNUM and not into STACK_POINTER_REGNUM. */
1310 #define CAN_ELIMINATE(FROM, TO) \
1311 (((TO) == STACK_POINTER_REGNUM && frame_pointer_needed) ? 0 : 1)
1313 /* Define the offset between two registers, one to be eliminated, and the other
1314 its replacement, at the start of a routine. */
1315 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1317 int volatile_func = arm_volatile_func (); \
1318 if ((FROM) == ARG_POINTER_REGNUM && (TO) == HARD_FRAME_POINTER_REGNUM)\
1320 else if ((FROM) == FRAME_POINTER_REGNUM \
1321 && (TO) == STACK_POINTER_REGNUM) \
1322 (OFFSET) = current_function_outgoing_args_size \
1323 + ((get_frame_size () + 3) & ~3); \
1328 int saved_hard_reg = 0; \
1330 if (! volatile_func) \
1332 for (regno = 0; regno <= 10; regno++) \
1333 if (regs_ever_live[regno] && ! call_used_regs[regno]) \
1334 saved_hard_reg = 1, offset += 4; \
1335 /* PIC register is a fixed reg, so call_used_regs set. */ \
1336 if (flag_pic && regs_ever_live[PIC_OFFSET_TABLE_REGNUM]) \
1337 saved_hard_reg = 1, offset += 4; \
1338 for (regno = 16; regno <=23; regno++) \
1339 if (regs_ever_live[regno] && ! call_used_regs[regno]) \
1342 if ((FROM) == FRAME_POINTER_REGNUM) \
1343 (OFFSET) = -offset; \
1346 if (! frame_pointer_needed) \
1348 if (! volatile_func \
1349 && (regs_ever_live[LR_REGNUM] || saved_hard_reg)) \
1351 offset += current_function_outgoing_args_size; \
1352 (OFFSET) = ((get_frame_size () + 3) & ~3) + offset; \
1357 /* Output assembler code for a block containing the constant parts
1358 of a trampoline, leaving space for the variable parts.
1360 On the ARM, (if r8 is the static chain regnum, and remembering that
1361 referencing pc adds an offset of 8) the trampoline looks like:
1364 .word static chain value
1365 .word function's address
1366 ??? FIXME: When the trampoline returns, r8 will be clobbered. */
1367 #define TRAMPOLINE_TEMPLATE(FILE) \
1369 fprintf ((FILE), "\tldr\t%s%s, [%s%s, #0]\n", \
1370 REGISTER_PREFIX, reg_names[STATIC_CHAIN_REGNUM], \
1371 REGISTER_PREFIX, reg_names[PC_REGNUM]); \
1372 fprintf ((FILE), "\tldr\t%s%s, [%s%s, #0]\n", \
1373 REGISTER_PREFIX, reg_names[PC_REGNUM], \
1374 REGISTER_PREFIX, reg_names[PC_REGNUM]); \
1375 ASM_OUTPUT_INT ((FILE), const0_rtx); \
1376 ASM_OUTPUT_INT ((FILE), const0_rtx); \
1379 /* Length in units of the trampoline for entering a nested function. */
1380 #define TRAMPOLINE_SIZE 16
1382 /* Alignment required for a trampoline in units. */
1383 #define TRAMPOLINE_ALIGN 4
1385 /* Emit RTL insns to initialize the variable parts of a trampoline.
1386 FNADDR is an RTX for the address of the function's pure code.
1387 CXT is an RTX for the static chain value for the function. */
1388 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
1390 emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 8)), \
1392 emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 12)), \
1397 /* Addressing modes, and classification of registers for them. */
1399 #define HAVE_POST_INCREMENT 1
1400 #define HAVE_PRE_INCREMENT 1
1401 #define HAVE_POST_DECREMENT 1
1402 #define HAVE_PRE_DECREMENT 1
1404 /* Macros to check register numbers against specific register classes. */
1406 /* These assume that REGNO is a hard or pseudo reg number.
1407 They give nonzero only if REGNO is a hard reg of the suitable class
1408 or a pseudo reg currently allocated to a suitable hard reg.
1409 Since they use reg_renumber, they are safe only once reg_renumber
1410 has been allocated, which happens in local-alloc.c.
1412 On the ARM, don't allow the pc to be used. */
1413 #define REGNO_OK_FOR_BASE_P(REGNO) \
1414 ((REGNO) < 15 || (REGNO) == FRAME_POINTER_REGNUM \
1415 || (REGNO) == ARG_POINTER_REGNUM \
1416 || (unsigned) reg_renumber[(REGNO)] < 15 \
1417 || (unsigned) reg_renumber[(REGNO)] == FRAME_POINTER_REGNUM \
1418 || (unsigned) reg_renumber[(REGNO)] == ARG_POINTER_REGNUM)
1419 #define REGNO_OK_FOR_INDEX_P(REGNO) \
1420 REGNO_OK_FOR_BASE_P(REGNO)
1422 /* Maximum number of registers that can appear in a valid memory address.
1423 Shifts in addresses can't be by a register. */
1425 #define MAX_REGS_PER_ADDRESS 2
1427 /* Recognize any constant value that is a valid address. */
1428 /* XXX We can address any constant, eventually... */
1430 #ifdef AOF_ASSEMBLER
1432 #define CONSTANT_ADDRESS_P(X) \
1433 (GET_CODE (X) == SYMBOL_REF \
1434 && CONSTANT_POOL_ADDRESS_P (X))
1438 #define CONSTANT_ADDRESS_P(X) \
1439 (GET_CODE (X) == SYMBOL_REF \
1440 && (CONSTANT_POOL_ADDRESS_P (X) \
1441 || (optimize > 0 && SYMBOL_REF_FLAG (X))))
1443 #endif /* AOF_ASSEMBLER */
1445 /* Nonzero if the constant value X is a legitimate general operand.
1446 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.
1448 On the ARM, allow any integer (invalid ones are removed later by insn
1449 patterns), nice doubles and symbol_refs which refer to the function's
1450 constant pool XXX. */
1451 #define LEGITIMATE_CONSTANT_P(X) (! label_mentioned_p (X))
1453 /* Symbols in the text segment can be accessed without indirecting via the
1454 constant pool; it may take an extra binary operation, but this is still
1455 faster than indirecting via memory. Don't do this when not optimizing,
1456 since we won't be calculating al of the offsets necessary to do this
1458 /* This doesn't work with AOF syntax, since the string table may be in
1459 a different AREA. */
1460 #ifndef AOF_ASSEMBLER
1461 #define ENCODE_SECTION_INFO(decl) \
1463 if (optimize > 0 && TREE_CONSTANT (decl) \
1464 && (!flag_writable_strings || TREE_CODE (decl) != STRING_CST)) \
1466 rtx rtl = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd' \
1467 ? TREE_CST_RTL (decl) : DECL_RTL (decl)); \
1468 SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1; \
1473 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1474 and check its validity for a certain class.
1475 We have two alternate definitions for each of them.
1476 The usual definition accepts all pseudo regs; the other rejects
1477 them unless they have been allocated suitable hard regs.
1478 The symbol REG_OK_STRICT causes the latter definition to be used. */
1479 #ifndef REG_OK_STRICT
1481 /* Nonzero if X is a hard reg that can be used as a base reg
1482 or if it is a pseudo reg. */
1483 #define REG_OK_FOR_BASE_P(X) \
1484 (REGNO (X) < 16 || REGNO (X) >= FIRST_PSEUDO_REGISTER \
1485 || REGNO (X) == FRAME_POINTER_REGNUM || REGNO (X) == ARG_POINTER_REGNUM)
1487 /* Nonzero if X is a hard reg that can be used as an index
1488 or if it is a pseudo reg. */
1489 #define REG_OK_FOR_INDEX_P(X) \
1490 REG_OK_FOR_BASE_P(X)
1492 #define REG_OK_FOR_PRE_POST_P(X) \
1493 (REGNO (X) < 16 || REGNO (X) >= FIRST_PSEUDO_REGISTER \
1494 || REGNO (X) == FRAME_POINTER_REGNUM || REGNO (X) == ARG_POINTER_REGNUM)
1498 /* Nonzero if X is a hard reg that can be used as a base reg. */
1499 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
1501 /* Nonzero if X is a hard reg that can be used as an index. */
1502 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
1504 #define REG_OK_FOR_PRE_POST_P(X) \
1505 (REGNO (X) < 16 || (unsigned) reg_renumber[REGNO (X)] < 16 \
1506 || REGNO (X) == FRAME_POINTER_REGNUM || REGNO (X) == ARG_POINTER_REGNUM \
1507 || (unsigned) reg_renumber[REGNO (X)] == FRAME_POINTER_REGNUM \
1508 || (unsigned) reg_renumber[REGNO (X)] == ARG_POINTER_REGNUM)
1512 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1513 that is a valid memory address for an instruction.
1514 The MODE argument is the machine mode for the MEM expression
1515 that wants to use this address.
1517 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS. */
1518 #define BASE_REGISTER_RTX_P(X) \
1519 (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X))
1521 #define INDEX_REGISTER_RTX_P(X) \
1522 (GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X))
1524 /* A C statement (sans semicolon) to jump to LABEL for legitimate index RTXs
1525 used by the macro GO_IF_LEGITIMATE_ADDRESS. Floating point indices can
1526 only be small constants. */
1527 #define GO_IF_LEGITIMATE_INDEX(MODE, BASE_REGNO, INDEX, LABEL) \
1530 HOST_WIDE_INT range; \
1531 enum rtx_code code = GET_CODE (INDEX); \
1533 if (TARGET_HARD_FLOAT && GET_MODE_CLASS (MODE) == MODE_FLOAT) \
1535 if (code == CONST_INT && INTVAL (INDEX) < 1024 \
1536 && INTVAL (INDEX) > -1024 \
1537 && (INTVAL (INDEX) & 3) == 0) \
1542 if (INDEX_REGISTER_RTX_P (INDEX) && GET_MODE_SIZE (MODE) <= 4) \
1544 if (GET_MODE_SIZE (MODE) <= 4 && code == MULT \
1545 && (! arm_arch4 || (MODE) != HImode)) \
1547 rtx xiop0 = XEXP (INDEX, 0); \
1548 rtx xiop1 = XEXP (INDEX, 1); \
1549 if (INDEX_REGISTER_RTX_P (xiop0) \
1550 && power_of_two_operand (xiop1, SImode)) \
1552 if (INDEX_REGISTER_RTX_P (xiop1) \
1553 && power_of_two_operand (xiop0, SImode)) \
1556 if (GET_MODE_SIZE (MODE) <= 4 \
1557 && (code == LSHIFTRT || code == ASHIFTRT \
1558 || code == ASHIFT || code == ROTATERT) \
1559 && (! arm_arch4 || (MODE) != HImode)) \
1561 rtx op = XEXP (INDEX, 1); \
1562 if (INDEX_REGISTER_RTX_P (XEXP (INDEX, 0)) \
1563 && GET_CODE (op) == CONST_INT && INTVAL (op) > 0 \
1564 && INTVAL (op) <= 31) \
1567 /* NASTY: Since this limits the addressing of unsigned byte loads */ \
1568 range = ((MODE) == HImode || (MODE) == QImode) \
1569 ? (arm_arch4 ? 256 : 4095) : 4096; \
1570 if (code == CONST_INT && INTVAL (INDEX) < range \
1571 && INTVAL (INDEX) > -range) \
1577 /* Jump to LABEL if X is a valid address RTX. This must also take
1578 REG_OK_STRICT into account when deciding about valid registers, but it uses
1579 the above macros so we are in luck. Allow REG, REG+REG, REG+INDEX,
1580 INDEX+REG, REG-INDEX, and non floating SYMBOL_REF to the constant pool.
1581 Allow REG-only and AUTINC-REG if handling TImode or HImode. Other symbol
1582 refs must be forced though a static cell to ensure addressability. */
1583 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
1585 if (BASE_REGISTER_RTX_P (X)) \
1587 else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC) \
1588 && GET_CODE (XEXP (X, 0)) == REG \
1589 && REG_OK_FOR_PRE_POST_P (XEXP (X, 0))) \
1591 else if (GET_MODE_SIZE (MODE) >= 4 && reload_completed \
1592 && (GET_CODE (X) == LABEL_REF \
1593 || (GET_CODE (X) == CONST \
1594 && GET_CODE (XEXP ((X), 0)) == PLUS \
1595 && GET_CODE (XEXP (XEXP ((X), 0), 0)) == LABEL_REF \
1596 && GET_CODE (XEXP (XEXP ((X), 0), 1)) == CONST_INT)))\
1598 else if ((MODE) == TImode) \
1600 else if ((MODE) == DImode || (TARGET_SOFT_FLOAT && (MODE) == DFmode)) \
1602 if (GET_CODE (X) == PLUS && BASE_REGISTER_RTX_P (XEXP (X, 0)) \
1603 && GET_CODE (XEXP (X, 1)) == CONST_INT) \
1605 HOST_WIDE_INT val = INTVAL (XEXP (X, 1)); \
1606 if (val == 4 || val == -4 || val == -8) \
1610 else if (GET_CODE (X) == PLUS) \
1612 rtx xop0 = XEXP(X,0); \
1613 rtx xop1 = XEXP(X,1); \
1615 if (BASE_REGISTER_RTX_P (xop0)) \
1616 GO_IF_LEGITIMATE_INDEX (MODE, REGNO (xop0), xop1, LABEL); \
1617 else if (BASE_REGISTER_RTX_P (xop1)) \
1618 GO_IF_LEGITIMATE_INDEX (MODE, REGNO (xop1), xop0, LABEL); \
1620 /* Reload currently can't handle MINUS, so disable this for now */ \
1621 /* else if (GET_CODE (X) == MINUS) \
1623 rtx xop0 = XEXP (X,0); \
1624 rtx xop1 = XEXP (X,1); \
1626 if (BASE_REGISTER_RTX_P (xop0)) \
1627 GO_IF_LEGITIMATE_INDEX (MODE, -1, xop1, LABEL); \
1629 else if (GET_MODE_CLASS (MODE) != MODE_FLOAT \
1630 && GET_CODE (X) == SYMBOL_REF \
1631 && CONSTANT_POOL_ADDRESS_P (X) \
1633 && symbol_mentioned_p (get_pool_constant (X)))) \
1635 else if ((GET_CODE (X) == PRE_INC || GET_CODE (X) == POST_DEC) \
1636 && (GET_MODE_SIZE (MODE) <= 4) \
1637 && GET_CODE (XEXP (X, 0)) == REG \
1638 && REG_OK_FOR_PRE_POST_P (XEXP (X, 0))) \
1642 /* Try machine-dependent ways of modifying an illegitimate address
1643 to be legitimate. If we find one, return the new, valid address.
1644 This macro is used in only one place: `memory_address' in explow.c.
1646 OLDX is the address as it was before break_out_memory_refs was called.
1647 In some cases it is useful to look at this to decide what needs to be done.
1649 MODE and WIN are passed so that this macro can use
1650 GO_IF_LEGITIMATE_ADDRESS.
1652 It is always safe for this macro to do nothing. It exists to recognize
1653 opportunities to optimize the output.
1655 On the ARM, try to convert [REG, #BIGCONST]
1656 into ADD BASE, REG, #UPPERCONST and [BASE, #VALIDCONST],
1657 where VALIDCONST == 0 in case of TImode. */
1658 #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
1660 if (GET_CODE (X) == PLUS) \
1662 rtx xop0 = XEXP (X, 0); \
1663 rtx xop1 = XEXP (X, 1); \
1665 if (CONSTANT_P (xop0) && ! symbol_mentioned_p (xop0)) \
1666 xop0 = force_reg (SImode, xop0); \
1667 if (CONSTANT_P (xop1) && ! symbol_mentioned_p (xop1)) \
1668 xop1 = force_reg (SImode, xop1); \
1669 if (BASE_REGISTER_RTX_P (xop0) && GET_CODE (xop1) == CONST_INT) \
1671 HOST_WIDE_INT n, low_n; \
1672 rtx base_reg, val; \
1673 n = INTVAL (xop1); \
1675 if (MODE == DImode || (TARGET_SOFT_FLOAT && MODE == DFmode)) \
1687 low_n = ((MODE) == TImode ? 0 \
1688 : n >= 0 ? (n & 0xfff) : -((-n) & 0xfff)); \
1691 base_reg = gen_reg_rtx (SImode); \
1692 val = force_operand (gen_rtx_PLUS (SImode, xop0, \
1693 GEN_INT (n)), NULL_RTX); \
1694 emit_move_insn (base_reg, val); \
1695 (X) = (low_n == 0 ? base_reg \
1696 : gen_rtx_PLUS (SImode, base_reg, GEN_INT (low_n))); \
1698 else if (xop0 != XEXP (X, 0) || xop1 != XEXP (x, 1)) \
1699 (X) = gen_rtx_PLUS (SImode, xop0, xop1); \
1701 else if (GET_CODE (X) == MINUS) \
1703 rtx xop0 = XEXP (X, 0); \
1704 rtx xop1 = XEXP (X, 1); \
1706 if (CONSTANT_P (xop0)) \
1707 xop0 = force_reg (SImode, xop0); \
1708 if (CONSTANT_P (xop1) && ! symbol_mentioned_p (xop1)) \
1709 xop1 = force_reg (SImode, xop1); \
1710 if (xop0 != XEXP (X, 0) || xop1 != XEXP (X, 1)) \
1711 (X) = gen_rtx_MINUS (SImode, xop0, xop1); \
1714 (X) = legitimize_pic_address (OLDX, MODE, NULL_RTX); \
1715 if (memory_address_p (MODE, X)) \
1719 /* Go to LABEL if ADDR (a legitimate address expression)
1720 has an effect that depends on the machine mode it is used for. */
1721 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1723 if (GET_CODE(ADDR) == PRE_DEC || GET_CODE(ADDR) == POST_DEC \
1724 || GET_CODE(ADDR) == PRE_INC || GET_CODE(ADDR) == POST_INC) \
1728 /* Specify the machine mode that this machine uses
1729 for the index in the tablejump instruction. */
1730 #define CASE_VECTOR_MODE SImode
1732 /* Define as C expression which evaluates to nonzero if the tablejump
1733 instruction expects the table to contain offsets from the address of the
1735 Do not define this if the table should contain absolute addresses. */
1736 /* #define CASE_VECTOR_PC_RELATIVE 1 */
1738 /* Specify the tree operation to be used to convert reals to integers. */
1739 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1741 /* This is the kind of divide that is easiest to do in the general case. */
1742 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
1744 /* signed 'char' is most compatible, but RISC OS wants it unsigned.
1745 unsigned is probably best, but may break some code. */
1746 #ifndef DEFAULT_SIGNED_CHAR
1747 #define DEFAULT_SIGNED_CHAR 0
1750 /* Don't cse the address of the function being compiled. */
1751 #define NO_RECURSIVE_FUNCTION_CSE 1
1753 /* Max number of bytes we can move from memory to memory
1754 in one reasonably fast instruction. */
1757 /* Define if operations between registers always perform the operation
1758 on the full register even if a narrower mode is specified. */
1759 #define WORD_REGISTER_OPERATIONS
1761 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1762 will either zero-extend or sign-extend. The value of this macro should
1763 be the code that says which one of the two operations is implicitly
1764 done, NIL if none. */
1765 #define LOAD_EXTEND_OP(MODE) \
1766 ((arm_arch4 || (MODE) == QImode) ? ZERO_EXTEND \
1767 : ((BYTES_BIG_ENDIAN && (MODE) == HImode) ? SIGN_EXTEND : NIL))
1769 /* Define this if zero-extension is slow (more than one real instruction).
1770 On the ARM, it is more than one instruction only if not fetching from
1772 /* #define SLOW_ZERO_EXTEND */
1774 /* Nonzero if access to memory by bytes is slow and undesirable. */
1775 #define SLOW_BYTE_ACCESS 0
1777 /* Immediate shift counts are truncated by the output routines (or was it
1778 the assembler?). Shift counts in a register are truncated by ARM. Note
1779 that the native compiler puts too large (> 32) immediate shift counts
1780 into a register and shifts by the register, letting the ARM decide what
1781 to do instead of doing that itself. */
1782 /* This is all wrong. Defining SHIFT_COUNT_TRUNCATED tells combine that
1783 code like (X << (Y % 32)) for register X, Y is equivalent to (X << Y).
1784 On the arm, Y in a register is used modulo 256 for the shift. Only for
1785 rotates is modulo 32 used. */
1786 /* #define SHIFT_COUNT_TRUNCATED 1 */
1788 /* All integers have the same format so truncation is easy. */
1789 #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) 1
1791 /* Calling from registers is a massive pain. */
1792 #define NO_FUNCTION_CSE 1
1794 /* Chars and shorts should be passed as ints. */
1795 #define PROMOTE_PROTOTYPES 1
1797 /* The machine modes of pointers and functions */
1798 #define Pmode SImode
1799 #define FUNCTION_MODE Pmode
1801 /* The structure type of the machine dependent info field of insns
1802 No uses for this yet. */
1803 /* #define INSN_MACHINE_INFO struct machine_info */
1805 /* The relative costs of various types of constants. Note that cse.c defines
1806 REG = 1, SUBREG = 2, any node = (2 + sum of subnodes). */
1807 #define CONST_COSTS(RTX, CODE, OUTER_CODE) \
1809 if (const_ok_for_arm (INTVAL (RTX))) \
1810 return (OUTER_CODE) == SET ? 2 : -1; \
1811 else if (OUTER_CODE == AND \
1812 && const_ok_for_arm (~INTVAL (RTX))) \
1814 else if ((OUTER_CODE == COMPARE \
1815 || OUTER_CODE == PLUS || OUTER_CODE == MINUS) \
1816 && const_ok_for_arm (-INTVAL (RTX))) \
1824 case CONST_DOUBLE: \
1825 if (const_double_rtx_ok_for_fpu (RTX)) \
1826 return (OUTER_CODE) == SET ? 2 : -1; \
1827 else if (((OUTER_CODE) == COMPARE || (OUTER_CODE) == PLUS) \
1828 && neg_const_double_rtx_ok_for_fpu (RTX)) \
1832 #define ARM_FRAME_RTX(X) \
1833 ((X) == frame_pointer_rtx || (X) == stack_pointer_rtx \
1834 || (X) == arg_pointer_rtx)
1836 #define DEFAULT_RTX_COSTS(X, CODE, OUTER_CODE) \
1837 return arm_rtx_costs (X, CODE);
1839 /* Moves to and from memory are quite expensive */
1840 #define MEMORY_MOVE_COST(MODE,CLASS,IN) 10
1842 /* All address computations that can be done are free, but rtx cost returns
1843 the same for practically all of them. So we weight the different types
1844 of address here in the order (most pref first):
1845 PRE/POST_INC/DEC, SHIFT or NON-INT sum, INT sum, REG, MEM or LABEL. */
1846 #define ADDRESS_COST(X) \
1847 (10 - ((GET_CODE (X) == MEM || GET_CODE (X) == LABEL_REF \
1848 || GET_CODE (X) == SYMBOL_REF) \
1850 : ((GET_CODE (X) == PRE_INC || GET_CODE (X) == PRE_DEC \
1851 || GET_CODE (X) == POST_INC || GET_CODE (X) == POST_DEC) \
1853 : (((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS) \
1854 ? 6 + (GET_CODE (XEXP (X, 1)) == CONST_INT ? 2 \
1855 : ((GET_RTX_CLASS (GET_CODE (XEXP (X, 0))) == '2' \
1856 || GET_RTX_CLASS (GET_CODE (XEXP (X, 0))) == 'c' \
1857 || GET_RTX_CLASS (GET_CODE (XEXP (X, 1))) == '2' \
1858 || GET_RTX_CLASS (GET_CODE (XEXP (X, 1))) == 'c') \
1862 /* Try to generate sequences that don't involve branches, we can then use
1863 conditional instructions */
1864 #define BRANCH_COST 4
1866 /* A C statement to update the variable COST based on the relationship
1867 between INSN that is dependent on DEP through dependence LINK. */
1868 #define ADJUST_COST(INSN, LINK, DEP, COST) \
1869 (COST) = arm_adjust_cost (INSN, LINK, DEP, COST)
1871 /* Position Independent Code. */
1872 /* We decide which register to use based on the compilation options and
1873 the assembler in use; this is more general than the APCS restriction of
1874 using sb (r9) all the time. */
1875 extern int arm_pic_register;
1877 /* Used when parsing command line option -mpic-register=. */
1878 extern const char * arm_pic_register_string;
1880 /* The register number of the register used to address a table of static
1881 data addresses in memory. */
1882 #define PIC_OFFSET_TABLE_REGNUM arm_pic_register
1884 #define FINALIZE_PIC arm_finalize_pic ()
1886 /* We can't directly access anything that contains a symbol,
1887 nor can we indirect via the constant pool. */
1888 #define LEGITIMATE_PIC_OPERAND_P(X) \
1889 (! symbol_mentioned_p (X) \
1890 && (! CONSTANT_POOL_ADDRESS_P (X) \
1891 || ! symbol_mentioned_p (get_pool_constant (X))))
1893 /* We need to know when we are making a constant pool; this determines
1894 whether data needs to be in the GOT or can be referenced via a GOT
1896 extern int making_const_table;
1899 /* Condition code information. */
1900 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
1901 return the mode to be used for the comparison.
1902 CCFPEmode should be used with floating inequalities,
1903 CCFPmode should be used with floating equalities.
1904 CC_NOOVmode should be used with SImode integer equalities.
1905 CC_Zmode should be used if only the Z flag is set correctly
1906 CCmode should be used otherwise. */
1908 #define EXTRA_CC_MODES \
1909 CC(CC_NOOVmode, "CC_NOOV") \
1910 CC(CC_Zmode, "CC_Z") \
1911 CC(CC_SWPmode, "CC_SWP") \
1912 CC(CCFPmode, "CCFP") \
1913 CC(CCFPEmode, "CCFPE") \
1914 CC(CC_DNEmode, "CC_DNE") \
1915 CC(CC_DEQmode, "CC_DEQ") \
1916 CC(CC_DLEmode, "CC_DLE") \
1917 CC(CC_DLTmode, "CC_DLT") \
1918 CC(CC_DGEmode, "CC_DGE") \
1919 CC(CC_DGTmode, "CC_DGT") \
1920 CC(CC_DLEUmode, "CC_DLEU") \
1921 CC(CC_DLTUmode, "CC_DLTU") \
1922 CC(CC_DGEUmode, "CC_DGEU") \
1923 CC(CC_DGTUmode, "CC_DGTU") \
1924 CC(CC_Cmode, "CC_C")
1926 #define SELECT_CC_MODE(OP,X,Y) arm_select_cc_mode ((OP), (X), (Y))
1928 #define REVERSIBLE_CC_MODE(MODE) ((MODE) != CCFPEmode)
1930 #define CANONICALIZE_COMPARISON(CODE, OP0, OP1) \
1933 if (GET_CODE (OP1) == CONST_INT \
1934 && ! (const_ok_for_arm (INTVAL (OP1)) \
1935 || (const_ok_for_arm (- INTVAL (OP1))))) \
1937 rtx const_op = OP1; \
1938 CODE = arm_canonicalize_comparison ((CODE), &const_op); \
1944 #define STORE_FLAG_VALUE 1
1946 /* Define the information needed to generate branch insns. This is
1947 stored from the compare operation. Note that we can't use "rtx" here
1948 since it hasn't been defined! */
1950 extern struct rtx_def * arm_compare_op0;
1951 extern struct rtx_def * arm_compare_op1;
1953 /* Define the codes that are matched by predicates in arm.c */
1954 #define PREDICATE_CODES \
1955 {"s_register_operand", {SUBREG, REG}}, \
1956 {"f_register_operand", {SUBREG, REG}}, \
1957 {"arm_add_operand", {SUBREG, REG, CONST_INT}}, \
1958 {"fpu_add_operand", {SUBREG, REG, CONST_DOUBLE}}, \
1959 {"arm_rhs_operand", {SUBREG, REG, CONST_INT}}, \
1960 {"fpu_rhs_operand", {SUBREG, REG, CONST_DOUBLE}}, \
1961 {"arm_not_operand", {SUBREG, REG, CONST_INT}}, \
1962 {"offsettable_memory_operand", {MEM}}, \
1963 {"bad_signed_byte_operand", {MEM}}, \
1964 {"alignable_memory_operand", {MEM}}, \
1965 {"shiftable_operator", {PLUS, MINUS, AND, IOR, XOR}}, \
1966 {"minmax_operator", {SMIN, SMAX, UMIN, UMAX}}, \
1967 {"shift_operator", {ASHIFT, ASHIFTRT, LSHIFTRT, ROTATERT, MULT}}, \
1968 {"di_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE, MEM}}, \
1969 {"soft_df_operand", {SUBREG, REG, CONST_DOUBLE, MEM}}, \
1970 {"load_multiple_operation", {PARALLEL}}, \
1971 {"store_multiple_operation", {PARALLEL}}, \
1972 {"equality_operator", {EQ, NE}}, \
1973 {"arm_rhsm_operand", {SUBREG, REG, CONST_INT, MEM}}, \
1974 {"const_shift_operand", {CONST_INT}}, \
1975 {"index_operand", {SUBREG, REG, CONST_INT}}, \
1976 {"reg_or_int_operand", {SUBREG, REG, CONST_INT}}, \
1977 {"multi_register_push", {PARALLEL}}, \
1978 {"cc_register", {REG}}, \
1979 {"logical_binary_operator", {AND, IOR, XOR}}, \
1980 {"dominant_cc_register", {REG}},
1984 /* Gcc puts the pool in the wrong place for ARM, since we can only
1985 load addresses a limited distance around the pc. We do some
1986 special munging to move the constant pool values to the correct
1987 point in the code. */
1988 #define MACHINE_DEPENDENT_REORG(INSN) arm_reorg ((INSN))
1990 /* Output an internal label definition. */
1991 #ifndef ASM_OUTPUT_INTERNAL_LABEL
1992 #define ASM_OUTPUT_INTERNAL_LABEL(STREAM, PREFIX, NUM) \
1995 char * s = (char *) alloca (40 + strlen (PREFIX)); \
1997 if (arm_ccfsm_state == 3 && arm_target_label == (NUM) \
1998 && !strcmp (PREFIX, "L")) \
2000 arm_ccfsm_state = 0; \
2001 arm_target_insn = NULL; \
2003 ASM_GENERATE_INTERNAL_LABEL (s, (PREFIX), (NUM)); \
2004 ASM_OUTPUT_LABEL (STREAM, s); \
2009 /* Output a push or a pop instruction (only used when profiling). */
2010 #define ASM_OUTPUT_REG_PUSH(STREAM, REGNO) \
2011 asm_fprintf (STREAM,"\tstmfd\t%r!,{%r}\n", SP_REGNUM, REGNO)
2013 #define ASM_OUTPUT_REG_POP(STREAM, REGNO) \
2014 asm_fprintf (STREAM,"\tldmfd\t%r!,{%r}\n", SP_REGNUM, REGNO)
2016 #define ARM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
2019 if (TARGET_POKE_FUNCTION_NAME) \
2020 arm_poke_function_name (STREAM, NAME); \
2024 /* Target characters. */
2025 #define TARGET_BELL 007
2026 #define TARGET_BS 010
2027 #define TARGET_TAB 011
2028 #define TARGET_NEWLINE 012
2029 #define TARGET_VT 013
2030 #define TARGET_FF 014
2031 #define TARGET_CR 015
2033 /* Only perform branch elimination (by making instructions conditional) if
2034 we're optimising. Otherwise it's of no use anyway. */
2035 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
2037 arm_final_prescan_insn (INSN)
2039 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
2040 ((CODE) == '?' || (CODE) == '|' || (CODE) == '@')
2042 /* Output an operand of an instruction. */
2043 #define PRINT_OPERAND(STREAM, X, CODE) \
2044 arm_print_operand (STREAM, X, CODE)
2046 #define ARM_SIGN_EXTEND(x) ((HOST_WIDE_INT) \
2047 (HOST_BITS_PER_WIDE_INT <= 32 ? (x) \
2048 : (((x) & (unsigned HOST_WIDE_INT) 0xffffffff) | \
2049 (((x) & (unsigned HOST_WIDE_INT) 0x80000000) \
2050 ? ((~ (HOST_WIDE_INT) 0) \
2051 & ~ (unsigned HOST_WIDE_INT) 0xffffffff) \
2054 /* Output the address of an operand. */
2055 #define PRINT_OPERAND_ADDRESS(STREAM,X) \
2057 int is_minus = GET_CODE (X) == MINUS; \
2059 if (GET_CODE (X) == REG) \
2060 asm_fprintf (STREAM, "[%r, #0]", REGNO (X)); \
2061 else if (GET_CODE (X) == PLUS || is_minus) \
2063 rtx base = XEXP (X, 0); \
2064 rtx index = XEXP (X, 1); \
2066 HOST_WIDE_INT offset = 0; \
2067 if (GET_CODE (base) != REG) \
2069 /* Ensure that BASE is a register (one of them must be). */ \
2074 base_reg = REGNO (base); \
2075 switch (GET_CODE (index)) \
2078 offset = INTVAL (index); \
2081 asm_fprintf (STREAM, "[%r, #%d]", base_reg, offset); \
2085 asm_fprintf (STREAM, "[%r, %s%r]", base_reg, \
2086 is_minus ? "-" : "", REGNO (index)); \
2095 asm_fprintf (STREAM, "[%r, %s%r", base_reg, \
2096 is_minus ? "-" : "", REGNO (XEXP (index, 0))); \
2097 arm_print_operand (STREAM, index, 'S'); \
2098 fputs ("]", STREAM); \
2106 else if (GET_CODE (X) == PRE_INC || GET_CODE (X) == POST_INC \
2107 || GET_CODE (X) == PRE_DEC || GET_CODE (X) == POST_DEC) \
2109 extern int output_memory_reference_mode; \
2111 if (GET_CODE (XEXP (X, 0)) != REG) \
2114 if (GET_CODE (X) == PRE_DEC || GET_CODE (X) == PRE_INC) \
2115 asm_fprintf (STREAM, "[%r, #%s%d]!", \
2116 REGNO (XEXP (X, 0)), \
2117 GET_CODE (X) == PRE_DEC ? "-" : "", \
2118 GET_MODE_SIZE (output_memory_reference_mode)); \
2120 asm_fprintf (STREAM, "[%r], #%s%d", \
2121 REGNO (XEXP (X, 0)), \
2122 GET_CODE (X) == POST_DEC ? "-" : "", \
2123 GET_MODE_SIZE (output_memory_reference_mode)); \
2125 else output_addr_const (STREAM, X); \
2128 /* Handles PIC addr specially */
2129 #define OUTPUT_INT_ADDR_CONST(STREAM,X) \
2131 if (flag_pic && GET_CODE (X) == CONST && is_pic (X)) \
2133 output_addr_const (STREAM, XEXP (XEXP (XEXP (X, 0), 0), 0)); \
2134 fputs (" - (", STREAM); \
2135 output_addr_const (STREAM, XEXP (XEXP (XEXP (X, 0), 1), 0)); \
2136 fputs (")", STREAM); \
2138 else output_addr_const (STREAM, X); \
2140 /* Mark symbols as position independent. We only do this in the \
2141 .text segment, not in the .data segment. */ \
2142 if (NEED_GOT_RELOC && flag_pic && making_const_table && \
2143 (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == LABEL_REF)) \
2145 if (GET_CODE (X) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (X)) \
2146 fprintf (STREAM, "(GOTOFF)"); \
2147 else if (GET_CODE (X) == LABEL_REF) \
2148 fprintf (STREAM, "(GOTOFF)"); \
2150 fprintf (STREAM, "(GOT)"); \
2154 /* Output code to add DELTA to the first argument, and then jump to FUNCTION.
2155 Used for C++ multiple inheritance. */
2156 #define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \
2159 int mi_delta = (DELTA); \
2160 char * mi_op = mi_delta < 0 ? "sub" : "add"; \
2162 int this_regno = (aggregate_value_p (TREE_TYPE (TREE_TYPE (FUNCTION))) \
2164 if (mi_delta < 0) mi_delta = -mi_delta; \
2165 while (mi_delta != 0) \
2167 if (mi_delta & (3 << shift) == 0) \
2171 asm_fprintf (FILE, "\t%s\t%r, %r, #%d\n", \
2172 mi_op, this_regno, this_regno, \
2173 mi_delta & (0xff << shift)); \
2174 mi_delta &= ~(0xff << shift); \
2178 fputs ("\tb\t", FILE); \
2179 assemble_name (FILE, XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0)); \
2180 if (NEED_PLT_RELOC) \
2181 fputs ("(PLT)", FILE); \
2182 fputc ('\n', FILE); \
2186 /* A C expression whose value is RTL representing the value of the return
2187 address for the frame COUNT steps up from the current frame. */
2189 #define RETURN_ADDR_RTX(COUNT, FRAME) \
2191 ? gen_rtx_MEM (Pmode, plus_constant (FRAME, -4)) \
2194 /* Used to mask out junk bits from the return address, such as
2195 processor state, interrupt status, condition codes and the like. */
2196 #define MASK_RETURN_ADDR \
2197 /* If we are generating code for an ARM2/ARM3 machine or for an ARM6 \
2198 in 26 bit mode, the condition codes must be masked out of the \
2199 return address. This does not apply to ARM6 and later processors \
2200 when running in 32 bit mode. */ \
2201 ((!TARGET_APCS_32) ? (GEN_INT (0x03fffffc)) : (GEN_INT (0xffffffff)))
2203 #endif /* __ARM_H__ */