From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16821 invoked by alias); 6 Jul 2004 14:28:36 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 16806 invoked from network); 6 Jul 2004 14:28:33 -0000 Received: from unknown (HELO emea1-mh.id2.novell.com) (195.33.99.129) by sourceware.org with SMTP; 6 Jul 2004 14:28:33 -0000 Received: from EMEA1-MTA by emea1-mh.id2.novell.com with Novell_GroupWise; Tue, 06 Jul 2004 15:28:32 +0200 Message-Id: Date: Tue, 06 Jul 2004 14:30:00 -0000 From: "Jan Beulich" To: Subject: enable maximum integer type to be 128 bits Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-SW-Source: 2004-07/txt/msg00466.txt.bz2 This enables forcing the internally used maximum integer types to 128 bits rather than the previous limit of the equivalent of 'long long'. bootstrapped and tested on x86-64-unknown-linux-gnu. Jan 2004-07-06 Jan Beulich * c-cppbuiltin.c (c_cpp_builtins): New predefined macro _INTEGRAL_MAX_BITS. * config/tm-int128.h: New target header defining [U]INTMAX_TYPE to __[u]int128_t. * configure.ac: Define and consume --with-int128 (borrowing construct from --with-dwarf2). testsuite: 2004-07-06 Jan Beulich * gcc.c-torture/execute/builtins/abs-2.c: Adjust declaration of intmax_t to account for the 128-bit case. * gcc.c-torture/execute/builtins/abs-3.c: Dito. * gcc.c-torture/execute/builtins/lib/abs.c: Dito. * gcc.dg/format/format.h: Dito. * gcc.dg/cpp/arith-3.c: Add 128-bit macro cases. * gcc.dg/cpp/if-1.c: Make constant to cause proprocessor overflow error large enough to also fit 128-bit case. * gcc.dg/titype-1.c: Use _INTEGRAL_MAX_BITS. * gcc.dg/titype-2.c: New test. --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/c-cppbuiltin.c 2004-07-02 15:13:11.000000000 +0200 +++ 2004-07-05.10.09/gcc/c-cppbuiltin.c 2004-07-05 15:28:58.249865992 +0200 @@ -353,6 +353,7 @@ builtin_define_type_max ("__WCHAR_MAX__", wchar_type_node, 0); builtin_define_type_precision ("__CHAR_BIT__", char_type_node); + builtin_define_type_precision ("_INTEGRAL_MAX_BITS", intmax_type_node); /* float.h needs to know these. */ --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/config/tm-int128.h 1970-01-01 01:00:00.000000000 +0100 +++ 2004-07-05.10.09/gcc/config/tm-int128.h 2004-05-13 11:58:42.000000000 +0200 @@ -0,0 +1,2 @@ +#define INTMAX_TYPE "__int128_t" +#define UINTMAX_TYPE "__uint128_t" --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/configure 2004-07-05 09:18:03.000000000 +0200 +++ 2004-07-05.10.09/gcc/configure 2004-07-05 15:28:58.292859456 +0200 @@ -919,6 +919,7 @@ --with-as arrange to use the specified as (full pathname) --with-stabs arrange to use stabs instead of host debug format --with-dwarf2 force the default debug format to be DWARF 2 + --with-int128 use __int128_t/__uint128_t as the maximum integral types --with-sysroot=DIR Search for usr/lib, usr/include, et al, within DIR. --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib --with-gc={page,zone} choose the garbage collection mechanism to use @@ -4704,6 +4705,15 @@ dwarf2=no fi; + +# Check whether --with-int128 or --without-int128 was given. +if test "${with_int128+set}" = set; then + withval="$with_int128" + int128="$with_int128" +else + int128=no +fi; + # Check whether --enable-shared or --disable-shared was given. if test "${enable_shared+set}" = set; then enableval="$enable_shared" @@ -9004,6 +9014,10 @@ then tm_file="$tm_file tm-dwarf2.h" fi +if test x"$int128" = xyes +then tm_file="$tm_file tm-int128.h" +fi + # Say what files are being used for the output code and MD file. echo "Using \`$srcdir/config/$out_file' for machine-specific logic." echo "Using \`$srcdir/config/$md_file' as machine description file." --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/configure.ac 2004-07-05 09:18:03.000000000 +0200 +++ 2004-07-05.10.09/gcc/configure.ac 2004-07-05 15:28:58.302857936 +0200 @@ -600,6 +600,11 @@ dwarf2="$with_dwarf2", dwarf2=no) +AC_ARG_WITH(int128, +[ --with-int128 use __int128_t/__uint128_t as the maximum integral types], +int128="$with_int128", +int128=no) + AC_ARG_ENABLE(shared, [ --disable-shared don't provide a shared libgcc], [ @@ -1131,6 +1136,10 @@ then tm_file="$tm_file tm-dwarf2.h" fi +if test x"$int128" = xyes +then tm_file="$tm_file tm-int128.h" +fi + # Say what files are being used for the output code and MD file. echo "Using \`$srcdir/config/$out_file' for machine-specific logic." echo "Using \`$srcdir/config/$md_file' as machine description file." --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.c-torture/execute/builtins/abs-2.c 2004-07-03 04:16:49.000000000 +0200 +++ 2004-07-05.10.09/gcc/testsuite/gcc.c-torture/execute/builtins/abs-2.c 2004-07-05 15:36:42.842237216 +0200 @@ -5,7 +5,10 @@ should be used. */ #include -#if INT_MAX == __LONG_LONG_MAX__ +#if _INTEGRAL_MAX_BITS == 128 +typedef __int128_t intmax_t; +#define INTMAX_MAX 0x7fffffffffffffffffffffffffffffffLL +#elif INT_MAX == __LONG_LONG_MAX__ typedef int intmax_t; #define INTMAX_MAX INT_MAX #elif LONG_MAX == __LONG_LONG_MAX__ --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.c-torture/execute/builtins/abs-3.c 2004-07-03 04:16:49.000000000 +0200 +++ 2004-07-05.10.09/gcc/testsuite/gcc.c-torture/execute/builtins/abs-3.c 2004-07-05 15:36:52.676742144 +0200 @@ -5,7 +5,10 @@ should be used. */ #include -#if INT_MAX == __LONG_LONG_MAX__ +#if _INTEGRAL_MAX_BITS == 128 +typedef __int128_t intmax_t; +#define INTMAX_MAX 0x7fffffffffffffffffffffffffffffffLL +#elif INT_MAX == __LONG_LONG_MAX__ typedef int intmax_t; #define INTMAX_MAX INT_MAX #elif LONG_MAX == __LONG_LONG_MAX__ --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.c-torture/execute/builtins/lib/abs.c 2004-07-03 04:16:50.000000000 +0200 +++ 2004-07-05.10.09/gcc/testsuite/gcc.c-torture/execute/builtins/lib/abs.c 2004-07-05 15:37:39.616606200 +0200 @@ -10,7 +10,10 @@ should be used. */ #include -#if INT_MAX == __LONG_LONG_MAX__ +#if _INTEGRAL_MAX_BITS == 128 +typedef __int128_t intmax_t; +#define INTMAX_MAX 0x7fffffffffffffffffffffffffffffffLL +#elif INT_MAX == __LONG_LONG_MAX__ typedef int intmax_t; #define INTMAX_MAX INT_MAX #elif LONG_MAX == __LONG_LONG_MAX__ --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.dg/cpp/arith-3.c 2002-05-27 22:23:13.000000000 +0200 +++ 2004-07-05.10.09/gcc/testsuite/gcc.dg/cpp/arith-3.c 2004-06-01 16:04:50.000000000 +0200 @@ -16,7 +16,11 @@ #define APPEND2(NUM, SUFF) NUM ## SUFF #define APPEND(NUM, SUFF) APPEND2(NUM, SUFF) -#define TARGET_UTYPE_MAX ULLONG_MAX +#if _INTEGRAL_MAX_BITS == 128 +# define TARGET_UTYPE_MAX 0xffffffffffffffffffffffffffffffffULL +#else +# define TARGET_UTYPE_MAX ULLONG_MAX +#endif /* The tests in this file depend only on the macros defined in this #if block. Note that it is no good calculating these values, as @@ -118,6 +122,38 @@ # define LONG_SMODULO -234582345927345L % 12345678901L # define LONG_SMODULO_ANSWER -2101129444L +#elif TARGET_UTYPE_MAX == 0xffffffffffffffffffffffffffffffff + +# define TARG_PRECISION 128 +# define MAX_INT 170141183460469231731687303715884105727 +# define MAX_UINT 340282366920938463463374607431768211455 + +# define TARG_MAX_HEX 0x7fffffffffffffffffffffffffffffff +# define TARG_MAX_OCT 01777777777777777777777777777777777777777777 +# define TARG_MAX_PLUS_1 170141183460469231731687303715884105728 +# define TARG_MAX_PLUS_1_U 170141183460469231731687303715884105728U +# define TARG_MAX_PLUS_1_HEX 0x80000000000000000000000000000000 +# define TARG_MAX_PLUS_1_OCT 02000000000000000000000000000000000000000000 +# define UTARG_MAX_HEX 0xffffffffffffffffffffffffffffffff +# define UTARG_MAX_OCT 03777777777777777777777777777777777777777777 +# define UTARG_MAX_PLUS_1 340282366920938463463374607431768211456 +# define UTARG_MAX_PLUS_1_HEX 0x100000000000000000000000000000000 +# define UTARG_MAX_PLUS_1_OCT 04000000000000000000000000000000000000000000 + +# define TARG_LOWPART_PLUS_1 18446744073709551616 +# define TARG_LOWPART_PLUS_1_U 18446744073709551616U + + /* Division and modulo; anything that uses the high half in both + dividend and divisor. */ +# define LONG_UDIVISION 987654321098765432109876543210 / 012345670123456701234567 +# define LONG_UDIVISION_ANSWER 10248087149 +# define LONG_SDIVISION -999888777666555444333222111000 / 01111222233334444555566667777 +# define LONG_SDIVISION_ANSWER -361762 +# define LONG_UMODULO 987654321098765432109876543210 % 012345670123456701234567 +# define LONG_UMODULO_ANSWER 89173958791952375103 +# define LONG_SMODULO -999888777666555444333222111000 % 01111222233334444555566667777 +# define LONG_SMODULO_ANSWER -2556578633054780958559290 + #else # error Please extend the macros here so that this file tests your target --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.dg/cpp/if-1.c 2002-05-29 19:15:42.000000000 +0200 +++ 2004-07-05.10.09/gcc/testsuite/gcc.dg/cpp/if-1.c 2004-06-01 16:08:35.000000000 +0200 @@ -37,5 +37,5 @@ #if 099 /* { dg-error "invalid digit" "decimal in octal constant" } */ #endif -#if 0xfffffffffffffffff /* { dg-error "integer constant" "range error" } */ +#if 0xfffffffffffffffffffffffffffffffff /* { dg-error "integer constant" "range error" } */ #endif --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.dg/format/format.h 2001-12-21 03:36:37.000000000 +0100 +++ 2004-07-05.10.09/gcc/testsuite/gcc.dg/format/format.h 2004-06-01 16:44:39.000000000 +0200 @@ -31,6 +31,13 @@ /* This next definition is a kludge. When GCC has a it should be used. */ +#if _INTEGRAL_MAX_BITS == 128 + +typedef __int128_t intmax_t; +typedef __uint128_t uintmax_t; + +#else + /* (T *) if E is zero, (void *) otherwise. */ #define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E)) @@ -54,6 +61,8 @@ typedef __typeof__(*((intmax_type_ptr)0)) intmax_t; typedef __typeof__(*((uintmax_type_ptr)0)) uintmax_t; +#endif + #if __STDC_VERSION__ < 199901L #define restrict /* "restrict" not in old C standard. */ #endif --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.dg/titype-1.c 2004-02-02 17:12:36.000000000 +0100 +++ 2004-07-05.10.09/gcc/testsuite/gcc.dg/titype-1.c 2004-07-05 15:30:02.926033720 +0200 @@ -1,7 +1,7 @@ /* { dg-do run } */ /* Not all platforms support TImode integers. */ -#if defined(__LP64__) || defined(__sparc__) +#if _INTEGRAL_MAX_BITS >= 128 || defined(__LP64__) || defined(__sparc__) typedef int TItype __attribute__ ((mode (TI))); /* { dg-error "no data type for mode" "TI" { target sparc-sun-solaris2.[0-6]* } } */ #else typedef long TItype; --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.dg/titype-2.c 1970-01-01 01:00:00.000000000 +0100 +++ 2004-07-05.10.09/gcc/testsuite/gcc.dg/titype-2.c 2004-07-05 15:24:59.000000000 +0200 @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +/* Not all platforms support TImode integers. */ +#if _INTEGRAL_MAX_BITS >= 128 +typedef int TItype __attribute__ ((mode (TI))); + +void test(TItype x) { + if (!x) + abort(); +} +#else +# define test(x) +#endif + +int main() { + test(0x10000000000000000LL); + return 0; +}