OSDN Git Service

* config/rs6000/x-rs6000: New file.
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / darwin.h
index adefe2f..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)");
@@ -40,6 +39,9 @@
 
 #define TARGET_OBJECT_FORMAT OBJECT_MACHO
 
 
 #define TARGET_OBJECT_FORMAT OBJECT_MACHO
 
+/* Size of the Obj-C jump buffer.  */
+#define OBJC_JBLEN ((TARGET_64BIT) ? (26*2 + 18*2 + 129 + 1) : (26 + 18*2 + 129 + 1))
+
 /* We're not ever going to do TOCs.  */
 
 #define TARGET_TOC 0
 /* We're not ever going to do TOCs.  */
 
 #define TARGET_TOC 0
 /* 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)
 
-/* Handle #pragma weak and #pragma pack.  */
-#define HANDLE_SYSV_PRAGMA 1
-
-
-#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)                                            \
-      {                                                                        \
-        /* Darwin doesn't support -fpic.  */                           \
-        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.
@@ -116,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}                                 \
@@ -143,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 },
 
@@ -252,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;                           \
@@ -289,21 +277,21 @@ do {                                                                      \
         fprintf (FILE, "\t.align32 %d,0x60000000\n", (LOG));  \
     } while (0)
 
         fprintf (FILE, "\t.align32 %d,0x60000000\n", (LOG));  \
     } while (0)
 
-/* Generate insns to call the profiler.  */
-
 #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
 /* This is supported in cctools 465 and later.  The macro test
    above prevents using it in earlier build environments.  */
 #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
 /* This is supported in cctools 465 and later.  The macro test
    above prevents using it in earlier build environments.  */
-#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP)           \
-   if ((LOG) != 0)                                             \
-     {                                                         \
-       if ((MAX_SKIP) == 0)                                    \
-         fprintf ((FILE), "\t.p2align %d\n", (LOG));           \
-       else                                                    \
-         fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \
-     }
+#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP)          \
+  if ((LOG) != 0)                                             \
+    {                                                         \
+      if ((MAX_SKIP) == 0)                                    \
+        fprintf ((FILE), "\t.p2align %d\n", (LOG));           \
+      else                                                    \
+        fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \
+    }
 #endif
 
 #endif
 
+/* Generate insns to call the profiler.  */
+
 #define PROFILE_HOOK(LABEL)   output_profile_hook (LABEL)
 
 /* Function name to call to do profiling.  */
 #define PROFILE_HOOK(LABEL)   output_profile_hook (LABEL)
 
 /* Function name to call to do profiling.  */
@@ -365,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
@@ -418,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
@@ -440,52 +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))
-
-/* Attempt to turn on execute permission for the stack.  This may be
-    used by INITIALIZE_TRAMPOLINE of the target needs it (that is,
-    if the target machine can change execute permissions on a page).
-
-    There is no way to query the execute permission of the stack, so
-    we always issue the mprotect() call.
-
-    Note that we go out of our way to use namespace-non-invasive calls
-    here.  Unfortunately, there is no libc-internal name for mprotect().
-
-    Also note that no errors should be emitted by this code; it is
-    considered dangerous for library calls to send messages to
-    stdout/stderr.  */
-
-#define ENABLE_EXECUTE_STACK                                            \
-extern void __enable_execute_stack (void *);                            \
-void                                                                    \
-__enable_execute_stack (void *addr)                                     \
-{                                                                       \
-   extern int mprotect (void *, size_t, int);                           \
-   extern int __sysctl (int *, unsigned int, void *, size_t *,          \
-                       void *, size_t);                                 \
-                                                                        \
-   static int size;                                                     \
-   static long mask;                                                    \
-                                                                        \
-   char *page, *end;                                                    \
-                                                                        \
-   if (size == 0)                                                       \
-     {                                                                  \
-       int mib[2];                                                      \
-       size_t len;                                                      \
-                                                                        \
-       mib[0] = 6; /* CTL_HW */                                         \
-       mib[1] = 7; /* HW_PAGESIZE */                                    \
-       len = sizeof (size);                                             \
-       (void) __sysctl (mib, 2, &size, &len, NULL, 0);                  \
-       mask = ~((long) size - 1);                                       \
-     }                                                                  \
-                                                                        \
-   page = (char *) (((long) addr) & mask);                              \
-   end  = (char *) ((((long) (addr + (TARGET_64BIT ? 48 : 40))) & mask) + size); \
-                                                                        \
-   /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */                        \
-   (void) mprotect (page, end - page, 7);                               \
-}
+   || 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)