* rtl.h (rtunion_def): Constify member `rtstr'.
[official-gcc.git] / gcc / config / arm / aof.h
bloba25a311b83221870e4766a2bc0d916a3112ca74c
1 /* Definitions of target machine for GNU compiler, for Advanced RISC Machines
2 ARM compilation, AOF Assembler.
3 Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
4 Contributed by Richard Earnshaw (rearnsha@armltd.co.uk)
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; 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 char *aof_text_section ();
56 #define TEXT_SECTION_ASM_OP aof_text_section ()
58 #define SELECT_RTX_SECTION(MODE,RTX) text_section ();
60 char *aof_data_section ();
61 #define DATA_SECTION_ASM_OP aof_data_section ()
63 #define EXTRA_SECTIONS in_zero_init, in_ctor, in_dtor, in_common
65 #define EXTRA_SECTION_FUNCTIONS \
66 ZERO_INIT_SECTION \
67 CTOR_SECTION \
68 DTOR_SECTION \
69 COMMON_SECTION
71 #define ZERO_INIT_SECTION \
72 void \
73 zero_init_section () \
74 { \
75 static int zero_init_count = 1; \
76 if (in_section != in_zero_init) \
77 { \
78 fprintf (asm_out_file, "\tAREA |C$$zidata%d|,NOINIT\n", \
79 zero_init_count++); \
80 in_section = in_zero_init; \
81 } \
84 #define CTOR_SECTION \
85 void \
86 ctor_section () \
87 { \
88 static int ctors_once = 0; \
89 if (in_section != in_ctor) \
90 { \
91 if (ctors_once) \
92 { \
93 fprintf (stderr, \
94 "Attempt to output more than one ctor section\n"); \
95 abort (); \
96 } \
97 fprintf (asm_out_file, "\t%s\n", CTORS_SECTION_ASM_OP); \
98 in_section = in_ctor; \
99 ctors_once = 1; \
103 #define DTOR_SECTION \
104 void \
105 dtor_section () \
107 static int dtors_once = 0; \
108 if (in_section != in_dtor) \
110 if (dtors_once) \
112 fprintf (stderr, \
113 "Attempt to output more than one dtor section\n"); \
114 abort (); \
116 fprintf (asm_out_file, "\t%s\n", DTORS_SECTION_ASM_OP); \
117 in_section = in_dtor; \
118 dtors_once = 1; \
122 /* Used by ASM_OUTPUT_COMMON (below) to tell varasm.c that we've
123 changed areas. */
124 #define COMMON_SECTION \
125 void \
126 common_section () \
128 static int common_count = 1; \
129 if (in_section != in_common) \
131 in_section = in_common; \
134 #define CTOR_LIST_BEGIN \
135 asm (CTORS_SECTION_ASM_OP); \
136 extern func_ptr __CTOR_END__[1]; \
137 func_ptr __CTOR_LIST__[1] = {__CTOR_END__};
139 #define CTOR_LIST_END \
140 asm (CTORS_SECTION_ASM_OP); \
141 func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
143 #define DO_GLOBAL_CTORS_BODY \
144 do { \
145 func_ptr *ptr = __CTOR_LIST__ + 1; \
146 while (*ptr) \
147 (*ptr++) (); \
148 } while (0)
150 #define DTOR_LIST_BEGIN \
151 asm (DTORS_SECTION_ASM_OP); \
152 extern func_ptr __DTOR_END__[1]; \
153 func_ptr __DTOR_LIST__[1] = {__DTOR_END__};
155 #define DTOR_LIST_END \
156 asm (DTORS_SECTION_ASM_OP); \
157 func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
159 #define DO_GLOBAL_DTORS_BODY \
160 do { \
161 func_ptr *ptr = __DTOR_LIST__ + 1; \
162 while (*ptr) \
163 (*ptr++) (); \
164 } while (0)
166 #define JUMP_TABLES_IN_TEXT_SECTION 1
168 #ifndef ARM_OS_NAME
169 #define ARM_OS_NAME "(generic)"
170 #endif
172 /* For the AOF linker, we need to reference __main to force the standard
173 library to get linked in. */
175 #define ASM_FILE_START(STREAM) \
177 fprintf ((STREAM), "%s Generated by gcc %s for ARM/%s\n", \
178 ASM_COMMENT_START, version_string, ARM_OS_NAME); \
179 fprintf ((STREAM), "__r0\tRN\t0\n"); \
180 fprintf ((STREAM), "__a1\tRN\t0\n"); \
181 fprintf ((STREAM), "__a2\tRN\t1\n"); \
182 fprintf ((STREAM), "__a3\tRN\t2\n"); \
183 fprintf ((STREAM), "__a4\tRN\t3\n"); \
184 fprintf ((STREAM), "__v1\tRN\t4\n"); \
185 fprintf ((STREAM), "__v2\tRN\t5\n"); \
186 fprintf ((STREAM), "__v3\tRN\t6\n"); \
187 fprintf ((STREAM), "__v4\tRN\t7\n"); \
188 fprintf ((STREAM), "__v5\tRN\t8\n"); \
189 fprintf ((STREAM), "__v6\tRN\t9\n"); \
190 fprintf ((STREAM), "__sl\tRN\t10\n"); \
191 fprintf ((STREAM), "__fp\tRN\t11\n"); \
192 fprintf ((STREAM), "__ip\tRN\t12\n"); \
193 fprintf ((STREAM), "__sp\tRN\t13\n"); \
194 fprintf ((STREAM), "__lr\tRN\t14\n"); \
195 fprintf ((STREAM), "__pc\tRN\t15\n"); \
196 fprintf ((STREAM), "__f0\tFN\t0\n"); \
197 fprintf ((STREAM), "__f1\tFN\t1\n"); \
198 fprintf ((STREAM), "__f2\tFN\t2\n"); \
199 fprintf ((STREAM), "__f3\tFN\t3\n"); \
200 fprintf ((STREAM), "__f4\tFN\t4\n"); \
201 fprintf ((STREAM), "__f5\tFN\t5\n"); \
202 fprintf ((STREAM), "__f6\tFN\t6\n"); \
203 fprintf ((STREAM), "__f7\tFN\t7\n"); \
204 text_section (); \
207 /* Some systems use __main in a way incompatible with its use in gcc, in these
208 cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
209 give the same symbol without quotes for an alternative entry point. You
210 must define both, or neither. */
211 #define NAME__MAIN "__gccmain"
212 #define SYMBOL__MAIN __gccmain
214 #define ASM_FILE_END(STREAM) \
215 do \
217 if (flag_pic) \
218 aof_dump_pic_table (STREAM); \
219 aof_dump_imports (STREAM); \
220 fputs ("\tEND\n", (STREAM)); \
221 } while (0);
223 #define ASM_IDENTIFY_GCC(STREAM) fputs ("|gcc2_compiled.|\n", (STREAM))
225 #define ASM_COMMENT_START ";"
227 #define ASM_APP_ON ""
229 #define ASM_APP_OFF ""
231 #define ASM_OUTPUT_LONG_DOUBLE(STREAM,VALUE) \
232 ASM_OUTPUT_DOUBLE((STREAM),(VALUE))
234 #define ASM_OUTPUT_DOUBLE(STREAM,VALUE) \
235 do { \
236 char dstr[30]; \
237 long l[2]; \
238 REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), l); \
239 REAL_VALUE_TO_DECIMAL ((VALUE), "%.14g", dstr); \
240 fprintf ((STREAM), "\tDCD &%lx, &%lx\t%s double %s\n", \
241 l[0], l[1], ASM_COMMENT_START, dstr); \
242 } while (0)
244 #define ASM_OUTPUT_FLOAT(STREAM,VALUE) \
245 do { \
246 char dstr[30]; \
247 long l; \
248 REAL_VALUE_TO_TARGET_SINGLE ((VALUE), l); \
249 REAL_VALUE_TO_DECIMAL ((VALUE), "%.7g", dstr); \
250 fprintf ((STREAM), "\tDCD &%lx\t%s double %s\n", \
251 l, ASM_COMMENT_START, dstr); \
252 } while (0)
254 #define ASM_OUTPUT_INT(STREAM,VALUE) \
255 (fprintf ((STREAM), "\tDCD\t"), \
256 output_addr_const ((STREAM), (VALUE)), \
257 fputc ('\n', (STREAM)))
259 #define ASM_OUTPUT_SHORT(STREAM,VALUE) \
260 (fprintf ((STREAM), "\tDCW\t"), \
261 output_addr_const ((STREAM), (VALUE)), \
262 fputc ('\n', (STREAM)))
264 #define ASM_OUTPUT_CHAR(STREAM,VALUE) \
265 (fprintf ((STREAM), "\tDCB\t"), \
266 output_addr_const ((STREAM), (VALUE)), \
267 fputc ('\n', (STREAM)))
269 #define ASM_OUTPUT_BYTE(STREAM,VALUE) \
270 fprintf ((STREAM), "\tDCB\t%d\n", (VALUE))
272 #define ASM_OUTPUT_ASCII(STREAM,PTR,LEN) \
274 int i; \
275 const char *ptr = (PTR); \
276 fprintf ((STREAM), "\tDCB"); \
277 for (i = 0; i < (LEN); i++) \
278 fprintf ((STREAM), " &%02x%s", \
279 (unsigned ) *(ptr++), \
280 (i + 1 < (LEN) \
281 ? ((i & 3) == 3 ? "\n\tDCB" : ",") \
282 : "\n")); \
285 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == '\n')
287 #define ASM_OPEN_PAREN "("
288 #define ASM_CLOSE_PAREN ")"
290 /* Output of Uninitialized Variables */
292 #define ASM_OUTPUT_COMMON(STREAM,NAME,SIZE,ROUNDED) \
293 (common_section (), \
294 fprintf ((STREAM), "\tAREA "), \
295 assemble_name ((STREAM), (NAME)), \
296 fprintf ((STREAM), ", DATA, COMMON\n\t%% %d\t%s size=%d\n", \
297 (ROUNDED), ASM_COMMENT_START, SIZE))
299 #define ASM_OUTPUT_LOCAL(STREAM,NAME,SIZE,ROUNDED) \
300 (zero_init_section (), \
301 assemble_name ((STREAM), (NAME)), \
302 fprintf ((STREAM), "\n"), \
303 fprintf ((STREAM), "\t%% %d\t%s size=%d\n", \
304 (ROUNDED), ASM_COMMENT_START, SIZE))
306 /* Output and Generation of Labels */
308 extern int arm_main_function;
310 #define ASM_GLOBALIZE_LABEL(STREAM,NAME) \
311 do { \
312 fprintf ((STREAM), "\tEXPORT\t"); \
313 assemble_name ((STREAM), (NAME)); \
314 fputc ('\n', (STREAM)); \
315 if ((NAME)[0] == 'm' && ! strcmp ((NAME), "main")) \
316 arm_main_function = 1; \
317 } while (0)
319 #define ASM_OUTPUT_LABEL(STREAM,NAME) \
320 do { \
321 assemble_name (STREAM,NAME); \
322 fputs ("\n", STREAM); \
323 } while (0)
325 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
327 if (TARGET_POKE_FUNCTION_NAME) \
328 arm_poke_function_name ((STREAM), (NAME)); \
329 ASM_OUTPUT_LABEL (STREAM, NAME); \
330 if (! TREE_PUBLIC (DECL)) \
332 fputs ("\tKEEP ", STREAM); \
333 ASM_OUTPUT_LABEL (STREAM, NAME); \
335 aof_delete_import ((NAME)); \
338 #define ASM_DECLARE_OBJECT_NAME(STREAM,NAME,DECL) \
340 ASM_OUTPUT_LABEL (STREAM, NAME); \
341 if (! TREE_PUBLIC (DECL)) \
343 fputs ("\tKEEP ", STREAM); \
344 ASM_OUTPUT_LABEL (STREAM, NAME); \
346 aof_delete_import ((NAME)); \
349 #define ASM_OUTPUT_EXTERNAL(STREAM,DECL,NAME) \
350 aof_add_import ((NAME))
352 #define ASM_OUTPUT_EXTERNAL_LIBCALL(STREAM,SYMREF) \
353 (fprintf ((STREAM), "\tIMPORT\t"), \
354 assemble_name ((STREAM), XSTR ((SYMREF), 0)), \
355 fputc ('\n', (STREAM)))
357 #define ASM_OUTPUT_LABELREF(STREAM,NAME) \
358 fprintf ((STREAM), "|%s|", NAME)
360 #define ASM_GENERATE_INTERNAL_LABEL(STRING,PREFIX,NUM) \
361 sprintf ((STRING), "*|%s..%d|", (PREFIX), (NUM))
363 #define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER) \
364 ((OUTVAR) = (char *) alloca (strlen ((NAME)) + 10), \
365 sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)))
367 /* How initialization functions are handled */
369 #define CTORS_SECTION_ASM_OP "AREA\t|C$$gnu_ctorsvec|, DATA, READONLY"
370 #define DTORS_SECTION_ASM_OP "AREA\t|C$$gnu_dtorsvec|, DATA, READONLY"
372 #define ASM_OUTPUT_CONSTRUCTOR(STREAM,NAME) \
373 do { \
374 ctor_section (); \
375 fprintf ((STREAM), "\tDCD\t"); \
376 assemble_name ((STREAM), (NAME)); \
377 fputc ('\n', (STREAM)); \
378 } while (0);
380 #define ASM_OUTPUT_DESTRUCTOR(STREAM,NAME) \
381 do { \
382 dtor_section (); \
383 fprintf ((STREAM), "\tDCD\t"); \
384 assemble_name ((STREAM), (NAME)); \
385 fputc ('\n', (STREAM)); \
386 } while (0);
388 /* Output of Assembler Instructions */
390 #define REGISTER_NAMES \
392 "a1", "a2", "a3", "a4", \
393 "v1", "v2", "v3", "v4", \
394 "v5", "v6", "sl", "fp", \
395 "ip", "sp", "lr", "pc", \
396 "f0", "f1", "f2", "f3", \
397 "f4", "f5", "f6", "f7", \
398 "cc", "sfp", "afp" \
401 #define ADDITIONAL_REGISTER_NAMES \
403 {"r0", 0}, {"a1", 0}, \
404 {"r1", 1}, {"a2", 1}, \
405 {"r2", 2}, {"a3", 2}, \
406 {"r3", 3}, {"a4", 3}, \
407 {"r4", 4}, {"v1", 4}, \
408 {"r5", 5}, {"v2", 5}, \
409 {"r6", 6}, {"v3", 6}, \
410 {"r7", 7}, {"wr", 7}, \
411 {"r8", 8}, {"v5", 8}, \
412 {"r9", 9}, {"v6", 9}, \
413 {"r10", 10}, {"sl", 10}, {"v7", 10}, \
414 {"r11", 11}, {"fp", 11}, \
415 {"r12", 12}, {"ip", 12}, \
416 {"r13", 13}, {"sp", 13}, \
417 {"r14", 14}, {"lr", 14}, \
418 {"r15", 15}, {"pc", 15} \
421 #define REGISTER_PREFIX "__"
422 #define USER_LABEL_PREFIX ""
423 #define LOCAL_LABEL_PREFIX ""
425 /* AOF does not prefix user function names with an underscore. */
426 #define ARM_MCOUNT_NAME "_mcount"
428 /* Output of Dispatch Tables */
430 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL) \
431 fprintf ((STREAM), "\tb\t|L..%d|\n", (VALUE))
433 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
434 fprintf ((STREAM), "\tDCD\t|L..%d|\n", (VALUE))
436 /* A label marking the start of a jump table is a data label. */
437 #define ASM_OUTPUT_CASE_LABEL(STREAM,PREFIX,NUM,TABLE) \
438 fprintf ((STREAM), "\tALIGN\n|%s..%d|\n", (PREFIX), (NUM))
440 /* Assembler Commands for Alignment */
442 #define ASM_OUTPUT_SKIP(STREAM,NBYTES) \
443 fprintf ((STREAM), "\t%%\t%d\n", (NBYTES))
445 #define ASM_OUTPUT_ALIGN(STREAM,POWER) \
446 do { \
447 register int amount = 1 << (POWER); \
448 if (amount == 2) \
449 fprintf ((STREAM), "\tALIGN 2\n"); \
450 else if (amount == 4) \
451 fprintf ((STREAM), "\tALIGN\n"); \
452 else \
453 fprintf ((STREAM), "\tALIGN %d\n", amount); \
454 } while (0)
456 #include "arm/arm.h"
458 #undef DBX_DEBUGGING_INFO