1 |
38 |
julius |
/* 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 3, 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 COPYING3. If not see
|
21 |
|
|
<http://www.gnu.org/licenses/>. */
|
22 |
|
|
|
23 |
|
|
|
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 -apcs 3/32bit"
|
38 |
|
|
#endif
|
39 |
|
|
|
40 |
|
|
#ifndef LIB_SPEC
|
41 |
|
|
#define LIB_SPEC "%{Eb: armlib_h.32b%s}%{!Eb: armlib_h.32l%s}"
|
42 |
|
|
#endif
|
43 |
|
|
|
44 |
|
|
#define LIBGCC_SPEC "libgcc.a%s"
|
45 |
|
|
|
46 |
|
|
#define CTOR_LIST_BEGIN \
|
47 |
|
|
asm (CTORS_SECTION_ASM_OP); \
|
48 |
|
|
extern func_ptr __CTOR_END__[1]; \
|
49 |
|
|
func_ptr __CTOR_LIST__[1] = {__CTOR_END__};
|
50 |
|
|
|
51 |
|
|
#define CTOR_LIST_END \
|
52 |
|
|
asm (CTORS_SECTION_ASM_OP); \
|
53 |
|
|
func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
|
54 |
|
|
|
55 |
|
|
#define DO_GLOBAL_CTORS_BODY \
|
56 |
|
|
do \
|
57 |
|
|
{ \
|
58 |
|
|
func_ptr *ptr = __CTOR_LIST__ + 1; \
|
59 |
|
|
\
|
60 |
|
|
while (*ptr) \
|
61 |
|
|
(*ptr++) (); \
|
62 |
|
|
} \
|
63 |
|
|
while (0)
|
64 |
|
|
|
65 |
|
|
#define DTOR_LIST_BEGIN \
|
66 |
|
|
asm (DTORS_SECTION_ASM_OP); \
|
67 |
|
|
extern func_ptr __DTOR_END__[1]; \
|
68 |
|
|
func_ptr __DTOR_LIST__[1] = {__DTOR_END__};
|
69 |
|
|
|
70 |
|
|
#define DTOR_LIST_END \
|
71 |
|
|
asm (DTORS_SECTION_ASM_OP); \
|
72 |
|
|
func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
|
73 |
|
|
|
74 |
|
|
#define DO_GLOBAL_DTORS_BODY \
|
75 |
|
|
do \
|
76 |
|
|
{ \
|
77 |
|
|
func_ptr *ptr = __DTOR_LIST__ + 1; \
|
78 |
|
|
\
|
79 |
|
|
while (*ptr) \
|
80 |
|
|
(*ptr++) (); \
|
81 |
|
|
} \
|
82 |
|
|
while (0)
|
83 |
|
|
|
84 |
|
|
/* We really want to put Thumb tables in a read-only data section, but
|
85 |
|
|
switching to another section during function output is not
|
86 |
|
|
possible. We could however do what the SPARC does and defer the
|
87 |
|
|
whole table generation until the end of the function. */
|
88 |
|
|
#define JUMP_TABLES_IN_TEXT_SECTION 1
|
89 |
|
|
|
90 |
|
|
#define TARGET_ASM_INIT_SECTIONS aof_asm_init_sections
|
91 |
|
|
|
92 |
|
|
/* Some systems use __main in a way incompatible with its use in gcc, in these
|
93 |
|
|
cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
|
94 |
|
|
give the same symbol without quotes for an alternative entry point. You
|
95 |
|
|
must define both, or neither. */
|
96 |
|
|
#define NAME__MAIN "__gccmain"
|
97 |
|
|
#define SYMBOL__MAIN __gccmain
|
98 |
|
|
|
99 |
|
|
#define ASM_COMMENT_START ";"
|
100 |
|
|
#define ASM_APP_ON ""
|
101 |
|
|
#define ASM_APP_OFF ""
|
102 |
|
|
|
103 |
|
|
#define ASM_OUTPUT_ASCII(STREAM, PTR, LEN) \
|
104 |
|
|
{ \
|
105 |
|
|
int i; \
|
106 |
|
|
const char *ptr = (PTR); \
|
107 |
|
|
fprintf ((STREAM), "\tDCB"); \
|
108 |
|
|
for (i = 0; i < (long)(LEN); i++) \
|
109 |
|
|
fprintf ((STREAM), " &%02x%s", \
|
110 |
|
|
(unsigned ) *(ptr++), \
|
111 |
|
|
(i + 1 < (long)(LEN) \
|
112 |
|
|
? ((i & 3) == 3 ? "\n\tDCB" : ",") \
|
113 |
|
|
: "\n")); \
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
#define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == '\n')
|
117 |
|
|
|
118 |
|
|
/* Output of Uninitialized Variables. */
|
119 |
|
|
|
120 |
|
|
#define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \
|
121 |
|
|
(in_section = NULL, \
|
122 |
|
|
fprintf ((STREAM), "\tAREA "), \
|
123 |
|
|
assemble_name ((STREAM), (NAME)), \
|
124 |
|
|
fprintf ((STREAM), ", DATA, COMMON\n\t%% %d\t%s size=%d\n", \
|
125 |
|
|
(int)(ROUNDED), ASM_COMMENT_START, (int)(SIZE)))
|
126 |
|
|
|
127 |
|
|
#define ASM_OUTPUT_LOCAL(STREAM, NAME, SIZE, ROUNDED) \
|
128 |
|
|
(zero_init_section (), \
|
129 |
|
|
assemble_name ((STREAM), (NAME)), \
|
130 |
|
|
fprintf ((STREAM), "\n"), \
|
131 |
|
|
fprintf ((STREAM), "\t%% %d\t%s size=%d\n", \
|
132 |
|
|
(int)(ROUNDED), ASM_COMMENT_START, (int)(SIZE)))
|
133 |
|
|
|
134 |
|
|
/* Output and Generation of Labels */
|
135 |
|
|
extern int arm_main_function;
|
136 |
|
|
|
137 |
|
|
/* Globalizing directive for a label. */
|
138 |
|
|
#define GLOBAL_ASM_OP "\tEXPORT\t"
|
139 |
|
|
|
140 |
|
|
#define ASM_OUTPUT_LABEL(STREAM,NAME) \
|
141 |
|
|
do { \
|
142 |
|
|
assemble_name (STREAM,NAME); \
|
143 |
|
|
fputs ("\n", STREAM); \
|
144 |
|
|
} while (0)
|
145 |
|
|
|
146 |
|
|
#define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
|
147 |
|
|
{ \
|
148 |
|
|
if (TARGET_POKE_FUNCTION_NAME) \
|
149 |
|
|
arm_poke_function_name ((STREAM), (NAME)); \
|
150 |
|
|
ASM_OUTPUT_LABEL (STREAM, NAME); \
|
151 |
|
|
if (! TREE_PUBLIC (DECL)) \
|
152 |
|
|
{ \
|
153 |
|
|
fputs ("\tKEEP ", STREAM); \
|
154 |
|
|
ASM_OUTPUT_LABEL (STREAM, NAME); \
|
155 |
|
|
} \
|
156 |
|
|
aof_delete_import ((NAME)); \
|
157 |
|
|
}
|
158 |
|
|
|
159 |
|
|
#define ASM_DECLARE_OBJECT_NAME(STREAM,NAME,DECL) \
|
160 |
|
|
{ \
|
161 |
|
|
ASM_OUTPUT_LABEL (STREAM, NAME); \
|
162 |
|
|
if (! TREE_PUBLIC (DECL)) \
|
163 |
|
|
{ \
|
164 |
|
|
fputs ("\tKEEP ", STREAM); \
|
165 |
|
|
ASM_OUTPUT_LABEL (STREAM, NAME); \
|
166 |
|
|
} \
|
167 |
|
|
aof_delete_import ((NAME)); \
|
168 |
|
|
}
|
169 |
|
|
|
170 |
|
|
#define ASM_OUTPUT_EXTERNAL(STREAM,DECL,NAME) \
|
171 |
|
|
aof_add_import ((NAME))
|
172 |
|
|
|
173 |
|
|
#define ASM_OUTPUT_EXTERNAL_LIBCALL(STREAM,SYMREF) \
|
174 |
|
|
(fprintf ((STREAM), "\tIMPORT\t"), \
|
175 |
|
|
assemble_name ((STREAM), XSTR ((SYMREF), 0)), \
|
176 |
|
|
fputc ('\n', (STREAM)))
|
177 |
|
|
|
178 |
|
|
#define ASM_OUTPUT_LABELREF(STREAM,NAME) \
|
179 |
|
|
fprintf ((STREAM), "|%s|", NAME)
|
180 |
|
|
|
181 |
|
|
#define ASM_GENERATE_INTERNAL_LABEL(STRING,PREFIX,NUM) \
|
182 |
|
|
sprintf ((STRING), "*|%s..%ld|", (PREFIX), (long)(NUM))
|
183 |
|
|
|
184 |
|
|
/* How initialization functions are handled. */
|
185 |
|
|
|
186 |
|
|
#define CTORS_SECTION_ASM_OP "\tAREA\t|C$$gnu_ctorsvec|, DATA, READONLY"
|
187 |
|
|
#define DTORS_SECTION_ASM_OP "\tAREA\t|C$$gnu_dtorsvec|, DATA, READONLY"
|
188 |
|
|
|
189 |
|
|
/* Output of Assembler Instructions. */
|
190 |
|
|
|
191 |
|
|
#define REGISTER_NAMES \
|
192 |
|
|
{ \
|
193 |
|
|
"a1", "a2", "a3", "a4", \
|
194 |
|
|
"v1", "v2", "v3", "v4", \
|
195 |
|
|
"v5", "v6", "sl", "fp", \
|
196 |
|
|
"ip", "sp", "lr", "pc", \
|
197 |
|
|
"f0", "f1", "f2", "f3", \
|
198 |
|
|
"f4", "f5", "f6", "f7", \
|
199 |
|
|
"cc", "sfp", "afp", \
|
200 |
|
|
"mv0", "mv1", "mv2", "mv3", \
|
201 |
|
|
"mv4", "mv5", "mv6", "mv7", \
|
202 |
|
|
"mv8", "mv9", "mv10", "mv11", \
|
203 |
|
|
"mv12", "mv13", "mv14", "mv15", \
|
204 |
|
|
"wcgr0", "wcgr1", "wcgr2", "wcgr3", \
|
205 |
|
|
"wr0", "wr1", "wr2", "wr3", \
|
206 |
|
|
"wr4", "wr5", "wr6", "wr7", \
|
207 |
|
|
"wr8", "wr9", "wr10", "wr11", \
|
208 |
|
|
"wr12", "wr13", "wr14", "wr15", \
|
209 |
|
|
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", \
|
210 |
|
|
"s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \
|
211 |
|
|
"s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \
|
212 |
|
|
"s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31", \
|
213 |
|
|
"vfpcc" \
|
214 |
|
|
}
|
215 |
|
|
|
216 |
|
|
#define ADDITIONAL_REGISTER_NAMES \
|
217 |
|
|
{ \
|
218 |
|
|
{"r0", 0}, {"a1", 0}, \
|
219 |
|
|
{"r1", 1}, {"a2", 1}, \
|
220 |
|
|
{"r2", 2}, {"a3", 2}, \
|
221 |
|
|
{"r3", 3}, {"a4", 3}, \
|
222 |
|
|
{"r4", 4}, {"v1", 4}, \
|
223 |
|
|
{"r5", 5}, {"v2", 5}, \
|
224 |
|
|
{"r6", 6}, {"v3", 6}, \
|
225 |
|
|
{"r7", 7}, {"wr", 7}, \
|
226 |
|
|
{"r8", 8}, {"v5", 8}, \
|
227 |
|
|
{"r9", 9}, {"v6", 9}, \
|
228 |
|
|
{"r10", 10}, {"sl", 10}, {"v7", 10}, \
|
229 |
|
|
{"r11", 11}, {"fp", 11}, \
|
230 |
|
|
{"r12", 12}, {"ip", 12}, \
|
231 |
|
|
{"r13", 13}, {"sp", 13}, \
|
232 |
|
|
{"r14", 14}, {"lr", 14}, \
|
233 |
|
|
{"r15", 15}, {"pc", 15}, \
|
234 |
|
|
{"d0", 63}, \
|
235 |
|
|
{"d1", 65}, \
|
236 |
|
|
{"d2", 67}, \
|
237 |
|
|
{"d3", 69}, \
|
238 |
|
|
{"d4", 71}, \
|
239 |
|
|
{"d5", 73}, \
|
240 |
|
|
{"d6", 75}, \
|
241 |
|
|
{"d7", 77}, \
|
242 |
|
|
{"d8", 79}, \
|
243 |
|
|
{"d9", 81}, \
|
244 |
|
|
{"d10", 83}, \
|
245 |
|
|
{"d11", 85}, \
|
246 |
|
|
{"d12", 87}, \
|
247 |
|
|
{"d13", 89}, \
|
248 |
|
|
{"d14", 91}, \
|
249 |
|
|
{"d15", 93} \
|
250 |
|
|
}
|
251 |
|
|
|
252 |
|
|
#define REGISTER_PREFIX "__"
|
253 |
|
|
#define USER_LABEL_PREFIX ""
|
254 |
|
|
#define LOCAL_LABEL_PREFIX ""
|
255 |
|
|
|
256 |
|
|
/* AOF does not prefix user function names with an underscore. */
|
257 |
|
|
#define ARM_MCOUNT_NAME "_mcount"
|
258 |
|
|
|
259 |
|
|
/* Output of Dispatch Tables. */
|
260 |
|
|
#define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL) \
|
261 |
|
|
do \
|
262 |
|
|
{ \
|
263 |
|
|
if (TARGET_ARM) \
|
264 |
|
|
fprintf ((STREAM), "\tb\t|L..%d|\n", (VALUE)); \
|
265 |
|
|
else \
|
266 |
|
|
fprintf ((STREAM), "\tDCD\t|L..%d| - |L..%d|\n", (VALUE), (REL)); \
|
267 |
|
|
} \
|
268 |
|
|
while (0)
|
269 |
|
|
|
270 |
|
|
#define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \
|
271 |
|
|
fprintf ((STREAM), "\tDCD\t|L..%d|\n", (VALUE))
|
272 |
|
|
|
273 |
|
|
/* A label marking the start of a jump table is a data label. */
|
274 |
|
|
#define ASM_OUTPUT_CASE_LABEL(STREAM, PREFIX, NUM, TABLE) \
|
275 |
|
|
fprintf ((STREAM), "\tALIGN\n|%s..%d|\n", (PREFIX), (NUM))
|
276 |
|
|
|
277 |
|
|
/* Assembler Commands for Alignment. */
|
278 |
|
|
#define ASM_OUTPUT_SKIP(STREAM, NBYTES) \
|
279 |
|
|
fprintf ((STREAM), "\t%%\t%d\n", (int) (NBYTES))
|
280 |
|
|
|
281 |
|
|
#define ASM_OUTPUT_ALIGN(STREAM, POWER) \
|
282 |
|
|
do \
|
283 |
|
|
{ \
|
284 |
|
|
int amount = 1 << (POWER); \
|
285 |
|
|
\
|
286 |
|
|
if (amount == 2) \
|
287 |
|
|
fprintf ((STREAM), "\tALIGN 2\n"); \
|
288 |
|
|
else if (amount == 4) \
|
289 |
|
|
fprintf ((STREAM), "\tALIGN\n"); \
|
290 |
|
|
else \
|
291 |
|
|
fprintf ((STREAM), "\tALIGN %d\n", amount); \
|
292 |
|
|
} \
|
293 |
|
|
while (0)
|
294 |
|
|
|
295 |
|
|
#undef DBX_DEBUGGING_INFO
|