This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] x86_64 darwin work


So, building on the SYMBOL_FLAG_MACH_DEP patch previously and part of Geoff's TImode patch here's the final patch for x86_64 support for darwin. It only affects darwin specific code. I've pulled out the part of Geoff's patch that I needed. I've separated the patches out for libcpp, gcc and the gcc testsuite.

The one big thing that isn't working yet is the x86_64 abi testsuite and that's because the asm file needs rewriting for darwin. Otherwise a few regressions from x86_64-linux.

OK? Tested on x86_64-darwin, i386-darwin and x86_64-linux.

-eric

2006-09-07 Eric Christopher <echristo@apple.com>

* configure.ac: Add 64-bit HWI support.

2006-09-07 Eric Christopher <echristo@apple.com>

	* config.gcc (i?86-*-darwin): Add 64-bit HWI support.
	* config.host: Ditto.
	* config/t-slibgcc-darwin: Support x86_64 multilib.
	* config/i386/i386.h (JUMP_TABLES_IN_TEXT_SECTION):
	Return 1 for x86_64-darwin.
	* config/i386/t-darwin: Add m64 multilib.
	(LIB2_SIDITI_CONV_FUNCS): Use.
	(LIB2FUNCS_EXTRA): Ditto.
	* config/i386/darwin.h: Support x86_64.
	* config/i386/i386.c (override_options): Turn on flag_pic
	for x86_64-darwin. Disable flag_omit_pointer.
	(get_pc_thunk_name): Assert !TARGET_64BIT.
	(legitimate_address_p): Disable machopic addressing for
	x86_64.
	(legitimize_pic_address): Ditto.
	(ix86_expand_move): Ditto.
	(ix86_expand_call): Ditto.
	(machopic_output_stub): Ditto.
	* config/darwin.c (machopic_select_section): Support literal16.
	(machopic_select_rtx_section): Ditto.
	* config/darwin-sections.def: Ditto.
	* config/darwin-64.c: New.

2006-09-07 Eric Christopher <echristo@apple.com>

	* gcc.target/i386/20060512-3.c: Run test on ilp32 only.
	* gcc.target/i386/memcpy-1.c: Ditto.
	* gcc.target/i386/asm-1.c: Ditto.
	* gcc.target/i386/20060512-4.c: Ditto.
	* gcc.target/i386/compress-float-387.c: Ditto.
	* gcc.target/i386/20060512-1.c: Ditto.
	* gcc.target/i386/compress-float-sse.c: Ditto.
	* gcc.target/i386/20060512-2.c: Ditto.
	* gcc.target/i386/compress-float-sse-pic.c: Ditto.
	* gcc.target/i386/stack-prot-kernel.c: Ditto.
	* gcc.target/i386/compress-float-387-pic.c: Ditto.
	* gcc.dg/pr26449.c: Ditto.
	* gcc.dg/attr-ms_struct-2.c: Ditto.
	* gcc.dg/attr-ms_struct-1.c: Ditto.
	* gcc.misc-tests/linkage.exp: Fix 64-bit darwin support.
Index: libcpp/configure.ac
===================================================================
--- libcpp/configure.ac	(revision 116758)
+++ libcpp/configure.ac	(working copy)
@@ -118,6 +118,7 @@ case $target in
 	x86_64-*-* | \
 	ia64-*-* | \
 	hppa*64*-*-* | parisc*64*-*-* | \
+	i[34567]86-*-darwin[0-9]* | \
 	i[34567]86-*-solaris2.1[0-9]* | \
 	mips*-*-* | \
 	mmix-*-* | \
Index: testsuite/gcc.target/i386/20060512-3.c
===================================================================
--- testsuite/gcc.target/i386/20060512-3.c	(revision 116758)
+++ testsuite/gcc.target/i386/20060512-3.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do run { target i?86-*-* } } */
+/* { dg-require-effective-target ilp32 } */
 /* { dg-options "-std=gnu99 -msse2 -mstackrealign" } */
 #include <emmintrin.h>
 __m128i __attribute__ ((__noinline__))
Index: testsuite/gcc.target/i386/memcpy-1.c
===================================================================
--- testsuite/gcc.target/i386/memcpy-1.c	(revision 116758)
+++ testsuite/gcc.target/i386/memcpy-1.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile { target i?86-*-* } } */
+/* { dg-require-effective-target ilp32 } */
 /* { dg-options "-O2 -march=pentiumpro -minline-all-stringops" } */
 /* { dg-final { scan-assembler "rep" } } */
 /* { dg-final { scan-assembler "movs" } } */
Index: testsuite/gcc.target/i386/asm-1.c
===================================================================
--- testsuite/gcc.target/i386/asm-1.c	(revision 116758)
+++ testsuite/gcc.target/i386/asm-1.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-effective-target ilp32 } */
 /* { dg-options "-m32" } */
 
 register unsigned int EAX asm ("r14"); /* { dg-error "register name" } */
Index: testsuite/gcc.target/i386/20060512-4.c
===================================================================
--- testsuite/gcc.target/i386/20060512-4.c	(revision 116758)
+++ testsuite/gcc.target/i386/20060512-4.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile { target i?86-*-* } } */
+/* { dg-require-effective-target ilp32 } */
 /* { dg-options "-mstackrealign" } */
 int
 outer_function (int x, int y)
Index: testsuite/gcc.target/i386/compress-float-387.c
===================================================================
--- testsuite/gcc.target/i386/compress-float-387.c	(revision 116758)
+++ testsuite/gcc.target/i386/compress-float-387.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile { target i?86*-*-* } } */
+/* { dg-require-effective-target ilp32 } */
 /* { dg-options "-O2 -march=pentium4 -mtune=prescott -mfpmath=387" } */
 double foo (double x) {
   return x + 1.75;
Index: testsuite/gcc.target/i386/20060512-1.c
===================================================================
--- testsuite/gcc.target/i386/20060512-1.c	(revision 116758)
+++ testsuite/gcc.target/i386/20060512-1.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do run { target i?86-*-* } } */
+/* { dg-require-effective-target ilp32 } */
 /* { dg-options "-std=gnu99 -msse2" } */
 #include <emmintrin.h>
 __m128i __attribute__ ((__noinline__))
Index: testsuite/gcc.target/i386/compress-float-sse.c
===================================================================
--- testsuite/gcc.target/i386/compress-float-sse.c	(revision 116758)
+++ testsuite/gcc.target/i386/compress-float-sse.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile { target i?86*-*-* } } */
+/* { dg-require-effective-target ilp32 } */
 /* { dg-options "-O2 -march=pentium4 -mtune=prescott -mfpmath=sse" } */
 double foo (double x) {
   return x + 1.75;
Index: testsuite/gcc.target/i386/20060512-2.c
===================================================================
--- testsuite/gcc.target/i386/20060512-2.c	(revision 116758)
+++ testsuite/gcc.target/i386/20060512-2.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile { target i?86-*-* } } */
+/* { dg-require-effective-target ilp32 } */
 /* { dg-options "-std=gnu99" } */
 int
 outer_function (int x, int y)
Index: testsuite/gcc.target/i386/compress-float-sse-pic.c
===================================================================
--- testsuite/gcc.target/i386/compress-float-sse-pic.c	(revision 116758)
+++ testsuite/gcc.target/i386/compress-float-sse-pic.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile { target i?86*-*-* } } */
+/* { dg-require-effective-target ilp32 } */
 /* { dg-options "-O2 -march=pentium4 -mtune=prescott -mfpmath=sse -fpic" } */
 double foo (double x) {
   return x + 1.75;
Index: testsuite/gcc.target/i386/stack-prot-kernel.c
===================================================================
--- testsuite/gcc.target/i386/stack-prot-kernel.c	(revision 116758)
+++ testsuite/gcc.target/i386/stack-prot-kernel.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile { target lp64 } } */
+/* { dg-skip-if "darwin x86_64 is pic" { *-*-darwin* } { "-m64" } { "" } } */
 /* { dg-options "-O2 -fstack-protector-all -mcmodel=kernel" } */
 
 void test1 (int x)
Index: testsuite/gcc.target/i386/compress-float-387-pic.c
===================================================================
--- testsuite/gcc.target/i386/compress-float-387-pic.c	(revision 116758)
+++ testsuite/gcc.target/i386/compress-float-387-pic.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile { target i?86*-*-* } } */
+/* { dg-require-effective-target ilp32 } */
 /* { dg-options "-O2 -march=pentium4 -mtune=prescott -mfpmath=387 -fpic" } */
 double foo (double x) {
   return x + 1.75;
Index: testsuite/gcc.dg/pr26449.c
===================================================================
--- testsuite/gcc.dg/pr26449.c	(revision 116758)
+++ testsuite/gcc.dg/pr26449.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile { target i?86-*-* } } */
+/* { dg-require-effective-target ilp32 } */
 /* { dg-options "-O1 -ftree-vectorize -march=pentium4 -std=c99" } */
 
 void matmul_i4 (int bbase_yn, int xcount)
@@ -12,4 +13,3 @@ void matmul_i4 (int bbase_yn, int xcount
       dest_y[x] += abase_n[x] * bbase_yn; 
     }
 }
-
Index: testsuite/gcc.dg/attr-ms_struct-2.c
===================================================================
--- testsuite/gcc.dg/attr-ms_struct-2.c	(revision 116758)
+++ testsuite/gcc.dg/attr-ms_struct-2.c	(working copy)
@@ -1,5 +1,6 @@
 /* Test for MS structure sizes.  */
-/* { dg-do run { target *-*-interix* *-*-mingw* *-*-cygwin* i?86-*-darwin* } }
+/* { dg-do run { target *-*-interix* *-*-mingw* *-*-cygwin* i?86-*-darwin* } } */
+/* { dg-require-effective-target ilp32 } */
 /* { dg-options "-std=gnu99" } */
 
 extern void abort ();
Index: testsuite/gcc.dg/attr-ms_struct-1.c
===================================================================
--- testsuite/gcc.dg/attr-ms_struct-1.c	(revision 116758)
+++ testsuite/gcc.dg/attr-ms_struct-1.c	(working copy)
@@ -1,5 +1,6 @@
 /* Test for MS structure sizes.  */
-/* { dg-do run { target *-*-interix* *-*-mingw* *-*-cygwin* i?86-*-darwin* } }
+/* { dg-do run { target *-*-interix* *-*-mingw* *-*-cygwin* i?86-*-darwin* } } */
+/* { dg-require-effective-target ilp32 } */
 /* { dg-options "-std=gnu99" } */
 
 extern void abort ();
Index: testsuite/gcc.misc-tests/linkage.exp
===================================================================
--- testsuite/gcc.misc-tests/linkage.exp	(revision 116758)
+++ testsuite/gcc.misc-tests/linkage.exp	(working copy)
@@ -73,6 +73,13 @@ if [isnative] then {
 	    } elseif [ string match "*32-bit*" $file_string ] {
 		set native_cflags "-m32"
 	    }
+        } elseif [istarget "*-*-darwin*"] {
+            set file_string [exec file "linkage-x.o"]
+            if [ string match "*64-bit*" $file_string ] {
+                set native_cflags "-m64"
+            } elseif [ string match "*32-bit*" $file_string ] {
+                set native_cflags "-m32"
+            }
 	}
 
 	if [file exists "linkage-y.o"] then {
Index: config.gcc
===================================================================
--- config.gcc	(revision 116774)
+++ config.gcc	(working copy)
@@ -1001,7 +1001,7 @@ hppa[12]*-*-hpux11*)
 	gas=yes
 	;;
 i[34567]86-*-darwin*)
-	# All the configuration is presently done generically.
+	need_64bit_hwint=yes
 	;;
 i[34567]86-*-elf*)
 	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h i386/i386elf.h"
Index: config.host
===================================================================
--- config.host	(revision 116774)
+++ config.host	(working copy)
@@ -183,6 +183,7 @@ case ${host} in
   i[34567]86-*-darwin*)
     out_host_hook_obj="${out_host_hook_obj} host-i386-darwin.o"
     host_xmake_file="${host_xmake_file} i386/x-darwin"
+    use_long_long_for_widest_fast_int=yes
     ;;
   powerpc-*-beos*)
     host_can_use_collect2=no
Index: config/t-slibgcc-darwin
===================================================================
--- config/t-slibgcc-darwin	(revision 116774)
+++ config/t-slibgcc-darwin	(working copy)
@@ -92,5 +92,10 @@ install-darwin-libgcc-stubs : $(INSTALL_
 	else true; fi
 	$(LN_S) libgcc_s.1.dylib \
 		$(DESTDIR)$(slibdir)/libgcc_s_ppc64.1.dylib
+	if [ -f $(DESTDIR)$(slibdir)/libgcc_s_x86_64.1.dylib ]; then \
+	  rm -f $(DESTDIR)$(slibdir)/libgcc_s_x86_64.1.dylib; \
+	else true; fi
+	$(LN_S) libgcc_s.1.dylib \
+		$(DESTDIR)$(slibdir)/libgcc_s_x86_64.1.dylib
 
 INSTALL_LIBGCC = install-darwin-libgcc-stubs install-multilib
Index: config/i386/i386.h
===================================================================
--- config/i386/i386.h	(revision 116774)
+++ config/i386/i386.h	(working copy)
@@ -2011,11 +2011,13 @@ do {									\
 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
   ix86_output_addr_diff_elt ((FILE), (VALUE), (REL))
 
-/* Under some conditions we need jump tables in the text section, because
-   the assembler cannot handle label differences between sections.  */
+/* Under some conditions we need jump tables in the text section,
+   because the assembler cannot handle label differences between
+   sections.  This is the case for x86_64 on Mach-O for example.  */
 
 #define JUMP_TABLES_IN_TEXT_SECTION \
-  (!TARGET_64BIT && flag_pic && !HAVE_AS_GOTOFF_IN_DATA)
+  (flag_pic && ((TARGET_MACHO && TARGET_64BIT) \
+   || (!TARGET_64BIT && !HAVE_AS_GOTOFF_IN_DATA)))
 
 /* Switch to init or fini section via SECTION_OP, emit a call to FUNC,
    and switch back.  For x86 we do this only to save a few bytes that
Index: config/i386/t-darwin
===================================================================
--- config/i386/t-darwin	(revision 116774)
+++ config/i386/t-darwin	(working copy)
@@ -1 +1,5 @@
 SHLIB_VERPFX = $(srcdir)/config/i386/darwin-libgcc
+MULTILIB_OPTIONS = m64
+MULTILIB_DIRNAMES = x86_64
+LIB2_SIDITI_CONV_FUNCS=yes
+LIB2FUNCS_EXTRA = $(srcdir)/config/darwin-64.c
Index: config/i386/darwin.h
===================================================================
--- config/i386/darwin.h	(revision 116774)
+++ config/i386/darwin.h	(working copy)
@@ -25,18 +25,44 @@ Boston, MA 02110-1301, USA.  */
 
 #define TARGET_VERSION fprintf (stderr, " (i686 Darwin)");
 
+#undef  TARGET_64BIT
+#define TARGET_64BIT (target_flags & MASK_64BIT)
+
+#ifdef IN_LIBGCC2
+#undef TARGET_64BIT
+#ifdef __x86_64__
+#define TARGET_64BIT 1
+#else
+#define TARGET_64BIT 0
+#endif
+#endif
+
 #undef TARGET_FPMATH_DEFAULT
 #define TARGET_FPMATH_DEFAULT (TARGET_SSE ? FPMATH_SSE : FPMATH_387)
 
 #define TARGET_OS_CPP_BUILTINS()                \
   do                                            \
     {                                           \
-      builtin_define ("__i386__");              \
       builtin_define ("__LITTLE_ENDIAN__");     \
       darwin_cpp_builtins (pfile);		\
     }                                           \
   while (0)
 
+#undef PTRDIFF_TYPE
+#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
+
+#undef SIZE_TYPE
+#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
+
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
+#undef MAX_BITS_PER_WORD
+#define MAX_BITS_PER_WORD 64
+
 #undef FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN
 #define FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN (0)
 
@@ -48,13 +74,18 @@ Boston, MA 02110-1301, USA.  */
   %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }}"
 
 #undef ASM_SPEC
-#define ASM_SPEC "-arch i386 -force_cpusubtype_ALL"
+#define ASM_SPEC "%{m64: -arch x86_64 -force_cpusubtype_ALL} \
+                  %{!m64: -arch i386 -force_cpusubtype_ALL}"
+#define DARWIN_ARCH_SPEC "%{m64:x86_64;:i386}"
+#define DARWIN_SUBARCH_SPEC "                                   \
+  %{m64: x86_64}                                                \
+  %{!m64: i386}"
 
 #undef SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS					\
-  { "darwin_arch", "i386" },					\
+  { "darwin_arch", DARWIN_ARCH_SPEC },                          \
   { "darwin_crt2", "" },					\
-  { "darwin_subarch", "i386" },
+  { "darwin_subarch", DARWIN_SUBARCH_SPEC },
 
 /* Use the following macro for any Darwin/x86-specific command-line option
    translation.  */
@@ -85,7 +116,7 @@ extern void darwin_x86_file_end (void);
 /* By default, target has a 80387, uses IEEE compatible arithmetic,
    and returns float values in the 387.  */
 
-#define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_128BIT_LONG_DOUBLE | MASK_ALIGN_DOUBLE)
+#define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_128BIT_LONG_DOUBLE)
 
 /* For now, disable dynamic-no-pic.  We'll need to go through i386.c
    with a fine-tooth comb looking for refs to flag_pic!  */
@@ -109,7 +140,7 @@ extern void darwin_x86_file_end (void);
 #define ASM_BYTE_OP "\t.byte\t"
 #define ASM_SHORT "\t.word\t"
 #define ASM_LONG "\t.long\t"
-/* Darwin as doesn't do ".quad".  */
+#define ASM_QUAD "\t.quad\t"
 
 #define SUBTARGET_ENCODE_SECTION_INFO  darwin_encode_section_info
 
@@ -144,7 +175,7 @@ extern void darwin_x86_file_end (void);
 #undef FUNCTION_PROFILER
 #define FUNCTION_PROFILER(FILE, LABELNO)				\
     do {								\
-      if (MACHOPIC_INDIRECT)						\
+      if (MACHOPIC_INDIRECT && !TARGET_64BIT)				\
 	{								\
 	  const char *name = machopic_mcount_stub_name ();		\
 	  fprintf (FILE, "\tcall %s\n", name+1);  /*  skip '&'  */	\
@@ -153,6 +184,10 @@ extern void darwin_x86_file_end (void);
       else fprintf (FILE, "\tcall mcount\n");				\
     } while (0)
 
+/* Darwin on x86_64 uses dwarf-2 by default.  */
+#undef PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE (TARGET_64BIT ? DWARF2_DEBUG : DBX_DEBUG)
+
 /* Darwin uses the standard DWARF register numbers but the default
    register numbers for STABS.  Fortunately for 64-bit code the
    default and the standard are the same.  */
@@ -224,6 +259,30 @@ __enable_execute_stack (void *addr)     
 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES darwin_set_default_type_attributes
 
+/* For 64-bit, we need to add 4 because @GOTPCREL is relative to the
+   end of the instruction, but without the 4 we'd only have the right
+   address for the start of the instruction.  */
+#undef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
+#define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE)	\
+  if (TARGET_64BIT)				                                \
+    {                                                                           \
+      if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_pcrel)			\
+        {                                                                       \
+	   fputs (ASM_LONG, FILE);                                              \
+	   assemble_name (FILE, XSTR (ADDR, 0));				\
+	   fputs ("+4@GOTPCREL", FILE);                                         \
+	   goto DONE;                                                           \
+        }									\
+    }										\
+  else                                                                          \
+    {										\
+      if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1))                      \
+        {                                                                       \
+          darwin_non_lazy_pcrel (FILE, ADDR);                                   \
+          goto DONE;								\
+        }                                                                       \
+    }
+
 /* This needs to move since i386 uses the first flag and other flags are
    used in Mach-O.  */
 #undef MACHO_SYMBOL_FLAG_VARIABLE
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 116774)
+++ config/i386/i386.c	(working copy)
@@ -1538,12 +1538,17 @@ override_options (void)
   SUBTARGET_OVERRIDE_OPTIONS;
 #endif
 
+  /* -fPIC is the default for x86_64.  */
+  if (TARGET_MACHO && TARGET_64BIT)
+    flag_pic = 2;
+
   /* Set the default values for switches whose default depends on TARGET_64BIT
      in case they weren't overwritten by command line options.  */
   if (TARGET_64BIT)
     {
+      /* Mach-O doesn't support omitting the frame pointer for now.  */
       if (flag_omit_frame_pointer == 2)
-	flag_omit_frame_pointer = 1;
+	flag_omit_frame_pointer = (TARGET_MACHO ? 0 : 1);
       if (flag_asynchronous_unwind_tables == 2)
 	flag_asynchronous_unwind_tables = 1;
       if (flag_pcc_struct_return == 2)
@@ -4788,6 +4793,8 @@ static int pic_labels_used;
 static void
 get_pc_thunk_name (char name[32], unsigned int regno)
 {
+  gcc_assert (!TARGET_64BIT);
+
   if (USE_HIDDEN_LINKONCE)
     sprintf (name, "__i686.get_pc_thunk.%s", reg_names[regno]);
   else
@@ -6426,12 +6433,16 @@ legitimate_address_p (enum machine_mode 
 	    goto report_error;
 	  }
 
-      else if (flag_pic && (SYMBOLIC_CONST (disp)
+      else if (SYMBOLIC_CONST (disp)
+	       && (flag_pic
+		   || (TARGET_MACHO
 #if TARGET_MACHO
+		       && MACHOPIC_INDIRECT
 			    && !machopic_operand_p (disp)
 #endif
-			    ))
+	       )))
 	{
+
 	is_legitimate_pic:
 	  if (TARGET_64BIT && (index || base))
 	    {
@@ -6544,10 +6555,13 @@ legitimize_pic_address (rtx orig, rtx re
   rtx base;
 
 #if TARGET_MACHO
+  if (TARGET_MACHO && !TARGET_64BIT)
+    {
   if (reg == 0)
     reg = gen_reg_rtx (Pmode);
   /* Use the generic Mach-O PIC machinery.  */
   return machopic_legitimize_pic_address (orig, GET_MODE (orig), reg);
+    }
 #endif
 
   if (TARGET_64BIT && legitimate_pic_address_disp_p (addr))
@@ -8909,6 +8923,8 @@ ix86_expand_move (enum machine_mode mode
 
   if (flag_pic && mode == Pmode && symbolic_operand (op1, Pmode))
     {
+      if (TARGET_MACHO && !TARGET_64BIT)
+	{
 #if TARGET_MACHO
       if (MACHOPIC_PURE)
 	{
@@ -8924,12 +8940,15 @@ ix86_expand_move (enum machine_mode mode
 	op1 = machopic_indirect_data_reference (op1, 0);
       if (op0 == op1)
 	return;
-#else
+#endif
+	}
+      else
+	{
       if (GET_CODE (op0) == MEM)
 	op1 = force_reg (Pmode, op1);
       else
 	op1 = legitimize_address (op1, op1, Pmode);
-#endif /* TARGET_MACHO */
+	}
     }
   else
     {
@@ -13329,15 +13348,21 @@ ix86_expand_call (rtx retval, rtx fnaddr
     pop = NULL;
   gcc_assert (!TARGET_64BIT || !pop);
 
+  if (TARGET_MACHO && !TARGET_64BIT)
+    {
 #if TARGET_MACHO
   if (flag_pic && GET_CODE (XEXP (fnaddr, 0)) == SYMBOL_REF)
     fnaddr = machopic_indirect_call_target (fnaddr);
-#else
+#endif
+    }
+  else
+    {
   /* Static functions and indirect calls don't need the pic register.  */
   if (! TARGET_64BIT && flag_pic
       && GET_CODE (XEXP (fnaddr, 0)) == SYMBOL_REF
       && ! SYMBOL_REF_LOCAL_P (XEXP (fnaddr, 0)))
     use_reg (&use, pic_offset_table_rtx);
+    }
 
   if (TARGET_64BIT && INTVAL (callarg2) >= 0)
     {
@@ -13345,7 +13370,6 @@ ix86_expand_call (rtx retval, rtx fnaddr
       emit_move_insn (al, callarg2);
       use_reg (&use, al);
     }
-#endif /* TARGET_MACHO */
 
   if (! call_insn_operand (XEXP (fnaddr, 0), Pmode))
     {
@@ -17249,6 +17273,9 @@ machopic_output_stub (FILE *file, const 
   char *binder_name, *symbol_name, lazy_ptr_name[32];
   int label = ++current_machopic_label_num;
 
+  /* For 64-bit we shouldn't get here.  */
+  gcc_assert (!TARGET_64BIT);
+
   /* Lose our funky encoding stuff so it doesn't contaminate the stub.  */
   symb = (*targetm.strip_name_encoding) (symb);
 
Index: config/darwin.c
===================================================================
--- config/darwin.c	(revision 116774)
+++ config/darwin.c	(working copy)
@@ -1136,6 +1136,11 @@ machopic_select_section (tree exp, int r
 	       TREE_INT_CST_LOW (size) == 8 &&
 	       TREE_INT_CST_HIGH (size) == 0)
 	return darwin_sections[literal8_section];
+      else if (TARGET_64BIT
+	       && TREE_CODE (size) == INTEGER_CST
+	       && TREE_INT_CST_LOW (size) == 16
+	       && TREE_INT_CST_HIGH (size) == 0)
+	return darwin_sections[literal16_section];
       else
 	return base_section;
     }
@@ -1234,6 +1239,10 @@ machopic_select_rtx_section (enum machin
 	   && (GET_CODE (x) == CONST_INT
 	       || GET_CODE (x) == CONST_DOUBLE))
     return darwin_sections[literal4_section];
+  else if (GET_MODE_SIZE (mode) == 16
+	   && (GET_CODE (x) == CONST_INT
+	       || GET_CODE (x) == CONST_DOUBLE))
+    return darwin_sections[literal16_section];
   else if (MACHOPIC_INDIRECT
 	   && (GET_CODE (x) == SYMBOL_REF
 	       || GET_CODE (x) == CONST
Index: config/darwin-sections.def
===================================================================
--- config/darwin-sections.def	(revision 116774)
+++ config/darwin-sections.def	(working copy)
@@ -14,6 +14,7 @@ DEF_SECTION (data_coal_section, SECTION_
 DEF_SECTION (cstring_section, SECTION_MERGE, ".cstring", 0)
 DEF_SECTION (literal4_section, SECTION_MERGE, ".literal4", 0)
 DEF_SECTION (literal8_section, SECTION_MERGE, ".literal8", 0)
+DEF_SECTION (literal16_section, SECTION_MERGE, ".literal16", 0)
 DEF_SECTION (constructor_section, 0, ".constructor", 0)
 DEF_SECTION (mod_init_section, 0, ".mod_init_func", 0)
 DEF_SECTION (mod_term_section, 0, ".mod_term_func", 0)
Index: config/darwin-64.c
===================================================================
--- config/darwin-64.c	(revision 0)
+++ config/darwin-64.c	(revision 0)
@@ -0,0 +1,77 @@
+/* Functions shipped in the ppc64 version of libgcc_s.1.dylib
+   in older Mac OS X versions, preserved for backwards compatibility.
+   Copyright (C) 2006  Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+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) any later
+version.
+
+In addition to the permissions in the GNU General Public License, the
+Free Software Foundation gives you unlimited permission to link the
+compiled version of this file into combinations with other programs,
+and to distribute those combinations without any restriction coming
+from the use of this file.  (The General Public License restrictions
+do apply in other respects; for example, they cover modification of
+the file, and distribution when not linked into a combine
+executable.)
+
+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 GCC; see the file COPYING.  If not, write to the Free
+Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.  */
+
+#if defined (__ppc64__) || defined (__x86_64__)
+/* Many of these functions have probably never been used by anyone
+   anywhere on ppc64, but it's hard to prove this, so they're defined
+   here.  None are actually necessary, as demonstrated below by defining
+   each function using the operation it implements.  */
+
+typedef long DI;
+typedef unsigned long uDI;
+typedef int SI;
+typedef unsigned int uSI;
+typedef int word_type __attribute__ ((mode (__word__)));
+
+DI __ashldi3 (DI x, word_type c);
+DI __ashrdi3 (DI x, word_type c);
+int __clzsi2 (uSI x);
+word_type __cmpdi2 (DI x, DI y);
+int __ctzsi2 (uSI x);
+DI __divdi3 (DI x, DI y);
+uDI __lshrdi3 (uDI x, word_type c);
+DI __moddi3 (DI x, DI y);
+DI __muldi3 (DI x, DI y);
+DI __negdi2 (DI x);
+int __paritysi2 (uSI x);
+int __popcountsi2 (uSI x);
+word_type __ucmpdi2 (uDI x, uDI y);
+uDI __udivdi3 (uDI x, uDI y);
+uDI __udivmoddi4 (uDI x, uDI y, uDI *r);
+uDI __umoddi3 (uDI x, uDI y);
+
+DI __ashldi3 (DI x, word_type c) { return x << c; }
+DI __ashrdi3 (DI x, word_type c) { return x >> c; }
+int __clzsi2 (uSI x) { return __builtin_clz (x); }
+word_type __cmpdi2 (DI x, DI y) { return x < y ? 0 : x == y ? 1 : 2; }
+int __ctzsi2 (uSI x) { return __builtin_ctz (x); }
+DI __divdi3 (DI x, DI y) { return x / y; }
+uDI __lshrdi3 (uDI x, word_type c) { return x >> c; }
+DI __moddi3 (DI x, DI y) { return x % y; }
+DI __muldi3 (DI x, DI y) { return x * y; }
+DI __negdi2 (DI x) { return -x; }
+int __paritysi2 (uSI x) { return __builtin_parity (x); }
+int __popcountsi2 (uSI x) { return __builtin_popcount (x); }
+word_type __ucmpdi2 (uDI x, uDI y) { return x < y ? 0 : x == y ? 1 : 2; }
+uDI __udivdi3 (uDI x, uDI y) { return x / y; }
+uDI __udivmoddi4 (uDI x, uDI y, uDI *r) { *r = x % y; return x / y; }
+uDI __umoddi3 (uDI x, uDI y) { return x % y; }
+
+#endif /* __ppc64__ || __x86_64__ */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]