|
|
1.1 root 1: /* Definitions of target machine for GNU compiler for m68k targets using
2: assemblers derived from AT&T "SGS" releases.
3:
4: Copyright (C) 1991, 1993 Free Software Foundation, Inc.
5:
6: Written by Fred Fish ([email protected])
7:
8: This file is part of GNU CC.
9:
10: GNU CC is free software; you can redistribute it and/or modify
11: it under the terms of the GNU General Public License as published by
12: the Free Software Foundation; either version 1, or (at your option)
13: any later version.
14:
15: GNU CC is distributed in the hope that it will be useful,
16: but WITHOUT ANY WARRANTY; without even the implied warranty of
17: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: GNU General Public License for more details.
19:
20: You should have received a copy of the GNU General Public License
21: along with GNU CC; see the file COPYING. If not, write to
22: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
23:
24: /* Control assembler-syntax conditionals in m68k.md and conditionals in
25: m68k.h. Note that some systems may also require SGS_SWAP_W and/or
26: SGS_SWITCH_TABLES to be defined as well. */
27:
28: #define MOTOROLA /* Use Motorola syntax rather than "MIT" */
29: #define SGS /* Uses SGS assembler */
30: #define SGS_CMP_ORDER /* Takes cmp operands in reverse order */
31:
32: #include "m68k/m68k.h"
33:
34: /* SGS specific assembler pseudo ops. */
35:
36: #define BYTE_ASM_OP ".byte"
37: #define WORD_ASM_OP ".short"
38: #define LONG_ASM_OP ".long"
39: #define SPACE_ASM_OP ".space"
40: #define ALIGN_ASM_OP ".align"
41: #undef GLOBAL_ASM_OP
42: #define GLOBAL_ASM_OP ".global"
43: #define SWBEG_ASM_OP ".swbeg"
44: #define SET_ASM_OP ".set"
45:
46: #define UNALIGNED_SHORT_ASM_OP ".short" /* Used in dwarfout.c */
47: #define UNALIGNED_INT_ASM_OP ".long" /* Used in dwarfout.c */
48:
49: #define ASM_PN_FORMAT "%s_%d" /* Format for private names */
50:
51: /* Here are four prefixes that are used by asm_fprintf to
52: facilitate customization for alternate assembler syntaxes.
53: Machines with no likelihood of an alternate syntax need not
54: define these and need not use asm_fprintf. */
55:
56: /* The prefix for register names. Note that REGISTER_NAMES
57: is supposed to include this prefix. Also note that this is NOT an
58: fprintf format string, it is a literal string */
59:
60: #undef REGISTER_PREFIX
61: #define REGISTER_PREFIX "%"
62:
63: /* The prefix for local (compiler generated) labels.
64: These labels will not appear in the symbol table. */
65:
66: #undef LOCAL_LABEL_PREFIX
67: #define LOCAL_LABEL_PREFIX "."
68:
69: /* The prefix to add to user-visible assembler symbols. */
70:
71: #undef USER_LABEL_PREFIX
72: #define USER_LABEL_PREFIX ""
73:
74: /* The prefix for immediate operands. */
75:
76: #undef IMMEDIATE_PREFIX
77: #define IMMEDIATE_PREFIX "&"
78:
79: /* How to refer to registers in assembler output.
80: This sequence is indexed by compiler's hard-register-number.
81: Motorola format uses different register names than defined in m68k.h.
82: We also take this chance to convert 'a6' to 'fp' */
83:
84: #undef REGISTER_NAMES
85:
86: #ifndef SUPPORT_SUN_FPA
87:
88: #define REGISTER_NAMES \
89: {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
90: "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp", \
91: "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7" }
92:
93: #else /* SUPPORTED_SUN_FPA */
94:
95: #define REGISTER_NAMES \
96: {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
97: "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp", \
98: "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7", \
99: "%fpa0", "%fpa1", "%fpa2", "%fpa3", "%fpa4", "%fpa5", "%fpa6","%fpa7", \
100: "%fpa8", "%fpa9", "%fpa10","%fpa11","%fpa12","%fpa13","%fpa14","%fpa15", \
101: "%fpa16","%fpa17","%fpa18","%fpa19","%fpa20","%fpa21","%fpa22","%fpa23", \
102: "%fpa24","%fpa25","%fpa26","%fpa27","%fpa28","%fpa29","%fpa30","%fpa31" }
103:
104: #endif /* defined SUPPORT_SUN_FPA */
105:
106: /* When using an SGS assembler, modify the name of the artificial label which
107: identifies this file as having been compiled with gcc, and the macro that
108: emits such a label in the assembly output, to use '%' rather than '.' */
109:
110: #define ASM_IDENTIFY_GCC(FILE) \
111: { fprintf ((FILE), "%s:\n", "gcc2_compiled%"); }
112:
113: /* This is how to output an assembler line defining an `int' constant. */
114: /* The SGS assembler doesn't understand ".word". */
115:
116: #undef ASM_OUTPUT_SHORT
117: #define ASM_OUTPUT_SHORT(FILE,VALUE) \
118: ( fprintf ((FILE), "\t%s ", WORD_ASM_OP), \
119: output_addr_const ((FILE), (VALUE)), \
120: fprintf ((FILE), "\n"))
121:
122: #undef ASM_OUTPUT_LONG_DOUBLE
123: #define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \
124: do { long l[3]; \
125: REAL_VALUE_TO_TARGET_LONG_DOUBLE (VALUE, l); \
126: fprintf ((FILE), "\t%s 0x%x,0x%x,0x%x\n", LONG_ASM_OP, \
127: l[0], l[1], l[2]); \
128: } while (0)
129:
130: /* This is how to output an assembler line defining a `double' constant. */
131:
132: #undef ASM_OUTPUT_DOUBLE
133: #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
134: do { long l[2]; \
135: REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \
136: fprintf ((FILE), "\t%s 0x%x,0x%x\n", LONG_ASM_OP, \
137: l[0], l[1]); \
138: } while (0)
139:
140: /* This is how to output an assembler line defining a `float' constant. */
141:
142: #undef ASM_OUTPUT_FLOAT
143: #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
144: do { long l; \
145: REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \
146: fprintf ((FILE), "\t%s 0x%x\n", LONG_ASM_OP, l); \
147: } while (0)
148:
149: /* This is how to output an assembler line that says to advance the
150: location counter to a multiple of 2**LOG bytes. */
151:
152: #undef ASM_OUTPUT_ALIGN
153: #define ASM_OUTPUT_ALIGN(FILE,LOG) \
154: if ((LOG) > 0) \
155: fprintf ((FILE), "\t%s \t%u\n", ALIGN_ASM_OP, 1 << (LOG)); \
156: else if ((LOG) > 31) \
157: abort ();
158:
159: /* The routine used to output null terminated string literals. We cannot
160: use the ".string" pseudo op, because it silently truncates strings to
161: 1023 bytes. There is no "partial string op" which works like ".string"
162: but doesn't append a null byte, so we can't chop the input string up
163: into small pieces and use that. Our only remaining alternative is to
164: output the string one byte at a time. */
165:
166: #define ASM_OUTPUT_ASCII(FILE,PTR,LEN) \
167: { \
168: register int sp = 0, lp = 0, ch; \
169: fprintf ((FILE), "\t%s ", BYTE_ASM_OP); \
170: do { \
171: ch = (PTR)[sp]; \
172: if (ch > ' ' && ! (ch & 0x80) && ch != '\\') \
173: { \
174: fprintf ((FILE), "'%c", ch); \
175: } \
176: else \
177: { \
178: fprintf ((FILE), "0x%x", ch); \
179: } \
180: if (++sp < (LEN)) \
181: { \
182: if ((sp % 10) == 0) \
183: { \
184: fprintf ((FILE), "\n\t%s ", BYTE_ASM_OP); \
185: } \
186: else \
187: { \
188: putc (',', (FILE)); \
189: } \
190: } \
191: } while (sp < (LEN)); \
192: putc ('\n', (FILE)); \
193: }
194:
195:
196: /* SGS based assemblers don't understand #NO_APP and #APP, so just don't
197: bother emitting them. */
198:
199: #undef ASM_APP_ON
200: #define ASM_APP_ON ""
201:
202: #undef ASM_APP_OFF
203: #define ASM_APP_OFF ""
204:
205: /* When using SGS derived assemblers, change the "MIT" or "MOTOROLA"
206: to "SGS/AT&T" */
207:
208: #undef TARGET_VERSION
209: #define TARGET_VERSION fprintf (stderr, " (68k, SGS/AT&T syntax)");
210:
211: /* Use proper assembler syntax for these macros. */
212: #undef ASM_OUTPUT_REG_PUSH
213: #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \
214: asm_fprintf (FILE, "\t%Omove.l %s,-(%Rsp)\n", reg_names[REGNO])
215:
216: #undef ASM_OUTPUT_REG_POP
217: #define ASM_OUTPUT_REG_POP(FILE,REGNO) \
218: asm_fprintf (FILE, "\t%Omove.l (%Rsp)+,%s\n", reg_names[REGNO])
219:
220: #undef ASM_OUTPUT_FLOAT_OPERAND
221: #define ASM_OUTPUT_FLOAT_OPERAND(CODE,FILE,VALUE) \
222: do { long l; \
223: REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \
224: asm_fprintf ((FILE), "%I0x%x", l); \
225: } while (0)
226:
227: #undef ASM_OUTPUT_DOUBLE_OPERAND
228: #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE) \
229: do { long l[2]; \
230: REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \
231: asm_fprintf ((FILE), "%I0x%x%08x", l[0], l[1]); \
232: } while (0)
233:
234: /* How to output a block of SIZE zero bytes. Note that the `space' pseudo,
235: when used in the text segment, causes SGS assemblers to output nop insns
236: rather than 0s, so we set ASM_NO_SKIP_IN_TEXT to prevent this. */
237:
238: #define ASM_NO_SKIP_IN_TEXT 1
239:
240: #undef ASM_OUTPUT_SKIP
241: #define ASM_OUTPUT_SKIP(FILE,SIZE) \
242: fprintf (FILE, "\t%s %u\n", SPACE_ASM_OP, (SIZE))
243:
244: /* Translate Motorola opcodes such as `jbeq' into SGS opcodes such
245: as `beq.w'.
246: Delete the `e' in `move...' and `fmove'.
247: Change `ftst' to `ftest'.
248: Change `fbne' to `fbneq'
249: Change `fsne' to `fsneq'
250: Change `divsl' to `tdivs' (32/32 -> 32r:32q)
251: Change `divul' to `tdivu' (32/32 -> 32r:32q)
252: Optionally change swap to swap.w.
253: */
254:
255: #ifdef SGS_SWAP_W
256: #define ASM_OUTPUT_OPCODE(FILE, PTR) \
257: { \
258: extern int flag_pic; \
259: if (!strncmp ((PTR), "jbsr", 4)) \
260: { if (flag_pic) \
261: fprintf ((FILE), "bsr"); \
262: else \
263: fprintf ((FILE), "jsr"); \
264: (PTR) += 4; } \
265: else if ((PTR)[0] == 'j' && (PTR)[1] == 'b') \
266: { ++(PTR); \
267: while (*(PTR) != ' ') \
268: { putc (*(PTR), (FILE)); ++(PTR); } \
269: fprintf ((FILE), ".w"); } \
270: else if ((PTR)[0] == 's') \
271: { \
272: if (!strncmp ((PTR), "swap", 4)) \
273: { fprintf ((FILE), "swap.w"); (PTR) += 4; } \
274: } \
275: /* FMOVE ==> FMOV, (and F%& F%$ translations) */ \
276: else if ((PTR)[0] == 'f') \
277: { \
278: if (!strncmp ((PTR), "fmove", 5)) \
279: { fprintf ((FILE), "fmov"); (PTR) += 5; } \
280: else if (!strncmp ((PTR), "ftst", 4)) \
281: { fprintf ((FILE), "ftest"); (PTR) += 4; } \
282: else if (!strncmp ((PTR), "fbne", 4)) \
283: { fprintf ((FILE), "fbneq"); (PTR) += 4; } \
284: else if (!strncmp ((PTR), "fsne", 4)) \
285: { fprintf ((FILE), "fsneq"); (PTR) += 4; } \
286: else if (!strncmp ((PTR), "f%$move", 7)) \
287: { (PTR) += 7; \
288: if (TARGET_68040_ONLY) \
289: fprintf ((FILE), "fsmov"); \
290: else fprintf ((FILE), "fmov"); } \
291: else if (!strncmp ((PTR), "f%&move", 7)) \
292: { (PTR) += 7; \
293: if (TARGET_68040_ONLY) \
294: fprintf ((FILE), "fdmov"); \
295: else fprintf ((FILE), "fmov"); } \
296: } \
297: /* MOVE, MOVEA, MOVEQ, MOVEC ==> MOV */ \
298: else if ((PTR)[0] == 'm' && (PTR)[1] == 'o' \
299: && (PTR)[2] == 'v' && (PTR)[3] == 'e') \
300: { fprintf ((FILE), "mov"); (PTR) += 4; \
301: if ((PTR)[0] == 'q' || (PTR)[0] == 'a' \
302: || (PTR)[0] == 'c') (PTR)++; } \
303: /* SUB, SUBQ, SUBA, SUBI ==> SUB */ \
304: else if ((PTR)[0] == 's' && (PTR)[1] == 'u' \
305: && (PTR)[2] == 'b') \
306: { fprintf ((FILE), "sub"); (PTR) += 3; \
307: if ((PTR)[0] == 'q' || (PTR)[0] == 'i' \
308: || (PTR)[0] == 'a') (PTR)++; } \
309: /* CMP, CMPA, CMPI, CMPM ==> CMP */ \
310: else if ((PTR)[0] == 'c' && (PTR)[1] == 'm' \
311: && (PTR)[2] == 'p') \
312: { fprintf ((FILE), "cmp"); (PTR) += 3; \
313: if ((PTR)[0] == 'a' || (PTR)[0] == 'i' \
314: || (PTR)[0] == 'm') (PTR)++; } \
315: /* DIVSL ==> TDIVS */ \
316: else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
317: && (PTR)[2] == 'v' && (PTR)[3] == 's' \
318: && (PTR)[4] == 'l') \
319: { fprintf ((FILE), "tdivs"); (PTR) += 5; } \
320: /* DIVUL ==> TDIVU */ \
321: else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
322: && (PTR)[2] == 'v' && (PTR)[3] == 'u' \
323: && (PTR)[4] == 'l') \
324: { fprintf ((FILE), "tdivu"); (PTR) += 5; } \
325: }
326:
327: #else /* not SGS_SWAP_W */
328:
329: #define ASM_OUTPUT_OPCODE(FILE, PTR) \
330: { \
331: extern int flag_pic; \
332: if (!strncmp ((PTR), "jbsr", 4)) \
333: { if (flag_pic) \
334: fprintf ((FILE), "bsr"); \
335: else \
336: fprintf ((FILE), "jsr"); \
337: (PTR) += 4; } \
338: else if ((PTR)[0] == 'j' && (PTR)[1] == 'b') \
339: { ++(PTR); \
340: while (*(PTR) != ' ') \
341: { putc (*(PTR), (FILE)); ++(PTR); } \
342: fprintf ((FILE), ".w"); } \
343: /* FMOVE ==> FMOV, (and F%& F%$ translations) */ \
344: else if ((PTR)[0] == 'f') \
345: { \
346: if (!strncmp ((PTR), "fmove", 5)) \
347: { fprintf ((FILE), "fmov"); (PTR) += 5; } \
348: else if (!strncmp ((PTR), "ftst", 4)) \
349: { fprintf ((FILE), "ftest"); (PTR) += 4; } \
350: else if (!strncmp ((PTR), "fbne", 4)) \
351: { fprintf ((FILE), "fbneq"); (PTR) += 4; } \
352: else if (!strncmp ((PTR), "fsne", 4)) \
353: { fprintf ((FILE), "fsneq"); (PTR) += 4; } \
354: else if (!strncmp ((PTR), "f%$move", 7)) \
355: { (PTR) += 7; \
356: if (TARGET_68040_ONLY) \
357: fprintf ((FILE), "fsmov"); \
358: else fprintf ((FILE), "fmov"); } \
359: else if (!strncmp ((PTR), "f%&move", 7)) \
360: { (PTR) += 7; \
361: if (TARGET_68040_ONLY) \
362: fprintf ((FILE), "fdmov"); \
363: else fprintf ((FILE), "fmov"); } \
364: } \
365: /* MOVE, MOVEA, MOVEQ, MOVEC ==> MOV */ \
366: else if ((PTR)[0] == 'm' && (PTR)[1] == 'o' \
367: && (PTR)[2] == 'v' && (PTR)[3] == 'e') \
368: { fprintf ((FILE), "mov"); (PTR) += 4; \
369: if ((PTR)[0] == 'q' || (PTR)[0] == 'a' \
370: || (PTR)[0] == 'c') (PTR)++; } \
371: /* SUB, SUBQ, SUBA, SUBI ==> SUB */ \
372: else if ((PTR)[0] == 's' && (PTR)[1] == 'u' \
373: && (PTR)[2] == 'b') \
374: { fprintf ((FILE), "sub"); (PTR) += 3; \
375: if ((PTR)[0] == 'q' || (PTR)[0] == 'i' \
376: || (PTR)[0] == 'a') (PTR)++; } \
377: /* CMP, CMPA, CMPI, CMPM ==> CMP */ \
378: else if ((PTR)[0] == 'c' && (PTR)[1] == 'm' \
379: && (PTR)[2] == 'p') \
380: { fprintf ((FILE), "cmp"); (PTR) += 3; \
381: if ((PTR)[0] == 'a' || (PTR)[0] == 'i' \
382: || (PTR)[0] == 'm') (PTR)++; } \
383: /* DIVSL ==> TDIVS */ \
384: else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
385: && (PTR)[2] == 'v' && (PTR)[3] == 's' \
386: && (PTR)[4] == 'l') \
387: { fprintf ((FILE), "tdivs"); (PTR) += 5; } \
388: /* DIVUL ==> TDIVU */ \
389: else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
390: && (PTR)[2] == 'v' && (PTR)[3] == 'u' \
391: && (PTR)[4] == 'l') \
392: { fprintf ((FILE), "tdivu"); (PTR) += 5; } \
393: }
394:
395: #endif /* not SGS_SWAP_W */
396:
397: /* This macro outputs the label at the start of a switch table. The
398: ".swbeg <N>" is an assembler directive that causes the switch table
399: size to be inserted into the object code so that disassemblers, for
400: example, can identify that it is the start of a switch table. */
401:
402: #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
403: fprintf ((FILE), "\t%s &%d\n", SWBEG_ASM_OP, XVECLEN (PATTERN (TABLE), 1));
404:
405: #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
406: do { \
407: ASM_OUTPUT_BEFORE_CASE_LABEL((FILE),(PREFIX),(NUM),(TABLE)); \
408: ASM_OUTPUT_INTERNAL_LABEL((FILE),(PREFIX),(NUM)); \
409: } while (0)
410:
411: /* At end of a switch table, define LDnnn iff the symbol LInnn was defined.
412: Some SGS assemblers have a bug such that "Lnnn-LInnn-2.b(pc,d0.l*2)"
413: fails to assemble. Luckily "LDnnn(pc,d0.l*2)" produces the results
414: we want. This difference can be accommodated by making the assembler
415: define such "LDnnn" to be either "Lnnn-LInnn-2.b", "Lnnn", or any other
416: string, as necessary. This is accomplished via the ASM_OUTPUT_CASE_END
417: macro. */
418:
419: #undef ASM_OUTPUT_CASE_END
420: #define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE) \
421: { if (switch_table_difference_label_flag) \
422: asm_fprintf (FILE, "\t%s %LLD%d,%LL%d-%LLI%d-2.b\n",\
423: SET_ASM_OP, (NUM), (NUM), (NUM)) \
424: switch_table_difference_label_flag = 0; }
425:
426: int switch_table_difference_label_flag;
427:
428: /* This is how to output an element of a case-vector that is relative. */
429:
430: #undef ASM_OUTPUT_ADDR_DIFF_ELT
431: #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
432: asm_fprintf (FILE, "\t%s %LL%d-%LL%d\n", WORD_ASM_OP, VALUE, REL)
433:
434: /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
435: keep switch tables in the text section. */
436:
437: #define JUMP_TABLES_IN_TEXT_SECTION 1
438:
439: /* Store in OUTPUT a string (made with alloca) containing
440: an assembler-name for a local static variable named NAME.
441: LABELNO is an integer which is different for each call. */
442:
443: #undef ASM_FORMAT_PRIVATE_NAME
444: #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
445: ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
446: sprintf ((OUTPUT), ASM_PN_FORMAT, (NAME), (LABELNO)))
447:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.