2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / config / arm / netbsd.h
blobc1db2df5e262f87ac0c093efe4ccd64b6ac909fe
1 /* NetBSD/arm a.out version.
2 Copyright (C) 1993, 1994, 1997, 1998, 2003 Free Software Foundation, Inc.
3 Contributed by Mark Brinicombe (amb@physig.ph.kcl.ac.uk)
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published
9 by the Free Software Foundation; either version 2, or (at your
10 option) any later version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* Run-time Target Specification. */
23 #undef TARGET_VERSION
24 #define TARGET_VERSION fputs (" (ARM/NetBSD)", stderr);
26 /* Unsigned chars produces much better code than signed. */
27 #define DEFAULT_SIGNED_CHAR 0
29 /* Since we always use GAS as our assembler we support stabs. */
30 #define DBX_DEBUGGING_INFO 1
32 /*#undef ASM_DECLARE_FUNCTION_NAME*/
34 /* ARM6 family default cpu. */
35 #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
37 /* Default is to use APCS-32 mode. */
38 #undef TARGET_DEFAULT
39 #define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_FRAME)
41 /* Some defines for CPP.
42 arm32 is the NetBSD port name, so we always define arm32 and __arm32__. */
43 #define TARGET_OS_CPP_BUILTINS() \
44 do { \
45 NETBSD_OS_CPP_BUILTINS_AOUT(); \
46 builtin_define_std ("arm32"); \
47 builtin_define_std ("unix"); \
48 builtin_define_std ("riscbsd"); \
49 } while (0)
51 #undef SUBTARGET_EXTRA_SPECS
52 #define SUBTARGET_EXTRA_SPECS \
53 { "netbsd_cpp_spec", NETBSD_CPP_SPEC }, \
54 { "netbsd_link_spec", NETBSD_LINK_SPEC_AOUT },
56 #undef CPP_SPEC
57 #define CPP_SPEC "\
58 %(cpp_cpu_arch) %(cpp_apcs_pc) %(cpp_float) %(cpp_endian) %(netbsd_cpp_spec) \
61 /* Because TARGET_DEFAULT sets ARM_FLAG_APCS_32 */
62 #undef CPP_APCS_PC_DEFAULT_SPEC
63 #define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
65 /* Because TARGET_DEFAULT sets ARM_FLAG_SOFT_FLOAT */
66 #undef CPP_FLOAT_DEFAULT_SPEC
67 #define CPP_FLOAT_DEFAULT_SPEC "-D__SOFTFP__"
69 /* Pass -X to the linker so that it will strip symbols starting with 'L' */
70 #undef LINK_SPEC
71 #define LINK_SPEC "-X %(netbsd_link_spec)"
73 #undef SIZE_TYPE
74 #define SIZE_TYPE "unsigned int"
76 #undef PTRDIFF_TYPE
77 #define PTRDIFF_TYPE "int"
79 #define HANDLE_SYSV_PRAGMA 1
81 /* We don't have any limit on the length as out debugger is GDB. */
82 #undef DBX_CONTIN_LENGTH
84 /* NetBSD does its profiling differently to the Acorn compiler. We
85 don't need a word following the mcount call; and to skip it
86 requires either an assembly stub or use of fomit-frame-pointer when
87 compiling the profiling functions. Since we break Acorn CC
88 compatibility below a little more won't hurt. */
90 #undef ARM_FUNCTION_PROFILER
91 #define ARM_FUNCTION_PROFILER(STREAM,LABELNO) \
92 { \
93 fprintf(STREAM, "\tmov\t%sip, %slr\n", REGISTER_PREFIX, REGISTER_PREFIX); \
94 fprintf(STREAM, "\tbl\tmcount\n"); \
97 /* On the ARM `@' introduces a comment, so we must use something else
98 for .type directives. */
99 #undef TYPE_OPERAND_FMT
100 #define TYPE_OPERAND_FMT "%%%s"
102 /* NetBSD uses the old PCC style aggregate returning conventions. */
103 #undef DEFAULT_PCC_STRUCT_RETURN
104 #define DEFAULT_PCC_STRUCT_RETURN 1
106 /* Although not normally relevant (since by default, all aggregates
107 are returned in memory) compiling some parts of libc requires
108 non-APCS style struct returns. */
109 #undef RETURN_IN_MEMORY
111 /* VERY BIG NOTE : Change of structure alignment for RiscBSD.
112 There are consequences you should be aware of...
114 Normally GCC/arm uses a structure alignment of 32 for compatibility
115 with armcc. This means that structures are padded to a word
116 boundary. However this causes problems with bugged NetBSD kernel
117 code (possibly userland code as well - I have not checked every
118 binary). The nature of this bugged code is to rely on sizeof()
119 returning the correct size of various structures rounded to the
120 nearest byte (SCSI and ether code are two examples, the vm system
121 is another). This code breaks when the structure alignment is 32
122 as sizeof() will report a word=rounded size. By changing the
123 structure alignment to 8. GCC will conform to what is expected by
124 NetBSD.
126 This has several side effects that should be considered.
127 1. Structures will only be aligned to the size of the largest member.
128 i.e. structures containing only bytes will be byte aligned.
129 structures containing shorts will be half word aligned.
130 structures containing ints will be word aligned.
132 This means structures should be padded to a word boundary if
133 alignment of 32 is required for byte structures etc.
135 2. A potential performance penalty may exist if strings are no longer
136 word aligned. GCC will not be able to use word load/stores to copy
137 short strings.
139 This modification is not encouraged but with the present state of the
140 NetBSD source tree it is currently the only solution that meets the
141 requirements. */
142 #undef DEFAULT_STRUCTURE_SIZE_BOUNDARY
143 #define DEFAULT_STRUCTURE_SIZE_BOUNDARY 8
145 /* Emit code to set up a trampoline and synchronize the caches. */
146 #undef INITIALIZE_TRAMPOLINE
147 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
149 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 8)), \
150 (CXT)); \
151 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 12)), \
152 (FNADDR)); \
153 emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__clear_cache"), \
154 0, VOIDmode, 2, TRAMP, Pmode, \
155 plus_constant (TRAMP, TRAMPOLINE_SIZE), Pmode); \
158 /* Clear the instruction cache from `BEG' to `END'. This makes a
159 call to the ARM32_SYNC_ICACHE architecture specific syscall. */
160 #define CLEAR_INSN_CACHE(BEG, END) \
162 extern int sysarch(int number, void *args); \
163 struct { \
164 unsigned int addr; \
165 int len; \
166 } s; \
167 s.addr = (unsigned int)(BEG); \
168 s.len = (END) - (BEG); \
169 (void)sysarch(0, &s); \