2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / config / m68k / sgs.h
blobe1967df8990b9fa1cf4f1936e0c4ed5deb8d9dc0
1 /* Definitions of target machine for GNU compiler for m68k targets using
2 assemblers derived from AT&T "SGS" releases.
3 Copyright (C) 1991, 1993, 1996, 2000, 2003 Free Software Foundation, Inc.
4 Written by Fred Fish (fnf@cygnus.com)
6 This file is part of GCC.
8 GCC 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.
13 GCC 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.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 #undef INT_OP_GROUP
24 #define INT_OP_GROUP INT_OP_STANDARD
26 /* SGS specific assembler pseudo ops. */
28 #define SPACE_ASM_OP "\t.space "
29 #define ALIGN_ASM_OP "\t.align "
30 #undef GLOBAL_ASM_OP
31 #define GLOBAL_ASM_OP "\t.global "
32 #define SWBEG_ASM_OP "\t.swbeg "
33 #define SET_ASM_OP "\t.set "
35 #define ASM_PN_FORMAT "%s_%lu" /* Format for private names */
37 /* Here are four prefixes that are used by asm_fprintf to
38 facilitate customization for alternate assembler syntaxes.
39 Machines with no likelihood of an alternate syntax need not
40 define these and need not use asm_fprintf. */
42 /* The prefix for register names. Note that REGISTER_NAMES
43 is supposed to include this prefix. Also note that this is NOT an
44 fprintf format string, it is a literal string */
46 #undef REGISTER_PREFIX
47 #define REGISTER_PREFIX "%"
49 /* The prefix for local (compiler generated) labels.
50 These labels will not appear in the symbol table. */
52 #undef LOCAL_LABEL_PREFIX
53 #define LOCAL_LABEL_PREFIX "."
55 /* The prefix to add to user-visible assembler symbols. */
57 #undef USER_LABEL_PREFIX
58 #define USER_LABEL_PREFIX ""
60 /* The prefix for immediate operands. */
62 #undef IMMEDIATE_PREFIX
63 #define IMMEDIATE_PREFIX "&"
65 /* How to refer to registers in assembler output.
66 This sequence is indexed by compiler's hard-register-number.
67 Motorola format uses different register names than defined in m68k.h.
68 We also take this chance to convert 'a6' to 'fp' */
70 #undef REGISTER_NAMES
72 #define REGISTER_NAMES \
73 {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
74 "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp", \
75 "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7", "argptr" }
77 /* This is how to output an assembler line that says to advance the
78 location counter to a multiple of 2**LOG bytes. */
80 #undef ASM_OUTPUT_ALIGN
81 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
82 do { \
83 if ((LOG) > 0) \
84 fprintf ((FILE), "%s%u\n", ALIGN_ASM_OP, 1 << (LOG)); \
85 else if ((LOG) > 31) \
86 abort (); \
87 } while (0)
89 /* The routine used to output null terminated string literals. We cannot
90 use the ".string" pseudo op, because it silently truncates strings to
91 1023 bytes. There is no "partial string op" which works like ".string"
92 but doesn't append a null byte, so we can't chop the input string up
93 into small pieces and use that. Our only remaining alternative is to
94 output the string one byte at a time. */
96 #define ASM_OUTPUT_ASCII(FILE,PTR,LEN) \
97 do { \
98 register size_t sp = 0, limit = (LEN); \
99 fputs (integer_asm_op (1, TRUE), (FILE)); \
100 do { \
101 int ch = (PTR)[sp]; \
102 if (ch > ' ' && ! (ch & 0x80) && ch != '\\') \
104 fprintf ((FILE), "'%c", ch); \
106 else \
108 fprintf ((FILE), "0x%x", ch); \
110 if (++sp < limit) \
112 if ((sp % 10) == 0) \
114 fprintf ((FILE), "\n%s", integer_asm_op (1, TRUE)); \
116 else \
118 putc (',', (FILE)); \
121 } while (sp < limit); \
122 putc ('\n', (FILE)); \
123 } while (0)
126 /* SGS based assemblers don't understand #NO_APP and #APP, so just don't
127 bother emitting them. */
129 #undef ASM_APP_ON
130 #define ASM_APP_ON ""
132 #undef ASM_APP_OFF
133 #define ASM_APP_OFF ""
135 /* When using SGS derived assemblers, change the "MIT" or "MOTOROLA"
136 to "SGS/AT&T" */
138 #undef TARGET_VERSION
139 #define TARGET_VERSION fprintf (stderr, " (68k, SGS/AT&T syntax)");
141 /* Use proper assembler syntax for these macros. */
142 #undef ASM_OUTPUT_REG_PUSH
143 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \
144 asm_fprintf (FILE, "\t%Omove.l %s,-(%Rsp)\n", reg_names[REGNO])
146 #undef ASM_OUTPUT_REG_POP
147 #define ASM_OUTPUT_REG_POP(FILE,REGNO) \
148 asm_fprintf (FILE, "\t%Omove.l (%Rsp)+,%s\n", reg_names[REGNO])
150 #undef ASM_OUTPUT_FLOAT_OPERAND
151 #define ASM_OUTPUT_FLOAT_OPERAND(CODE,FILE,VALUE) \
152 do { long l; \
153 REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \
154 asm_fprintf ((FILE), "%I0x%lx", l); \
155 } while (0)
157 #undef ASM_OUTPUT_DOUBLE_OPERAND
158 #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE) \
159 do { long l[2]; \
160 REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \
161 asm_fprintf ((FILE), "%I0x%lx%08lx", l[0], l[1]);\
162 } while (0)
164 /* How to output a block of SIZE zero bytes. Note that the `space' pseudo,
165 when used in the text segment, causes SGS assemblers to output nop insns
166 rather than 0s, so we set ASM_NO_SKIP_IN_TEXT to prevent this. */
168 #define ASM_NO_SKIP_IN_TEXT 1
170 #undef ASM_OUTPUT_SKIP
171 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
172 fprintf (FILE, "%s%u\n", SPACE_ASM_OP, (int)(SIZE))
174 /* Translate Motorola opcodes such as `jbeq' into SGS opcodes such
175 as `beq.w'.
176 Delete the `e' in `move...' and `fmove'.
177 Change `ftst' to `ftest'.
178 Change `fbne' to `fbneq'
179 Change `fsne' to `fsneq'
180 Change `divsl' to `tdivs' (32/32 -> 32r:32q)
181 Change `divul' to `tdivu' (32/32 -> 32r:32q)
182 Optionally change swap to swap.w.
185 #ifdef SGS_SWAP_W
186 #define ASM_OUTPUT_OPCODE(FILE, PTR) \
188 extern int flag_pic; \
189 if (!strncmp ((PTR), "jbsr", 4)) \
190 { if (flag_pic) \
191 fprintf ((FILE), "bsr"); \
192 else \
193 fprintf ((FILE), "jsr"); \
194 (PTR) += 4; } \
195 else if ((PTR)[0] == 'j' && (PTR)[1] == 'b') \
196 { ++(PTR); \
197 while (*(PTR) != ' ') \
198 { putc (*(PTR), (FILE)); ++(PTR); } \
199 fprintf ((FILE), ".w"); } \
200 else if ((PTR)[0] == 's') \
202 if (!strncmp ((PTR), "swap", 4)) \
203 { fprintf ((FILE), "swap.w"); (PTR) += 4; } \
205 /* FMOVE ==> FMOV, (and F%& F%$ translations) */ \
206 else if ((PTR)[0] == 'f') \
208 if (!strncmp ((PTR), "fmove", 5)) \
209 { fprintf ((FILE), "fmov"); (PTR) += 5; } \
210 else if (!strncmp ((PTR), "ftst", 4)) \
211 { fprintf ((FILE), "ftest"); (PTR) += 4; } \
212 else if (!strncmp ((PTR), "fbne", 4)) \
213 { fprintf ((FILE), "fbneq"); (PTR) += 4; } \
214 else if (!strncmp ((PTR), "fsne", 4)) \
215 { fprintf ((FILE), "fsneq"); (PTR) += 4; } \
216 else if (!strncmp ((PTR), "f%$move", 7)) \
217 { (PTR) += 7; \
218 if (TARGET_68040_ONLY) \
219 fprintf ((FILE), "fsmov"); \
220 else fprintf ((FILE), "fmov"); } \
221 else if (!strncmp ((PTR), "f%&move", 7)) \
222 { (PTR) += 7; \
223 if (TARGET_68040_ONLY) \
224 fprintf ((FILE), "fdmov"); \
225 else fprintf ((FILE), "fmov"); } \
227 /* MOVE, MOVEA, MOVEQ, MOVEC ==> MOV */ \
228 else if ((PTR)[0] == 'm' && (PTR)[1] == 'o' \
229 && (PTR)[2] == 'v' && (PTR)[3] == 'e') \
230 { fprintf ((FILE), "mov"); (PTR) += 4; \
231 if ((PTR)[0] == 'q' || (PTR)[0] == 'a' \
232 || (PTR)[0] == 'c') (PTR)++; } \
233 /* SUB, SUBQ, SUBA, SUBI ==> SUB */ \
234 else if ((PTR)[0] == 's' && (PTR)[1] == 'u' \
235 && (PTR)[2] == 'b') \
236 { fprintf ((FILE), "sub"); (PTR) += 3; \
237 if ((PTR)[0] == 'q' || (PTR)[0] == 'i' \
238 || (PTR)[0] == 'a') (PTR)++; } \
239 /* CMP, CMPA, CMPI, CMPM ==> CMP */ \
240 else if ((PTR)[0] == 'c' && (PTR)[1] == 'm' \
241 && (PTR)[2] == 'p') \
242 { fprintf ((FILE), "cmp"); (PTR) += 3; \
243 if ((PTR)[0] == 'a' || (PTR)[0] == 'i' \
244 || (PTR)[0] == 'm') (PTR)++; } \
245 /* DIVSL ==> TDIVS */ \
246 else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
247 && (PTR)[2] == 'v' && (PTR)[3] == 's' \
248 && (PTR)[4] == 'l') \
249 { fprintf ((FILE), "tdivs"); (PTR) += 5; } \
250 /* DIVUL ==> TDIVU */ \
251 else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
252 && (PTR)[2] == 'v' && (PTR)[3] == 'u' \
253 && (PTR)[4] == 'l') \
254 { fprintf ((FILE), "tdivu"); (PTR) += 5; } \
257 #else /* not SGS_SWAP_W */
259 #define ASM_OUTPUT_OPCODE(FILE, PTR) \
261 extern int flag_pic; \
262 if (!strncmp ((PTR), "jbsr", 4)) \
263 { if (flag_pic) \
264 fprintf ((FILE), "bsr"); \
265 else \
266 fprintf ((FILE), "jsr"); \
267 (PTR) += 4; } \
268 else if ((PTR)[0] == 'j' && (PTR)[1] == 'b') \
269 { ++(PTR); \
270 while (*(PTR) != ' ') \
271 { putc (*(PTR), (FILE)); ++(PTR); } \
272 fprintf ((FILE), ".w"); } \
273 /* FMOVE ==> FMOV, (and F%& F%$ translations) */ \
274 else if ((PTR)[0] == 'f') \
276 if (!strncmp ((PTR), "fmove", 5)) \
277 { fprintf ((FILE), "fmov"); (PTR) += 5; } \
278 else if (!strncmp ((PTR), "ftst", 4)) \
279 { fprintf ((FILE), "ftest"); (PTR) += 4; } \
280 else if (!strncmp ((PTR), "fbne", 4)) \
281 { fprintf ((FILE), "fbneq"); (PTR) += 4; } \
282 else if (!strncmp ((PTR), "fsne", 4)) \
283 { fprintf ((FILE), "fsneq"); (PTR) += 4; } \
284 else if (!strncmp ((PTR), "f%$move", 7)) \
285 { (PTR) += 7; \
286 if (TARGET_68040_ONLY) \
287 fprintf ((FILE), "fsmov"); \
288 else fprintf ((FILE), "fmov"); } \
289 else if (!strncmp ((PTR), "f%&move", 7)) \
290 { (PTR) += 7; \
291 if (TARGET_68040_ONLY) \
292 fprintf ((FILE), "fdmov"); \
293 else fprintf ((FILE), "fmov"); } \
295 /* MOVE, MOVEA, MOVEQ, MOVEC ==> MOV */ \
296 else if ((PTR)[0] == 'm' && (PTR)[1] == 'o' \
297 && (PTR)[2] == 'v' && (PTR)[3] == 'e') \
298 { fprintf ((FILE), "mov"); (PTR) += 4; \
299 if ((PTR)[0] == 'q' || (PTR)[0] == 'a' \
300 || (PTR)[0] == 'c') (PTR)++; } \
301 /* SUB, SUBQ, SUBA, SUBI ==> SUB */ \
302 else if ((PTR)[0] == 's' && (PTR)[1] == 'u' \
303 && (PTR)[2] == 'b') \
304 { fprintf ((FILE), "sub"); (PTR) += 3; \
305 if ((PTR)[0] == 'q' || (PTR)[0] == 'i' \
306 || (PTR)[0] == 'a') (PTR)++; } \
307 /* CMP, CMPA, CMPI, CMPM ==> CMP */ \
308 else if ((PTR)[0] == 'c' && (PTR)[1] == 'm' \
309 && (PTR)[2] == 'p') \
310 { fprintf ((FILE), "cmp"); (PTR) += 3; \
311 if ((PTR)[0] == 'a' || (PTR)[0] == 'i' \
312 || (PTR)[0] == 'm') (PTR)++; } \
313 /* DIVSL ==> TDIVS */ \
314 else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
315 && (PTR)[2] == 'v' && (PTR)[3] == 's' \
316 && (PTR)[4] == 'l') \
317 { fprintf ((FILE), "tdivs"); (PTR) += 5; } \
318 /* DIVUL ==> TDIVU */ \
319 else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
320 && (PTR)[2] == 'v' && (PTR)[3] == 'u' \
321 && (PTR)[4] == 'l') \
322 { fprintf ((FILE), "tdivu"); (PTR) += 5; } \
325 #endif /* not SGS_SWAP_W */
327 /* This macro outputs the label at the start of a switch table. The
328 ".swbeg <N>" is an assembler directive that causes the switch table
329 size to be inserted into the object code so that disassemblers, for
330 example, can identify that it is the start of a switch table. */
332 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
333 fprintf ((FILE), "%s&%d\n", SWBEG_ASM_OP, XVECLEN (PATTERN (TABLE), 1));
335 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
336 do { \
337 ASM_OUTPUT_BEFORE_CASE_LABEL((FILE),(PREFIX),(NUM),(TABLE)); \
338 (*targetm.asm_out.internal_label)((FILE),(PREFIX),(NUM)); \
339 } while (0)
341 /* At end of a switch table, define LDnnn iff the symbol LInnn was defined.
342 Some SGS assemblers have a bug such that "Lnnn-LInnn-2.b(pc,d0.l*2)"
343 fails to assemble. Luckily "LDnnn(pc,d0.l*2)" produces the results
344 we want. This difference can be accommodated by making the assembler
345 define such "LDnnn" to be either "Lnnn-LInnn-2.b", "Lnnn", or any other
346 string, as necessary. This is accomplished via the ASM_OUTPUT_CASE_END
347 macro. */
349 #undef ASM_OUTPUT_CASE_END
350 #define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE) \
351 { if (switch_table_difference_label_flag) \
352 asm_fprintf (FILE, "%s%LLD%d,%LL%d-%LLI%d-2.b\n",\
353 SET_ASM_OP, (NUM), (NUM), (NUM)); \
354 switch_table_difference_label_flag = 0; }
356 extern int switch_table_difference_label_flag;
358 /* This is how to output an element of a case-vector that is relative. */
360 #undef ASM_OUTPUT_ADDR_DIFF_ELT
361 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
362 asm_fprintf (FILE, "%s%LL%d-%LL%d\n", integer_asm_op (2, TRUE), VALUE, REL)
364 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
365 keep switch tables in the text section. */
367 #define JUMP_TABLES_IN_TEXT_SECTION 1