OSDN Git Service

* configure.in: Check whether assembler supports section merging.
[pf3gnuchains/gcc-fork.git] / gcc / config / arm / aof.h
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)
5
6 This file is part of GNU CC.
7
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.
12
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.
17
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.  */
22    
23 \f
24
25 #define AOF_ASSEMBLER
26
27 #define LINK_LIBGCC_SPECIAL 1
28
29 #define LINK_SPEC "%{aof} %{bin} %{aif} %{ihf} %{shl,*} %{reent*} %{split} \
30                    %{ov*,*} %{reloc*} -nodebug"
31
32 #define STARTFILE_SPEC "crtbegin.o%s"
33
34 #define ENDFILE_SPEC "crtend.o%s"
35
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
40
41 #ifndef LIB_SPEC
42 #define LIB_SPEC "%{Eb: armlib_h.32b%s}%{!Eb: armlib_h.32l%s}"
43 #endif
44
45 #define LIBGCC_SPEC "libgcc.a%s"
46
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 ()
57
58 #define SELECT_RTX_SECTION(MODE,RTX,ALIGN) text_section ();
59
60 char *aof_data_section ();
61 #define DATA_SECTION_ASM_OP aof_data_section ()
62
63 #define EXTRA_SECTIONS in_zero_init, in_common
64
65 #define EXTRA_SECTION_FUNCTIONS \
66 ZERO_INIT_SECTION               \
67 COMMON_SECTION
68
69 #define ZERO_INIT_SECTION                                       \
70 void                                                            \
71 zero_init_section ()                                            \
72 {                                                               \
73   static int zero_init_count = 1;                               \
74   if (in_section != in_zero_init)                               \
75     {                                                           \
76       fprintf (asm_out_file, "\tAREA |C$$zidata%d|,NOINIT\n",   \
77                zero_init_count++);                              \
78       in_section = in_zero_init;                                \
79     }                                                           \
80 }
81
82 /* Used by ASM_OUTPUT_COMMON (below) to tell varasm.c that we've
83    changed areas.  */
84 #define COMMON_SECTION                                          \
85 void                                                            \
86 common_section ()                                               \
87 {                                                               \
88   static int common_count = 1;                                  \
89   if (in_section != in_common)                                  \
90     {                                                           \
91       in_section = in_common;                                   \
92     }                                                           \
93 }
94 #define CTOR_LIST_BEGIN                                 \
95 asm (CTORS_SECTION_ASM_OP);                             \
96 extern func_ptr __CTOR_END__[1];                        \
97 func_ptr __CTOR_LIST__[1] = {__CTOR_END__};
98
99 #define CTOR_LIST_END                                   \
100 asm (CTORS_SECTION_ASM_OP);                             \
101 func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
102
103 #define DO_GLOBAL_CTORS_BODY            \
104 do {                                    \
105   func_ptr *ptr = __CTOR_LIST__ + 1;    \
106   while (*ptr)                          \
107     (*ptr++) ();                        \
108 } while (0)
109
110 #define DTOR_LIST_BEGIN                                 \
111 asm (DTORS_SECTION_ASM_OP);                             \
112 extern func_ptr __DTOR_END__[1];                        \
113 func_ptr __DTOR_LIST__[1] = {__DTOR_END__};
114
115 #define DTOR_LIST_END                                   \
116 asm (DTORS_SECTION_ASM_OP);                             \
117 func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
118
119 #define DO_GLOBAL_DTORS_BODY            \
120 do {                                    \
121   func_ptr *ptr = __DTOR_LIST__ + 1;    \
122   while (*ptr)                          \
123     (*ptr++) ();                        \
124 } while (0)
125
126 #define JUMP_TABLES_IN_TEXT_SECTION 1
127
128 #ifndef ARM_OS_NAME
129 #define ARM_OS_NAME "(generic)"
130 #endif
131
132 /* For the AOF linker, we need to reference __main to force the standard
133    library to get linked in. */
134
135 #define ASM_FILE_START(STREAM)                                  \
136 {                                                               \
137   fprintf ((STREAM), "%s Generated by gcc %s for ARM/%s\n",     \
138            ASM_COMMENT_START, version_string, ARM_OS_NAME);     \
139   fprintf ((STREAM), "__r0\tRN\t0\n");                          \
140   fprintf ((STREAM), "__a1\tRN\t0\n");                          \
141   fprintf ((STREAM), "__a2\tRN\t1\n");                          \
142   fprintf ((STREAM), "__a3\tRN\t2\n");                          \
143   fprintf ((STREAM), "__a4\tRN\t3\n");                          \
144   fprintf ((STREAM), "__v1\tRN\t4\n");                          \
145   fprintf ((STREAM), "__v2\tRN\t5\n");                          \
146   fprintf ((STREAM), "__v3\tRN\t6\n");                          \
147   fprintf ((STREAM), "__v4\tRN\t7\n");                          \
148   fprintf ((STREAM), "__v5\tRN\t8\n");                          \
149   fprintf ((STREAM), "__v6\tRN\t9\n");                          \
150   fprintf ((STREAM), "__sl\tRN\t10\n");                         \
151   fprintf ((STREAM), "__fp\tRN\t11\n");                         \
152   fprintf ((STREAM), "__ip\tRN\t12\n");                         \
153   fprintf ((STREAM), "__sp\tRN\t13\n");                         \
154   fprintf ((STREAM), "__lr\tRN\t14\n");                         \
155   fprintf ((STREAM), "__pc\tRN\t15\n");                         \
156   fprintf ((STREAM), "__f0\tFN\t0\n");                          \
157   fprintf ((STREAM), "__f1\tFN\t1\n");                          \
158   fprintf ((STREAM), "__f2\tFN\t2\n");                          \
159   fprintf ((STREAM), "__f3\tFN\t3\n");                          \
160   fprintf ((STREAM), "__f4\tFN\t4\n");                          \
161   fprintf ((STREAM), "__f5\tFN\t5\n");                          \
162   fprintf ((STREAM), "__f6\tFN\t6\n");                          \
163   fprintf ((STREAM), "__f7\tFN\t7\n");                          \
164   text_section ();                                              \
165 }
166
167 /* Some systems use __main in a way incompatible with its use in gcc, in these
168    cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
169    give the same symbol without quotes for an alternative entry point.  You
170    must define both, or neither. */
171 #define NAME__MAIN "__gccmain"
172 #define SYMBOL__MAIN __gccmain
173
174 #define ASM_FILE_END(STREAM)            \
175 do                                      \
176 {                                       \
177   if (flag_pic)                         \
178     aof_dump_pic_table (STREAM);        \
179   aof_dump_imports (STREAM);            \
180   fputs ("\tEND\n", (STREAM));          \
181 } while (0);
182
183 #define ASM_COMMENT_START ";"
184
185 #define ASM_APP_ON ""
186
187 #define ASM_APP_OFF ""
188
189 #define ASM_OUTPUT_LONG_DOUBLE(STREAM,VALUE) \
190   ASM_OUTPUT_DOUBLE((STREAM),(VALUE))
191
192 #define ASM_OUTPUT_DOUBLE(STREAM,VALUE)                         \
193 do {                                                            \
194   char dstr[30];                                                \
195   long l[2];                                                    \
196   REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), l);                     \
197   REAL_VALUE_TO_DECIMAL ((VALUE), "%.14g", dstr);               \
198   fprintf ((STREAM), "\tDCD &%lx, &%lx\t%s double %s\n",        \
199            l[0], l[1], ASM_COMMENT_START, dstr);                \
200 } while (0)
201
202 #define ASM_OUTPUT_FLOAT(STREAM,VALUE)                  \
203 do {                                                    \
204   char dstr[30];                                        \
205   long l;                                               \
206   REAL_VALUE_TO_TARGET_SINGLE ((VALUE), l);             \
207   REAL_VALUE_TO_DECIMAL ((VALUE), "%.7g", dstr);        \
208   fprintf ((STREAM), "\tDCD &%lx\t%s double %s\n",      \
209            l, ASM_COMMENT_START, dstr);                 \
210 } while (0)
211
212 #define ASM_OUTPUT_INT(STREAM,VALUE)            \
213   (fprintf ((STREAM), "\tDCD\t"),               \
214    output_addr_const ((STREAM), (VALUE)),       \
215    fputc ('\n', (STREAM)))
216
217 #define ASM_OUTPUT_SHORT(STREAM,VALUE)          \
218   (fprintf ((STREAM), "\tDCW\t"),               \
219    output_addr_const ((STREAM), (VALUE)),       \
220    fputc ('\n', (STREAM)))
221
222 #define ASM_OUTPUT_CHAR(STREAM,VALUE)           \
223   (fprintf ((STREAM), "\tDCB\t"),               \
224    output_addr_const ((STREAM), (VALUE)),       \
225    fputc ('\n', (STREAM)))
226
227 #define ASM_OUTPUT_BYTE(STREAM,VALUE)           \
228   fprintf ((STREAM), "\tDCB\t%d\n", (VALUE))
229
230 #define ASM_OUTPUT_ASCII(STREAM,PTR,LEN)                \
231 {                                                       \
232   int i;                                                \
233   const char *ptr = (PTR);                              \
234   fprintf ((STREAM), "\tDCB");                          \
235   for (i = 0; i < (LEN); i++)                           \
236     fprintf ((STREAM), " &%02x%s",                      \
237              (unsigned ) *(ptr++),                      \
238              (i + 1 < (LEN)                             \
239               ? ((i & 3) == 3 ? "\n\tDCB" : ",")        \
240               : "\n"));                                 \
241 }
242
243 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == '\n')
244
245 /* Output of Uninitialized Variables */
246
247 #define ASM_OUTPUT_COMMON(STREAM,NAME,SIZE,ROUNDED)             \
248   (common_section (),                                           \
249    fprintf ((STREAM), "\tAREA "),                               \
250    assemble_name ((STREAM), (NAME)),                            \
251    fprintf ((STREAM), ", DATA, COMMON\n\t%% %d\t%s size=%d\n",  \
252             (ROUNDED), ASM_COMMENT_START, SIZE))
253
254 #define ASM_OUTPUT_LOCAL(STREAM,NAME,SIZE,ROUNDED)      \
255    (zero_init_section (),                               \
256     assemble_name ((STREAM), (NAME)),                   \
257     fprintf ((STREAM), "\n"),                           \
258     fprintf ((STREAM), "\t%% %d\t%s size=%d\n",         \
259              (ROUNDED), ASM_COMMENT_START, SIZE))
260
261 /* Output and Generation of Labels */
262
263 extern int arm_main_function;
264
265 #define ASM_GLOBALIZE_LABEL(STREAM,NAME)                \
266 do {                                                    \
267   fprintf ((STREAM), "\tEXPORT\t");                     \
268   assemble_name ((STREAM), (NAME));                     \
269   fputc ('\n', (STREAM));                               \
270   if ((NAME)[0] == 'm' && ! strcmp ((NAME), "main"))    \
271     arm_main_function = 1;                              \
272 } while (0)
273
274 #define ASM_OUTPUT_LABEL(STREAM,NAME)   \
275 do {                                    \
276   assemble_name (STREAM,NAME);          \
277   fputs ("\n", STREAM);                 \
278 } while (0)
279
280 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
281 {                                               \
282   if (TARGET_POKE_FUNCTION_NAME)                \
283     arm_poke_function_name ((STREAM), (NAME));  \
284   ASM_OUTPUT_LABEL (STREAM, NAME);              \
285   if (! TREE_PUBLIC (DECL))                     \
286     {                                           \
287       fputs ("\tKEEP ", STREAM);                \
288       ASM_OUTPUT_LABEL (STREAM, NAME);          \
289     }                                           \
290   aof_delete_import ((NAME));                   \
291 }
292
293 #define ASM_DECLARE_OBJECT_NAME(STREAM,NAME,DECL) \
294 {                                               \
295   ASM_OUTPUT_LABEL (STREAM, NAME);              \
296   if (! TREE_PUBLIC (DECL))                     \
297     {                                           \
298       fputs ("\tKEEP ", STREAM);                \
299       ASM_OUTPUT_LABEL (STREAM, NAME);          \
300     }                                           \
301   aof_delete_import ((NAME));                   \
302 }
303
304 #define ASM_OUTPUT_EXTERNAL(STREAM,DECL,NAME)   \
305  aof_add_import ((NAME))
306
307 #define ASM_OUTPUT_EXTERNAL_LIBCALL(STREAM,SYMREF)      \
308  (fprintf ((STREAM), "\tIMPORT\t"),                     \
309   assemble_name ((STREAM), XSTR ((SYMREF), 0)),         \
310   fputc ('\n', (STREAM)))
311
312 #define ASM_OUTPUT_LABELREF(STREAM,NAME)        \
313   fprintf ((STREAM), "|%s|", NAME)
314
315 #define ASM_GENERATE_INTERNAL_LABEL(STRING,PREFIX,NUM)  \
316   sprintf ((STRING), "*|%s..%d|", (PREFIX), (NUM))
317
318 #define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER)     \
319  ((OUTVAR) = (char *) alloca (strlen ((NAME)) + 10),    \
320   sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)))
321
322 /* How initialization functions are handled */
323
324 #define CTORS_SECTION_ASM_OP "\tAREA\t|C$$gnu_ctorsvec|, DATA, READONLY"
325 #define DTORS_SECTION_ASM_OP "\tAREA\t|C$$gnu_dtorsvec|, DATA, READONLY"
326
327 /* Output of Assembler Instructions */
328
329 #define REGISTER_NAMES                  \
330 {                                       \
331   "a1", "a2", "a3", "a4",       \
332   "v1", "v2", "v3", "v4",       \
333   "v5", "v6", "sl", "fp",       \
334   "ip", "sp", "lr", "pc",       \
335   "f0", "f1", "f2", "f3",       \
336   "f4", "f5", "f6", "f7",       \
337   "cc", "sfp", "afp"            \
338 }
339
340 #define ADDITIONAL_REGISTER_NAMES               \
341 {                                               \
342   {"r0", 0}, {"a1", 0},                         \
343   {"r1", 1}, {"a2", 1},                         \
344   {"r2", 2}, {"a3", 2},                         \
345   {"r3", 3}, {"a4", 3},                         \
346   {"r4", 4}, {"v1", 4},                         \
347   {"r5", 5}, {"v2", 5},                         \
348   {"r6", 6}, {"v3", 6},                         \
349   {"r7", 7}, {"wr", 7},                         \
350   {"r8", 8}, {"v5", 8},                         \
351   {"r9", 9}, {"v6", 9},                         \
352   {"r10", 10}, {"sl", 10}, {"v7", 10},          \
353   {"r11", 11}, {"fp", 11},                      \
354   {"r12", 12}, {"ip", 12},                      \
355   {"r13", 13}, {"sp", 13},                      \
356   {"r14", 14}, {"lr", 14},                      \
357   {"r15", 15}, {"pc", 15}                       \
358 }
359
360 #define REGISTER_PREFIX "__"
361 #define USER_LABEL_PREFIX ""
362 #define LOCAL_LABEL_PREFIX ""
363
364 /* AOF does not prefix user function names with an underscore.  */
365 #define ARM_MCOUNT_NAME "_mcount"
366
367 /* Output of Dispatch Tables */
368
369 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL)         \
370   fprintf ((STREAM), "\tb\t|L..%d|\n", (VALUE))
371
372 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE)   \
373   fprintf ((STREAM), "\tDCD\t|L..%d|\n", (VALUE))
374
375 /* A label marking the start of a jump table is a data label. */
376 #define ASM_OUTPUT_CASE_LABEL(STREAM,PREFIX,NUM,TABLE)  \
377   fprintf ((STREAM), "\tALIGN\n|%s..%d|\n", (PREFIX), (NUM))
378
379 /* Assembler Commands for Alignment */
380
381 #define ASM_OUTPUT_SKIP(STREAM,NBYTES)          \
382  fprintf ((STREAM), "\t%%\t%d\n", (NBYTES))
383
384 #define ASM_OUTPUT_ALIGN(STREAM,POWER)                  \
385 do {                                                    \
386   register int amount = 1 << (POWER);                   \
387   if (amount == 2)                                      \
388     fprintf ((STREAM), "\tALIGN 2\n");                  \
389   else if (amount == 4)                                 \
390     fprintf ((STREAM), "\tALIGN\n");                    \
391   else                                                  \
392     fprintf ((STREAM), "\tALIGN %d\n", amount);         \
393 } while (0)
394
395 #include "arm/arm.h"
396
397 #undef DBX_DEBUGGING_INFO