diff options
author | Richard Biener <rguenther@suse.de> | 2014-06-04 12:35:26 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2014-06-04 12:35:26 +0000 |
commit | 35987ae95da833242def2e32fcc24100c20ef4b5 (patch) | |
tree | 4a55929af84e7326cea76394ff68cffedc557108 /gcc | |
parent | 0ea48022b83f9f960724dab8fd75a4dc9d6e2269 (diff) | |
download | gcc-35987ae95da833242def2e32fcc24100c20ef4b5.zip gcc-35987ae95da833242def2e32fcc24100c20ef4b5.tar.gz gcc-35987ae95da833242def2e32fcc24100c20ef4b5.tar.bz2 |
configure.ac: Check whether the underlying type of int64_t is long or long long.
2014-06-04 Richard Biener <rguenther@suse.de>
* configure.ac: Check whether the underlying type of int64_t
is long or long long.
* configure: Regenerate.
* config.in: Likewise.
* hwint.h (HOST_WIDE_INT): Match the underlying type of int64_t.
(HOST_WIDE_INT_PRINT_*): Define in terms of PRI*64.
From-SVN: r211228
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/config.in | 6 | ||||
-rwxr-xr-x | gcc/configure | 93 | ||||
-rw-r--r-- | gcc/configure.ac | 40 | ||||
-rw-r--r-- | gcc/hwint.h | 69 |
5 files changed, 173 insertions, 44 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 645dc0b..71bad63 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,14 @@ 2014-06-04 Richard Biener <rguenther@suse.de> + * configure.ac: Check whether the underlying type of int64_t + is long or long long. + * configure: Regenerate. + * config.in: Likewise. + * hwint.h (HOST_WIDE_INT): Match the underlying type of int64_t. + (HOST_WIDE_INT_PRINT_*): Define in terms of PRI*64. + +2014-06-04 Richard Biener <rguenther@suse.de> + PR tree-optimization/60098 * tree-ssa-dse.c (dse_possible_dead_store_p): Walk until we hit a kill. diff --git a/gcc/config.in b/gcc/config.in index 2313307..fb7bf95 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1680,6 +1680,12 @@ #endif +/* Define if int64_t uses long as underlying type. */ +#ifndef USED_FOR_TARGET +#undef INT64_T_IS_LONG +#endif + + /* Define to the linker option to ignore unused dependencies. */ #ifndef USED_FOR_TARGET #undef LD_AS_NEEDED_OPTION diff --git a/gcc/configure b/gcc/configure index f60d347..6c35041 100755 --- a/gcc/configure +++ b/gcc/configure @@ -6230,6 +6230,87 @@ if test x"$ac_cv_c_uint64_t" = x"no" -o x"$ac_cv_c_int64_t" = x"no"; then as_fn_error "uint64_t or int64_t not found" "$LINENO" 5 fi +# check what underlying integer type int64_t uses +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for int64_t underlying type" >&5 +$as_echo_n "checking for int64_t underlying type... " >&6; } +if test "${ac_cv_int64_t_type+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef HAVE_STDINT_H +#include <stdint.h> +#endif +template <typename T> struct X { }; +template <> +struct X<long> { typedef long t; }; + +int +main () +{ +X<int64_t>::t x; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_int64_t_type=long +else + ac_cv_int64_t_type="long long" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_int64_t_type" >&5 +$as_echo "$ac_cv_int64_t_type" >&6; } +if test "$ac_cv_int64_t_type" = "long"; then + +$as_echo "#define INT64_T_IS_LONG 1" >>confdefs.h + +else +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef HAVE_STDINT_H +#include <stdint.h> +#endif +template <typename T> struct X { }; +template <> +struct X<long long> { typedef long long t; }; + +int +main () +{ +X<int64_t>::t x; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + as_fn_error "error verifying int64_t uses long long" "$LINENO" 5 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + # --------------------- # Warnings and checking # --------------------- @@ -8746,7 +8827,6 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - for ac_header in unordered_map do : ac_fn_cxx_check_header_preproc "$LINENO" "unordered_map" "ac_cv_header_unordered_map" @@ -9163,7 +9243,8 @@ LIBS="$save_LIBS" # Use <inttypes.h> only if it exists, -# doesn't clash with <sys/types.h>, and declares intmax_t. +# doesn't clash with <sys/types.h>, declares intmax_t and defines +# PRId64 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inttypes.h" >&5 $as_echo_n "checking for inttypes.h... " >&6; } if test "${gcc_cv_header_inttypes_h+set}" = set; then : @@ -9171,12 +9252,16 @@ if test "${gcc_cv_header_inttypes_h+set}" = set; then : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#define __STDC_FORMAT_MACROS #include <sys/types.h> #include <inttypes.h> int main () { intmax_t i = -1; +#ifndef PRId64 +choke me +#endif ; return 0; } @@ -17948,7 +18033,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17951 "configure" +#line 18036 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18054,7 +18139,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18057 "configure" +#line 18142 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index aa697ce..2cec62a 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -316,6 +316,35 @@ if test x"$ac_cv_c_uint64_t" = x"no" -o x"$ac_cv_c_int64_t" = x"no"; then AC_MSG_ERROR([uint64_t or int64_t not found]) fi +# check what underlying integer type int64_t uses +AC_LANG_PUSH(C++) +AC_CACHE_CHECK(for int64_t underlying type, ac_cv_int64_t_type, [ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifdef HAVE_STDINT_H +#include <stdint.h> +#endif +template <typename T> struct X { }; +template <> +struct X<long> { typedef long t; }; +]], [[X<int64_t>::t x;]])],[ac_cv_int64_t_type=long],[ac_cv_int64_t_type="long long"])]) +if test "$ac_cv_int64_t_type" = "long"; then + AC_DEFINE(INT64_T_IS_LONG, 1, + [Define if int64_t uses long as underlying type.]) +else +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifdef HAVE_STDINT_H +#include <stdint.h> +#endif +template <typename T> struct X { }; +template <> +struct X<long long> { typedef long long t; }; +]], [[X<int64_t>::t x;]])],[],[AC_MSG_ERROR([error verifying int64_t uses long long])]) +fi +AC_LANG_POP(C++) + + + + # --------------------- # Warnings and checking # --------------------- @@ -1055,13 +1084,18 @@ LIBS="$save_LIBS" AC_SUBST(LDEXP_LIB) # Use <inttypes.h> only if it exists, -# doesn't clash with <sys/types.h>, and declares intmax_t. +# doesn't clash with <sys/types.h>, declares intmax_t and defines +# PRId64 AC_MSG_CHECKING(for inttypes.h) AC_CACHE_VAL(gcc_cv_header_inttypes_h, [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( -[[#include <sys/types.h> +[[#define __STDC_FORMAT_MACROS +#include <sys/types.h> #include <inttypes.h>]], - [[intmax_t i = -1;]])], + [[intmax_t i = -1; +#ifndef PRId64 +choke me +#endif]])], [gcc_cv_header_inttypes_h=yes], [gcc_cv_header_inttypes_h=no])]) AC_MSG_RESULT($gcc_cv_header_inttypes_h) diff --git a/gcc/hwint.h b/gcc/hwint.h index e3b8a8a..fd961fd 100644 --- a/gcc/hwint.h +++ b/gcc/hwint.h @@ -46,13 +46,11 @@ extern char sizeof_long_long_must_be_8[sizeof (long long) == 8 ? 1 : -1]; #endif /* Set HOST_WIDE_INT, this should be always 64 bits. - - With a sane ABI, 'long' is the largest efficient host integer type. - Thus, we use that unless we have to use 'long long' - because we're on a 32-bit host. */ + The underlying type is matched to that of int64_t and assumed + to be either long or long long. */ #define HOST_BITS_PER_WIDE_INT 64 -#if HOST_BITS_PER_LONG == 64 +#if INT64_T_IS_LONG # define HOST_WIDE_INT long # define HOST_WIDE_INT_C(X) X ## L #else @@ -75,48 +73,45 @@ extern char sizeof_long_long_must_be_8[sizeof (long long) == 8 ? 1 : -1]; typedef before using the __asm_fprintf__ format attribute. */ typedef HOST_WIDE_INT __gcc_host_wide_int__; -/* Various printf format strings for HOST_WIDE_INT. */ - -#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG -# define HOST_WIDE_INT_PRINT HOST_LONG_FORMAT -# define HOST_WIDE_INT_PRINT_C "L" - /* HOST_BITS_PER_WIDE_INT is 64 bits. */ -# define HOST_WIDE_INT_PRINT_DOUBLE_HEX \ - "0x%" HOST_LONG_FORMAT "x%016" HOST_LONG_FORMAT "x" -# define HOST_WIDE_INT_PRINT_PADDED_HEX \ - "%016" HOST_LONG_FORMAT "x" -#else -# define HOST_WIDE_INT_PRINT HOST_LONG_LONG_FORMAT -# define HOST_WIDE_INT_PRINT_C "LL" - /* HOST_BITS_PER_WIDE_INT is 64 bits. */ -# define HOST_WIDE_INT_PRINT_DOUBLE_HEX \ - "0x%" HOST_LONG_LONG_FORMAT "x%016" HOST_LONG_LONG_FORMAT "x" -# define HOST_WIDE_INT_PRINT_PADDED_HEX \ - "%016" HOST_LONG_LONG_FORMAT "x" -#endif /* HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG */ - -#define HOST_WIDE_INT_PRINT_DEC "%" HOST_WIDE_INT_PRINT "d" -#define HOST_WIDE_INT_PRINT_DEC_C HOST_WIDE_INT_PRINT_DEC HOST_WIDE_INT_PRINT_C -#define HOST_WIDE_INT_PRINT_UNSIGNED "%" HOST_WIDE_INT_PRINT "u" -#define HOST_WIDE_INT_PRINT_HEX "%#" HOST_WIDE_INT_PRINT "x" -#define HOST_WIDE_INT_PRINT_HEX_PURE "%" HOST_WIDE_INT_PRINT "x" - /* Provide C99 <inttypes.h> style format definitions for 64bits. */ #ifndef HAVE_INTTYPES_H +#if INT64_T_IS_LONG +# define GCC_PRI64 HOST_LONG_FORMAT +#else +# define GCC_PRI64 HOST_LONG_LONG_FORMAT +#endif #undef PRId64 -#define PRId64 HOST_WIDE_INT_PRINT "d" +#define PRId64 GCC_PRI64 "d" #undef PRIi64 -#define PRIi64 HOST_WIDE_INT_PRINT "i" +#define PRIi64 GCC_PRI64 "i" #undef PRIo64 -#define PRIo64 HOST_WIDE_INT_PRINT "o" +#define PRIo64 GCC_PRI64 "o" #undef PRIu64 -#define PRIu64 HOST_WIDE_INT_PRINT "u" +#define PRIu64 GCC_PRI64 "u" #undef PRIx64 -#define PRIx64 HOST_WIDE_INT_PRINT "x" +#define PRIx64 GCC_PRI64 "x" #undef PRIX64 -#define PRIX64 HOST_WIDE_INT_PRINT "X" +#define PRIX64 GCC_PRI64 "X" #endif +/* Various printf format strings for HOST_WIDE_INT. */ + +#if INT64_T_IS_LONG +# define HOST_WIDE_INT_PRINT HOST_LONG_FORMAT +# define HOST_WIDE_INT_PRINT_C "L" +#else +# define HOST_WIDE_INT_PRINT HOST_LONG_LONG_FORMAT +# define HOST_WIDE_INT_PRINT_C "LL" +#endif + +#define HOST_WIDE_INT_PRINT_DEC "%" PRId64 +#define HOST_WIDE_INT_PRINT_DEC_C "%" PRId64 HOST_WIDE_INT_PRINT_C +#define HOST_WIDE_INT_PRINT_UNSIGNED "%" PRIu64 +#define HOST_WIDE_INT_PRINT_HEX "%#" PRIx64 +#define HOST_WIDE_INT_PRINT_HEX_PURE "%" PRIx64 +#define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%" PRIx64 "%016" PRIx64 +#define HOST_WIDE_INT_PRINT_PADDED_HEX "%016" PRIx64 + /* Define HOST_WIDEST_FAST_INT to the widest integer type supported efficiently in hardware. (That is, the widest integer type that fits in a hardware register.) Normally this is "long" but on some hosts it |