OSDN Git Service

PR fortran/20441
[pf3gnuchains/gcc-fork.git] / gcc / config / mips / netbsd.h
index b2440c0..636e3ad 100644 (file)
-/* Definitions for DECstation running BSD as target machine for GNU compiler.
-   Copyright (C) 1993, 1995 Free Software Foundation, Inc.
+/* Definitions of target machine for GNU compiler, for MIPS NetBSD systems.
+   Copyright (C) 1993, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004,
+   2007 Free Software Foundation, Inc.
 
-This file is part of GNU CC.
+This file is part of GCC.
 
-GNU CC is free software; you can redistribute it and/or modify
+GCC is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
-GNU CC is distributed in the hope that it will be useful,
+GCC is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
-#define DECSTATION
 
-/* Look for the include files in the system-defined places.  */
+/* Define default target values.  */
 
-#ifndef CROSS_COMPILE
-#undef GPLUSPLUS_INCLUDE_DIR
-#define GPLUSPLUS_INCLUDE_DIR "/usr/include/g++"
-
-#undef GCC_INCLUDE_DIR
-#define GCC_INCLUDE_DIR "/usr/include"
-
-#undef INCLUDE_DEFAULTS
-#define INCLUDE_DEFAULTS               \
-  {                                    \
-    { GPLUSPLUS_INCLUDE_DIR, 1, 1 },   \
-    { GCC_INCLUDE_DIR, 0, 0 },         \
-    { 0, 0, 0 }                                \
-  }
-
-/* Under NetBSD, the normal location of the various *crt*.o files is the
-   /usr/lib directory.  */
-
-#undef STANDARD_STARTFILE_PREFIX
-#define STANDARD_STARTFILE_PREFIX "/usr/lib/"
+#undef MACHINE_TYPE
+#if TARGET_ENDIAN_DEFAULT != 0
+#define MACHINE_TYPE "NetBSD/mipseb ELF"
+#else
+#define MACHINE_TYPE "NetBSD/mipsel ELF"
 #endif
 
-/* Provide a LINK_SPEC appropriate for NetBSD.  Here we provide support
-   for the special GCC options -static, -assert, and -nostdlib.  */
+#define TARGET_OS_CPP_BUILTINS()                       \
+  do                                                   \
+    {                                                  \
+      NETBSD_OS_CPP_BUILTINS_ELF();                    \
+      builtin_define ("__NO_LEADING_UNDERSCORES__");   \
+      builtin_define ("__GP_SUPPORT__");               \
+      if (TARGET_LONG64)                               \
+       builtin_define ("__LONG64");                    \
+                                                       \
+      if (TARGET_ABICALLS)                             \
+       builtin_define ("__ABICALLS__");                \
+                                                       \
+      if (mips_abi == ABI_EABI)                                \
+       builtin_define ("__mips_eabi");                 \
+      else if (mips_abi == ABI_N32)                    \
+       builtin_define ("__mips_n32");                  \
+      else if (mips_abi == ABI_64)                     \
+       builtin_define ("__mips_n64");                  \
+      else if (mips_abi == ABI_O64)                    \
+       builtin_define ("__mips_o64");                  \
+    }                                                  \
+  while (0)
+
+/* The generic MIPS TARGET_CPU_CPP_BUILTINS are incorrect for NetBSD.
+   Specifically, they define too many namespace-invasive macros.  Override
+   them here.  Note this is structured for easy comparison to the version
+   in mips.h.
+
+   FIXME: This probably isn't the best solution.  But in the absence
+   of something better, it will have to do, for now.  */
+
+#undef TARGET_CPU_CPP_BUILTINS
+#define TARGET_CPU_CPP_BUILTINS()                              \
+  do                                                           \
+    {                                                          \
+      builtin_assert ("cpu=mips");                             \
+      builtin_define ("__mips__");                             \
+      builtin_define ("_mips");                                        \
+                                                               \
+      /* No _R3000 or _R4000.  */                              \
+      if (TARGET_64BIT)                                                \
+       builtin_define ("__mips64");                            \
+                                                               \
+      if (TARGET_FLOAT64)                                      \
+       builtin_define ("__mips_fpr=64");                       \
+      else                                                     \
+       builtin_define ("__mips_fpr=32");                       \
+                                                               \
+      if (TARGET_MIPS16)                                       \
+       builtin_define ("__mips16");                            \
+                                                               \
+      MIPS_CPP_SET_PROCESSOR ("_MIPS_ARCH", mips_arch_info);   \
+      MIPS_CPP_SET_PROCESSOR ("_MIPS_TUNE", mips_tune_info);   \
+                                                               \
+      if (ISA_MIPS1)                                           \
+       builtin_define ("__mips=1");                            \
+      else if (ISA_MIPS2)                                      \
+       builtin_define ("__mips=2");                            \
+      else if (ISA_MIPS3)                                      \
+       builtin_define ("__mips=3");                            \
+      else if (ISA_MIPS4)                                      \
+       builtin_define ("__mips=4");                            \
+      else if (ISA_MIPS32)                                     \
+       {                                                       \
+         builtin_define ("__mips=32");                         \
+         builtin_define ("__mips_isa_rev=1");                  \
+       }                                                       \
+      else if (ISA_MIPS32R2)                                   \
+       {                                                       \
+         builtin_define ("__mips=32");                         \
+         builtin_define ("__mips_isa_rev=2");                  \
+       }                                                       \
+      else if (ISA_MIPS64)                                     \
+       {                                                       \
+         builtin_define ("__mips=64");                         \
+         builtin_define ("__mips_isa_rev=1");                  \
+       }                                                       \
+                                                               \
+      if (TARGET_HARD_FLOAT)                                   \
+       builtin_define ("__mips_hard_float");                   \
+      else if (TARGET_SOFT_FLOAT)                              \
+       builtin_define ("__mips_soft_float");                   \
+                                                               \
+      if (TARGET_SINGLE_FLOAT)                                 \
+       builtin_define ("__mips_single_float");                 \
+                                                               \
+      if (TARGET_BIG_ENDIAN)                                   \
+       builtin_define ("__MIPSEB__");                          \
+      else                                                     \
+       builtin_define ("__MIPSEL__");                          \
+                                                               \
+      /* No language dialect defines.  */                      \
+                                                               \
+      /* ABIs handled in TARGET_OS_CPP_BUILTINS.  */           \
+    }                                                          \
+  while (0)
+
+
+/* Clean up after the generic MIPS/ELF configuration.  */
+#undef MD_EXEC_PREFIX
+#undef MD_STARTFILE_PREFIX
+
+/* Extra specs we need.  */
+#undef SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS                                          \
+  { "netbsd_cpp_spec",         NETBSD_CPP_SPEC },                      \
+  { "netbsd_link_spec",                NETBSD_LINK_SPEC_ELF },                 \
+  { "netbsd_entry_point",      NETBSD_ENTRY_POINT },
+
+/* Provide a SUBTARGET_CPP_SPEC appropriate for NetBSD.  */
+
+#undef SUBTARGET_CPP_SPEC
+#define SUBTARGET_CPP_SPEC "%(netbsd_cpp_spec)"
+
+/* Provide a LINK_SPEC appropriate for a NetBSD/mips target.
+   This is a copy of LINK_SPEC from <netbsd-elf.h> tweaked for
+   the MIPS target.  */
 
 #undef LINK_SPEC
 #define LINK_SPEC \
-  "%{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} \
-   %{!nostdlib:%{!r*:%{!e*:-e __start}}} -dc -dp %{static:-Bstatic} %{assert*}"
+  "%{EL:-m elf32lmip} \
+   %{EB:-m elf32bmip} \
+   %(endian_spec) \
+   %{G*} %{mips1} %{mips2} %{mips3} %{mips4} %{mips32} %{mips32r2} %{mips64} \
+   %{bestGnum} %{call_shared} %{no_archive} %{exact_version} \
+   %(netbsd_link_spec)"
 
-/* We have atexit(3).  */
+#define NETBSD_ENTRY_POINT "__start"
 
-#define HAVE_ATEXIT
+#undef SUBTARGET_ASM_SPEC
+#define SUBTARGET_ASM_SPEC \
+  "%{!mno-abicalls: \
+     %{!fno-PIC:%{!fno-pic:-KPIC}}}"
 
-/* Implicit library calls should use memcpy, not bcopy, etc.  */
 
-#define TARGET_MEM_FUNCTIONS
+/* -G is incompatible with -KPIC which is the default, so only allow objects
+   in the small data section if the user explicitly asks for it.  */
 
-/* Define mips-specific netbsd predefines... */
-#ifndef CPP_PREDEFINES
-#define CPP_PREDEFINES "-D__ANSI_COMPAT \
--DMIPSEL -DR3000 -DSYSTYPE_BSD -D_SYSTYPE_BSD -D__NetBSD__ -Dmips \
--D__NO_LEADING_UNDERSCORES__ -D__GP_SUPPORT__ \
--Dunix -D_R3000 \
--Asystem(unix) -Asystem(NetBSD) -Amachine(mips)"
-#endif
+#undef MIPS_DEFAULT_GVALUE
+#define MIPS_DEFAULT_GVALUE 0
 
-/* Always uses gas.  */
-#ifndef ASM_SPEC
-#define ASM_SPEC "\
-%{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} %{v} \
-%{noasmopt:-O0} \
-%{!noasmopt:%{O:-O2} %{O1:-O2} %{O2:-O2} %{O3:-O3}} \
-%{g} %{g0} %{g1} %{g2} %{g3} \
-%{ggdb:-g} %{ggdb0:-g0} %{ggdb1:-g1} %{ggdb2:-g2} %{ggdb3:-g3} \
-%{gstabs:-g} %{gstabs0:-g0} %{gstabs1:-g1} %{gstabs2:-g2} %{gstabs3:-g3} \
-%{gstabs+:-g} %{gstabs+0:-g0} %{gstabs+1:-g1} %{gstabs+2:-g2} %{gstabs+3:-g3} \
-%{gcoff:-g} %{gcoff0:-g0} %{gcoff1:-g1} %{gcoff2:-g2} %{gcoff3:-g3}"
-#endif
 
-#ifndef CPP_SPEC
-#define CPP_SPEC "\
-%{posix:-D_POSIX_SOURCE} \
-%{mlong64:-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int} \
-%{!mlong64:-D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int} \
-%{mips3:-U__mips -D__mips=3 -D__mips64}"
-%{mgp32:-U__mips64} %{mgp64:-D__mips64} \
-#endif
+/* This defines which switch letters take arguments.  -G is a MIPS
+   special.  */
 
-#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
-#define STARTFILE_SPEC ""
+#undef SWITCH_TAKES_ARG
+#define SWITCH_TAKES_ARG(CHAR)                                         \
+  (DEFAULT_SWITCH_TAKES_ARG (CHAR)                                     \
+   || (CHAR) == 'R'                                                    \
+   || (CHAR) == 'G')
 
-#ifndef MACHINE_TYPE
-#define MACHINE_TYPE "NetBSD/pmax"
-#endif
 
-#define TARGET_DEFAULT MASK_GAS
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-
-#define LOCAL_LABEL_PREFIX     "."
-
-#include "mips/mips.h"
-
-/*
- * Some imports from svr4.h in support of shared libraries.
- * Currently, we need the DECLARE_OBJECT_SIZE stuff.
- */
-
-/* Define the strings used for the special svr4 .type and .size directives.
-   These strings generally do not vary from one system running svr4 to
-   another, but if a given system (e.g. m88k running svr) needs to use
-   different pseudo-op names for these, they may be overridden in the
-   file which includes this one.  */
+#undef ASM_FINAL_SPEC
+#undef SET_ASM_OP
 
-#undef TYPE_ASM_OP
-#undef SIZE_ASM_OP
-#undef WEAK_ASM_OP
-#define TYPE_ASM_OP    ".type"
-#define SIZE_ASM_OP    ".size"
-#define WEAK_ASM_OP    ".weak"
 
-/* The following macro defines the format used to output the second
-   operand of the .type assembler directive.  Different svr4 assemblers
-   expect various different forms for this operand.  The one given here
-   is just a default.  You may need to override it in your machine-
-   specific tm.h file (depending upon the particulars of your assembler).  */
+/* NetBSD hasn't historically provided _flush_cache(), but rather
+   _cacheflush(), which takes the same arguments as the former.  */
+#undef CACHE_FLUSH_FUNC
+#define CACHE_FLUSH_FUNC "_cacheflush"
 
-#undef TYPE_OPERAND_FMT
-#define TYPE_OPERAND_FMT       "@%s"
 
-/* Write the extra assembler code needed to declare a function's result.
-   Most svr4 assemblers don't require any special declaration of the
-   result value, but there are exceptions.  */
+/* Make gcc agree with <machine/ansi.h> */
 
-#ifndef ASM_DECLARE_RESULT
-#define ASM_DECLARE_RESULT(FILE, RESULT)
-#endif
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "int"
 
-/* These macros generate the special .type and .size directives which
-   are used to set the corresponding fields of the linker symbol table
-   entries in an ELF object file under SVR4.  These macros also output
-   the starting labels for the relevant functions/objects.  */
-
-/* Write the extra assembler code needed to declare a function properly.
-   Some svr4 assemblers need to also have something extra said about the
-   function's return value.  We allow for that here.  */
-
-#undef ASM_DECLARE_FUNCTION_NAME
-#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                    \
-  do {                                                                 \
-    fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);                            \
-    assemble_name (FILE, NAME);                                                \
-    putc (',', FILE);                                                  \
-    fprintf (FILE, TYPE_OPERAND_FMT, "function");                      \
-    putc ('\n', FILE);                                                 \
-    ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));                     \
-  } while (0)
-
-/* Write the extra assembler code needed to declare an object properly.  */
-
-#undef ASM_DECLARE_OBJECT_NAME
-#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                      \
-  do {                                                                 \
-    fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);                            \
-    assemble_name (FILE, NAME);                                                \
-    putc (',', FILE);                                                  \
-    fprintf (FILE, TYPE_OPERAND_FMT, "object");                                \
-    putc ('\n', FILE);                                                 \
-    size_directive_output = 0;                                         \
-    if (!flag_inhibit_size_directive && DECL_SIZE (DECL))              \
-      {                                                                        \
-       size_directive_output = 1;                                      \
-       fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);                         \
-       assemble_name (FILE, NAME);                                     \
-       fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL))); \
-      }                                                                        \
-    ASM_OUTPUT_LABEL(FILE, NAME);                                      \
-  } while (0)
-
-/* Output the size directive for a decl in rest_of_decl_compilation
-   in the case where we did not do so before the initializer.
-   Once we find the error_mark_node, we know that the value of
-   size_directive_output was set
-   by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
-
-#undef ASM_FINISH_DECLARE_OBJECT
-#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)        \
-do {                                                                    \
-     char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);                  \
-     if (!flag_inhibit_size_directive && DECL_SIZE (DECL)               \
-         && ! AT_END && TOP_LEVEL                                       \
-        && DECL_INITIAL (DECL) == error_mark_node                       \
-        && !size_directive_output)                                      \
-       {                                                                \
-        size_directive_output = 1;                                      \
-        fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);                         \
-        assemble_name (FILE, name);                                     \
-        fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL))); \
-       }                                                                \
-   } while (0)
-
-/* This is how to declare the size of a function.  */
-
-#undef ASM_DECLARE_FUNCTION_SIZE
-#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)                   \
-  do {                                                                 \
-    if (!flag_inhibit_size_directive)                                  \
-      {                                                                        \
-        char label[256];                                               \
-       static int labelno;                                             \
-       labelno++;                                                      \
-       ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno);            \
-       ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno);               \
-       fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);                         \
-       assemble_name (FILE, (FNAME));                                  \
-        fprintf (FILE, ",");                                           \
-       assemble_name (FILE, label);                                    \
-        fprintf (FILE, "-");                                           \
-       assemble_name (FILE, (FNAME));                                  \
-       putc ('\n', FILE);                                              \
-      }                                                                        \
-  } while (0)
-
-/* Since gas and gld are standard on NetBSD, we don't need these */
-#undef ASM_FINAL_SPEC
-#undef STARTFILE_SPEC
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
 
+#undef WINT_TYPE
+#define WINT_TYPE "int"