2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / config / arm / aof.h
blob5a6ab2c0e2c833d20578e98b35ac51ddc0c7b0c1
1 /* Definitions of target machine for GNU compiler, for Advanced RISC Machines
2 ARM compilation, AOF Assembler.
3 Copyright (C) 1995, 1996, 1997, 2000, 2003 Free Software Foundation, Inc.
4 Contributed by Richard Earnshaw (rearnsha@armltd.co.uk)
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 2, or (at your
11 option) any later version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
25 #define AOF_ASSEMBLER
27 #define LINK_LIBGCC_SPECIAL 1
29 #define LINK_SPEC "%{aof} %{bin} %{aif} %{ihf} %{shl,*} %{reent*} %{split} \
30 %{ov*} %{reloc*} -nodebug"
32 #define STARTFILE_SPEC "crtbegin.o%s"
34 #define ENDFILE_SPEC "crtend.o%s"
36 #ifndef ASM_SPEC
37 #define ASM_SPEC "%{g -g} -arch 4 \
38 -apcs 3%{mapcs-32:/32bit}%{mapcs-26:/26bit}%{!mapcs-26:%{!macps-32:/26bit}}"
39 #endif
41 #ifndef LIB_SPEC
42 #define LIB_SPEC "%{Eb: armlib_h.32b%s}%{!Eb: armlib_h.32l%s}"
43 #endif
45 #define LIBGCC_SPEC "libgcc.a%s"
47 /* Dividing the Output into Sections (Text, Data, ...) */
48 /* AOF Assembler syntax is a nightmare when it comes to areas, since once
49 we change from one area to another, we can't go back again. Instead,
50 we must create a new area with the same attributes and add the new output
51 to that. Unfortunately, there is nothing we can do here to guarantee that
52 two areas with the same attributes will be linked adjacently in the
53 resulting executable, so we have to be careful not to do pc-relative
54 addressing across such boundaries. */
55 #define TEXT_SECTION_ASM_OP aof_text_section ()
57 #define DATA_SECTION_ASM_OP aof_data_section ()
59 #define EXTRA_SECTIONS in_zero_init, in_common
61 #define EXTRA_SECTION_FUNCTIONS \
62 ZERO_INIT_SECTION \
63 COMMON_SECTION
65 #define ZERO_INIT_SECTION \
66 void \
67 zero_init_section () \
68 { \
69 static int zero_init_count = 1; \
71 if (in_section != in_zero_init) \
72 { \
73 fprintf (asm_out_file, "\tAREA |C$$zidata%d|,NOINIT\n", \
74 zero_init_count++); \
75 in_section = in_zero_init; \
76 } \
79 /* Used by ASM_OUTPUT_COMMON (below) to tell varasm.c that we've
80 changed areas. */
81 #define COMMON_SECTION \
82 void \
83 common_section () \
84 { \
85 if (in_section != in_common) \
86 in_section = in_common; \
89 #define CTOR_LIST_BEGIN \
90 asm (CTORS_SECTION_ASM_OP); \
91 extern func_ptr __CTOR_END__[1]; \
92 func_ptr __CTOR_LIST__[1] = {__CTOR_END__};
94 #define CTOR_LIST_END \
95 asm (CTORS_SECTION_ASM_OP); \
96 func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
98 #define DO_GLOBAL_CTORS_BODY \
99 do \
101 func_ptr *ptr = __CTOR_LIST__ + 1; \
103 while (*ptr) \
104 (*ptr++) (); \
106 while (0)
108 #define DTOR_LIST_BEGIN \
109 asm (DTORS_SECTION_ASM_OP); \
110 extern func_ptr __DTOR_END__[1]; \
111 func_ptr __DTOR_LIST__[1] = {__DTOR_END__};
113 #define DTOR_LIST_END \
114 asm (DTORS_SECTION_ASM_OP); \
115 func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
117 #define DO_GLOBAL_DTORS_BODY \
118 do \
120 func_ptr *ptr = __DTOR_LIST__ + 1; \
122 while (*ptr) \
123 (*ptr++) (); \
125 while (0)
127 /* We really want to put Thumb tables in a read-only data section, but
128 switching to another section during function output is not
129 possible. We could however do what the SPARC does and defer the
130 whole table generation until the end of the function. */
131 #define JUMP_TABLES_IN_TEXT_SECTION 1
133 /* Some systems use __main in a way incompatible with its use in gcc, in these
134 cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
135 give the same symbol without quotes for an alternative entry point. You
136 must define both, or neither. */
137 #define NAME__MAIN "__gccmain"
138 #define SYMBOL__MAIN __gccmain
140 #define ASM_COMMENT_START ";"
141 #define ASM_APP_ON ""
142 #define ASM_APP_OFF ""
144 #define ASM_OUTPUT_ASCII(STREAM, PTR, LEN) \
146 int i; \
147 const char *ptr = (PTR); \
148 fprintf ((STREAM), "\tDCB"); \
149 for (i = 0; i < (long)(LEN); i++) \
150 fprintf ((STREAM), " &%02x%s", \
151 (unsigned ) *(ptr++), \
152 (i + 1 < (long)(LEN) \
153 ? ((i & 3) == 3 ? "\n\tDCB" : ",") \
154 : "\n")); \
157 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == '\n')
159 /* Output of Uninitialized Variables. */
161 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \
162 (common_section (), \
163 fprintf ((STREAM), "\tAREA "), \
164 assemble_name ((STREAM), (NAME)), \
165 fprintf ((STREAM), ", DATA, COMMON\n\t%% %d\t%s size=%d\n", \
166 (int)(ROUNDED), ASM_COMMENT_START, (int)(SIZE)))
168 #define ASM_OUTPUT_LOCAL(STREAM, NAME, SIZE, ROUNDED) \
169 (zero_init_section (), \
170 assemble_name ((STREAM), (NAME)), \
171 fprintf ((STREAM), "\n"), \
172 fprintf ((STREAM), "\t%% %d\t%s size=%d\n", \
173 (int)(ROUNDED), ASM_COMMENT_START, (int)(SIZE)))
175 /* Output and Generation of Labels */
176 extern int arm_main_function;
178 /* Globalizing directive for a label. */
179 #define GLOBAL_ASM_OP "\tEXPORT\t"
181 #define ASM_OUTPUT_LABEL(STREAM,NAME) \
182 do { \
183 assemble_name (STREAM,NAME); \
184 fputs ("\n", STREAM); \
185 } while (0)
187 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
189 if (TARGET_POKE_FUNCTION_NAME) \
190 arm_poke_function_name ((STREAM), (NAME)); \
191 ASM_OUTPUT_LABEL (STREAM, NAME); \
192 if (! TREE_PUBLIC (DECL)) \
194 fputs ("\tKEEP ", STREAM); \
195 ASM_OUTPUT_LABEL (STREAM, NAME); \
197 aof_delete_import ((NAME)); \
200 #define ASM_DECLARE_OBJECT_NAME(STREAM,NAME,DECL) \
202 ASM_OUTPUT_LABEL (STREAM, NAME); \
203 if (! TREE_PUBLIC (DECL)) \
205 fputs ("\tKEEP ", STREAM); \
206 ASM_OUTPUT_LABEL (STREAM, NAME); \
208 aof_delete_import ((NAME)); \
211 #define ASM_OUTPUT_EXTERNAL(STREAM,DECL,NAME) \
212 aof_add_import ((NAME))
214 #define ASM_OUTPUT_EXTERNAL_LIBCALL(STREAM,SYMREF) \
215 (fprintf ((STREAM), "\tIMPORT\t"), \
216 assemble_name ((STREAM), XSTR ((SYMREF), 0)), \
217 fputc ('\n', (STREAM)))
219 #define ASM_OUTPUT_LABELREF(STREAM,NAME) \
220 fprintf ((STREAM), "|%s|", NAME)
222 #define ASM_GENERATE_INTERNAL_LABEL(STRING,PREFIX,NUM) \
223 sprintf ((STRING), "*|%s..%ld|", (PREFIX), (long)(NUM))
225 /* How initialization functions are handled. */
227 #define CTORS_SECTION_ASM_OP "\tAREA\t|C$$gnu_ctorsvec|, DATA, READONLY"
228 #define DTORS_SECTION_ASM_OP "\tAREA\t|C$$gnu_dtorsvec|, DATA, READONLY"
230 /* Output of Assembler Instructions. */
232 #define REGISTER_NAMES \
234 "a1", "a2", "a3", "a4", \
235 "v1", "v2", "v3", "v4", \
236 "v5", "v6", "sl", "fp", \
237 "ip", "sp", "lr", "pc", \
238 "f0", "f1", "f2", "f3", \
239 "f4", "f5", "f6", "f7", \
240 "cc", "sfp", "afp", \
241 "mv0", "mv1", "mv2", "mv3", \
242 "mv4", "mv5", "mv6", "mv7", \
243 "mv8", "mv9", "mv10", "mv11", \
244 "mv12", "mv13", "mv14", "mv15", \
245 "wcgr0", "wcgr1", "wcgr2", "wcgr3", \
246 "wr0", "wr1", "wr2", "wr3", \
247 "wr4", "wr5", "wr6", "wr7", \
248 "wr8", "wr9", "wr10", "wr11", \
249 "wr12", "wr13", "wr14", "wr15" \
252 #define ADDITIONAL_REGISTER_NAMES \
254 {"r0", 0}, {"a1", 0}, \
255 {"r1", 1}, {"a2", 1}, \
256 {"r2", 2}, {"a3", 2}, \
257 {"r3", 3}, {"a4", 3}, \
258 {"r4", 4}, {"v1", 4}, \
259 {"r5", 5}, {"v2", 5}, \
260 {"r6", 6}, {"v3", 6}, \
261 {"r7", 7}, {"wr", 7}, \
262 {"r8", 8}, {"v5", 8}, \
263 {"r9", 9}, {"v6", 9}, \
264 {"r10", 10}, {"sl", 10}, {"v7", 10}, \
265 {"r11", 11}, {"fp", 11}, \
266 {"r12", 12}, {"ip", 12}, \
267 {"r13", 13}, {"sp", 13}, \
268 {"r14", 14}, {"lr", 14}, \
269 {"r15", 15}, {"pc", 15} \
272 #define REGISTER_PREFIX "__"
273 #define USER_LABEL_PREFIX ""
274 #define LOCAL_LABEL_PREFIX ""
276 /* AOF does not prefix user function names with an underscore. */
277 #define ARM_MCOUNT_NAME "_mcount"
279 /* Output of Dispatch Tables. */
280 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL) \
281 do \
283 if (TARGET_ARM) \
284 fprintf ((STREAM), "\tb\t|L..%d|\n", (VALUE)); \
285 else \
286 fprintf ((STREAM), "\tDCD\t|L..%d| - |L..%d|\n", (VALUE), (REL)); \
288 while (0)
290 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \
291 fprintf ((STREAM), "\tDCD\t|L..%d|\n", (VALUE))
293 /* A label marking the start of a jump table is a data label. */
294 #define ASM_OUTPUT_CASE_LABEL(STREAM, PREFIX, NUM, TABLE) \
295 fprintf ((STREAM), "\tALIGN\n|%s..%d|\n", (PREFIX), (NUM))
297 /* Assembler Commands for Alignment. */
298 #define ASM_OUTPUT_SKIP(STREAM, NBYTES) \
299 fprintf ((STREAM), "\t%%\t%d\n", (int) (NBYTES))
301 #define ASM_OUTPUT_ALIGN(STREAM, POWER) \
302 do \
304 int amount = 1 << (POWER); \
306 if (amount == 2) \
307 fprintf ((STREAM), "\tALIGN 2\n"); \
308 else if (amount == 4) \
309 fprintf ((STREAM), "\tALIGN\n"); \
310 else \
311 fprintf ((STREAM), "\tALIGN %d\n", amount); \
313 while (0)
315 #undef DBX_DEBUGGING_INFO