OSDN Git Service

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