home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer) / NeXT_Developer-3.3.iso / NextDeveloper / Source / GNU / cc / config / m68k / next.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-26  |  9.0 KB  |  259 lines

  1. /* Target definitions for GNU compiler for mc680x0 running NeXTSTEP
  2.    Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include "m68k/m68k.h"
  21. #include "nextstep.h"
  22.  
  23. /* The default -arch flag in the driver */
  24. #define DEFAULT_TARGET_ARCH "m68k"
  25.  
  26. #define MACHO_PIC 1
  27.  
  28. #ifndef MACHOPIC_PURE
  29. #define MACHOPIC_PURE          (flag_pic == 2)
  30. #define MACHOPIC_INDIRECT      (flag_pic)
  31. #define MACHOPIC_JUST_INDIRECT (flag_pic == 1)
  32. #endif
  33.  
  34. #define MACHOPIC_FUNCTION_BRANCHES
  35.  
  36. /* See m68k.h.  0407 means 68040 (or 68030 or 68020, with 68881/2).  */
  37.  
  38. #define TARGET_DEFAULT 0407
  39.  
  40. #define TARGET_ARCHITECTURE \
  41.   { { "m68k", 0 },        /* Accept.  */                   \
  42.     { "m68030", -01400 },    /* Just -like -m68030.  */    \
  43.     { "m68030", 5 },                        \
  44.     { "m68040", 01007 }}    /* Just like -m68040-only.  */
  45.  
  46. /* Boundary (in *bits*) on which stack pointer should be aligned.  */
  47.  
  48. #undef    STACK_BOUNDARY
  49. #define STACK_BOUNDARY 32
  50.  
  51. /* NeXT's calling convention is to use the struct-value register 
  52.    passing a pointer to the struct to the function being called. */
  53. #undef PCC_STATIC_STRUCT_RETURN
  54.  
  55. /* Names to predefine in the preprocessor for this target machine.  */
  56.  
  57. #define CPP_PREDEFINES "-Dmc68000 -Dm68k -DNeXT -Dunix -D__MACH__ -D__BIG_ENDIAN__ -D__ARCHITECTURE__=\"m68k\""
  58.  
  59. /* Every structure or union's size must be a multiple of 2 bytes.
  60.    (Why isn't this in m68k.h?)  */
  61.  
  62. #define STRUCTURE_SIZE_BOUNDARY 16
  63. /* This is how to output an assembler line defining a `double' constant.  */
  64.  
  65. #undef    ASM_OUTPUT_DOUBLE
  66. #ifdef REAL_VALUE_TO_TARGET_DOUBLE
  67. #define ASM_OUTPUT_DOUBLE(FILE,VALUE)                    \
  68.   do {                                    \
  69.     long hex[2];                            \
  70.     REAL_VALUE_TO_TARGET_DOUBLE (VALUE, hex);                \
  71.     if (sizeof (int) == sizeof (long))                    \
  72.       fprintf (FILE, "\t.long 0x%x\n\t.long 0x%x\n", hex[0], hex[1]);    \
  73.     else                                \
  74.       fprintf (FILE, "\t.long 0x%lx\n\t.long 0x%lx\n", hex[0], hex[1]);    \
  75.   } while (0)
  76. #else
  77. #define ASM_OUTPUT_DOUBLE(FILE,VALUE)                    \
  78.  do { if (REAL_VALUE_ISINF (VALUE))                    \
  79.         {                                \
  80.           if (REAL_VALUE_NEGATIVE (VALUE))                \
  81.             fprintf (FILE, "\t.double 0r-99e999\n");            \
  82.           else                                \
  83.             fprintf (FILE, "\t.double 0r99e999\n");            \
  84.         }                                \
  85.       else                                \
  86.         { char dstr[30];                        \
  87.           REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr);        \
  88.           fprintf (FILE, "\t.double 0r%s\n", dstr);            \
  89.         }                                \
  90.     } while (0)
  91. #endif
  92.  
  93. /* This is how to output an assembler line defining a `float' constant.  */
  94.  
  95. #undef    ASM_OUTPUT_FLOAT
  96. #ifdef REAL_VALUE_TO_TARGET_SINGLE
  97. #define ASM_OUTPUT_FLOAT(FILE,VALUE)                    \
  98.   do {                                    \
  99.     long hex;                                \
  100.     REAL_VALUE_TO_TARGET_SINGLE (VALUE, hex);                \
  101.     if (sizeof (int) == sizeof (long))                    \
  102.       fprintf (FILE, "\t.long 0x%x\n", hex);                \
  103.     else                                \
  104.       fprintf (FILE, "\t.long 0x%lx\n", hex);                \
  105.   } while (0)
  106. #else
  107. #define ASM_OUTPUT_FLOAT(FILE,VALUE)                    \
  108.  do { if (REAL_VALUE_ISINF (VALUE))                    \
  109.         {                                \
  110.           if (REAL_VALUE_NEGATIVE (VALUE))                \
  111.             fprintf (FILE, "\t.single 0r-99e999\n");            \
  112.           else                                \
  113.             fprintf (FILE, "\t.single 0r99e999\n");            \
  114.         }                                \
  115.       else                                \
  116.         { char dstr[30];                        \
  117.           REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr);        \
  118.           fprintf (FILE, "\t.single 0r%s\n", dstr);            \
  119.         }                                \
  120.     } while (0)
  121. #endif
  122.  
  123. #undef    ASM_OUTPUT_FLOAT_OPERAND
  124. #ifdef REAL_VALUE_TO_TARGET_SINGLE
  125. #define ASM_OUTPUT_FLOAT_OPERAND(CODE,FILE,VALUE)            \
  126.   do {                                    \
  127.     long hex;                                \
  128.     REAL_VALUE_TO_TARGET_SINGLE (VALUE, hex);                \
  129.     fprintf (FILE, "#0%c%x", (CODE) == 'f' ? 'b' : 'x', hex);        \
  130.   } while (0)
  131. #else
  132. #define ASM_OUTPUT_FLOAT_OPERAND(CODE,FILE,VALUE)        \
  133.   do{                                 \
  134.       if (CODE != 'f')                        \
  135.         {                            \
  136.           long l;                        \
  137.           REAL_VALUE_TO_TARGET_SINGLE (VALUE, l);        \
  138.           if (sizeof (int) == sizeof (long))            \
  139.             asm_fprintf ((FILE), "%I0x%x", l);            \
  140.           else                            \
  141.             asm_fprintf ((FILE), "%I0x%lx", l);            \
  142.         }                            \
  143.       else if (REAL_VALUE_ISINF (VALUE))            \
  144.         {                            \
  145.           if (REAL_VALUE_NEGATIVE (VALUE))            \
  146.             fprintf (FILE, "#0r-99e999");            \
  147.           else                            \
  148.             fprintf (FILE, "#0r99e999");            \
  149.         }                            \
  150.       else                            \
  151.         { char dstr[30];                    \
  152.           REAL_VALUE_TO_DECIMAL ((VALUE), "%.9g", dstr);    \
  153.           fprintf (FILE, "#0r%s", dstr);            \
  154.         }                            \
  155.     } while (0)
  156. #endif
  157.  
  158. #undef    ASM_OUTPUT_DOUBLE_OPERAND
  159. #ifdef REAL_VALUE_TO_TARGET_DOUBLE
  160. #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE)                \
  161.   do {                                    \
  162.     long hex[2];                            \
  163.     REAL_VALUE_TO_TARGET_DOUBLE (VALUE, hex);                \
  164.     fprintf (FILE, "#0b%x%08x", hex[0], hex[1]);            \
  165.   } while (0)
  166. #else
  167. #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE)                \
  168.  do { if (REAL_VALUE_ISINF (VALUE))                    \
  169.         {                                \
  170.           if (REAL_VALUE_NEGATIVE (VALUE))                \
  171.             fprintf (FILE, "#0r-99e999");                \
  172.           else                                \
  173.             fprintf (FILE, "#0r99e999");                \
  174.         }                                \
  175.       else                                \
  176.         { char dstr[30];                        \
  177.           REAL_VALUE_TO_DECIMAL ((VALUE), "%.20g", dstr);        \
  178.           fprintf (FILE, "#0r%s", dstr);                \
  179.         }                                \
  180.     } while (0)
  181. #endif
  182.  
  183. /* We do not define JUMP_TABLES_IN_TEXT_SECTION, since we wish to keep
  184.    the text section pure.  There is no point in addressing the jump
  185.    tables using pc relative addressing, since they are not in the text
  186.    section, so we undefine CASE_VECTOR_PC_RELATIVE.  This also
  187.    causes the compiler to use absolute addresses in the jump table,
  188.    so we redefine CASE_VECTOR_MODE to be SImode. */
  189.  
  190. #undef    CASE_VECTOR_MODE
  191. #define CASE_VECTOR_MODE SImode
  192. #undef    CASE_VECTOR_PC_RELATIVE
  193.  
  194. /* When generating PIC code, jump tables must have 32 bits elements,
  195.    to support scattered loading in the future.  */
  196. #undef ASM_OUTPUT_ADDR_DIFF_ELT
  197. #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL)         \
  198. do { fprintf (FILE, "\t.long\tL%u-", (VALUE));             \
  199.      assemble_name (FILE, (char*)machopic_function_base_name ()); \
  200.      fprintf (FILE, "\n"); } while (0)
  201.  
  202. /* Make sure jump tables have the same alignment as other pointers.  */
  203.  
  204. #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLEINSN)    \
  205. { ASM_OUTPUT_ALIGN (FILE, 1); ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); }
  206.  
  207. /* Don't treat addresses involving labels differently from symbol names.
  208.    Previously, references to labels generated pc-relative addressing modes
  209.    while references to symbol names generated absolute addressing modes.  */
  210.  
  211. #undef    GO_IF_INDEXABLE_BASE(X, ADDR)
  212. #define GO_IF_INDEXABLE_BASE(X, ADDR)    \
  213. {  if (LEGITIMATE_BASE_REG_P (X)) goto ADDR; }
  214.  
  215. /* This accounts for the return pc and saved fp on the m68k. */
  216.  
  217. #define OBJC_FORWARDING_STACK_OFFSET 8
  218. #define OBJC_FORWARDING_MIN_OFFSET 8
  219.  
  220. /* INITIALIZE_TRAMPOLINE is changed so that it also enables executable
  221.    stack.  The __enable_execute_stack also clears the insn cache. */
  222.  
  223. /* NOTE: part of this is copied from m68k.h */
  224. #undef INITIALIZE_TRAMPOLINE
  225. #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)                          \
  226. {                                                                          \
  227.   rtx _addr, _func;                                                        \
  228.   emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 2)), TRAMP);   \
  229.   emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 18)), CXT);    \
  230.   emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 22)), FNADDR); \
  231.   _addr = memory_address (SImode, (TRAMP));                                  \
  232.   _func =  gen_rtx (SYMBOL_REF, Pmode, "__enable_execute_stack");          \
  233.   emit_library_call (_func, 0, VOIDmode, 1, _addr, Pmode);                   \
  234. }
  235.  
  236. /* A C expression used to clear the instruction cache from 
  237.    address BEG to address END.   On NeXTSTEP this i a system trap. */
  238.  
  239. #define CLEAR_INSN_CACHE(BEG, END)   \
  240.    asm volatile ("trap #2")
  241.  
  242. /* Turn on floating point precision control as default */
  243.  
  244. /* #define DEFAULT_FPPC 1 */
  245.  
  246.  
  247. #undef SUBTARGET_OVERRIDE_OPTIONS
  248. #define SUBTARGET_OVERRIDE_OPTIONS \
  249.  { extern int flag_dave_indirect; \
  250.    if (flag_dave_indirect) flag_pic = 2; \
  251.    if (flag_pic == 2) flag_no_function_cse = 1; }
  252.  
  253.  
  254. #undef LEGITIMATE_PIC_OPERAND_P
  255. #define LEGITIMATE_PIC_OPERAND_P(X) \
  256.   (! symbolic_operand (X, VOIDmode) \
  257.    || machopic_operand_p (X)        \
  258.    || ((GET_CODE(X) == SYMBOL_REF) && SYMBOL_REF_FLAG(X)))
  259.