* target.h (asm_out.byte_op, asm_out.aligned_op, asm_out.unaligned_op,
[official-gcc.git] / gcc / config / m68k / sgs.h
blob7f44b2682093cde5e9c1080c6ddcc9daa3f27620
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_%d" /* 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 defining an `int' constant. */
103 /* The SGS assembler doesn't understand ".word". */
105 #undef ASM_OUTPUT_LONG_DOUBLE
106 #define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \
107 do { long l[3]; \
108 REAL_VALUE_TO_TARGET_LONG_DOUBLE (VALUE, l); \
109 fprintf ((FILE), "%s0x%lx,0x%lx,0x%lx\n", \
110 integer_asm_op (4, TRUE), l[0], l[1], l[2]); \
111 } while (0)
113 /* This is how to output an assembler line defining a `double' constant. */
115 #undef ASM_OUTPUT_DOUBLE
116 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
117 do { long l[2]; \
118 REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \
119 fprintf ((FILE), "%s0x%lx,0x%lx\n", \
120 integer_asm_op (4, TRUE), l[0], l[1]); \
121 } while (0)
123 /* This is how to output an assembler line defining a `float' constant. */
125 #undef ASM_OUTPUT_FLOAT
126 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
127 do { long l; \
128 REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \
129 assemble_aligned_integer (4, GEN_INT (l)); \
130 } while (0)
132 /* This is how to output an assembler line that says to advance the
133 location counter to a multiple of 2**LOG bytes. */
135 #undef ASM_OUTPUT_ALIGN
136 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
137 do { \
138 if ((LOG) > 0) \
139 fprintf ((FILE), "%s%u\n", ALIGN_ASM_OP, 1 << (LOG)); \
140 else if ((LOG) > 31) \
141 abort (); \
142 } while (0)
144 /* The routine used to output null terminated string literals. We cannot
145 use the ".string" pseudo op, because it silently truncates strings to
146 1023 bytes. There is no "partial string op" which works like ".string"
147 but doesn't append a null byte, so we can't chop the input string up
148 into small pieces and use that. Our only remaining alternative is to
149 output the string one byte at a time. */
151 #define ASM_OUTPUT_ASCII(FILE,PTR,LEN) \
152 do { \
153 register size_t sp = 0, limit = (LEN); \
154 fputs (integer_asm_op (1, TRUE), (FILE)); \
155 do { \
156 int ch = (PTR)[sp]; \
157 if (ch > ' ' && ! (ch & 0x80) && ch != '\\') \
159 fprintf ((FILE), "'%c", ch); \
161 else \
163 fprintf ((FILE), "0x%x", ch); \
165 if (++sp < limit) \
167 if ((sp % 10) == 0) \
169 fprintf ((FILE), "\n%s", integer_asm_op (1, TRUE)); \
171 else \
173 putc (',', (FILE)); \
176 } while (sp < limit); \
177 putc ('\n', (FILE)); \
178 } while (0)
181 /* SGS based assemblers don't understand #NO_APP and #APP, so just don't
182 bother emitting them. */
184 #undef ASM_APP_ON
185 #define ASM_APP_ON ""
187 #undef ASM_APP_OFF
188 #define ASM_APP_OFF ""
190 /* When using SGS derived assemblers, change the "MIT" or "MOTOROLA"
191 to "SGS/AT&T" */
193 #undef TARGET_VERSION
194 #define TARGET_VERSION fprintf (stderr, " (68k, SGS/AT&T syntax)");
196 /* Use proper assembler syntax for these macros. */
197 #undef ASM_OUTPUT_REG_PUSH
198 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \
199 asm_fprintf (FILE, "\t%Omove.l %s,-(%Rsp)\n", reg_names[REGNO])
201 #undef ASM_OUTPUT_REG_POP
202 #define ASM_OUTPUT_REG_POP(FILE,REGNO) \
203 asm_fprintf (FILE, "\t%Omove.l (%Rsp)+,%s\n", reg_names[REGNO])
205 #undef ASM_OUTPUT_FLOAT_OPERAND
206 #define ASM_OUTPUT_FLOAT_OPERAND(CODE,FILE,VALUE) \
207 do { long l; \
208 REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \
209 asm_fprintf ((FILE), "%I0x%lx", l); \
210 } while (0)
212 #undef ASM_OUTPUT_DOUBLE_OPERAND
213 #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE) \
214 do { long l[2]; \
215 REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \
216 asm_fprintf ((FILE), "%I0x%lx%08lx", l[0], l[1]);\
217 } while (0)
219 /* How to output a block of SIZE zero bytes. Note that the `space' pseudo,
220 when used in the text segment, causes SGS assemblers to output nop insns
221 rather than 0s, so we set ASM_NO_SKIP_IN_TEXT to prevent this. */
223 #define ASM_NO_SKIP_IN_TEXT 1
225 #undef ASM_OUTPUT_SKIP
226 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
227 fprintf (FILE, "%s%u\n", SPACE_ASM_OP, (SIZE))
229 /* Translate Motorola opcodes such as `jbeq' into SGS opcodes such
230 as `beq.w'.
231 Delete the `e' in `move...' and `fmove'.
232 Change `ftst' to `ftest'.
233 Change `fbne' to `fbneq'
234 Change `fsne' to `fsneq'
235 Change `divsl' to `tdivs' (32/32 -> 32r:32q)
236 Change `divul' to `tdivu' (32/32 -> 32r:32q)
237 Optionally change swap to swap.w.
240 #ifdef SGS_SWAP_W
241 #define ASM_OUTPUT_OPCODE(FILE, PTR) \
243 extern int flag_pic; \
244 if (!strncmp ((PTR), "jbsr", 4)) \
245 { if (flag_pic) \
246 fprintf ((FILE), "bsr"); \
247 else \
248 fprintf ((FILE), "jsr"); \
249 (PTR) += 4; } \
250 else if ((PTR)[0] == 'j' && (PTR)[1] == 'b') \
251 { ++(PTR); \
252 while (*(PTR) != ' ') \
253 { putc (*(PTR), (FILE)); ++(PTR); } \
254 fprintf ((FILE), ".w"); } \
255 else if ((PTR)[0] == 's') \
257 if (!strncmp ((PTR), "swap", 4)) \
258 { fprintf ((FILE), "swap.w"); (PTR) += 4; } \
260 /* FMOVE ==> FMOV, (and F%& F%$ translations) */ \
261 else if ((PTR)[0] == 'f') \
263 if (!strncmp ((PTR), "fmove", 5)) \
264 { fprintf ((FILE), "fmov"); (PTR) += 5; } \
265 else if (!strncmp ((PTR), "ftst", 4)) \
266 { fprintf ((FILE), "ftest"); (PTR) += 4; } \
267 else if (!strncmp ((PTR), "fbne", 4)) \
268 { fprintf ((FILE), "fbneq"); (PTR) += 4; } \
269 else if (!strncmp ((PTR), "fsne", 4)) \
270 { fprintf ((FILE), "fsneq"); (PTR) += 4; } \
271 else if (!strncmp ((PTR), "f%$move", 7)) \
272 { (PTR) += 7; \
273 if (TARGET_68040_ONLY) \
274 fprintf ((FILE), "fsmov"); \
275 else fprintf ((FILE), "fmov"); } \
276 else if (!strncmp ((PTR), "f%&move", 7)) \
277 { (PTR) += 7; \
278 if (TARGET_68040_ONLY) \
279 fprintf ((FILE), "fdmov"); \
280 else fprintf ((FILE), "fmov"); } \
282 /* MOVE, MOVEA, MOVEQ, MOVEC ==> MOV */ \
283 else if ((PTR)[0] == 'm' && (PTR)[1] == 'o' \
284 && (PTR)[2] == 'v' && (PTR)[3] == 'e') \
285 { fprintf ((FILE), "mov"); (PTR) += 4; \
286 if ((PTR)[0] == 'q' || (PTR)[0] == 'a' \
287 || (PTR)[0] == 'c') (PTR)++; } \
288 /* SUB, SUBQ, SUBA, SUBI ==> SUB */ \
289 else if ((PTR)[0] == 's' && (PTR)[1] == 'u' \
290 && (PTR)[2] == 'b') \
291 { fprintf ((FILE), "sub"); (PTR) += 3; \
292 if ((PTR)[0] == 'q' || (PTR)[0] == 'i' \
293 || (PTR)[0] == 'a') (PTR)++; } \
294 /* CMP, CMPA, CMPI, CMPM ==> CMP */ \
295 else if ((PTR)[0] == 'c' && (PTR)[1] == 'm' \
296 && (PTR)[2] == 'p') \
297 { fprintf ((FILE), "cmp"); (PTR) += 3; \
298 if ((PTR)[0] == 'a' || (PTR)[0] == 'i' \
299 || (PTR)[0] == 'm') (PTR)++; } \
300 /* DIVSL ==> TDIVS */ \
301 else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
302 && (PTR)[2] == 'v' && (PTR)[3] == 's' \
303 && (PTR)[4] == 'l') \
304 { fprintf ((FILE), "tdivs"); (PTR) += 5; } \
305 /* DIVUL ==> TDIVU */ \
306 else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
307 && (PTR)[2] == 'v' && (PTR)[3] == 'u' \
308 && (PTR)[4] == 'l') \
309 { fprintf ((FILE), "tdivu"); (PTR) += 5; } \
312 #else /* not SGS_SWAP_W */
314 #define ASM_OUTPUT_OPCODE(FILE, PTR) \
316 extern int flag_pic; \
317 if (!strncmp ((PTR), "jbsr", 4)) \
318 { if (flag_pic) \
319 fprintf ((FILE), "bsr"); \
320 else \
321 fprintf ((FILE), "jsr"); \
322 (PTR) += 4; } \
323 else if ((PTR)[0] == 'j' && (PTR)[1] == 'b') \
324 { ++(PTR); \
325 while (*(PTR) != ' ') \
326 { putc (*(PTR), (FILE)); ++(PTR); } \
327 fprintf ((FILE), ".w"); } \
328 /* FMOVE ==> FMOV, (and F%& F%$ translations) */ \
329 else if ((PTR)[0] == 'f') \
331 if (!strncmp ((PTR), "fmove", 5)) \
332 { fprintf ((FILE), "fmov"); (PTR) += 5; } \
333 else if (!strncmp ((PTR), "ftst", 4)) \
334 { fprintf ((FILE), "ftest"); (PTR) += 4; } \
335 else if (!strncmp ((PTR), "fbne", 4)) \
336 { fprintf ((FILE), "fbneq"); (PTR) += 4; } \
337 else if (!strncmp ((PTR), "fsne", 4)) \
338 { fprintf ((FILE), "fsneq"); (PTR) += 4; } \
339 else if (!strncmp ((PTR), "f%$move", 7)) \
340 { (PTR) += 7; \
341 if (TARGET_68040_ONLY) \
342 fprintf ((FILE), "fsmov"); \
343 else fprintf ((FILE), "fmov"); } \
344 else if (!strncmp ((PTR), "f%&move", 7)) \
345 { (PTR) += 7; \
346 if (TARGET_68040_ONLY) \
347 fprintf ((FILE), "fdmov"); \
348 else fprintf ((FILE), "fmov"); } \
350 /* MOVE, MOVEA, MOVEQ, MOVEC ==> MOV */ \
351 else if ((PTR)[0] == 'm' && (PTR)[1] == 'o' \
352 && (PTR)[2] == 'v' && (PTR)[3] == 'e') \
353 { fprintf ((FILE), "mov"); (PTR) += 4; \
354 if ((PTR)[0] == 'q' || (PTR)[0] == 'a' \
355 || (PTR)[0] == 'c') (PTR)++; } \
356 /* SUB, SUBQ, SUBA, SUBI ==> SUB */ \
357 else if ((PTR)[0] == 's' && (PTR)[1] == 'u' \
358 && (PTR)[2] == 'b') \
359 { fprintf ((FILE), "sub"); (PTR) += 3; \
360 if ((PTR)[0] == 'q' || (PTR)[0] == 'i' \
361 || (PTR)[0] == 'a') (PTR)++; } \
362 /* CMP, CMPA, CMPI, CMPM ==> CMP */ \
363 else if ((PTR)[0] == 'c' && (PTR)[1] == 'm' \
364 && (PTR)[2] == 'p') \
365 { fprintf ((FILE), "cmp"); (PTR) += 3; \
366 if ((PTR)[0] == 'a' || (PTR)[0] == 'i' \
367 || (PTR)[0] == 'm') (PTR)++; } \
368 /* DIVSL ==> TDIVS */ \
369 else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
370 && (PTR)[2] == 'v' && (PTR)[3] == 's' \
371 && (PTR)[4] == 'l') \
372 { fprintf ((FILE), "tdivs"); (PTR) += 5; } \
373 /* DIVUL ==> TDIVU */ \
374 else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
375 && (PTR)[2] == 'v' && (PTR)[3] == 'u' \
376 && (PTR)[4] == 'l') \
377 { fprintf ((FILE), "tdivu"); (PTR) += 5; } \
380 #endif /* not SGS_SWAP_W */
382 /* This macro outputs the label at the start of a switch table. The
383 ".swbeg <N>" is an assembler directive that causes the switch table
384 size to be inserted into the object code so that disassemblers, for
385 example, can identify that it is the start of a switch table. */
387 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
388 fprintf ((FILE), "%s&%d\n", SWBEG_ASM_OP, XVECLEN (PATTERN (TABLE), 1));
390 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
391 do { \
392 ASM_OUTPUT_BEFORE_CASE_LABEL((FILE),(PREFIX),(NUM),(TABLE)); \
393 ASM_OUTPUT_INTERNAL_LABEL((FILE),(PREFIX),(NUM)); \
394 } while (0)
396 /* At end of a switch table, define LDnnn iff the symbol LInnn was defined.
397 Some SGS assemblers have a bug such that "Lnnn-LInnn-2.b(pc,d0.l*2)"
398 fails to assemble. Luckily "LDnnn(pc,d0.l*2)" produces the results
399 we want. This difference can be accommodated by making the assembler
400 define such "LDnnn" to be either "Lnnn-LInnn-2.b", "Lnnn", or any other
401 string, as necessary. This is accomplished via the ASM_OUTPUT_CASE_END
402 macro. */
404 #undef ASM_OUTPUT_CASE_END
405 #define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE) \
406 { if (switch_table_difference_label_flag) \
407 asm_fprintf (FILE, "%s%LLD%d,%LL%d-%LLI%d-2.b\n",\
408 SET_ASM_OP, (NUM), (NUM), (NUM)); \
409 switch_table_difference_label_flag = 0; }
411 extern int switch_table_difference_label_flag;
413 /* This is how to output an element of a case-vector that is relative. */
415 #undef ASM_OUTPUT_ADDR_DIFF_ELT
416 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
417 asm_fprintf (FILE, "%s%LL%d-%LL%d\n", integer_asm_op (2, TRUE), VALUE, REL)
419 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
420 keep switch tables in the text section. */
422 #define JUMP_TABLES_IN_TEXT_SECTION 1
424 /* Store in OUTPUT a string (made with alloca) containing
425 an assembler-name for a local static variable named NAME.
426 LABELNO is an integer which is different for each call. */
428 #undef ASM_FORMAT_PRIVATE_NAME
429 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
430 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
431 sprintf ((OUTPUT), ASM_PN_FORMAT, (NAME), (LABELNO)))