FSF GCC merge 02/23/03
[official-gcc.git] / gcc / config / m68k / sgs.h
blobfb799bed6bdcfd1120225db473541b227a004b00
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 Free Software Foundation, Inc.
4 Written by Fred Fish (fnf@cygnus.com)
6 This file is part of GNU CC.
8 GNU CC 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 GNU CC 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 GNU CC; 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 /* Control assembler-syntax conditionals in m68k.md and conditionals in
24 m68k.h. Note that some systems may also require SGS_SWAP_W and/or
25 SGS_SWITCH_TABLES to be defined as well. */
27 #define MOTOROLA /* Use Motorola syntax rather than "MIT" */
28 #define SGS /* Uses SGS assembler */
29 #define SGS_CMP_ORDER /* Takes cmp operands in reverse order */
31 #include "m68k/m68k.h"
33 #undef INT_OP_GROUP
34 #define INT_OP_GROUP INT_OP_STANDARD
36 /* SGS specific assembler pseudo ops. */
38 #define SPACE_ASM_OP "\t.space "
39 #define ALIGN_ASM_OP "\t.align "
40 #undef GLOBAL_ASM_OP
41 #define GLOBAL_ASM_OP "\t.global "
42 #define SWBEG_ASM_OP "\t.swbeg "
43 #define SET_ASM_OP "\t.set "
45 #define ASM_PN_FORMAT "%s_%lu" /* Format for private names */
47 /* Here are four prefixes that are used by asm_fprintf to
48 facilitate customization for alternate assembler syntaxes.
49 Machines with no likelihood of an alternate syntax need not
50 define these and need not use asm_fprintf. */
52 /* The prefix for register names. Note that REGISTER_NAMES
53 is supposed to include this prefix. Also note that this is NOT an
54 fprintf format string, it is a literal string */
56 #undef REGISTER_PREFIX
57 #define REGISTER_PREFIX "%"
59 /* The prefix for local (compiler generated) labels.
60 These labels will not appear in the symbol table. */
62 #undef LOCAL_LABEL_PREFIX
63 #define LOCAL_LABEL_PREFIX "."
65 /* The prefix to add to user-visible assembler symbols. */
67 #undef USER_LABEL_PREFIX
68 #define USER_LABEL_PREFIX ""
70 /* The prefix for immediate operands. */
72 #undef IMMEDIATE_PREFIX
73 #define IMMEDIATE_PREFIX "&"
75 /* How to refer to registers in assembler output.
76 This sequence is indexed by compiler's hard-register-number.
77 Motorola format uses different register names than defined in m68k.h.
78 We also take this chance to convert 'a6' to 'fp' */
80 #undef REGISTER_NAMES
82 #ifndef SUPPORT_SUN_FPA
84 #define REGISTER_NAMES \
85 {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
86 "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp", \
87 "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7" }
89 #else /* SUPPORTED_SUN_FPA */
91 #define REGISTER_NAMES \
92 {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
93 "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp", \
94 "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7", \
95 "%fpa0", "%fpa1", "%fpa2", "%fpa3", "%fpa4", "%fpa5", "%fpa6","%fpa7", \
96 "%fpa8", "%fpa9", "%fpa10","%fpa11","%fpa12","%fpa13","%fpa14","%fpa15", \
97 "%fpa16","%fpa17","%fpa18","%fpa19","%fpa20","%fpa21","%fpa22","%fpa23", \
98 "%fpa24","%fpa25","%fpa26","%fpa27","%fpa28","%fpa29","%fpa30","%fpa31" }
100 #endif /* defined SUPPORT_SUN_FPA */
102 /* This is how to output an assembler line that says to advance the
103 location counter to a multiple of 2**LOG bytes. */
105 #undef ASM_OUTPUT_ALIGN
106 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
107 do { \
108 if ((LOG) > 0) \
109 fprintf ((FILE), "%s%u\n", ALIGN_ASM_OP, 1 << (LOG)); \
110 else if ((LOG) > 31) \
111 abort (); \
112 } while (0)
114 /* The routine used to output null terminated string literals. We cannot
115 use the ".string" pseudo op, because it silently truncates strings to
116 1023 bytes. There is no "partial string op" which works like ".string"
117 but doesn't append a null byte, so we can't chop the input string up
118 into small pieces and use that. Our only remaining alternative is to
119 output the string one byte at a time. */
121 #define ASM_OUTPUT_ASCII(FILE,PTR,LEN) \
122 do { \
123 register size_t sp = 0, limit = (LEN); \
124 fputs (integer_asm_op (1, TRUE), (FILE)); \
125 do { \
126 int ch = (PTR)[sp]; \
127 if (ch > ' ' && ! (ch & 0x80) && ch != '\\') \
129 fprintf ((FILE), "'%c", ch); \
131 else \
133 fprintf ((FILE), "0x%x", ch); \
135 if (++sp < limit) \
137 if ((sp % 10) == 0) \
139 fprintf ((FILE), "\n%s", integer_asm_op (1, TRUE)); \
141 else \
143 putc (',', (FILE)); \
146 } while (sp < limit); \
147 putc ('\n', (FILE)); \
148 } while (0)
151 /* SGS based assemblers don't understand #NO_APP and #APP, so just don't
152 bother emitting them. */
154 #undef ASM_APP_ON
155 #define ASM_APP_ON ""
157 #undef ASM_APP_OFF
158 #define ASM_APP_OFF ""
160 /* When using SGS derived assemblers, change the "MIT" or "MOTOROLA"
161 to "SGS/AT&T" */
163 #undef TARGET_VERSION
164 #define TARGET_VERSION fprintf (stderr, " (68k, SGS/AT&T syntax)");
166 /* Use proper assembler syntax for these macros. */
167 #undef ASM_OUTPUT_REG_PUSH
168 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \
169 asm_fprintf (FILE, "\t%Omove.l %s,-(%Rsp)\n", reg_names[REGNO])
171 #undef ASM_OUTPUT_REG_POP
172 #define ASM_OUTPUT_REG_POP(FILE,REGNO) \
173 asm_fprintf (FILE, "\t%Omove.l (%Rsp)+,%s\n", reg_names[REGNO])
175 #undef ASM_OUTPUT_FLOAT_OPERAND
176 #define ASM_OUTPUT_FLOAT_OPERAND(CODE,FILE,VALUE) \
177 do { long l; \
178 REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \
179 asm_fprintf ((FILE), "%I0x%lx", l); \
180 } while (0)
182 #undef ASM_OUTPUT_DOUBLE_OPERAND
183 #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE) \
184 do { long l[2]; \
185 REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \
186 asm_fprintf ((FILE), "%I0x%lx%08lx", l[0], l[1]);\
187 } while (0)
189 /* How to output a block of SIZE zero bytes. Note that the `space' pseudo,
190 when used in the text segment, causes SGS assemblers to output nop insns
191 rather than 0s, so we set ASM_NO_SKIP_IN_TEXT to prevent this. */
193 #define ASM_NO_SKIP_IN_TEXT 1
195 #undef ASM_OUTPUT_SKIP
196 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
197 fprintf (FILE, "%s%u\n", SPACE_ASM_OP, (SIZE))
199 /* Translate Motorola opcodes such as `jbeq' into SGS opcodes such
200 as `beq.w'.
201 Delete the `e' in `move...' and `fmove'.
202 Change `ftst' to `ftest'.
203 Change `fbne' to `fbneq'
204 Change `fsne' to `fsneq'
205 Change `divsl' to `tdivs' (32/32 -> 32r:32q)
206 Change `divul' to `tdivu' (32/32 -> 32r:32q)
207 Optionally change swap to swap.w.
210 #ifdef SGS_SWAP_W
211 #define ASM_OUTPUT_OPCODE(FILE, PTR) \
213 extern int flag_pic; \
214 if (!strncmp ((PTR), "jbsr", 4)) \
215 { if (flag_pic) \
216 fprintf ((FILE), "bsr"); \
217 else \
218 fprintf ((FILE), "jsr"); \
219 (PTR) += 4; } \
220 else if ((PTR)[0] == 'j' && (PTR)[1] == 'b') \
221 { ++(PTR); \
222 while (*(PTR) != ' ') \
223 { putc (*(PTR), (FILE)); ++(PTR); } \
224 fprintf ((FILE), ".w"); } \
225 else if ((PTR)[0] == 's') \
227 if (!strncmp ((PTR), "swap", 4)) \
228 { fprintf ((FILE), "swap.w"); (PTR) += 4; } \
230 /* FMOVE ==> FMOV, (and F%& F%$ translations) */ \
231 else if ((PTR)[0] == 'f') \
233 if (!strncmp ((PTR), "fmove", 5)) \
234 { fprintf ((FILE), "fmov"); (PTR) += 5; } \
235 else if (!strncmp ((PTR), "ftst", 4)) \
236 { fprintf ((FILE), "ftest"); (PTR) += 4; } \
237 else if (!strncmp ((PTR), "fbne", 4)) \
238 { fprintf ((FILE), "fbneq"); (PTR) += 4; } \
239 else if (!strncmp ((PTR), "fsne", 4)) \
240 { fprintf ((FILE), "fsneq"); (PTR) += 4; } \
241 else if (!strncmp ((PTR), "f%$move", 7)) \
242 { (PTR) += 7; \
243 if (TARGET_68040_ONLY) \
244 fprintf ((FILE), "fsmov"); \
245 else fprintf ((FILE), "fmov"); } \
246 else if (!strncmp ((PTR), "f%&move", 7)) \
247 { (PTR) += 7; \
248 if (TARGET_68040_ONLY) \
249 fprintf ((FILE), "fdmov"); \
250 else fprintf ((FILE), "fmov"); } \
252 /* MOVE, MOVEA, MOVEQ, MOVEC ==> MOV */ \
253 else if ((PTR)[0] == 'm' && (PTR)[1] == 'o' \
254 && (PTR)[2] == 'v' && (PTR)[3] == 'e') \
255 { fprintf ((FILE), "mov"); (PTR) += 4; \
256 if ((PTR)[0] == 'q' || (PTR)[0] == 'a' \
257 || (PTR)[0] == 'c') (PTR)++; } \
258 /* SUB, SUBQ, SUBA, SUBI ==> SUB */ \
259 else if ((PTR)[0] == 's' && (PTR)[1] == 'u' \
260 && (PTR)[2] == 'b') \
261 { fprintf ((FILE), "sub"); (PTR) += 3; \
262 if ((PTR)[0] == 'q' || (PTR)[0] == 'i' \
263 || (PTR)[0] == 'a') (PTR)++; } \
264 /* CMP, CMPA, CMPI, CMPM ==> CMP */ \
265 else if ((PTR)[0] == 'c' && (PTR)[1] == 'm' \
266 && (PTR)[2] == 'p') \
267 { fprintf ((FILE), "cmp"); (PTR) += 3; \
268 if ((PTR)[0] == 'a' || (PTR)[0] == 'i' \
269 || (PTR)[0] == 'm') (PTR)++; } \
270 /* DIVSL ==> TDIVS */ \
271 else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
272 && (PTR)[2] == 'v' && (PTR)[3] == 's' \
273 && (PTR)[4] == 'l') \
274 { fprintf ((FILE), "tdivs"); (PTR) += 5; } \
275 /* DIVUL ==> TDIVU */ \
276 else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
277 && (PTR)[2] == 'v' && (PTR)[3] == 'u' \
278 && (PTR)[4] == 'l') \
279 { fprintf ((FILE), "tdivu"); (PTR) += 5; } \
282 #else /* not SGS_SWAP_W */
284 #define ASM_OUTPUT_OPCODE(FILE, PTR) \
286 extern int flag_pic; \
287 if (!strncmp ((PTR), "jbsr", 4)) \
288 { if (flag_pic) \
289 fprintf ((FILE), "bsr"); \
290 else \
291 fprintf ((FILE), "jsr"); \
292 (PTR) += 4; } \
293 else if ((PTR)[0] == 'j' && (PTR)[1] == 'b') \
294 { ++(PTR); \
295 while (*(PTR) != ' ') \
296 { putc (*(PTR), (FILE)); ++(PTR); } \
297 fprintf ((FILE), ".w"); } \
298 /* FMOVE ==> FMOV, (and F%& F%$ translations) */ \
299 else if ((PTR)[0] == 'f') \
301 if (!strncmp ((PTR), "fmove", 5)) \
302 { fprintf ((FILE), "fmov"); (PTR) += 5; } \
303 else if (!strncmp ((PTR), "ftst", 4)) \
304 { fprintf ((FILE), "ftest"); (PTR) += 4; } \
305 else if (!strncmp ((PTR), "fbne", 4)) \
306 { fprintf ((FILE), "fbneq"); (PTR) += 4; } \
307 else if (!strncmp ((PTR), "fsne", 4)) \
308 { fprintf ((FILE), "fsneq"); (PTR) += 4; } \
309 else if (!strncmp ((PTR), "f%$move", 7)) \
310 { (PTR) += 7; \
311 if (TARGET_68040_ONLY) \
312 fprintf ((FILE), "fsmov"); \
313 else fprintf ((FILE), "fmov"); } \
314 else if (!strncmp ((PTR), "f%&move", 7)) \
315 { (PTR) += 7; \
316 if (TARGET_68040_ONLY) \
317 fprintf ((FILE), "fdmov"); \
318 else fprintf ((FILE), "fmov"); } \
320 /* MOVE, MOVEA, MOVEQ, MOVEC ==> MOV */ \
321 else if ((PTR)[0] == 'm' && (PTR)[1] == 'o' \
322 && (PTR)[2] == 'v' && (PTR)[3] == 'e') \
323 { fprintf ((FILE), "mov"); (PTR) += 4; \
324 if ((PTR)[0] == 'q' || (PTR)[0] == 'a' \
325 || (PTR)[0] == 'c') (PTR)++; } \
326 /* SUB, SUBQ, SUBA, SUBI ==> SUB */ \
327 else if ((PTR)[0] == 's' && (PTR)[1] == 'u' \
328 && (PTR)[2] == 'b') \
329 { fprintf ((FILE), "sub"); (PTR) += 3; \
330 if ((PTR)[0] == 'q' || (PTR)[0] == 'i' \
331 || (PTR)[0] == 'a') (PTR)++; } \
332 /* CMP, CMPA, CMPI, CMPM ==> CMP */ \
333 else if ((PTR)[0] == 'c' && (PTR)[1] == 'm' \
334 && (PTR)[2] == 'p') \
335 { fprintf ((FILE), "cmp"); (PTR) += 3; \
336 if ((PTR)[0] == 'a' || (PTR)[0] == 'i' \
337 || (PTR)[0] == 'm') (PTR)++; } \
338 /* DIVSL ==> TDIVS */ \
339 else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
340 && (PTR)[2] == 'v' && (PTR)[3] == 's' \
341 && (PTR)[4] == 'l') \
342 { fprintf ((FILE), "tdivs"); (PTR) += 5; } \
343 /* DIVUL ==> TDIVU */ \
344 else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
345 && (PTR)[2] == 'v' && (PTR)[3] == 'u' \
346 && (PTR)[4] == 'l') \
347 { fprintf ((FILE), "tdivu"); (PTR) += 5; } \
350 #endif /* not SGS_SWAP_W */
352 /* This macro outputs the label at the start of a switch table. The
353 ".swbeg <N>" is an assembler directive that causes the switch table
354 size to be inserted into the object code so that disassemblers, for
355 example, can identify that it is the start of a switch table. */
357 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
358 fprintf ((FILE), "%s&%d\n", SWBEG_ASM_OP, XVECLEN (PATTERN (TABLE), 1));
360 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
361 do { \
362 ASM_OUTPUT_BEFORE_CASE_LABEL((FILE),(PREFIX),(NUM),(TABLE)); \
363 (*targetm.asm_out.internal_label)((FILE),(PREFIX),(NUM)); \
364 } while (0)
366 /* At end of a switch table, define LDnnn iff the symbol LInnn was defined.
367 Some SGS assemblers have a bug such that "Lnnn-LInnn-2.b(pc,d0.l*2)"
368 fails to assemble. Luckily "LDnnn(pc,d0.l*2)" produces the results
369 we want. This difference can be accommodated by making the assembler
370 define such "LDnnn" to be either "Lnnn-LInnn-2.b", "Lnnn", or any other
371 string, as necessary. This is accomplished via the ASM_OUTPUT_CASE_END
372 macro. */
374 #undef ASM_OUTPUT_CASE_END
375 #define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE) \
376 { if (switch_table_difference_label_flag) \
377 asm_fprintf (FILE, "%s%LLD%d,%LL%d-%LLI%d-2.b\n",\
378 SET_ASM_OP, (NUM), (NUM), (NUM)); \
379 switch_table_difference_label_flag = 0; }
381 extern int switch_table_difference_label_flag;
383 /* This is how to output an element of a case-vector that is relative. */
385 #undef ASM_OUTPUT_ADDR_DIFF_ELT
386 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
387 asm_fprintf (FILE, "%s%LL%d-%LL%d\n", integer_asm_op (2, TRUE), VALUE, REL)
389 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
390 keep switch tables in the text section. */
392 #define JUMP_TABLES_IN_TEXT_SECTION 1