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