OSDN Git Service

* config/rs6000/x-rs6000: New file.
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / darwin.h
index 763cf56..6c88757 100644 (file)
@@ -1,5 +1,5 @@
 /* Target definitions for PowerPC running Darwin (Mac OS X).
 /* Target definitions for PowerPC running Darwin (Mac OS X).
-   Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006
+   Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
    Contributed by Apple Computer Inc.
 
    Free Software Foundation, Inc.
    Contributed by Apple Computer Inc.
 
@@ -7,7 +7,7 @@
 
    GCC is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published
 
    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
+   by the Free Software Foundation; either version 3, or (at your
    option) any later version.
 
    GCC is distributed in the hope that it will be useful, but WITHOUT
    option) any later version.
 
    GCC is distributed in the hope that it will be useful, but WITHOUT
@@ -16,9 +16,8 @@
    License for more details.
 
    You should have received a copy of the GNU General Public License
    License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with GCC; see the file COPYING.  If not, write to the
-   Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
 
 #undef  TARGET_VERSION
 #define TARGET_VERSION fprintf (stderr, " (Darwin/PowerPC)");
 
 #undef  TARGET_VERSION
 #define TARGET_VERSION fprintf (stderr, " (Darwin/PowerPC)");
 /* Translate config/rs6000/darwin.opt to config/darwin.h.  */
 #define TARGET_DYNAMIC_NO_PIC (TARGET_MACHO_DYNAMIC_NO_PIC)
 
 /* Translate config/rs6000/darwin.opt to config/darwin.h.  */
 #define TARGET_DYNAMIC_NO_PIC (TARGET_MACHO_DYNAMIC_NO_PIC)
 
-#define TARGET_OS_CPP_BUILTINS()                \
-  do                                            \
-    {                                           \
-      if (!TARGET_64BIT) builtin_define ("__ppc__");   \
-      if (TARGET_64BIT) builtin_define ("__ppc64__");  \
-      builtin_define ("__POWERPC__");           \
-      builtin_define ("__NATURAL_ALIGNMENT__"); \
-      darwin_cpp_builtins (pfile);             \
-    }                                           \
+#define TARGET_OS_CPP_BUILTINS()                       \
+  do                                                   \
+    {                                                  \
+      if (!TARGET_64BIT) builtin_define ("__ppc__");   \
+      if (TARGET_64BIT) builtin_define ("__ppc64__");  \
+      builtin_define ("__POWERPC__");                  \
+      builtin_define ("__NATURAL_ALIGNMENT__");                \
+      darwin_cpp_builtins (pfile);                     \
+    }                                                  \
   while (0)
 
   while (0)
 
-
-#define SUBTARGET_OVERRIDE_OPTIONS                                     \
-do {                                                                   \
-  /* The Darwin ABI always includes AltiVec, can't be (validly) turned \
-     off.  */                                                          \
-  rs6000_altivec_abi = 1;                                              \
-  TARGET_ALTIVEC_VRSAVE = 1;                                           \
-  if (DEFAULT_ABI == ABI_DARWIN)                                       \
-  {                                                                    \
-    if (MACHO_DYNAMIC_NO_PIC_P)                                                \
-      {                                                                        \
-        if (flag_pic)                                                  \
-            warning (0, "-mdynamic-no-pic overrides -fpic or -fPIC");  \
-        flag_pic = 0;                                                  \
-      }                                                                        \
-    else if (flag_pic == 1)                                            \
-      {                                                                        \
-        flag_pic = 2;                                                  \
-      }                                                                        \
-  }                                                                    \
-  if (TARGET_64BIT && ! TARGET_POWERPC64)                              \
-    {                                                                  \
-      target_flags |= MASK_POWERPC64;                                  \
-      warning (0, "-m64 requires PowerPC64 architecture, enabling");   \
-    }                                                                  \
-} while(0)
+#define SUBTARGET_OVERRIDE_OPTIONS darwin_rs6000_override_options ()
 
 #define C_COMMON_OVERRIDE_OPTIONS do {                                 \
   /* On powerpc, __cxa_get_exception_ptr is available starting in the  \
      10.4.6 libstdc++.dylib.  */                                       \
 
 #define C_COMMON_OVERRIDE_OPTIONS do {                                 \
   /* On powerpc, __cxa_get_exception_ptr is available starting in the  \
      10.4.6 libstdc++.dylib.  */                                       \
-  if ((! darwin_macosx_version_min                                     \
-       || strverscmp (darwin_macosx_version_min, "10.4.6") < 0)                \
+  if (strverscmp (darwin_macosx_version_min, "10.4.6") < 0             \
       && flag_use_cxa_get_exception_ptr == 2)                          \
     flag_use_cxa_get_exception_ptr = 0;                                        \
       && flag_use_cxa_get_exception_ptr == 2)                          \
     flag_use_cxa_get_exception_ptr = 0;                                        \
+  if (flag_mkernel)                                                    \
+    flag_no_builtin = 1;                                               \
+  SUBTARGET_C_COMMON_OVERRIDE_OPTIONS;                                 \
 } while (0)
 
 /* Darwin has 128-bit long double support in libc in 10.4 and later.
 } while (0)
 
 /* Darwin has 128-bit long double support in libc in 10.4 and later.
@@ -114,9 +90,13 @@ do {                                                                        \
    the kernel or some such.  */
 
 #define CC1_SPEC "\
    the kernel or some such.  */
 
 #define CC1_SPEC "\
-%{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }} \
-%{static: %{Zdynamic: %e conflicting code gen style switches are used}}\
-%{!static:%{!mdynamic-no-pic:-fPIC}}"
+  %(cc1_cpu) \
+  %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }} \
+  %{static: %{Zdynamic: %e conflicting code gen style switches are used}}\
+  %{!mmacosx-version-min=*:-mmacosx-version-min=%(darwin_minversion)} \
+  %{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}}"
+
+#define DARWIN_ARCH_SPEC "%{m64:ppc64;:ppc}"
 
 #define DARWIN_SUBARCH_SPEC "                  \
  %{m64: ppc64}                                 \
 
 #define DARWIN_SUBARCH_SPEC "                  \
  %{m64: ppc64}                                 \
@@ -141,9 +121,21 @@ do {                                                                       \
 #define DARWIN_CRT2_SPEC \
   "%{!m64:%:version-compare(!> 10.4 mmacosx-version-min= crt2.o%s)}"
 
 #define DARWIN_CRT2_SPEC \
   "%{!m64:%:version-compare(!> 10.4 mmacosx-version-min= crt2.o%s)}"
 
+/* Determine a minimum version based on compiler options.  */
+#define DARWIN_MINVERSION_SPEC                                 \
+  "%{m64:%{fgnu-runtime:10.4;                                  \
+          ,objective-c|,objc-cpp-output:10.5;                  \
+          ,objective-c-header:10.5;                            \
+          ,objective-c++|,objective-c++-cpp-output:10.5;       \
+          ,objective-c++-header|,objc++-cpp-output:10.5;       \
+          :10.4};                                              \
+     shared-libgcc:10.3;                                       \
+     :10.1}"
+
 #undef SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS                  \
 #undef SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS                  \
-  { "darwin_arch", "%{m64:ppc64;:ppc}" },      \
+  DARWIN_EXTRA_SPECS                            \
+  { "darwin_arch", DARWIN_ARCH_SPEC },         \
   { "darwin_crt2", DARWIN_CRT2_SPEC },         \
   { "darwin_subarch", DARWIN_SUBARCH_SPEC },
 
   { "darwin_crt2", DARWIN_CRT2_SPEC },         \
   { "darwin_subarch", DARWIN_SUBARCH_SPEC },
 
@@ -250,8 +242,6 @@ do {                                                                        \
 
 /* This says how to output an assembler line to define a global common
    symbol.  */
 
 /* This says how to output an assembler line to define a global common
    symbol.  */
-/* ? */
-#undef  ASM_OUTPUT_ALIGNED_COMMON
 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)                   \
   do {                                                                 \
     unsigned HOST_WIDE_INT _new_size = SIZE;                           \
 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)                   \
   do {                                                                 \
     unsigned HOST_WIDE_INT _new_size = SIZE;                           \
@@ -363,29 +353,28 @@ do {                                                                      \
    ? GENERAL_REGS                                              \
    : (CLASS))
 
    ? GENERAL_REGS                                              \
    : (CLASS))
 
-/* Fix for emit_group_load (): force large constants to be pushed via regs.  */
-#define ALWAYS_PUSH_CONSTS_USING_REGS_P                1
-
-/* This now supports a natural alignment mode */
-/* Darwin word-aligns FP doubles but doubleword-aligns 64-bit ints.  */
-#define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
-  (TARGET_ALIGN_NATURAL ? (COMPUTED) : \
-  (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
-             ? get_inner_array_type (FIELD) \
-             : TREE_TYPE (FIELD)) == DFmode \
-   ? MIN ((COMPUTED), 32) : (COMPUTED)))
+/* Compute field alignment.  This is similar to the version of the
+   macro in the Apple version of GCC, except that version supports
+   'mac68k' alignment, and that version uses the computed alignment
+   always for the first field of a structure.  The first-field
+   behavior is dealt with by
+   darwin_rs6000_special_round_type_align.  */
+#define ADJUST_FIELD_ALIGN(FIELD, COMPUTED)    \
+  (TARGET_ALIGN_NATURAL ? (COMPUTED)           \
+   : (COMPUTED) == 128 ? 128                   \
+   : MIN ((COMPUTED), 32))
 
 /* Darwin increases natural record alignment to doubleword if the first
    field is an FP double while the FP fields remain word aligned.  */
 
 /* Darwin increases natural record alignment to doubleword if the first
    field is an FP double while the FP fields remain word aligned.  */
-#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)                  \
-  ((TREE_CODE (STRUCT) == RECORD_TYPE                                  \
-    || TREE_CODE (STRUCT) == UNION_TYPE                                        \
-    || TREE_CODE (STRUCT) == QUAL_UNION_TYPE)                          \
-   && TARGET_ALIGN_NATURAL == 0                                        \
-   ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED)     \
-   : (TREE_CODE (STRUCT) == VECTOR_TYPE                                        \
-      && ALTIVEC_VECTOR_MODE (TYPE_MODE (STRUCT)))                     \
-   ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128)                                   \
+#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)                    \
+  ((TREE_CODE (STRUCT) == RECORD_TYPE                                    \
+    || TREE_CODE (STRUCT) == UNION_TYPE                                          \
+    || TREE_CODE (STRUCT) == QUAL_UNION_TYPE)                            \
+   && TARGET_ALIGN_NATURAL == 0                                                  \
+   ? darwin_rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \
+   : (TREE_CODE (STRUCT) == VECTOR_TYPE                                          \
+      && ALTIVEC_VECTOR_MODE (TYPE_MODE (STRUCT)))                       \
+   ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128)                            \
    : MAX ((COMPUTED), (SPECIFIED)))
 
 /* Specify padding for the last element of a block move between
    : MAX ((COMPUTED), (SPECIFIED)))
 
 /* Specify padding for the last element of a block move between
@@ -416,9 +405,9 @@ do {                                                                        \
 #include <stdbool.h>
 #endif
 
 #include <stdbool.h>
 #endif
 
+#if !defined(__LP64__) && !defined(DARWIN_LIBSYSTEM_HAS_UNWIND)
 #define MD_UNWIND_SUPPORT "config/rs6000/darwin-unwind.h"
 #define MD_UNWIND_SUPPORT "config/rs6000/darwin-unwind.h"
-
-#define HAS_MD_FALLBACK_FRAME_STATE_FOR 1
+#endif
 
 /* True, iff we're generating fast turn around debugging code.  When
    true, we arrange for function prologues to start with 5 nops so
 
 /* True, iff we're generating fast turn around debugging code.  When
    true, we arrange for function prologues to start with 5 nops so
@@ -438,5 +427,8 @@ do {                                                                        \
 #undef TARGET_C99_FUNCTIONS
 #define TARGET_C99_FUNCTIONS                                   \
   (TARGET_64BIT                                                        \
 #undef TARGET_C99_FUNCTIONS
 #define TARGET_C99_FUNCTIONS                                   \
   (TARGET_64BIT                                                        \
-   || (darwin_macosx_version_min                               \
-       && strverscmp (darwin_macosx_version_min, "10.3") >= 0))
+   || strverscmp (darwin_macosx_version_min, "10.3") >= 0)
+
+/* When generating kernel code or kexts, we don't use Altivec by
+   default, as kernel code doesn't save/restore those registers.  */
+#define OS_MISSING_ALTIVEC (flag_mkernel || flag_apple_kext)