home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / bbs / gnu / gcc-2.5.8-src.lha / src / amiga / gcc-2.5.8 / config / m68k / amigados.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-22  |  13.4 KB  |  409 lines

  1. /* Definitions of target machine for GNU compiler.  amiga 68000/68020 version.
  2.    Copyright (C) 1992 Free Software Foundation, Inc.
  3.    Contributed by Markus M. Wild (wild@amiga.physik.unizh.ch).
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. #include "m68k/m68k.h"
  22.  
  23. /* See m68k.h for bits in TARGET_DEFAULT.
  24.    0 means 68000, no hardware fpu (68881/68882/68040).
  25.    7 means 68020 (or higher) with hardware fpu.  */
  26.  
  27. #ifndef TARGET_DEFAULT
  28. #define TARGET_DEFAULT 0
  29. #endif
  30.  
  31. /* Define __HAVE_68881__ in preprocessor according to the -m flags.
  32.    This will control the use of inline 68881 insns in certain macros.
  33.    Also inform the program which CPU this is for.  */
  34.  
  35. #if TARGET_DEFAULT & 02
  36.  
  37. /* -m68881 is the default */
  38. #define CPP_SPEC \
  39. "%{!msoft-float:-D__HAVE_68881__ }\
  40. %{!ansi:%{m68000:-Dmc68010}%{mc68000:-Dmc68010}%{!mc68000:%{!m68000:-Dmc68020}}}"
  41.  
  42. #else
  43.  
  44. /* -msoft-float is the default, assume -mc68000 as well */
  45. #define CPP_SPEC \
  46. "%{m68881:-D__HAVE_68881__ }\
  47. %{!ansi:%{m68020:-Dmc68020}%{mc68020:-Dmc68020}%{!mc68020:%{!m68020:-Dmc68010}}}"
  48.  
  49. /* Don't try using XFmode since we don't have appropriate runtime software
  50.    support.  */
  51. #undef LONG_DOUBLE_TYPE_SIZE
  52. #define LONG_DOUBLE_TYPE_SIZE 64
  53.  
  54. #endif
  55.  
  56. /* -m68000 requires special flags to the assembler.  */
  57.  
  58. #if TARGET_DEFAULT & 01
  59.  
  60. #define ASM_SPEC \
  61.  "%{m68000:-mc68010}%{mc68000:-mc68010}%{!mc68000:%{!m68000:-mc68020}} %{msmall-code:-l} "
  62.  
  63. #else
  64.  
  65. #define ASM_SPEC \
  66.  "%{m68020:-mc68020}%{mc68020:-mc68020}%{!mc68020:%{!m68020:-mc68010}} %{msmall-code:-l} "
  67.  
  68. #endif
  69.  
  70. /* amiga/amigados are the new "standard" defines for the Amiga, MCH_AMIGA
  71.  * was used before and is included for compatibility reasons */
  72.  
  73. #define CPP_PREDEFINES "-Dmc68000 -Damiga -Damigados -DMCH_AMIGA -DAMIGA"
  74.  
  75. /* Choose the right startup file, depending on whether we use base relative
  76.    code, base relative code with automatic relocation (-resident), or plain
  77.    crt0.o. 
  78.   
  79.    Profiling is currently only available for plain startup.
  80.    mcrt0.o does not (yet) exist. */
  81.  
  82. #define STARTFILE_SPEC \
  83.   "%{resident:rcrt0.o%s}%{!resident:%{!fbaserel:%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}%{fbaserel:%{pg:bgcrt0.o%s}%{!pg:%{p:bmcrt0.o%s}%{!p:bcrt0.o%s}}}}"
  84.  
  85.  
  86. /* Automatically search libamiga.a for AmigaDOS specific functions.  Note
  87.    that we first search the standard C library to resolve as much as
  88.    possible from there, since it has names that are duplicated in libamiga.a
  89.    which we *don't* want from there.  Then search the standard C library
  90.    again to resolve any references that libamiga.a might have generated.
  91.    This may only be a temporary solution since it might be better to simply
  92.    remove the things from libamiga.a that should be pulled in from libc.a
  93.    instead, which would eliminate the first reference to libc.a. */
  94.  
  95. #define LIB_SPEC "%{!p:%{!pg:-lc -lamiga -lc}}%{p:-lc_p -lamiga -lc_p}%{pg:-lc_p -lamiga -lc_p}"
  96.  
  97. /* if debugging, tell the linker to output amiga-hunk symbols *and* a BSD
  98.    compatible debug hunk (which will probably change in the future, it's not
  99.    tremendously useful in its current state). */
  100.  
  101. #define LINK_SPEC "%{g:-amiga-debug-hunk} %{fbaserel:-databss-together} %{resident:-databss-together -datadata-reloc -f libb} "
  102.  
  103. #define CC1_SPEC "%{resident:-fbaserel} "
  104.  
  105. #define CC1PLUS_SPEC "%{resident:-fbaserel} "
  106.  
  107. /* Omit frame pointer at high optimization levels. (This doesn't hurt, since
  108.    GDB doesn't work under AmigaDOS at the moment anyway..) */
  109.   
  110. #define OPTIMIZATION_OPTIONS(OPTIMIZE) \
  111. {                                  \
  112.   if (OPTIMIZE >= 2)                         \
  113.     flag_omit_frame_pointer = 1;                \
  114. }
  115.  
  116. /* provide a dummy entry for the small-code switch. This is currently only
  117.    needed by the assembler (explanations: m68k.h), but will be used by cc1
  118.    to output 16bit pc-relative code later. */
  119.  
  120. #undef TARGET_SWITCHES
  121. #define TARGET_SWITCHES  \
  122.   { { "68020", 5},                \
  123.     { "c68020", 5},                \
  124.     { "68881", 2},                \
  125.     { "bitfield", 4},                \
  126.     { "68000", -5},                \
  127.     { "c68000", -5},                \
  128.     { "soft-float", -0102},            \
  129.     { "nobitfield", -4},            \
  130.     { "rtd", 8},                \
  131.     { "nortd", -8},                \
  132.     { "short", 040},                \
  133.     { "noshort", -040},                \
  134.     { "fpa", 0100},                \
  135.     { "nofpa", -0100},                \
  136.     { "sky", 0200},                \
  137.     { "nosky", -0200},                \
  138.     { "68040", 0407},                \
  139.     { "68030", -01400},                \
  140.     { "68030", 7},                \
  141.     { "68040-only", 01000},            \
  142.     { "small-code", 0 },            \
  143.     { "", TARGET_DEFAULT}}
  144.  
  145. /* Every structure or union's size must be a multiple of 2 bytes.  */
  146.  
  147. #define STRUCTURE_SIZE_BOUNDARY 16
  148.  
  149. /* This is (almost;-)) BSD, so it wants DBX format.  */
  150.  
  151. #define DBX_DEBUGGING_INFO
  152.  
  153. /* Allow folding division by zero.  */
  154. #define REAL_INFINITY
  155.  
  156. #if 0    /* This apparently is no longer necessary? */
  157.  
  158. /* This is how to output an assembler line defining a `double' constant.  */
  159.  
  160. #undef ASM_OUTPUT_DOUBLE
  161. #define ASM_OUTPUT_DOUBLE(FILE,VALUE)                    \
  162.   {                                    \
  163.     if (REAL_VALUE_ISINF (VALUE))                    \
  164.       fprintf (FILE, "\t.double 0r%s99e999\n", (VALUE) > 0 ? "" : "-");    \
  165.     else if (isnan (VALUE))                        \
  166.       {                                    \
  167.     union { double d; long l[2];} t;                \
  168.     t.d = (VALUE);                            \
  169.     fprintf (FILE, "\t.long 0x%lx\n\t.long 0x%lx\n", t.l[0], t.l[1]); \
  170.       }                                    \
  171.     else                                \
  172.       fprintf (FILE, "\t.double 0r%.17g\n", VALUE);            \
  173.   }
  174.  
  175. /* This is how to output an assembler line defining a `float' constant.  */
  176.  
  177. #undef ASM_OUTPUT_FLOAT
  178. #define ASM_OUTPUT_FLOAT(FILE,VALUE)                    \
  179.   {                                    \
  180.     if (REAL_VALUE_ISINF (VALUE))                    \
  181.       fprintf (FILE, "\t.single 0r%s99e999\n", (VALUE) > 0 ? "" : "-");    \
  182.     else if (isnan (VALUE))                        \
  183.       {                                    \
  184.     union { float f; long l;} t;                    \
  185.     t.f = (VALUE);                            \
  186.     fprintf (FILE, "\t.long 0x%lx\n", t.l);                \
  187.       }                                    \
  188.     else                                \
  189.       fprintf (FILE, "\t.single 0r%.9g\n", VALUE);            \
  190.   }
  191.  
  192. /* This is how to output an assembler lines defining floating operands.
  193.    There's no way to output a NaN's fraction, so we lose it.  */
  194.   
  195. #undef ASM_OUTPUT_FLOAT_OPERAND
  196. #define ASM_OUTPUT_FLOAT_OPERAND(CODE,FILE,VALUE)                \
  197.  do {                                \
  198.       if (CODE == 'f')                        \
  199.         {                            \
  200.           (REAL_VALUE_ISINF ((VALUE))                        \
  201.            ? asm_fprintf (FILE, "%I0r%s99e999", ((VALUE) > 0 ? "" : "-")) \
  202.            : (VALUE) == -0.0                            \
  203.            ? asm_fprintf (FILE, "%I0r-0.0")                    \
  204.            : asm_fprintf (FILE, "%I0r%.9g", (VALUE))) \
  205.         } else {                                        \
  206.           long l;                        \
  207.           REAL_VALUE_TO_TARGET_SINGLE (VALUE, l);        \
  208.           if (sizeof (int) == sizeof (long))            \
  209.             asm_fprintf ((FILE), "%I0x%x", l);            \
  210.           else                            \
  211.             asm_fprintf ((FILE), "%I0x%lx", l);            \
  212.         }                            \
  213.      } while (0)
  214.  
  215. #undef ASM_OUTPUT_DOUBLE_OPERAND
  216. #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE)                \
  217.   (REAL_VALUE_ISINF ((VALUE))                        \
  218.    ? asm_fprintf (FILE, "%I0r%s99e999", ((VALUE) > 0 ? "" : "-")) \
  219.    : (VALUE) == -0.0                            \
  220.    ? asm_fprintf (FILE, "%I0r-0.0")                    \
  221.    : asm_fprintf (FILE, "%I0r%.17g", (VALUE)))
  222.  
  223. #endif    /* 0 */
  224.  
  225. /* use A5 as framepointer instead of A6, this makes A6 available as a
  226.    general purpose register, and can thus be used without problems in
  227.    direct library calls. */
  228.  
  229. #undef FRAME_POINTER_REGNUM
  230. #define FRAME_POINTER_REGNUM 13
  231. #undef ARG_POINTER_REGNUM
  232. #define ARG_POINTER_REGNUM 13
  233.  
  234. /* we use A4 for this, not A5, which is the framepointer */
  235. #undef PIC_OFFSET_TABLE_REGNUM
  236. #define PIC_OFFSET_TABLE_REGNUM 12
  237.  
  238. /* setup a default shell return value for those (gazillion..) programs that
  239.    (inspite of ANSI-C) declare main() to be void (or even VOID...) and thus
  240.    cause the shell to randomly caugh upon executing such programs (contrary
  241.    to Unix, AmigaDOS scripts are terminated with an error if a program returns
  242.    with an error code above the `error' or even `failure' level
  243.    (which is configurable with the FAILAT command) */
  244.  
  245. #define DEFAULT_MAIN_RETURN c_expand_return (integer_zero_node)
  246.  
  247. /* we do have an ansi-compliant c-library ;-) */
  248. #define HAVE_VPRINTF
  249. #define HAVE_VFPRINTF
  250. #define HAVE_PUTENV
  251. #define HAVE_STRERROR
  252. #define HAVE_ATEXIT
  253.  
  254. /* given that symbolic_operand(X), return TRUE if no special
  255.    base relative relocation is necessary */
  256.  
  257. #define LEGITIMATE_BASEREL_OPERAND_P(X) \
  258.   (flag_pic >= 3 && read_only_operand (X))
  259.  
  260. #undef LEGITIMATE_PIC_OPERAND_P
  261. #define LEGITIMATE_PIC_OPERAND_P(X) \
  262.   (! symbolic_operand (X, VOIDmode) || LEGITIMATE_BASEREL_OPERAND_P (X))
  263.  
  264.  
  265. /* Define this macro if references to a symbol must be treated
  266.    differently depending on something about the variable or
  267.    function named by the symbol (such as what section it is in).
  268.  
  269.    The macro definition, if any, is executed immediately after the
  270.    rtl for DECL or other node is created.
  271.    The value of the rtl will be a `mem' whose address is a
  272.    `symbol_ref'.
  273.  
  274.    The usual thing for this macro to do is to a flag in the
  275.    `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified
  276.    name string in the `symbol_ref' (if one bit is not enough
  277.    information).
  278.  
  279.    On the Amiga we use this to indicate if a symbol is in text or
  280.    data space.  */
  281.  
  282. #define ENCODE_SECTION_INFO(DECL)\
  283. do                                    \
  284.   {                                    \
  285.     if (TREE_CODE (DECL) == FUNCTION_DECL)                \
  286.       SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1;            \
  287.     else                                \
  288.       {                                    \
  289.     rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd'        \
  290.            ? TREE_CST_RTL (DECL) : DECL_RTL (DECL));        \
  291.     if (RTX_UNCHANGING_P (rtl) && !MEM_VOLATILE_P (rtl))        \
  292.       SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;                \
  293.       }                                    \
  294.   }                                    \
  295. while (0)
  296.  
  297. #undef SELECT_RTX_SECTION
  298. #define SELECT_RTX_SECTION(MODE, X) readonly_data_section ();
  299.  
  300. /* according to varasm.c, RELOC referrs *only* to whether constants (!)
  301.    are addressed by address. This doesn't matter in baserelative code,
  302.    so we allow (inspite of flag_pic) readonly_data_section() in that
  303.    case */
  304.  
  305. #undef SELECT_SECTION
  306. #define SELECT_SECTION(DECL, RELOC)                    \
  307. {                                    \
  308.   if (TREE_CODE (DECL) == STRING_CST)                    \
  309.     {                                    \
  310.       if (! flag_writable_strings)                    \
  311.     readonly_data_section ();                    \
  312.       else                                \
  313.     data_section ();                        \
  314.     }                                    \
  315.   else if (TREE_CODE (DECL) == VAR_DECL)                \
  316.     {                                    \
  317.       if ((flag_pic && flag_pic < 3 && RELOC)                \
  318.       || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL))        \
  319.     data_section ();                        \
  320.       else                                \
  321.     readonly_data_section ();                    \
  322.     }                                    \
  323.   else                                    \
  324.     readonly_data_section ();                        \
  325. }
  326.  
  327.  
  328.  
  329. #if not_yet_working
  330.  
  331. /* starting support for amiga specific keywords
  332.  * --------------------------------------------
  333.  */
  334.  
  335. /* validate attributes that don't take a parameter. Currently we support
  336.  * __attribute__ (saveds) and __attribute__ (interrupt)
  337.  */
  338. #define HANDLE_ATTRIBUTE0(attr) \
  339.   (strcmp(attr, "saveds") != 0 && strcmp(attr, "interrupt") != 0)
  340.  
  341. /* (c-common.c)
  342.  * install additional attributes
  343.  */
  344. #define HANDLE_EXTRA_ATTRIBUTES(a)                         \
  345.   if (TREE_VALUE (a) != 0                            \
  346.       && TREE_CODE (TREE_VALUE (a)) == IDENTIFIER_NODE                \
  347.       && TREE_VALUE (a) == get_identifier ("saveds"))                \
  348.     {                                        \
  349.       if (TREE_CODE (decl) != FUNCTION_DECL)                    \
  350.         {                                    \
  351.           warning_with_decl (decl,                        \
  352.               "saveds attribute specified for non-function `%s'");        \
  353.       return;                                \
  354.         }                                    \
  355.                                               \
  356.       attr_do_saveds (DECL_NAME (decl));                    \
  357.     }                                        \
  358.   else if (TREE_VALUE (a) != 0                            \
  359.       && TREE_CODE (TREE_VALUE (a)) == IDENTIFIER_NODE                \
  360.       && TREE_VALUE (a) == get_identifier ("interrupt"))            \
  361.     {                                        \
  362.       if (TREE_CODE (decl) != FUNCTION_DECL)                    \
  363.         {                                    \
  364.           warning_with_decl (decl,                        \
  365.               "saveds attribute specified for non-function `%s'");        \
  366.       return;                                \
  367.         }                                    \
  368.                                               \
  369.       attr_do_interrupt (DECL_NAME (decl));                    \
  370.     }                                        \
  371.  
  372.  
  373. #define PROLOGUE_EXTRA_SAVE(mask)                        \
  374.   { extern char *current_function_name;                        \
  375.     /* saveds makes the function preserve d1/a0/a1 as well */            \
  376.     if (attr_does_saveds (current_function_name))                \
  377.       mask |= 0x40c0; }                                \
  378.  
  379.  
  380. #define EPILOGUE_EXTRA_RESTORE(mask, nregs)                    \
  381.   { extern char *current_function_name;                        \
  382.     /* restore those extra registers */                        \
  383.     if (attr_does_saveds (current_function_name))                \
  384.       {                                        \
  385.     mask |= 0x0302;                                \
  386.     nregs += 3;                                \
  387.       } }                                    \
  388.  
  389.  
  390. #define EPILOGUE_EXTRA_BARRIER_KLUDGE(stream)                    \
  391.   { extern char *current_function_name;                        \
  392.     /* PLEASE Help! how is this done cleaner?? */                \
  393.     if (attr_does_saveds (current_function_name))                \
  394.       {                                        \
  395.     fprintf (stderr,                             \
  396.          "warning: couldn't cleanup `saveds'-stack in `%s'.\n");    \
  397.     fprintf (stderr,                            \
  398.          "         this is only ok, if the function never returns!\n");    \
  399.       }    }                                    \
  400.         
  401.  
  402. #define EPILOGUE_EXTRA_TEST(stream)                        \
  403.   { extern char *current_function_name;                        \
  404.     /* with the interrupt-attribute, we have to set the cc before rts */    \
  405.     if (attr_does_interrupt (current_function_name))                \
  406.       asm_fprintf (stream, "\ttstl %s\n", reg_names[0]); }            \
  407.  
  408. #endif
  409.