OSDN Git Service

More MIPS vector cleanup work.
[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, 2003, 2004
4    Free Software Foundation, Inc.
5    Contributed by Richard Earnshaw (rearnsha@armltd.co.uk)
6
7    This file is part of GCC.
8
9    GCC is free software; you can redistribute it and/or modify it
10    under the terms of the GNU General Public License as published
11    by the Free Software Foundation; either version 2, or (at your
12    option) any later version.
13
14    GCC is distributed in the hope that it will be useful, but WITHOUT
15    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
17    License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with GCC; see the file COPYING.  If not, write to
21    the Free Software Foundation, 59 Temple Place - Suite 330,
22    Boston, MA 02111-1307, USA.  */
23    
24 \f
25
26 #define AOF_ASSEMBLER
27
28 #define LINK_LIBGCC_SPECIAL 1
29
30 #define LINK_SPEC "%{aof} %{bin} %{aif} %{ihf} %{shl,*} %{reent*} %{split} \
31                    %{ov*} %{reloc*} -nodebug"
32
33 #define STARTFILE_SPEC "crtbegin.o%s"
34
35 #define ENDFILE_SPEC "crtend.o%s"
36
37 #ifndef ASM_SPEC
38 #define ASM_SPEC "%{g -g} -arch 4 -apcs 3/32bit"
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 #define TEXT_SECTION_ASM_OP aof_text_section ()
56
57 #define DATA_SECTION_ASM_OP aof_data_section ()
58
59 #define EXTRA_SECTIONS in_zero_init, in_common
60
61 #define EXTRA_SECTION_FUNCTIONS \
62   ZERO_INIT_SECTION             \
63   COMMON_SECTION
64
65 #define ZERO_INIT_SECTION                                       \
66   void                                                          \
67   zero_init_section ()                                          \
68   {                                                             \
69     static int zero_init_count = 1;                             \
70                                                                 \
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       }                                                         \
77   }
78
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;                                   \
87   }
88
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__};
93
94 #define CTOR_LIST_END                           \
95   asm (CTORS_SECTION_ASM_OP);                   \
96   func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
97
98 #define DO_GLOBAL_CTORS_BODY                    \
99   do                                            \
100     {                                           \
101       func_ptr *ptr = __CTOR_LIST__ + 1;        \
102                                                 \
103       while (*ptr)                              \
104         (*ptr++) ();                            \
105     }                                           \
106   while (0)
107
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__};
112
113 #define DTOR_LIST_END                           \
114   asm (DTORS_SECTION_ASM_OP);                   \
115   func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
116
117 #define DO_GLOBAL_DTORS_BODY                    \
118   do                                            \
119     {                                           \
120       func_ptr *ptr = __DTOR_LIST__ + 1;        \
121                                                 \
122       while (*ptr)                              \
123         (*ptr++) ();                            \
124     }                                           \
125   while (0)
126
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
132
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
139
140 #define ASM_COMMENT_START ";"
141 #define ASM_APP_ON        ""
142 #define ASM_APP_OFF       ""
143
144 #define ASM_OUTPUT_ASCII(STREAM, PTR, LEN)              \
145 {                                                       \
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"));                                 \
155 }
156
157 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == '\n')
158
159 /* Output of Uninitialized Variables.  */
160
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)))
167
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)))
174
175 /* Output and Generation of Labels */
176 extern int arm_main_function;
177
178 /* Globalizing directive for a label.  */
179 #define GLOBAL_ASM_OP "\tEXPORT\t"
180
181 #define ASM_OUTPUT_LABEL(STREAM,NAME)   \
182 do {                                    \
183   assemble_name (STREAM,NAME);          \
184   fputs ("\n", STREAM);                 \
185 } while (0)
186
187 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
188 {                                               \
189   if (TARGET_POKE_FUNCTION_NAME)                \
190     arm_poke_function_name ((STREAM), (NAME));  \
191   ASM_OUTPUT_LABEL (STREAM, NAME);              \
192   if (! TREE_PUBLIC (DECL))                     \
193     {                                           \
194       fputs ("\tKEEP ", STREAM);                \
195       ASM_OUTPUT_LABEL (STREAM, NAME);          \
196     }                                           \
197   aof_delete_import ((NAME));                   \
198 }
199
200 #define ASM_DECLARE_OBJECT_NAME(STREAM,NAME,DECL) \
201 {                                               \
202   ASM_OUTPUT_LABEL (STREAM, NAME);              \
203   if (! TREE_PUBLIC (DECL))                     \
204     {                                           \
205       fputs ("\tKEEP ", STREAM);                \
206       ASM_OUTPUT_LABEL (STREAM, NAME);          \
207     }                                           \
208   aof_delete_import ((NAME));                   \
209 }
210
211 #define ASM_OUTPUT_EXTERNAL(STREAM,DECL,NAME)   \
212  aof_add_import ((NAME))
213
214 #define ASM_OUTPUT_EXTERNAL_LIBCALL(STREAM,SYMREF)      \
215  (fprintf ((STREAM), "\tIMPORT\t"),                     \
216   assemble_name ((STREAM), XSTR ((SYMREF), 0)),         \
217   fputc ('\n', (STREAM)))
218
219 #define ASM_OUTPUT_LABELREF(STREAM,NAME)        \
220   fprintf ((STREAM), "|%s|", NAME)
221
222 #define ASM_GENERATE_INTERNAL_LABEL(STRING,PREFIX,NUM)  \
223   sprintf ((STRING), "*|%s..%ld|", (PREFIX), (long)(NUM))
224
225 /* How initialization functions are handled.  */
226
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"
229
230 /* Output of Assembler Instructions.  */
231
232 #define REGISTER_NAMES                          \
233 {                                               \
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",            \
250   "s0",  "s1",  "s2",  "s3",  "s4",  "s5",  "s6",  "s7",  \
251   "s8",  "s9",  "s10", "s11", "s12", "s13", "s14", "s15", \
252   "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \
253   "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",  \
254   "vfpcc"
255 }
256
257 #define ADDITIONAL_REGISTER_NAMES               \
258 {                                               \
259   {"r0", 0}, {"a1", 0},                         \
260   {"r1", 1}, {"a2", 1},                         \
261   {"r2", 2}, {"a3", 2},                         \
262   {"r3", 3}, {"a4", 3},                         \
263   {"r4", 4}, {"v1", 4},                         \
264   {"r5", 5}, {"v2", 5},                         \
265   {"r6", 6}, {"v3", 6},                         \
266   {"r7", 7}, {"wr", 7},                         \
267   {"r8", 8}, {"v5", 8},                         \
268   {"r9", 9}, {"v6", 9},                         \
269   {"r10", 10}, {"sl", 10}, {"v7", 10},          \
270   {"r11", 11}, {"fp", 11},                      \
271   {"r12", 12}, {"ip", 12},                      \
272   {"r13", 13}, {"sp", 13},                      \
273   {"r14", 14}, {"lr", 14},                      \
274   {"r15", 15}, {"pc", 15}                       \
275   {"d0", 63},                                   \
276   {"d1", 65},                                   \
277   {"d2", 67},                                   \
278   {"d3", 69},                                   \
279   {"d4", 71},                                   \
280   {"d5", 73},                                   \
281   {"d6", 75},                                   \
282   {"d7", 77},                                   \
283   {"d8", 79},                                   \
284   {"d9", 81},                                   \
285   {"d10", 83},                                  \
286   {"d11", 85},                                  \
287   {"d12", 87},                                  \
288   {"d13", 89},                                  \
289   {"d14", 91},                                  \
290   {"d15", 93},                                  \
291 }
292
293 #define REGISTER_PREFIX "__"
294 #define USER_LABEL_PREFIX ""
295 #define LOCAL_LABEL_PREFIX ""
296
297 /* AOF does not prefix user function names with an underscore.  */
298 #define ARM_MCOUNT_NAME "_mcount"
299
300 /* Output of Dispatch Tables.  */
301 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL)                      \
302   do                                                                            \
303     {                                                                           \
304       if (TARGET_ARM)                                                           \
305         fprintf ((STREAM), "\tb\t|L..%d|\n", (VALUE));                          \
306       else                                                                      \
307         fprintf ((STREAM), "\tDCD\t|L..%d| - |L..%d|\n", (VALUE), (REL));       \
308     }                                                                           \
309   while (0)
310
311 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE)  \
312   fprintf ((STREAM), "\tDCD\t|L..%d|\n", (VALUE))
313
314 /* A label marking the start of a jump table is a data label.  */
315 #define ASM_OUTPUT_CASE_LABEL(STREAM, PREFIX, NUM, TABLE)       \
316   fprintf ((STREAM), "\tALIGN\n|%s..%d|\n", (PREFIX), (NUM))
317
318 /* Assembler Commands for Alignment.  */
319 #define ASM_OUTPUT_SKIP(STREAM, NBYTES)         \
320  fprintf ((STREAM), "\t%%\t%d\n", (int) (NBYTES))
321
322 #define ASM_OUTPUT_ALIGN(STREAM, POWER)                 \
323   do                                                    \
324     {                                                   \
325       int amount = 1 << (POWER);                        \
326                                                         \
327       if (amount == 2)                                  \
328         fprintf ((STREAM), "\tALIGN 2\n");              \
329       else if (amount == 4)                             \
330         fprintf ((STREAM), "\tALIGN\n");                \
331       else                                              \
332         fprintf ((STREAM), "\tALIGN %d\n", amount);     \
333     }                                                   \
334   while (0)
335
336 #undef DBX_DEBUGGING_INFO