|
|
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:
203: #undef PRINT_OPERAND_PRINT_FLOAT
204: #define PRINT_OPERAND_PRINT_FLOAT(CODE,FILE) \
205: asm_fprintf ((FILE), "%I0x%x", u1.i);
206:
207: #undef ASM_OUTPUT_DOUBLE_OPERAND
208: #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE) \
209: asm_fprintf ((FILE),"%I0x%x%08x", u.i[0], u.i[1]);
210:
211: /* How to output a block of SIZE zero bytes. Note that the `space' pseudo,
212: when used in the text segment, causes SGS assemblers to output nop insns
213: rather than 0s, so we set ASM_NO_SKIP_IN_TEXT to prevent this. */
214:
215: #define ASM_NO_SKIP_IN_TEXT 1
216:
217: #undef ASM_OUTPUT_SKIP
218: #define ASM_OUTPUT_SKIP(FILE,SIZE) \
1.1.1.2 root 219: fprintf (FILE, "\t%s %u\n", SPACE_ASM_OP, (SIZE))
220:
1.1 root 221: /* Translate Motorola opcodes such as `jbeq' into SGS opcodes such
222: as `beq.w'.
223: Delete the `e' in `move...' and `fmove'.
224: Change `ftst' to `ftest'.
225: Change `fbne' to `fbneq'
226: Change `fsne' to `fsneq'
227: Change `divsl' to `tdivs' (32/32 -> 32r:32q)
228: Change `divul' to `tdivu' (32/32 -> 32r:32q)
1.1.1.2 root 229: Optionally change swap to swap.w.
1.1 root 230: */
231:
1.1.1.2 root 232: #ifdef SGS_SWAP_W
233: #define ASM_OUTPUT_OPCODE(FILE, PTR) \
234: { \
235: extern int flag_pic; \
236: if (!strncmp ((PTR), "jbsr", 4)) \
237: { if (flag_pic) \
238: fprintf ((FILE), "bsr"); \
239: else \
240: fprintf ((FILE), "jsr"); \
241: (PTR) += 4; } \
242: else if ((PTR)[0] == 'j' && (PTR)[1] == 'b') \
243: { ++(PTR); \
244: while (*(PTR) != ' ') \
245: { putc (*(PTR), (FILE)); ++(PTR); } \
246: fprintf ((FILE), ".w"); } \
247: else if ((PTR)[0] == 's') \
248: { \
249: if (!strncmp ((PTR), "swap", 4)) \
250: { fprintf ((FILE), "swap.w"); (PTR) += 4; } \
251: } \
252: /* FMOVE ==> FMOV, (and F%& F%$ translations) */ \
253: else if ((PTR)[0] == 'f') \
254: { \
255: if (!strncmp ((PTR), "fmove", 5)) \
256: { fprintf ((FILE), "fmov"); (PTR) += 5; } \
257: else if (!strncmp ((PTR), "ftst", 4)) \
258: { fprintf ((FILE), "ftest"); (PTR) += 4; } \
259: else if (!strncmp ((PTR), "fbne", 4)) \
260: { fprintf ((FILE), "fbneq"); (PTR) += 4; } \
261: else if (!strncmp ((PTR), "fsne", 4)) \
262: { fprintf ((FILE), "fsneq"); (PTR) += 4; } \
263: else if (!strncmp ((PTR), "f%$move", 7)) \
264: { (PTR) += 7; \
265: if (TARGET_68040_ONLY) \
266: fprintf ((FILE), "fsmov"); \
267: else fprintf ((FILE), "fmov"); } \
268: else if (!strncmp ((PTR), "f%&move", 7)) \
269: { (PTR) += 7; \
270: if (TARGET_68040_ONLY) \
271: fprintf ((FILE), "fdmov"); \
272: else fprintf ((FILE), "fmov"); } \
273: } \
274: /* MOVE, MOVEA, MOVEQ, MOVEC ==> MOV */ \
275: else if ((PTR)[0] == 'm' && (PTR)[1] == 'o' \
276: && (PTR)[2] == 'v' && (PTR)[3] == 'e') \
277: { fprintf ((FILE), "mov"); (PTR) += 4; \
278: if ((PTR)[0] == 'q' || (PTR)[0] == 'a' \
279: || (PTR)[0] == 'c') (PTR)++; } \
280: /* SUB, SUBQ, SUBA, SUBI ==> SUB */ \
281: else if ((PTR)[0] == 's' && (PTR)[1] == 'u' \
282: && (PTR)[2] == 'b') \
283: { fprintf ((FILE), "sub"); (PTR) += 3; \
284: if ((PTR)[0] == 'q' || (PTR)[0] == 'i' \
285: || (PTR)[0] == 'a') (PTR)++; } \
286: /* CMP, CMPA, CMPI, CMPM ==> CMP */ \
287: else if ((PTR)[0] == 'c' && (PTR)[1] == 'm' \
288: && (PTR)[2] == 'p') \
289: { fprintf ((FILE), "cmp"); (PTR) += 3; \
290: if ((PTR)[0] == 'a' || (PTR)[0] == 'i' \
291: || (PTR)[0] == 'm') (PTR)++; } \
292: /* DIVSL ==> TDIVS */ \
293: else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
294: && (PTR)[2] == 'v' && (PTR)[3] == 's' \
295: && (PTR)[4] == 'l') \
296: { fprintf ((FILE), "tdivs"); (PTR) += 5; } \
297: /* DIVUL ==> TDIVU */ \
298: else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
299: && (PTR)[2] == 'v' && (PTR)[3] == 'u' \
300: && (PTR)[4] == 'l') \
301: { fprintf ((FILE), "tdivu"); (PTR) += 5; } \
302: }
303:
304: #else /* not SGS_SWAP_W */
305:
1.1 root 306: #define ASM_OUTPUT_OPCODE(FILE, PTR) \
307: { \
308: extern int flag_pic; \
1.1.1.2 root 309: if (!strncmp ((PTR), "jbsr", 4)) \
310: { if (flag_pic) \
311: fprintf ((FILE), "bsr"); \
312: else \
313: fprintf ((FILE), "jsr"); \
314: (PTR) += 4; } \
315: else if ((PTR)[0] == 'j' && (PTR)[1] == 'b') \
1.1 root 316: { ++(PTR); \
317: while (*(PTR) != ' ') \
318: { putc (*(PTR), (FILE)); ++(PTR); } \
319: fprintf ((FILE), ".w"); } \
320: /* FMOVE ==> FMOV, (and F%& F%$ translations) */ \
321: else if ((PTR)[0] == 'f') \
322: { \
323: if (!strncmp ((PTR), "fmove", 5)) \
324: { fprintf ((FILE), "fmov"); (PTR) += 5; } \
325: else if (!strncmp ((PTR), "ftst", 4)) \
326: { fprintf ((FILE), "ftest"); (PTR) += 4; } \
327: else if (!strncmp ((PTR), "fbne", 4)) \
328: { fprintf ((FILE), "fbneq"); (PTR) += 4; } \
329: else if (!strncmp ((PTR), "fsne", 4)) \
330: { fprintf ((FILE), "fsneq"); (PTR) += 4; } \
331: else if (!strncmp ((PTR), "f%$move", 7)) \
332: { (PTR) += 7; \
333: if (TARGET_68040_ONLY) \
334: fprintf ((FILE), "fsmov"); \
335: else fprintf ((FILE), "fmov"); } \
336: else if (!strncmp ((PTR), "f%&move", 7)) \
337: { (PTR) += 7; \
338: if (TARGET_68040_ONLY) \
339: fprintf ((FILE), "fdmov"); \
340: else fprintf ((FILE), "fmov"); } \
341: } \
342: /* MOVE, MOVEA, MOVEQ, MOVEC ==> MOV */ \
343: else if ((PTR)[0] == 'm' && (PTR)[1] == 'o' \
344: && (PTR)[2] == 'v' && (PTR)[3] == 'e') \
345: { fprintf ((FILE), "mov"); (PTR) += 4; \
1.1.1.2 root 346: if ((PTR)[0] == 'q' || (PTR)[0] == 'a' \
347: || (PTR)[0] == 'c') (PTR)++; } \
1.1 root 348: /* SUB, SUBQ, SUBA, SUBI ==> SUB */ \
349: else if ((PTR)[0] == 's' && (PTR)[1] == 'u' \
350: && (PTR)[2] == 'b') \
351: { fprintf ((FILE), "sub"); (PTR) += 3; \
1.1.1.2 root 352: if ((PTR)[0] == 'q' || (PTR)[0] == 'i' \
353: || (PTR)[0] == 'a') (PTR)++; } \
1.1 root 354: /* CMP, CMPA, CMPI, CMPM ==> CMP */ \
355: else if ((PTR)[0] == 'c' && (PTR)[1] == 'm' \
356: && (PTR)[2] == 'p') \
357: { fprintf ((FILE), "cmp"); (PTR) += 3; \
1.1.1.2 root 358: if ((PTR)[0] == 'a' || (PTR)[0] == 'i' \
359: || (PTR)[0] == 'm') (PTR)++; } \
1.1 root 360: /* DIVSL ==> TDIVS */ \
361: else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
362: && (PTR)[2] == 'v' && (PTR)[3] == 's' \
363: && (PTR)[4] == 'l') \
364: { fprintf ((FILE), "tdivs"); (PTR) += 5; } \
365: /* DIVUL ==> TDIVU */ \
366: else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \
367: && (PTR)[2] == 'v' && (PTR)[3] == 'u' \
368: && (PTR)[4] == 'l') \
369: { fprintf ((FILE), "tdivu"); (PTR) += 5; } \
370: }
371:
1.1.1.2 root 372: #endif /* not SGS_SWAP_W */
373:
1.1 root 374: /* This macro outputs the label at the start of a switch table. The
375: ".swbeg <N>" is an assembler directive that causes the switch table
376: size to be inserted into the object code so that disassemblers, for
377: example, can identify that it is the start of a switch table. */
378:
379: #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
1.1.1.2 root 380: fprintf ((FILE), "\t%s &%d\n", SWBEG_ASM_OP, XVECLEN (PATTERN (TABLE), 1)); \
1.1 root 381: ASM_OUTPUT_INTERNAL_LABEL((FILE),(PREFIX),(NUM));
382:
383: /* At end of a switch table, define LDnnn iff the symbol LInnn was defined.
384: Some SGS assemblers have a bug such that "Lnnn-LInnn-2.b(pc,d0.l*2)"
1.1.1.3 ! root 385: fails to assemble. Luckily "LDnnn(pc,d0.l*2)" produces the results
! 386: we want. This difference can be accommodated by making the assembler
1.1 root 387: define such "LDnnn" to be either "Lnnn-LInnn-2.b", "Lnnn", or any other
388: string, as necessary. This is accomplished via the ASM_OUTPUT_CASE_END
389: macro. */
390:
391: #undef ASM_OUTPUT_CASE_END
392: #define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE) \
1.1.1.3 ! root 393: { if (switch_table_difference_label_flag) \
1.1.1.2 root 394: asm_fprintf (FILE, "\t%s %LLD%d,%LL%d-%LLI%d-2.b\n",\
1.1.1.3 ! root 395: SET_ASM_OP, (NUM), (NUM), (NUM)) \
! 396: switch_table_difference_label_flag = 0; }
! 397:
! 398: int switch_table_difference_label_flag;
1.1 root 399:
400: /* This is how to output an element of a case-vector that is relative. */
401:
402: #undef ASM_OUTPUT_ADDR_DIFF_ELT
403: #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
1.1.1.2 root 404: asm_fprintf (FILE, "\t%s %LL%d-%LL%d\n", WORD_ASM_OP, VALUE, REL)
1.1 root 405:
406: /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
407: keep switch tables in the text section. */
408:
409: #define JUMP_TABLES_IN_TEXT_SECTION 1
410:
411: /* Store in OUTPUT a string (made with alloca) containing
412: an assembler-name for a local static variable named NAME.
413: LABELNO is an integer which is different for each call. */
414:
415: #undef ASM_FORMAT_PRIVATE_NAME
416: #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
417: ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
418: sprintf ((OUTPUT), ASM_PN_FORMAT, (NAME), (LABELNO)))
419:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.