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