* target.h (asm_out.byte_op, asm_out.aligned_op, asm_out.unaligned_op,
[official-gcc.git] / gcc / config / arm / aof.h
blob01826b8172713c950a9acb3327158f83dd48cd81
1 /* Definitions of target machine for GNU compiler, for Advanced RISC Machines
2 ARM compilation, AOF Assembler.
3 Copyright (C) 1995, 1996, 1997, 2000 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 #define TEXT_SECTION_ASM_OP aof_text_section ()
57 #define SELECT_RTX_SECTION(MODE,RTX,ALIGN) text_section ();
59 #define DATA_SECTION_ASM_OP aof_data_section ()
61 #define EXTRA_SECTIONS in_zero_init, in_common
63 #define EXTRA_SECTION_FUNCTIONS \
64 ZERO_INIT_SECTION \
65 COMMON_SECTION
67 #define ZERO_INIT_SECTION \
68 void \
69 zero_init_section () \
70 { \
71 static int zero_init_count = 1; \
72 if (in_section != in_zero_init) \
73 { \
74 fprintf (asm_out_file, "\tAREA |C$$zidata%d|,NOINIT\n", \
75 zero_init_count++); \
76 in_section = in_zero_init; \
77 } \
80 /* Used by ASM_OUTPUT_COMMON (below) to tell varasm.c that we've
81 changed areas. */
82 #define COMMON_SECTION \
83 void \
84 common_section () \
85 { \
86 if (in_section != in_common) \
87 { \
88 in_section = in_common; \
89 } \
91 #define CTOR_LIST_BEGIN \
92 asm (CTORS_SECTION_ASM_OP); \
93 extern func_ptr __CTOR_END__[1]; \
94 func_ptr __CTOR_LIST__[1] = {__CTOR_END__};
96 #define CTOR_LIST_END \
97 asm (CTORS_SECTION_ASM_OP); \
98 func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
100 #define DO_GLOBAL_CTORS_BODY \
101 do { \
102 func_ptr *ptr = __CTOR_LIST__ + 1; \
103 while (*ptr) \
104 (*ptr++) (); \
105 } while (0)
107 #define DTOR_LIST_BEGIN \
108 asm (DTORS_SECTION_ASM_OP); \
109 extern func_ptr __DTOR_END__[1]; \
110 func_ptr __DTOR_LIST__[1] = {__DTOR_END__};
112 #define DTOR_LIST_END \
113 asm (DTORS_SECTION_ASM_OP); \
114 func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
116 #define DO_GLOBAL_DTORS_BODY \
117 do { \
118 func_ptr *ptr = __DTOR_LIST__ + 1; \
119 while (*ptr) \
120 (*ptr++) (); \
121 } while (0)
123 #define JUMP_TABLES_IN_TEXT_SECTION 1
125 #ifndef ARM_OS_NAME
126 #define ARM_OS_NAME "(generic)"
127 #endif
129 /* For the AOF linker, we need to reference __main to force the standard
130 library to get linked in. */
132 #define ASM_FILE_START(STREAM) \
134 fprintf ((STREAM), "%s Generated by gcc %s for ARM/%s\n", \
135 ASM_COMMENT_START, version_string, ARM_OS_NAME); \
136 fprintf ((STREAM), "__r0\tRN\t0\n"); \
137 fprintf ((STREAM), "__a1\tRN\t0\n"); \
138 fprintf ((STREAM), "__a2\tRN\t1\n"); \
139 fprintf ((STREAM), "__a3\tRN\t2\n"); \
140 fprintf ((STREAM), "__a4\tRN\t3\n"); \
141 fprintf ((STREAM), "__v1\tRN\t4\n"); \
142 fprintf ((STREAM), "__v2\tRN\t5\n"); \
143 fprintf ((STREAM), "__v3\tRN\t6\n"); \
144 fprintf ((STREAM), "__v4\tRN\t7\n"); \
145 fprintf ((STREAM), "__v5\tRN\t8\n"); \
146 fprintf ((STREAM), "__v6\tRN\t9\n"); \
147 fprintf ((STREAM), "__sl\tRN\t10\n"); \
148 fprintf ((STREAM), "__fp\tRN\t11\n"); \
149 fprintf ((STREAM), "__ip\tRN\t12\n"); \
150 fprintf ((STREAM), "__sp\tRN\t13\n"); \
151 fprintf ((STREAM), "__lr\tRN\t14\n"); \
152 fprintf ((STREAM), "__pc\tRN\t15\n"); \
153 fprintf ((STREAM), "__f0\tFN\t0\n"); \
154 fprintf ((STREAM), "__f1\tFN\t1\n"); \
155 fprintf ((STREAM), "__f2\tFN\t2\n"); \
156 fprintf ((STREAM), "__f3\tFN\t3\n"); \
157 fprintf ((STREAM), "__f4\tFN\t4\n"); \
158 fprintf ((STREAM), "__f5\tFN\t5\n"); \
159 fprintf ((STREAM), "__f6\tFN\t6\n"); \
160 fprintf ((STREAM), "__f7\tFN\t7\n"); \
161 text_section (); \
164 /* Some systems use __main in a way incompatible with its use in gcc, in these
165 cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
166 give the same symbol without quotes for an alternative entry point. You
167 must define both, or neither. */
168 #define NAME__MAIN "__gccmain"
169 #define SYMBOL__MAIN __gccmain
171 #define ASM_FILE_END(STREAM) \
172 do \
174 if (flag_pic) \
175 aof_dump_pic_table (STREAM); \
176 aof_dump_imports (STREAM); \
177 fputs ("\tEND\n", (STREAM)); \
178 } while (0);
180 #define ASM_COMMENT_START ";"
182 #define ASM_APP_ON ""
184 #define ASM_APP_OFF ""
186 #define ASM_OUTPUT_LONG_DOUBLE(STREAM,VALUE) \
187 ASM_OUTPUT_DOUBLE((STREAM),(VALUE))
189 #define ASM_OUTPUT_DOUBLE(STREAM,VALUE) \
190 do { \
191 char dstr[30]; \
192 long l[2]; \
193 REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), l); \
194 REAL_VALUE_TO_DECIMAL ((VALUE), "%.14g", dstr); \
195 fprintf ((STREAM), "\tDCD &%lx, &%lx\t%s double %s\n", \
196 l[0], l[1], ASM_COMMENT_START, dstr); \
197 } while (0)
199 #define ASM_OUTPUT_FLOAT(STREAM,VALUE) \
200 do { \
201 char dstr[30]; \
202 long l; \
203 REAL_VALUE_TO_TARGET_SINGLE ((VALUE), l); \
204 REAL_VALUE_TO_DECIMAL ((VALUE), "%.7g", dstr); \
205 fprintf ((STREAM), "\tDCD &%lx\t%s double %s\n", \
206 l, ASM_COMMENT_START, dstr); \
207 } while (0)
209 #define ASM_OUTPUT_ASCII(STREAM,PTR,LEN) \
211 int i; \
212 const char *ptr = (PTR); \
213 fprintf ((STREAM), "\tDCB"); \
214 for (i = 0; i < (long)(LEN); i++) \
215 fprintf ((STREAM), " &%02x%s", \
216 (unsigned ) *(ptr++), \
217 (i + 1 < (long)(LEN) \
218 ? ((i & 3) == 3 ? "\n\tDCB" : ",") \
219 : "\n")); \
222 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == '\n')
224 /* Output of Uninitialized Variables */
226 #define ASM_OUTPUT_COMMON(STREAM,NAME,SIZE,ROUNDED) \
227 (common_section (), \
228 fprintf ((STREAM), "\tAREA "), \
229 assemble_name ((STREAM), (NAME)), \
230 fprintf ((STREAM), ", DATA, COMMON\n\t%% %d\t%s size=%d\n", \
231 (ROUNDED), ASM_COMMENT_START, SIZE))
233 #define ASM_OUTPUT_LOCAL(STREAM,NAME,SIZE,ROUNDED) \
234 (zero_init_section (), \
235 assemble_name ((STREAM), (NAME)), \
236 fprintf ((STREAM), "\n"), \
237 fprintf ((STREAM), "\t%% %d\t%s size=%d\n", \
238 (ROUNDED), ASM_COMMENT_START, SIZE))
240 /* Output and Generation of Labels */
242 extern int arm_main_function;
244 #define ASM_GLOBALIZE_LABEL(STREAM,NAME) \
245 do { \
246 fprintf ((STREAM), "\tEXPORT\t"); \
247 assemble_name ((STREAM), (NAME)); \
248 fputc ('\n', (STREAM)); \
249 if ((NAME)[0] == 'm' && ! strcmp ((NAME), "main")) \
250 arm_main_function = 1; \
251 } while (0)
253 #define ASM_OUTPUT_LABEL(STREAM,NAME) \
254 do { \
255 assemble_name (STREAM,NAME); \
256 fputs ("\n", STREAM); \
257 } while (0)
259 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
261 if (TARGET_POKE_FUNCTION_NAME) \
262 arm_poke_function_name ((STREAM), (NAME)); \
263 ASM_OUTPUT_LABEL (STREAM, NAME); \
264 if (! TREE_PUBLIC (DECL)) \
266 fputs ("\tKEEP ", STREAM); \
267 ASM_OUTPUT_LABEL (STREAM, NAME); \
269 aof_delete_import ((NAME)); \
272 #define ASM_DECLARE_OBJECT_NAME(STREAM,NAME,DECL) \
274 ASM_OUTPUT_LABEL (STREAM, NAME); \
275 if (! TREE_PUBLIC (DECL)) \
277 fputs ("\tKEEP ", STREAM); \
278 ASM_OUTPUT_LABEL (STREAM, NAME); \
280 aof_delete_import ((NAME)); \
283 #define ASM_OUTPUT_EXTERNAL(STREAM,DECL,NAME) \
284 aof_add_import ((NAME))
286 #define ASM_OUTPUT_EXTERNAL_LIBCALL(STREAM,SYMREF) \
287 (fprintf ((STREAM), "\tIMPORT\t"), \
288 assemble_name ((STREAM), XSTR ((SYMREF), 0)), \
289 fputc ('\n', (STREAM)))
291 #define ASM_OUTPUT_LABELREF(STREAM,NAME) \
292 fprintf ((STREAM), "|%s|", NAME)
294 #define ASM_GENERATE_INTERNAL_LABEL(STRING,PREFIX,NUM) \
295 sprintf ((STRING), "*|%s..%ld|", (PREFIX), (long)(NUM))
297 #define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER) \
298 ((OUTVAR) = (char *) alloca (strlen ((NAME)) + 10), \
299 sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)))
301 /* How initialization functions are handled */
303 #define CTORS_SECTION_ASM_OP "\tAREA\t|C$$gnu_ctorsvec|, DATA, READONLY"
304 #define DTORS_SECTION_ASM_OP "\tAREA\t|C$$gnu_dtorsvec|, DATA, READONLY"
306 /* Output of Assembler Instructions */
308 #define REGISTER_NAMES \
310 "a1", "a2", "a3", "a4", \
311 "v1", "v2", "v3", "v4", \
312 "v5", "v6", "sl", "fp", \
313 "ip", "sp", "lr", "pc", \
314 "f0", "f1", "f2", "f3", \
315 "f4", "f5", "f6", "f7", \
316 "cc", "sfp", "afp" \
319 #define ADDITIONAL_REGISTER_NAMES \
321 {"r0", 0}, {"a1", 0}, \
322 {"r1", 1}, {"a2", 1}, \
323 {"r2", 2}, {"a3", 2}, \
324 {"r3", 3}, {"a4", 3}, \
325 {"r4", 4}, {"v1", 4}, \
326 {"r5", 5}, {"v2", 5}, \
327 {"r6", 6}, {"v3", 6}, \
328 {"r7", 7}, {"wr", 7}, \
329 {"r8", 8}, {"v5", 8}, \
330 {"r9", 9}, {"v6", 9}, \
331 {"r10", 10}, {"sl", 10}, {"v7", 10}, \
332 {"r11", 11}, {"fp", 11}, \
333 {"r12", 12}, {"ip", 12}, \
334 {"r13", 13}, {"sp", 13}, \
335 {"r14", 14}, {"lr", 14}, \
336 {"r15", 15}, {"pc", 15} \
339 #define REGISTER_PREFIX "__"
340 #define USER_LABEL_PREFIX ""
341 #define LOCAL_LABEL_PREFIX ""
343 /* AOF does not prefix user function names with an underscore. */
344 #define ARM_MCOUNT_NAME "_mcount"
346 /* Output of Dispatch Tables */
348 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL) \
349 fprintf ((STREAM), "\tb\t|L..%d|\n", (VALUE))
351 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
352 fprintf ((STREAM), "\tDCD\t|L..%d|\n", (VALUE))
354 /* A label marking the start of a jump table is a data label. */
355 #define ASM_OUTPUT_CASE_LABEL(STREAM,PREFIX,NUM,TABLE) \
356 fprintf ((STREAM), "\tALIGN\n|%s..%d|\n", (PREFIX), (NUM))
358 /* Assembler Commands for Alignment */
360 #define ASM_OUTPUT_SKIP(STREAM,NBYTES) \
361 fprintf ((STREAM), "\t%%\t%d\n", (NBYTES))
363 #define ASM_OUTPUT_ALIGN(STREAM,POWER) \
364 do { \
365 register int amount = 1 << (POWER); \
366 if (amount == 2) \
367 fprintf ((STREAM), "\tALIGN 2\n"); \
368 else if (amount == 4) \
369 fprintf ((STREAM), "\tALIGN\n"); \
370 else \
371 fprintf ((STREAM), "\tALIGN %d\n", amount); \
372 } while (0)
374 #undef DBX_DEBUGGING_INFO