home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / gnu / gcc-2.3.3-src.lha / GNU / src / amiga / gcc-2.3.3 / config / tower-as.h < prev    next >
C/C++ Source or Header  |  1994-02-06  |  24KB  |  673 lines

  1. /* Definitions of target machine for GNU compiler.
  2.    Copyright (C) 1990 Free Software Foundation, Inc.
  3.  
  4.    Written by Robert Andersson, International Systems, Oslo, Norway.
  5.    Send bug reports, questions and improvements to ra@intsys.no.
  6.  
  7.    For NCR Tower 32/4x0 and 32/6x0 running System V Release 3.
  8.    This file outputs assembler source suitable for the native Tower as
  9.    and with sdb debugging symbols.  See tower.h for more comments.
  10.  
  11.    This file was based on m68k.h, hp320.h and 3b1.h
  12.    as of the 1.37.1 version.
  13.  
  14.  
  15. This file is part of GNU CC.
  16.  
  17. GNU CC is free software; you can redistribute it and/or modify
  18. it under the terms of the GNU General Public License as published by
  19. the Free Software Foundation; either version 2, or (at your option)
  20. any later version.
  21.  
  22. GNU CC is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  25. GNU General Public License for more details.
  26.  
  27. You should have received a copy of the GNU General Public License
  28. along with GNU CC; see the file COPYING.  If not, write to
  29. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  30.  
  31.  
  32. #include "tower.h"
  33. #undef SELECT_RTX_SECTION
  34.  
  35. /* Use default settings for system V.3.  */
  36.  
  37. #include "svr3.h"
  38.  
  39. /* Names to predefine in the preprocessor for this target machine.  */
  40.  
  41. #define CPP_PREDEFINES "-Dunix -Dtower32 -Dtower32_600"
  42.  
  43. /* Define __HAVE_68881 in preprocessor only if -m68881 is specified.
  44.    This will control the use of inline 68881 insns in certain macros.
  45.    Also, define special define used to identify the Tower assembler.  */
  46.  
  47. #define CPP_SPEC "-D__TOWER_ASM__ %{m68881:-D__HAVE_68881__}"
  48.  
  49. /* The startfiles and libraries depend on the -p and -m68881 options.
  50.    The Tower does not support the -pg option.  */
  51.  
  52. #define STARTFILE_SPEC                                         \
  53. "%{p:%{m68881:/usr/lib/fp/mcrt1.o}%{!m68881:/lib/mcrt1.o}}     \
  54.  %{!p:%{m68881:/usr/lib/fp/crt1.o}%{!m68881:/lib/crt1.o}}      \
  55.  crtbegin.o%s"
  56.  
  57. /* We don't want local labels to start with period.
  58.    See ASM_OUTPUT_INTERNAL_LABEL.  */
  59. #undef LOCAL_LABEL_PREFIX
  60. #define LOCAL_LABEL_PREFIX ""
  61.  
  62. /* These four macros control how m68k.md is expanded.  */
  63.  
  64. #define MOTOROLA        /* Use Motorola syntax rather than "MIT" */
  65. #define SGS            /* Uses SGS assembler */
  66. #define SGS_CMP_ORDER        /* Takes cmp operands in reverse order */
  67. #define SGS_NO_LI        /* Suppress jump table label usage */
  68.  
  69. /* Turn on SDB debugging info.  */
  70.  
  71. #define SDB_DEBUGGING_INFO
  72.  
  73. /* This is only useful if gdb is changed, but doesn't harm anyway.  */
  74.  
  75. #define ASM_IDENTIFY_GCC(FILE) \
  76.   fprintf (FILE, "gcc2_compiled%%:\n")
  77.  
  78. /* All the ASM_OUTPUT macros need to conform to the Tower as syntax.  */
  79.  
  80. #define ASM_OUTPUT_SOURCE_FILENAME(FILE, FILENAME) \
  81.   do {                           \
  82.     fprintf (FILE, "\tfile\t\"%s\"\n", FILENAME);  \
  83.     fprintf (FILE, "section ~init,\"x\"\n");       \
  84.     fprintf (FILE, "section ~fini,\"x\"\n");       \
  85.     fprintf (FILE, "section ~rodata,\"x\"\n");   \
  86.     fprintf (FILE, "text\n");               \
  87.   } while (0)
  88.  
  89. #define ASM_OUTPUT_SOURCE_LINE(FILE, LINENO)    \
  90.   fprintf (FILE, "\tln\t%d\n",            \
  91.        (sdb_begin_function_line        \
  92.         ? last_linenum - sdb_begin_function_line : 1))
  93.  
  94. #undef ASM_OUTPUT_IDENT
  95. #define ASM_OUTPUT_IDENT(FILE, NAME) \
  96.   fprintf (FILE, "\tident\t\"%s\" \n", NAME)
  97.  
  98. #define ASM_OUTPUT_ASCII(FILE,PTR,LEN) \
  99.   { register int sp = 0, lp = 0; \
  100.     fprintf ((FILE), "\tbyte\t"); \
  101.   loop: \
  102.     if ((PTR)[sp] > ' ' && ! ((PTR)[sp] & 0x80) && (PTR)[sp] != '\\') \
  103.       { lp += 3; \
  104.     fprintf ((FILE), "'%c", (PTR)[sp]); } \
  105.     else \
  106.       { lp += 5; \
  107.     fprintf ((FILE), "0x%x", (PTR)[sp]); } \
  108.     if (++sp < (LEN)) \
  109.       {    if (lp > 60) \
  110.       { lp = 0; \
  111.         fprintf ((FILE), "\n\tbyte\t"); }    \
  112.     else \
  113.       putc (',', (FILE)); \
  114.     goto loop; } \
  115.     putc ('\n', (FILE)); }
  116.  
  117. /* Translate Motorola opcodes such as `jbeq'
  118.    into SGS/Tower opcodes such as `beq.w'.
  119.    Change `move' to `mov'.
  120.    Change `cmpm' to `cmp'.
  121.    Change `divsl' to `tdivs'.
  122.    Change `divul' to `tdivu'.
  123.    Change `ftst' to `ftest'.
  124.    Change `fmove' to `fmov'.  */
  125.  
  126. #define ASM_OUTPUT_OPCODE(FILE, PTR)            \
  127. { if ((PTR)[0] == 'j' && (PTR)[1] == 'b')        \
  128.     { ++(PTR);                        \
  129.       while (*(PTR) != ' ')                \
  130.     { putc (*(PTR), (FILE)); ++(PTR); }        \
  131.       fprintf ((FILE), ".w"); }                \
  132.   else if ((PTR)[0] == 'm' && (PTR)[1] == 'o'        \
  133.        && (PTR)[2] == 'v' && (PTR)[3] == 'e')    \
  134.     { fprintf ((FILE), "mov"); (PTR) += 4; }        \
  135.   else if ((PTR)[0] == 'c' && (PTR)[1] == 'm'        \
  136.        && (PTR)[2] == 'p' && (PTR)[3] == 'm')    \
  137.     { fprintf ((FILE), "cmp"); (PTR) += 4; }        \
  138.   else if ((PTR)[0] == 'd' && (PTR)[1] == 'i'        \
  139.        && (PTR)[2] == 'v' && (PTR)[3] == 's'    \
  140.        && (PTR)[4] == 'l')                \
  141.     { fprintf ((FILE), "tdivs"); (PTR) += 5; }        \
  142.   else if ((PTR)[0] == 'd' && (PTR)[1] == 'i'        \
  143.        && (PTR)[2] == 'v' && (PTR)[3] == 'u'    \
  144.        && (PTR)[4] == 'l')                \
  145.     { fprintf ((FILE), "tdivu"); (PTR) += 5; }        \
  146.   else if ((PTR)[0] == 'f' && (PTR)[1] == 't'        \
  147.        && (PTR)[2] == 's' && (PTR)[3] == 't')    \
  148.     { fprintf ((FILE), "ftest"); (PTR) += 4; }        \
  149.   else if ((PTR)[0] == 'f' && (PTR)[1] == 'm'        \
  150.        && (PTR)[2] == 'o' && (PTR)[3] == 'v'     \
  151.        && (PTR)[4] == 'e')                \
  152.     { fprintf ((FILE), "fmov"); (PTR) += 5; }        \
  153. }
  154.  
  155.  
  156.  
  157. /* Override parts of m68k.h to fit the Tower assembler.
  158.    This section needs to track changes done to m68k.h in the future.  */
  159.  
  160. #undef TARGET_VERSION
  161. #define TARGET_VERSION fprintf (stderr, " (68k, Motorola/SGS/Tower32 syntax)");
  162.  
  163. #undef FUNCTION_BLOCK_PROFILER
  164. #define FUNCTION_BLOCK_PROFILER(FILE, LABELNO)                \
  165.   do {                                    \
  166.     char label1[20], label2[20];                    \
  167.     ASM_GENERATE_INTERNAL_LABEL (label1, "LPBX", 0);            \
  168.     ASM_GENERATE_INTERNAL_LABEL (label2, "LPI", LABELNO);        \
  169.     fprintf (FILE, "\ttst.l %s\n\tbne %s\n\tpea %s\n\tjsr __bb_init_func\n\taddq.l &4,%%sp\n",    \
  170.          label1, label2, label1);                    \
  171.     ASM_OUTPUT_INTERNAL_LABEL (FILE, "LPI", LABELNO);            \
  172.     putc ('\n', FILE);                        \
  173.     } while (0)
  174.  
  175. #undef BLOCK_PROFILER
  176. #define BLOCK_PROFILER(FILE, BLOCKNO)                \
  177.   do {                                \
  178.     char label[20];                        \
  179.     ASM_GENERATE_INTERNAL_LABEL (label, "LPBX", 2);        \
  180.     fprintf (FILE, "\taddq.l &1,%s+%d\n", label, 4 * BLOCKNO);    \
  181.     } while (0)
  182.  
  183. #undef FUNCTION_PROFILER
  184. #define FUNCTION_PROFILER(FILE, LABEL_NO)    \
  185.     fprintf (FILE, "\tmov.l &LP%%%d,%%a0\n\tjsr mcount%%\n", (LABEL_NO))
  186.  
  187. /* The prologue is identical to the one in m68k.h except that the
  188.    assembler syntax is different.  */
  189.  
  190. #undef FUNCTION_PROLOGUE
  191. #define FUNCTION_PROLOGUE(FILE, SIZE)     \
  192. { register int regno;                        \
  193.   register int mask = 0;                    \
  194.   extern char call_used_regs[];                    \
  195.   int fsize = ((SIZE) + 3) & -4;                \
  196.   if (frame_pointer_needed)                    \
  197.     { if (TARGET_68020 || fsize < 0x8000)            \
  198.         fprintf (FILE, "\tlink %%a6,&%d\n", -fsize);        \
  199.       else                            \
  200.     fprintf (FILE, "\tlink %%a6,&0\n\tsub.l &%d,%%sp\n", fsize); }  \
  201.   for (regno = 16; regno < 24; regno++)                \
  202.     if (regs_ever_live[regno] && ! call_used_regs[regno])    \
  203.        mask |= 1 << (regno - 16);                \
  204.   if ((mask & 0xff) != 0)                    \
  205.     fprintf (FILE, "\tfmovm &0x%x,-(%%sp)\n", mask & 0xff);     \
  206.   mask = 0;                            \
  207.   for (regno = 0; regno < 16; regno++)                \
  208.     if (regs_ever_live[regno] && ! call_used_regs[regno])    \
  209.        mask |= 1 << (15 - regno);                \
  210.   if (frame_pointer_needed)                    \
  211.     mask &= ~ (1 << (15-FRAME_POINTER_REGNUM));            \
  212.   if (exact_log2 (mask) >= 0)                    \
  213.     fprintf (FILE, "\tmov.l %s,-(%%sp)\n", reg_names[15 - exact_log2 (mask)]); \
  214.   else if (mask) fprintf (FILE, "\tmovm.l &0x%x,-(%%sp)\n", mask); }
  215.  
  216. /* The epilogue is identical to the one in m68k.h except that:
  217.    a) The assembler syntax is different.
  218.    b) Pointers are returned both in %d0 and %a0.
  219.    c) FUNCTION_EXTRA_EPILOGUE is not needed.  */
  220.  
  221. #undef FUNCTION_EPILOGUE
  222. #define FUNCTION_EPILOGUE(FILE, SIZE) \
  223. { register int regno;                        \
  224.   register int mask, fmask;                    \
  225.   register int nregs;                        \
  226.   int offset, foffset;                                       \
  227.   extern char call_used_regs[];                    \
  228.   int fsize = ((SIZE) + 3) & -4;                \
  229.   int big = 0;                            \
  230.   nregs = 0;  fmask = 0;                      \
  231.   for (regno