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] disallow -m32 -mpowerpc64 on powerpc64-linux


PR 27619 has been sitting around for a couple of years.  It turned out
to be trickier than I had thought to disallow -mpowerpc64 with -m32 on
powerpc64-unknown-linux-gnu.  For reasons I don't understand, -m32
turns off TARGET_POWERPC64, which means that "-mpowerpc64 -m32" is
handled differently from "-m32 -mpowerpc64".  This patch allow both
combinations to be reported as errors for GNU/Linux.

Several tests use -mpowerpc64, which works in most cases on GNU/Linux.
Those tests are now skipped for Linux and AIX for ILP32.

Bootstrapped and tested on powerpc64-linux with -m32/-m64.  I  used
cross compilers to compare the generated code for the testcase in the
PR with and without the patch for powerpc-apple-darwin-[89].5.0 to
ensure that powerpc-ibm-aix5.3.0.0 continues to report errors for
invalid combinations of options.

Is this OK for trunk?  It's not a regression, but it is target-specific
and allows a user to request generation of code that gets wrong answers
on GNU/Linux.  If it's OK for trunk, is it also OK for active release
branches?

2008-12-12  Janis Johnson  <janis187@us.ibm.com>

gcc/
	PR target/27619
	* config/rs6000/rs6000.c (OS_MISSING_POWERPC64): Define default.
	(rs6000_override_options): Remove ifdef for OS_MISSING_POWERPC64,
	check for 32-bit code generation.
	(rs6000_handle_option): Don't clear POWERPC64 flag for -m32 if
	we'll need it to check for conflicting options.
	* config/rs6000/sysv4.h (SUBTARGET_OVERRIDE_OPTIONS): Report error
	for use of both -m32 and -mpowerpc64.

gcc/testsuite/
	PR target/27619
	* gcc.target/powerpc/mpowerpc64-1.c: New test.
	* gcc.target/powerpc/ppc64-double-1.c: Skip if -mpowerpc64 not
	supported.
	* gcc.target/powerpc/rs6000-fpint-2.c: Ditto.
	* gcc.dg/vect/vect-82_64.c: Ditto.
	* gcc.dg/vect/vect-83_64.c: Ditto.

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 142688)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -68,6 +68,10 @@
 #define TARGET_NO_PROTOTYPE 0
 #endif
 
+#ifndef OS_MISSING_POWERPC64
+#define OS_MISSING_POWERPC64 0
+#endif
+
 #define min(A,B)	((A) < (B) ? (A) : (B))
 #define max(A,B)	((A) > (B) ? (A) : (B))
 
@@ -1553,10 +1557,8 @@
   };
 
   set_masks = POWER_MASKS | POWERPC_MASKS | MASK_SOFT_FLOAT;
-#ifdef OS_MISSING_POWERPC64
-  if (OS_MISSING_POWERPC64)
+  if (OS_MISSING_POWERPC64 && !TARGET_64BIT)
     set_masks &= ~MASK_POWERPC64;
-#endif
 #ifdef OS_MISSING_ALTIVEC
   if (OS_MISSING_ALTIVEC)
     set_masks &= ~MASK_ALTIVEC;
@@ -2273,7 +2275,10 @@
 #else
     case OPT_m32:
 #endif
-      target_flags &= ~MASK_POWERPC64;
+      /* If -mpowerpc64 isn't supported, don't clear the flag.  We'll
+	 need it for detecting the error later in subtarget overrides.  */
+      if (!OS_MISSING_POWERPC64)
+	target_flags &= ~MASK_POWERPC64;
       target_flags_explicit |= MASK_POWERPC64;
       break;
 
Index: gcc/config/rs6000/sysv4.h
===================================================================
--- gcc/config/rs6000/sysv4.h	(revision 142688)
+++ gcc/config/rs6000/sysv4.h	(working copy)
@@ -214,6 +214,9 @@
       error ("-msecure-plt not supported by your assembler");		\
     }									\
 									\
+  if (OS_MISSING_POWERPC64 && TARGET_POWERPC64)				\
+    error ("64-bit computation with 32-bit ABI is not supported");	\
+									\
   /* Treat -fPIC the same as -mrelocatable.  */				\
   if (flag_pic > 1 && DEFAULT_ABI != ABI_AIX)				\
     {									\
Index: gcc/testsuite/gcc.target/powerpc/mpowerpc64-1.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/mpowerpc64-1.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/mpowerpc64-1.c	(revision 0)
@@ -0,0 +1,9 @@
+/* GNU/Linux and Aix don't support using -mpowerpc64 when generating
+   code for a 32-bit ABI.  */
+
+/* { dg-do compile { target { powerpc*-*-linux* powerpc*-*-aix* } } }
+/* { dg-options "-mpowerpc64" } */
+
+/* { dg-error "64-bit computation" "" { target ilp32 } 0 } */
+int i;
+
Index: gcc/testsuite/gcc.target/powerpc/ppc64-double-1.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/ppc64-double-1.c	(revision 142688)
+++ gcc/testsuite/gcc.target/powerpc/ppc64-double-1.c	(working copy)
@@ -1,4 +1,5 @@
 // { dg-do compile }
+// { dg-skip-if "no support for -mpowerpc64" { "powerpc*-*-linux* powerpc*-*-aix*" && ilp32 } { "*" } { "" } }
 // { dg-options "-O2 -mpowerpc64" }
 // { dg-final { scan-assembler-not "stfd"  }  }
 
Index: gcc/testsuite/gcc.target/powerpc/rs6000-fpint-2.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/rs6000-fpint-2.c	(revision 142688)
+++ gcc/testsuite/gcc.target/powerpc/rs6000-fpint-2.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile { target powerpc*-*-darwin* powerpc*-*-linux* } } */
+/* { dg-skip-if "no support for -mpowerpc64" { powerpc*-*-linux* && ilp32 } { "*" } { "" } } */
 /* { dg-options "-mno-powerpc-gfxopt -mpowerpc64" } */
 extern void bar (void *);
 extern double x;
Index: gcc/testsuite/gcc.dg/vect/vect-82_64.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-82_64.c	(revision 142688)
+++ gcc/testsuite/gcc.dg/vect/vect-82_64.c	(working copy)
@@ -1,5 +1,6 @@
 /* { dg-do run { target { { powerpc*-*-* && lp64 } && powerpc_altivec_ok } } } */
 /* { dg-do compile { target { { powerpc*-*-* && ilp32 } && powerpc_altivec_ok } } } */
+/* { dg-skip-if "no support for -mpowerpc64" { "powerpc*-*-linux* powerpc*-*-aix*" && ilp32 } { "*" } { "" } } */
 /* { dg-options "-O2 -ftree-vectorize -mpowerpc64 -fdump-tree-vect-stats -maltivec" } */
 
 #include <stdarg.h>
Index: gcc/testsuite/gcc.dg/vect/vect-83_64.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-83_64.c	(revision 142688)
+++ gcc/testsuite/gcc.dg/vect/vect-83_64.c	(working copy)
@@ -1,5 +1,6 @@
 /* { dg-do run { target { { powerpc*-*-* && lp64 } && powerpc_altivec_ok } } } */
 /* { dg-do compile { target { { powerpc*-*-* && ilp32 } && powerpc_altivec_ok } } } */
+/* { dg-skip-if "no support for -mpowerpc64" { "powerpc*-*-linux* powerpc*-*-aix*" && ilp32 } { "*" } { "" } } */
 /* { dg-options "-O2 -ftree-vectorize -mpowerpc64 -fdump-tree-vect-stats -maltivec" } */
 
 #include <stdarg.h>



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