diff mbox

Unify MIPS ABI macros

Message ID AANLkTi=ypT5fGnFaBviQ6Pg7U-WhY=O6U-gRcF1haQ0A@mail.gmail.com
State New
Headers show

Commit Message

Robert Millan Jan. 22, 2011, 9:59 a.m. UTC
There are a few macros indicating MIPS ABI which are defined
in netbsd.h but are not really OS-specific.  This patch unifies
them for all MIPS platforms.

Note: they're also defined in the modified versions of GCC
included with FreeBSD [1] and OpenBSD [2].  They would
clearly be useful on GNU systems; e.g. Glibc currently
resolves this by defining its own set of macros based on
${host} triplet.

[1] http://svn.freebsd.org/viewvc/base/head/contrib/gcc/config/mips/freebsd.h?revision=208737&view=markup
[2] http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/gnu/gcc/gcc/config/mips/openbsd.h?rev=1.2;content-type=text%2Fplain

Comments

David Daney Jan. 24, 2011, 6:48 p.m. UTC | #1
On 01/22/2011 01:59 AM, Robert Millan wrote:
> There are a few macros indicating MIPS ABI which are defined
> in netbsd.h but are not really OS-specific.  This patch unifies
> them for all MIPS platforms.
>
> Note: they're also defined in the modified versions of GCC
> included with FreeBSD [1] and OpenBSD [2].  They would
> clearly be useful on GNU systems; e.g. Glibc currently
> resolves this by defining its own set of macros based on
> ${host} triplet.
>
> [1]http://svn.freebsd.org/viewvc/base/head/contrib/gcc/config/mips/freebsd.h?revision=208737&view=markup
> [2]http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/gnu/gcc/gcc/config/mips/openbsd.h?rev=1.2;content-type=text%2Fplain
>
> -- Robert Millan
>
>
> mips_abi.diff
>
>
> 2011-01-22  Robert Millan<rmh@gnu.org>
>
> 	* config/mips/netbsd.h (TARGET_OS_CPP_BUILTINS): Move definition of
> 	"__mips_eabi", "__mips_n32", "__mips_n64", or "__mips_o64" ...
> 	* config/mips/mips.h (TARGET_CPU_CPP_BUILTINS): ... here.
>
> Index: gcc/config/mips/netbsd.h
> ===================================================================
> --- gcc/config/mips/netbsd.h	(revision 169055)
> +++ gcc/config/mips/netbsd.h	(working copy)
> @@ -39,15 +39,6 @@
>   							\
>         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)
>
> Index: gcc/config/mips/mips.h
> ===================================================================
> --- gcc/config/mips/mips.h	(revision 169055)
> +++ gcc/config/mips/mips.h	(working copy)
> @@ -553,6 +553,12 @@
>   									\
>         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");					\
>   									\
>         if (TARGET_CACHE_BUILTIN)						\
>   	builtin_define ("__GCC_HAVE_BUILTIN_MIPS_CACHE");		\

I don't think this is a good idea.

On Linux/glibc systems, we test the built-in _MIPS_SIM macro.  Adding an 
additional way to determine the ABI, makes things less clean rather than 
simplifying them.

David Daney
Robert Millan Jan. 26, 2011, 8:35 a.m. UTC | #2
2011/1/24 David Daney <ddaney@caviumnetworks.com>:
> Adding an
> additional way to determine the ABI, makes things less clean rather than
> simplifying them.

Then why not remove the deprecated macros?  This half-way approach
is very harmful, because it renders __mips_{o64,n32,n64} macros as
inherently unportable, but there's no clear indication that they can't
be used portably (other than reading GCC source).
diff mbox

Patch

2011-01-22  Robert Millan  <rmh@gnu.org>

	* config/mips/netbsd.h (TARGET_OS_CPP_BUILTINS): Move definition of
	"__mips_eabi", "__mips_n32", "__mips_n64", or "__mips_o64" ...
	* config/mips/mips.h (TARGET_CPU_CPP_BUILTINS): ... here.

Index: gcc/config/mips/netbsd.h
===================================================================
--- gcc/config/mips/netbsd.h	(revision 169055)
+++ gcc/config/mips/netbsd.h	(working copy)
@@ -39,15 +39,6 @@ 
 							\
       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)
 
Index: gcc/config/mips/mips.h
===================================================================
--- gcc/config/mips/mips.h	(revision 169055)
+++ gcc/config/mips/mips.h	(working copy)
@@ -553,6 +553,12 @@ 
 									\
       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");					\
 									\
       if (TARGET_CACHE_BUILTIN)						\
 	builtin_define ("__GCC_HAVE_BUILTIN_MIPS_CACHE");		\