1 /* Definitions of target machine for GNU compiler, for ARM with a.out
2 Copyright (C) 1995, 1996 Free Software Foundation, Inc.
3 Contributed by Richard Earnshaw (rearnsha@armltd.co.uk)
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 #define ARM_OS_NAME "(generic)"
26 /* The text to go at the start of the assembler file */
27 #define ASM_FILE_START(STREAM) \
29 fprintf (STREAM,"%srfp\t.req\t%sr9\n", REGISTER_PREFIX, REGISTER_PREFIX); \
30 fprintf (STREAM,"%ssl\t.req\t%sr10\n", REGISTER_PREFIX, REGISTER_PREFIX); \
31 fprintf (STREAM,"%sfp\t.req\t%sr11\n", REGISTER_PREFIX, REGISTER_PREFIX); \
32 fprintf (STREAM,"%sip\t.req\t%sr12\n", REGISTER_PREFIX, REGISTER_PREFIX); \
33 fprintf (STREAM,"%ssp\t.req\t%sr13\n", REGISTER_PREFIX, REGISTER_PREFIX); \
34 fprintf (STREAM,"%slr\t.req\t%sr14\n", REGISTER_PREFIX, REGISTER_PREFIX); \
35 fprintf (STREAM,"%spc\t.req\t%sr15\n", REGISTER_PREFIX, REGISTER_PREFIX); \
39 #define ASM_APP_OFF ""
41 /* Switch to the text or data segment. */
42 #define TEXT_SECTION_ASM_OP ".text"
43 #define DATA_SECTION_ASM_OP ".data"
44 #define BSS_SECTION_ASM_OP ".bss"
46 #define REGISTER_PREFIX ""
47 #define USER_LABEL_PREFIX "_"
48 #define LOCAL_LABEL_PREFIX ""
50 /* The assembler's names for the registers. */
51 #ifndef REGISTER_NAMES
52 #define REGISTER_NAMES \
54 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
55 "r8", "r9", "sl", "fp", "ip", "sp", "lr", "pc", \
56 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
61 #ifndef ADDITIONAL_REGISTER_NAMES
62 #define ADDITIONAL_REGISTER_NAMES \
74 {"rfp", 9}, /* Gcc used to call it this */ \
77 {"r10", 10}, /* sl */ \
78 {"r11", 11}, /* fp */ \
79 {"r12", 12}, /* ip */ \
80 {"r13", 13}, /* sp */ \
81 {"r14", 14}, /* lr */ \
82 {"r15", 15} /* pc */ \
86 /* Arm Assembler barfs on dollars */
87 #define DOLLARS_IN_IDENTIFIERS 0
89 #define NO_DOLLAR_IN_LABEL
91 /* DBX register number for a given compiler register number */
92 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
94 /* Generate DBX debugging information. riscix.h will undefine this because
95 the native assembler does not support stabs. */
96 #define DBX_DEBUGGING_INFO 1
98 /* Acorn dbx moans about continuation chars, so don't use any. */
99 #ifndef DBX_CONTIN_LENGTH
100 #define DBX_CONTIN_LENGTH 0
103 /* Output a source filename for the debugger. RISCiX dbx insists that the
104 ``desc'' field is set to compiler version number >= 315 (sic). */
105 #define DBX_OUTPUT_MAIN_SOURCE_FILENAME(STREAM,NAME) \
107 fprintf (STREAM, ".stabs \"%s\",%d,0,315,%s\n", (NAME), N_SO, \
108 <ext_label_name[1]); \
110 ASM_OUTPUT_INTERNAL_LABEL (STREAM, "Ltext", 0); \
113 /* Output a function label definition. */
114 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
115 ASM_OUTPUT_LABEL(STREAM, NAME)
117 #define ARM_OUTPUT_LABEL(STREAM,NAME) \
119 assemble_name (STREAM,NAME); \
120 fputs (":\n", STREAM); \
123 /* Output a globalising directive for a label. */
124 #define ASM_GLOBALIZE_LABEL(STREAM,NAME) \
125 (fprintf (STREAM, "\t.global\t"), \
126 assemble_name (STREAM, NAME), \
127 fputc ('\n',STREAM)) \
129 /* Output a reference to a label. */
130 #define ASM_OUTPUT_LABELREF(STREAM,NAME) \
131 fprintf (STREAM, "%s%s", USER_LABEL_PREFIX, NAME)
133 /* Make an internal label into a string. */
134 #define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
135 sprintf (STRING, "*%s%s%d", LOCAL_LABEL_PREFIX, PREFIX, NUM)
137 /* Nothing special is done about jump tables */
138 /* #define ASM_OUTPUT_CASE_LABEL(STREAM,PREFIX,NUM,TABLE) */
139 /* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE) */
141 /* Construct a private name. */
142 #define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER) \
143 ((OUTVAR) = (char *) alloca (strlen (NAME) + 10), \
144 sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)))
146 /* Output an element of a dispatch table. */
147 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
148 fprintf (STREAM, "\t.word\t%sL%d\n", LOCAL_LABEL_PREFIX, VALUE)
150 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,VALUE,REL) \
151 fprintf (STREAM, "\tb\t%sL%d\n", LOCAL_LABEL_PREFIX, (VALUE))
153 /* Output various types of constants. For real numbers we output hex, with
154 a comment containing the "human" value, this allows us to pass NaN's which
155 the riscix assembler doesn't understand (it also makes cross-assembling
156 less likely to fail). */
158 #define ASM_OUTPUT_LONG_DOUBLE(STREAM,VALUE) \
159 do { char dstr[30]; \
161 arm_increase_location (12); \
162 REAL_VALUE_TO_TARGET_LONG_DOUBLE (VALUE, l); \
163 REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \
164 fprintf (STREAM, "\t.long 0x%lx,0x%lx,0x%lx\t%s long double %s\n", \
165 l[0], l[1], l[2], ASM_COMMENT_START, dstr); \
169 #define ASM_OUTPUT_DOUBLE(STREAM, VALUE) \
170 do { char dstr[30]; \
172 arm_increase_location (8); \
173 REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \
174 REAL_VALUE_TO_DECIMAL (VALUE, "%.14g", dstr); \
175 fprintf (STREAM, "\t.long 0x%lx, 0x%lx\t%s double %s\n", l[0], \
176 l[1], ASM_COMMENT_START, dstr); \
179 #define ASM_OUTPUT_FLOAT(STREAM, VALUE) \
180 do { char dstr[30]; \
182 arm_increase_location (4); \
183 REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \
184 REAL_VALUE_TO_DECIMAL (VALUE, "%.7g", dstr); \
185 fprintf (STREAM, "\t.word 0x%lx\t%s float %s\n", l, \
186 ASM_COMMENT_START, dstr); \
189 #define ASM_OUTPUT_INT(STREAM, EXP) \
190 (fprintf (STREAM, "\t.word\t"), \
191 output_addr_const (STREAM, (EXP)), \
192 arm_increase_location (4), \
193 fputc ('\n', STREAM))
195 #define ASM_OUTPUT_SHORT(STREAM, EXP) \
196 (fprintf (STREAM, "\t.short\t"), \
197 output_addr_const (STREAM, (EXP)), \
198 arm_increase_location (2), \
199 fputc ('\n', STREAM))
201 #define ASM_OUTPUT_CHAR(STREAM, EXP) \
202 (fprintf (STREAM, "\t.byte\t"), \
203 output_addr_const (STREAM, (EXP)), \
204 arm_increase_location (1), \
205 fputc ('\n', STREAM))
207 #define ASM_OUTPUT_BYTE(STREAM, VALUE) \
208 (fprintf (STREAM, "\t.byte\t%d\n", VALUE), \
209 arm_increase_location (1))
211 #define ASM_OUTPUT_ASCII(STREAM, PTR, LEN) \
212 output_ascii_pseudo_op ((STREAM), (unsigned char *)(PTR), (LEN))
214 /* Output a gap. In fact we fill it with nulls. */
215 #define ASM_OUTPUT_SKIP(STREAM, NBYTES) \
216 (arm_increase_location (NBYTES), \
217 fprintf (STREAM, "\t.space\t%d\n", NBYTES))
219 /* Align output to a power of two. Horrible /bin/as. */
220 #define ASM_OUTPUT_ALIGN(STREAM, POWER) \
223 register int amount = 1 << (POWER); \
224 extern int arm_text_location; \
227 fprintf (STREAM, "\t.even\n"); \
228 else if (amount != 1) \
229 fprintf (STREAM, "\t.align\t%d\n", amount - 4); \
231 if (in_text_section ()) \
232 arm_text_location = ((arm_text_location + amount - 1) \
236 /* Output a common block */
237 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \
238 (fprintf (STREAM, "\t.comm\t"), \
239 assemble_name ((STREAM), (NAME)), \
240 fprintf(STREAM, ", %d\t%s %d\n", ROUNDED, ASM_COMMENT_START, SIZE))
242 /* Output a local common block. /bin/as can't do this, so hack a `.space' into
243 the bss segment. Note that this is *bad* practice. */
244 #define ASM_OUTPUT_ALIGNED_LOCAL(STREAM,NAME,SIZE,ALIGN) \
245 output_lcomm_directive (STREAM, NAME, SIZE, ALIGN)
247 /* Output a zero-initialized block. */
248 #define ASM_OUTPUT_ALIGNED_BSS(STREAM,NAME,SIZE,ALIGN) \
249 asm_output_aligned_bss(STREAM, NAME, SIZE, ALIGN)
251 /* Output a source line for the debugger. */
252 /* #define ASM_OUTPUT_SOURCE_LINE(STREAM,LINE) */
254 /* Output a #ident directive. */
255 #define ASM_OUTPUT_IDENT(STREAM,STRING) \
256 fprintf (STREAM,"- - - ident %s\n",STRING)
258 /* The assembler's parentheses characters. */
259 #define ASM_OPEN_PAREN "("
260 #define ASM_CLOSE_PAREN ")"
262 #ifndef ASM_COMMENT_START
263 #define ASM_COMMENT_START "@"