|
|
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: ! 36: #define BYTE_ASM_OP "\t.byte" ! 37: #define WORD_ASM_OP "\t.short" ! 38: #define LONG_ASM_OP "\t.long" ! 39: #define SPACE_ASM_OP "\t.space" ! 40: #define ALIGN_ASM_OP "\t.align" ! 41: #define GLOBAL_ASM_OP "\t.global" ! 42: #define SWBEG_ASM_OP "\t.swbeg" ! 43: #define SET_ASM_OP "\t.set" ! 44: ! 45: #define UNALIGNED_SHORT_ASM_OP "\t.short" /* Used in dwarfout.c */ ! 46: #define UNALIGNED_INT_ASM_OP "\t.long" /* Used in dwarfout.c */ ! 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) \ ! 117: ( fprintf ((FILE), "%s ", WORD_ASM_OP), \ ! 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); \ ! 127: fprintf((FILE), "%s 0x%x,0x%x\n", LONG_ASM_OP, \ ! 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); \ ! 137: fprintf ((FILE), "%s 0x%x\n", LONG_ASM_OP, tem.l); \ ! 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) \ ! 146: fprintf ((FILE), "%s \t%u\n", ALIGN_ASM_OP, 1 << (LOG)); \ ! 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; \ ! 160: fprintf ((FILE), "%s ", BYTE_ASM_OP); \ ! 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: { \ ! 175: fprintf ((FILE), "\n%s ", BYTE_ASM_OP); \ ! 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 { \ ! 208: fprintf ((FILE), "%s ", GLOBAL_ASM_OP); \ ! 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) \ ! 229: fprintf (FILE, "%s %u\n", SPACE_ASM_OP, (SIZE)) ! 230: ! 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) ! 239: */ ! 240: ! 241: #define ASM_OUTPUT_OPCODE(FILE, PTR) \ ! 242: { \ ! 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: /* FMOVE ==> FMOV, (and F%& F%$ translations) */ \ ! 256: else if ((PTR)[0] == 'f') \ ! 257: { \ ! 258: if (!strncmp ((PTR), "fmove", 5)) \ ! 259: { fprintf ((FILE), "fmov"); (PTR) += 5; } \ ! 260: else if (!strncmp ((PTR), "ftst", 4)) \ ! 261: { fprintf ((FILE), "ftest"); (PTR) += 4; } \ ! 262: else if (!strncmp ((PTR), "fbne", 4)) \ ! 263: { fprintf ((FILE), "fbneq"); (PTR) += 4; } \ ! 264: else if (!strncmp ((PTR), "fsne", 4)) \ ! 265: { fprintf ((FILE), "fsneq"); (PTR) += 4; } \ ! 266: else if (!strncmp ((PTR), "f%$move", 7)) \ ! 267: { (PTR) += 7; \ ! 268: if (TARGET_68040_ONLY) \ ! 269: fprintf ((FILE), "fsmov"); \ ! 270: else fprintf ((FILE), "fmov"); } \ ! 271: else if (!strncmp ((PTR), "f%&move", 7)) \ ! 272: { (PTR) += 7; \ ! 273: if (TARGET_68040_ONLY) \ ! 274: fprintf ((FILE), "fdmov"); \ ! 275: else fprintf ((FILE), "fmov"); } \ ! 276: } \ ! 277: /* MOVE, MOVEA, MOVEQ, MOVEC ==> MOV */ \ ! 278: else if ((PTR)[0] == 'm' && (PTR)[1] == 'o' \ ! 279: && (PTR)[2] == 'v' && (PTR)[3] == 'e') \ ! 280: { fprintf ((FILE), "mov"); (PTR) += 4; \ ! 281: if ((PTR)[0] == 'q' || (PTR)[0] == 'a' || \ ! 282: (PTR)[0] == 'c') (PTR)++; } \ ! 283: /* SUB, SUBQ, SUBA, SUBI ==> SUB */ \ ! 284: else if ((PTR)[0] == 's' && (PTR)[1] == 'u' \ ! 285: && (PTR)[2] == 'b') \ ! 286: { fprintf ((FILE), "sub"); (PTR) += 3; \ ! 287: if ((PTR)[0] == 'q' || (PTR)[0] == 'i' || \ ! 288: (PTR)[0] == 'a') (PTR)++; } \ ! 289: /* CMP, CMPA, CMPI, CMPM ==> CMP */ \ ! 290: else if ((PTR)[0] == 'c' && (PTR)[1] == 'm' \ ! 291: && (PTR)[2] == 'p') \ ! 292: { fprintf ((FILE), "cmp"); (PTR) += 3; \ ! 293: if ((PTR)[0] == 'a' || (PTR)[0] == 'i' || \ ! 294: (PTR)[0] == 'm') (PTR)++; } \ ! 295: /* DIVSL ==> TDIVS */ \ ! 296: else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \ ! 297: && (PTR)[2] == 'v' && (PTR)[3] == 's' \ ! 298: && (PTR)[4] == 'l') \ ! 299: { fprintf ((FILE), "tdivs"); (PTR) += 5; } \ ! 300: /* DIVUL ==> TDIVU */ \ ! 301: else if ((PTR)[0] == 'd' && (PTR)[1] == 'i' \ ! 302: && (PTR)[2] == 'v' && (PTR)[3] == 'u' \ ! 303: && (PTR)[4] == 'l') \ ! 304: { fprintf ((FILE), "tdivu"); (PTR) += 5; } \ ! 305: } ! 306: ! 307: /* This macro outputs the label at the start of a switch table. The ! 308: ".swbeg <N>" is an assembler directive that causes the switch table ! 309: size to be inserted into the object code so that disassemblers, for ! 310: example, can identify that it is the start of a switch table. */ ! 311: ! 312: #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \ ! 313: fprintf ((FILE), "%s &%d\n", SWBEG_ASM_OP, XVECLEN (PATTERN (TABLE), 1)); \ ! 314: ASM_OUTPUT_INTERNAL_LABEL((FILE),(PREFIX),(NUM)); ! 315: ! 316: /* At end of a switch table, define LDnnn iff the symbol LInnn was defined. ! 317: Some SGS assemblers have a bug such that "Lnnn-LInnn-2.b(pc,d0.l*2)" ! 318: fails to assemble. Luckily "Lnnn(pc,d0.l*2)" produces the results ! 319: we want. This difference can be accommodated by using an assembler ! 320: define such "LDnnn" to be either "Lnnn-LInnn-2.b", "Lnnn", or any other ! 321: string, as necessary. This is accomplished via the ASM_OUTPUT_CASE_END ! 322: macro. */ ! 323: ! 324: #undef ASM_OUTPUT_CASE_END ! 325: #define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE) \ ! 326: if (RTX_INTEGRATED_P (TABLE)) \ ! 327: asm_fprintf (FILE, "%s %LLD%d,%LL%d-%LLI%d-2.b\n", \ ! 328: SET_ASM_OP, (NUM), (NUM), (NUM)) ! 329: ! 330: /* This is how to output an element of a case-vector that is relative. */ ! 331: ! 332: #undef ASM_OUTPUT_ADDR_DIFF_ELT ! 333: #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ ! 334: asm_fprintf (FILE, "%s %LL%d-%LL%d\n", WORD_ASM_OP, VALUE, REL) ! 335: ! 336: /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to ! 337: keep switch tables in the text section. */ ! 338: ! 339: #define JUMP_TABLES_IN_TEXT_SECTION 1 ! 340: ! 341: /* Store in OUTPUT a string (made with alloca) containing ! 342: an assembler-name for a local static variable named NAME. ! 343: LABELNO is an integer which is different for each call. */ ! 344: ! 345: #undef ASM_FORMAT_PRIVATE_NAME ! 346: #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \ ! 347: ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \ ! 348: sprintf ((OUTPUT), ASM_PN_FORMAT, (NAME), (LABELNO))) ! 349:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.