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