OSDN Git Service

gcc/
[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, 2007
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, 51 Franklin Street, Fifth Floor,
22    Boston, MA 02110-1301, 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 #define CTOR_LIST_BEGIN                         \
48   asm (CTORS_SECTION_ASM_OP);                   \
49   extern func_ptr __CTOR_END__[1];              \
50   func_ptr __CTOR_LIST__[1] = {__CTOR_END__};
51
52 #define CTOR_LIST_END                           \
53   asm (CTORS_SECTION_ASM_OP);                   \
54   func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
55
56 #define DO_GLOBAL_CTORS_BODY                    \
57   do                                            \
58     {                                           \
59       func_ptr *ptr = __CTOR_LIST__ + 1;        \
60                                                 \
61       while (*ptr)                              \
62         (*ptr++) ();                            \
63     }                                           \
64   while (0)
65
66 #define DTOR_LIST_BEGIN                         \
67   asm (DTORS_SECTION_ASM_OP);                   \
68   extern func_ptr __DTOR_END__[1];              \
69   func_ptr __DTOR_LIST__[1] = {__DTOR_END__};
70
71 #define DTOR_LIST_END                           \
72   asm (DTORS_SECTION_ASM_OP);                   \
73   func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
74
75 #define DO_GLOBAL_DTORS_BODY                    \
76   do                                            \
77     {                                           \
78       func_ptr *ptr = __DTOR_LIST__ + 1;        \
79                                                 \
80       while (*ptr)                              \
81         (*ptr++) ();                            \
82     }                                           \
83   while (0)
84
85 /* We really want to put Thumb tables in a read-only data section, but
86    switching to another section during function output is not
87    possible.  We could however do what the SPARC does and defer the
88    whole table generation until the end of the function.  */
89 #define JUMP_TABLES_IN_TEXT_SECTION 1
90
91 #define TARGET_ASM_INIT_SECTIONS aof_asm_init_sections
92
93 /* Some systems use __main in a way incompatible with its use in gcc, in these
94    cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
95    give the same symbol without quotes for an alternative entry point.  You
96    must define both, or neither.  */
97 #define NAME__MAIN "__gccmain"
98 #define SYMBOL__MAIN __gccmain
99
100 #define ASM_COMMENT_START ";"
101 #define ASM_APP_ON        ""
102 #define ASM_APP_OFF       ""
103
104 #define ASM_OUTPUT_ASCII(STREAM, PTR, LEN)              \
105 {                                                       \
106   int i;                                                \
107   const char *ptr = (PTR);                              \
108   fprintf ((STREAM), "\tDCB");                          \
109   for (i = 0; i < (long)(LEN); i++)                     \
110     fprintf ((STREAM), " &%02x%s",                      \
111              (unsigned ) *(ptr++),                      \
112              (i + 1 < (long)(LEN)                       \
113               ? ((i & 3) == 3 ? "\n\tDCB" : ",")        \
114               : "\n"));                                 \
115 }
116
117 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == '\n')
118
119 /* Output of Uninitialized Variables.  */
120
121 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)          \
122   (in_section = NULL,                                           \
123    fprintf ((STREAM), "\tAREA "),                               \
124    assemble_name ((STREAM), (NAME)),                            \
125    fprintf ((STREAM), ", DATA, COMMON\n\t%% %d\t%s size=%d\n",  \
126             (int)(ROUNDED), ASM_COMMENT_START, (int)(SIZE)))
127
128 #define ASM_OUTPUT_LOCAL(STREAM, NAME, SIZE, ROUNDED)   \
129    (zero_init_section (),                               \
130     assemble_name ((STREAM), (NAME)),                   \
131     fprintf ((STREAM), "\n"),                           \
132     fprintf ((STREAM), "\t%% %d\t%s size=%d\n",         \
133              (int)(ROUNDED), ASM_COMMENT_START, (int)(SIZE)))
134
135 /* Output and Generation of Labels */
136 extern int arm_main_function;
137
138 /* Globalizing directive for a label.  */
139 #define GLOBAL_ASM_OP "\tEXPORT\t"
140
141 #define ASM_OUTPUT_LABEL(STREAM,NAME)   \
142 do {                                    \
143   assemble_name (STREAM,NAME);          \
144   fputs ("\n", STREAM);                 \
145 } while (0)
146
147 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
148 {                                               \
149   if (TARGET_POKE_FUNCTION_NAME)                \
150     arm_poke_function_name ((STREAM), (NAME));  \
151   ASM_OUTPUT_LABEL (STREAM, NAME);              \
152   if (! TREE_PUBLIC (DECL))                     \
153     {                                           \
154       fputs ("\tKEEP ", STREAM);                \
155       ASM_OUTPUT_LABEL (STREAM, NAME);          \
156     }                                           \
157   aof_delete_import ((NAME));                   \
158 }
159
160 #define ASM_DECLARE_OBJECT_NAME(STREAM,NAME,DECL) \
161 {                                               \
162   ASM_OUTPUT_LABEL (STREAM, NAME);              \
163   if (! TREE_PUBLIC (DECL))                     \
164     {                                           \
165       fputs ("\tKEEP ", STREAM);                \
166       ASM_OUTPUT_LABEL (STREAM, NAME);          \
167     }                                           \
168   aof_delete_import ((NAME));                   \
169 }
170
171 #define ASM_OUTPUT_EXTERNAL(STREAM,DECL,NAME)   \
172  aof_add_import ((NAME))
173
174 #define ASM_OUTPUT_EXTERNAL_LIBCALL(STREAM,SYMREF)      \
175  (fprintf ((STREAM), "\tIMPORT\t"),                     \
176   assemble_name ((STREAM), XSTR ((SYMREF), 0)),         \
177   fputc ('\n', (STREAM)))
178
179 #define ASM_OUTPUT_LABELREF(STREAM,NAME)        \
180   fprintf ((STREAM), "|%s|", NAME)
181
182 #define ASM_GENERATE_INTERNAL_LABEL(STRING,PREFIX,NUM)  \
183   sprintf ((STRING), "*|%s..%ld|", (PREFIX), (long)(NUM))
184
185 /* How initialization functions are handled.  */
186
187 #define CTORS_SECTION_ASM_OP "\tAREA\t|C$$gnu_ctorsvec|, DATA, READONLY"
188 #define DTORS_SECTION_ASM_OP "\tAREA\t|C$$gnu_dtorsvec|, DATA, READONLY"
189
190 /* Output of Assembler Instructions.  Note that the ?xx registers are
191    there so that VFPv3/NEON registers D16-D31 have the same spacing as D0-D15
192    (each of which is overlaid on two S registers), although there are no
193    actual single-precision registers which correspond to D16-D31.  */
194
195 #define REGISTER_NAMES                          \
196 {                                               \
197   "a1", "a2", "a3", "a4",                       \
198   "v1", "v2", "v3", "v4",                       \
199   "v5", "v6", "sl", "fp",                       \
200   "ip", "sp", "lr", "pc",                       \
201   "f0", "f1", "f2", "f3",                       \
202   "f4", "f5", "f6", "f7",                       \
203   "cc", "sfp", "afp",                           \
204   "mv0",   "mv1",   "mv2",   "mv3",             \
205   "mv4",   "mv5",   "mv6",   "mv7",             \
206   "mv8",   "mv9",   "mv10",  "mv11",            \
207   "mv12",  "mv13",  "mv14",  "mv15",            \
208   "wcgr0", "wcgr1", "wcgr2", "wcgr3",           \
209   "wr0",   "wr1",   "wr2",   "wr3",             \
210   "wr4",   "wr5",   "wr6",   "wr7",             \
211   "wr8",   "wr9",   "wr10",  "wr11",            \
212   "wr12",  "wr13",  "wr14",  "wr15",            \
213   "s0",  "s1",  "s2",  "s3",  "s4",  "s5",  "s6",  "s7",  \
214   "s8",  "s9",  "s10", "s11", "s12", "s13", "s14", "s15", \
215   "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \
216   "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31", \
217   "d16", "?16", "d17", "?17", "d18", "?18", "d19", "?19", \
218   "d20", "?20", "d21", "?21", "d22", "?22", "d23", "?23", \
219   "d24", "?24", "d25", "?25", "d26", "?26", "d27", "?27", \
220   "d28", "?28", "d29", "?29", "d30", "?30", "d31", "?31", \
221   "vfpcc"                                       \
222 }
223
224 #define ADDITIONAL_REGISTER_NAMES               \
225 {                                               \
226   {"r0", 0}, {"a1", 0},                         \
227   {"r1", 1}, {"a2", 1},                         \
228   {"r2", 2}, {"a3", 2},                         \
229   {"r3", 3}, {"a4", 3},                         \
230   {"r4", 4}, {"v1", 4},                         \
231   {"r5", 5}, {"v2", 5},                         \
232   {"r6", 6}, {"v3", 6},                         \
233   {"r7", 7}, {"wr", 7},                         \
234   {"r8", 8}, {"v5", 8},                         \
235   {"r9", 9}, {"v6", 9},                         \
236   {"r10", 10}, {"sl", 10}, {"v7", 10},          \
237   {"r11", 11}, {"fp", 11},                      \
238   {"r12", 12}, {"ip", 12},                      \
239   {"r13", 13}, {"sp", 13},                      \
240   {"r14", 14}, {"lr", 14},                      \
241   {"r15", 15}, {"pc", 15},                      \
242   {"d0", 63}, {"q0", 63},                       \
243   {"d1", 65},                                   \
244   {"d2", 67}, {"q1", 67},                       \
245   {"d3", 69},                                   \
246   {"d4", 71}, {"q2", 71},                       \
247   {"d5", 73},                                   \
248   {"d6", 75}, {"q3", 75},                       \
249   {"d7", 77},                                   \
250   {"d8", 79}, {"q4", 79},                       \
251   {"d9", 81},                                   \
252   {"d10", 83}, {"q5", 83},                      \
253   {"d11", 85},                                  \
254   {"d12", 87}, {"q6", 87},                      \
255   {"d13", 89},                                  \
256   {"d14", 91}, {"q7", 91},                      \
257   {"d15", 93},                                  \
258   {"q8", 95},                                   \
259   {"q9", 99},                                   \
260   {"q10", 103},                                 \
261   {"q11", 107},                                 \
262   {"q12", 111},                                 \
263   {"q13", 115},                                 \
264   {"q14", 119},                                 \
265   {"q15", 123}                                  \
266 }
267
268 #define REGISTER_PREFIX "__"
269 #define USER_LABEL_PREFIX ""
270 #define LOCAL_LABEL_PREFIX ""
271
272 /* AOF does not prefix user function names with an underscore.  */
273 #define ARM_MCOUNT_NAME "_mcount"
274
275 /* Output of Dispatch Tables.  */
276 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL)              \
277   do                                                                    \
278     {                                                                   \
279       if (TARGET_ARM)                                                   \
280         fprintf ((STREAM), "\tb\t|L..%d|\n", (VALUE));                  \
281       else if (TARGET_THUMB1)                                           \
282         fprintf ((STREAM), "\tDCD\t|L..%d| - |L..%d|\n", (VALUE), (REL)); \
283       else /* Thumb-2 */                                                \
284         {                                                               \
285           switch (GET_MODE(body))                                       \
286             {                                                           \
287             case QImode: /* TBB */                                      \
288               asm_fprintf (STREAM, "\tDCB\t(|L..%d| - |L..%d|)/2\n",    \
289                            VALUE, REL);                                 \
290               break;                                                    \
291             case HImode: /* TBH */                                      \
292               asm_fprintf (STREAM, "\tDCW\t|L..%d| - |L..%d|)/2\n",     \
293                            VALUE, REL);                                 \
294               break;                                                    \
295             case SImode:                                                \
296               if (flag_pic)                                             \
297                 asm_fprintf (STREAM, "\tDCD\t|L..%d| + 1 - |L..%d|\n",  \
298                              VALUE, REL);                               \
299               else                                                      \
300                 asm_fprintf (STREAM, "\tDCD\t|L..%d| + 1\n", VALUE);    \
301               break;                                                    \
302             default:                                                    \
303               gcc_unreachable();                                        \
304             }                                                           \
305         }                                                               \
306     }                                                                   \
307   while (0)
308
309 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE)                  \
310   do                                                            \
311     {                                                           \
312       gcc_assert (!TARGET_THUMB2)                               \
313       fprintf ((STREAM), "\tDCD\t|L..%d|\n", (VALUE))           \
314     }                                                           \
315   while (0)
316         
317
318 /* A label marking the start of a jump table is a data label.  */
319 #define ASM_OUTPUT_CASE_LABEL(STREAM, PREFIX, NUM, TABLE)       \
320   fprintf ((STREAM), "\tALIGN\n|%s..%d|\n", (PREFIX), (NUM))
321
322 /* Assembler Commands for Alignment.  */
323 #define ASM_OUTPUT_SKIP(STREAM, NBYTES)         \
324  fprintf ((STREAM), "\t%%\t%d\n", (int) (NBYTES))
325
326 #define ASM_OUTPUT_ALIGN(STREAM, POWER)                 \
327   do                                                    \
328     {                                                   \
329       int amount = 1 << (POWER);                        \
330                                                         \
331       if (amount == 2)                                  \
332         fprintf ((STREAM), "\tALIGN 2\n");              \
333       else if (amount == 4)                             \
334         fprintf ((STREAM), "\tALIGN\n");                \
335       else                                              \
336         fprintf ((STREAM), "\tALIGN %d\n", amount);     \
337     }                                                   \
338   while (0)
339
340 #undef DBX_DEBUGGING_INFO