This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: MIPS SIZE_TYPE and PTRDIFF_TYPE revamp
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 08 Mar 2002 02:55:03 -0300
- Subject: Re: MIPS SIZE_TYPE and PTRDIFF_TYPE revamp
- Organization: GCC Team, Red Hat
- References: <or1yev1vwt.fsf@free.redhat.lsd.ic.unicamp.br>
And here's a complement to that patch, that fixes the setting of
LONG_MAX such that it agrees with the compiler's internal notion of
the width of a long. There were some divergences, particularly when
using -mgp32 and -mlong64 together. This patch, approved by Eric
Christopher, addresses these problems, such that, on that same MIPS
port, the number of C++ failures goes down significantly, and newlib
gets a correct implementation of strchr(). It's optimized to walk the
string long by long, so an incorrect setting of LONG_MAX causes it to
fail in some corner cases, which is great.
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* config/mips/mips.h (LONG_MAX_SPEC): Rewrite, along with
SUBTARGET_CPP_SIZE_SPEC.
* config/mips/abi64.h (LONG_MAX_SPEC): Delete.
Index: gcc/config/mips/mips.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/mips/mips.h,v
retrieving revision 1.160
diff -u -p -r1.160 mips.h
--- gcc/config/mips/mips.h 2002/03/08 05:17:43 1.160
+++ gcc/config/mips/mips.h 2002/03/08 05:43:16
@@ -1060,6 +1060,23 @@ extern int mips_abi;
%{mgp64:%{mlong64:-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int}}} \
%{mabi=32:-D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int} \
"
+#define LONG_MAX_SPEC "\
+%{mlong64:-D__LONG_MAX__=9223372036854775807L}\
+%{!mlong64:\
+ %{mabi=eabi|!mabi=*:\
+ %{!mips1:%{!mips2:%{!mips32:%{!mgp32:%{!mlong32: \
+ %{mips3|mips4|mips5|mips64|mgp64: \
+ -D__LONG_MAX__=9223372036854775807L}}}}}}}} \
+"
+#else /* ABI_DEFAULT != ABI_EABI */
+#define LONG_MAX_SPEC "\
+%{mlong64:-D__LONG_MAX__=9223372036854775807L}\
+%{!mlong64:\
+ %{mabi=eabi:\
+ %{!mips1:%{!mips2:%{!mips32:%{!mgp32:%{!mlong32: \
+ %{mips3|mips4|mips5|mips64|mgp64: \
+ -D__LONG_MAX__=9223372036854775807L}}}}}}}} \
+"
#endif
#if MIPS_ABI_DEFAULT == ABI_O64
@@ -1131,6 +1148,21 @@ extern int mips_abi;
%{!mgp32:%{mlong64:-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int}}} \
%{mabi=32:-D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int} \
"
+#define LONG_MAX_SPEC "\
+%{mlong64:-D__LONG_MAX__=9223372036854775807L}\
+%{!mlong64:\
+ %{mabi=eabi|!mabi=*:\
+ %{!mips1:%{!mips2:%{!mips32:%{!mgp32:%{!mlong32: \
+ -D__LONG_MAX__=9223372036854775807L}}}}}}}\
+"
+#else /* ABI_DEFAULT != ABI_EABI */
+#define LONG_MAX_SPEC "\
+%{mlong64:-D__LONG_MAX__=9223372036854775807L}\
+%{!mlong64:\
+ %{mabi=eabi:\
+ %{!mips1:%{!mips2:%{!mips32:%{!mgp32:%{!mlong32: \
+ -D__LONG_MAX__=9223372036854775807L}}}}}}}\
+"
#endif
#if MIPS_ABI_DEFAULT == ABI_O64
@@ -1186,16 +1218,6 @@ extern int mips_abi;
overridden by subtargets. */
#ifndef SUBTARGET_CPP_SPEC
#define SUBTARGET_CPP_SPEC ""
-#endif
-
-/* If we're using 64bit longs, then we have to define __LONG_MAX__
- correctly. Similarly for 64bit ints and __INT_MAX__. */
-#ifndef LONG_MAX_SPEC
-#if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_LONG64)
-#define LONG_MAX_SPEC "%{!mlong32:-D__LONG_MAX__=9223372036854775807L}"
-#else
-#define LONG_MAX_SPEC "%{mlong64:-D__LONG_MAX__=9223372036854775807L}"
-#endif
#endif
/* Define appropriate macros for fpr register size. */
Index: gcc/config/mips/abi64.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/mips/abi64.h,v
retrieving revision 1.20
diff -u -p -r1.20 abi64.h
--- gcc/config/mips/abi64.h 2002/02/27 18:47:40 1.20
+++ gcc/config/mips/abi64.h 2002/03/08 05:43:16
@@ -1,5 +1,5 @@
/* Definitions of target machine for GNU compiler. 64 bit ABI support.
- Copyright (C) 1994, 1995, 1996, 1998, 1999, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1994, 1995, 1996, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -213,25 +213,6 @@ Boston, MA 02111-1307, USA. */
#define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) \
(mips_abi == ABI_EABI && (NAMED) \
&& FUNCTION_ARG_PASS_BY_REFERENCE (CUM, MODE, TYPE, NAMED))
-
-/* Define LONG_MAX correctly for all users. We need to handle 32 bit EABI,
- 64 bit EABI, N32, and N64 as possible defaults. The checks performed here
- are the same as the checks in override_options in mips.c that determines
- whether MASK_LONG64 will be set.
-
- This does not handle inappropriate options or ununusal option
- combinations. */
-
-#undef LONG_MAX_SPEC
-#if ((MIPS_ABI_DEFAULT == ABI_64) || ((MIPS_ABI_DEFAULT == ABI_EABI) && ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_64BIT)))
-#define LONG_MAX_SPEC \
- "%{!mabi=32:%{!mabi=n32:%{!mlong32:%{!mgp32:%{!mips1:%{!mips2:-D__LONG_MAX__=9223372036854775807L}}}}}}"
-#else
-#define LONG_MAX_SPEC \
- "%{mabi=64:-D__LONG_MAX__=9223372036854775807L} \
- %{mlong64:-D__LONG_MAX__=9223372036854775807L} \
- %{mgp64:-D__LONG_MAX__=9223372036854775807L}"
-#endif
/* ??? Unimplemented stuff follows. */
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer