Commit 9c727c9a by Ian Lance Taylor Committed by Ian Lance Taylor

toplev.h (floor_log2): If GCC_VERSION >= 3004, declare as static inline, not extern inline.

	* toplev.h (floor_log2): If GCC_VERSION >= 3004, declare as static
	inline, not extern inline.
	(exact_log2): Likewise.
	* toplev.c (floor_log2): Only define if GCC_VERSION < 3004. Don't
	test CLZ_HWI.
	(exact_log2): Likewise, but don't test CTZ_HWI.

From-SVN: r148540
parent 5fd8300b
2009-06-16 Ian Lance Taylor <iant@google.com> 2009-06-16 Ian Lance Taylor <iant@google.com>
* toplev.h (floor_log2): If GCC_VERSION >= 3004, declare as static
inline, not extern inline.
(exact_log2): Likewise.
* toplev.c (floor_log2): Only define if GCC_VERSION < 3004. Don't
test CLZ_HWI.
(exact_log2): Likewise, but don't test CTZ_HWI.
2009-06-16 Ian Lance Taylor <iant@google.com>
* bitmap.c (bitmap_clear): Don't declare as inline. * bitmap.c (bitmap_clear): Don't declare as inline.
* gimple.c (gimplify_assign): Likewise. * gimple.c (gimplify_assign): Likewise.
* tree-ssa-sccvn.c (vn_nary_op_compute_hash): Likewise. * tree-ssa-sccvn.c (vn_nary_op_compute_hash): Likewise.
......
...@@ -532,11 +532,11 @@ read_integral_parameter (const char *p, const char *pname, const int defval) ...@@ -532,11 +532,11 @@ read_integral_parameter (const char *p, const char *pname, const int defval)
return atoi (p); return atoi (p);
} }
/* When compiling with a recent enough GCC, we use the GNU C "extern inline" #if GCC_VERSION < 3004
for floor_log2 and exact_log2; see toplev.h. That construct, however,
conflicts with the ISO C++ One Definition Rule. */
#if GCC_VERSION < 3004 || !defined (__cplusplus) /* The functions floor_log2 and exact_log2 are defined as inline
functions in toplev.h if GCC_VERSION >= 3004. The definitions here
are used for older versions of gcc. */
/* Given X, an unsigned number, return the largest int Y such that 2**Y <= X. /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
If X is 0, return -1. */ If X is 0, return -1. */
...@@ -549,9 +549,6 @@ floor_log2 (unsigned HOST_WIDE_INT x) ...@@ -549,9 +549,6 @@ floor_log2 (unsigned HOST_WIDE_INT x)
if (x == 0) if (x == 0)
return -1; return -1;
#ifdef CLZ_HWI
t = HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x);
#else
if (HOST_BITS_PER_WIDE_INT > 64) if (HOST_BITS_PER_WIDE_INT > 64)
if (x >= (unsigned HOST_WIDE_INT) 1 << (t + 64)) if (x >= (unsigned HOST_WIDE_INT) 1 << (t + 64))
t += 64; t += 64;
...@@ -568,7 +565,6 @@ floor_log2 (unsigned HOST_WIDE_INT x) ...@@ -568,7 +565,6 @@ floor_log2 (unsigned HOST_WIDE_INT x)
t += 2; t += 2;
if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 1)) if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 1))
t += 1; t += 1;
#endif
return t; return t;
} }
...@@ -581,14 +577,10 @@ exact_log2 (unsigned HOST_WIDE_INT x) ...@@ -581,14 +577,10 @@ exact_log2 (unsigned HOST_WIDE_INT x)
{ {
if (x != (x & -x)) if (x != (x & -x))
return -1; return -1;
#ifdef CTZ_HWI
return x ? CTZ_HWI (x) : -1;
#else
return floor_log2 (x); return floor_log2 (x);
#endif
} }
#endif /* GCC_VERSION < 3004 || !defined (__cplusplus) */ #endif /* GCC_VERSION < 3004 */
/* Handler for fatal signals, such as SIGSEGV. These are transformed /* Handler for fatal signals, such as SIGSEGV. These are transformed
into ICE messages, which is much more user friendly. In case the into ICE messages, which is much more user friendly. In case the
......
...@@ -169,14 +169,17 @@ extern void decode_d_option (const char *); ...@@ -169,14 +169,17 @@ extern void decode_d_option (const char *);
extern bool fast_math_flags_set_p (void); extern bool fast_math_flags_set_p (void);
extern bool fast_math_flags_struct_set_p (struct cl_optimization *); extern bool fast_math_flags_struct_set_p (struct cl_optimization *);
/* Inline versions of the above for speed. */
#if GCC_VERSION < 3004
/* Return log2, or -1 if not exact. */ /* Return log2, or -1 if not exact. */
extern int exact_log2 (unsigned HOST_WIDE_INT); extern int exact_log2 (unsigned HOST_WIDE_INT);
/* Return floor of log2, with -1 for zero. */ /* Return floor of log2, with -1 for zero. */
extern int floor_log2 (unsigned HOST_WIDE_INT); extern int floor_log2 (unsigned HOST_WIDE_INT);
/* Inline versions of the above for speed. */ #else /* GCC_VERSION >= 3004 */
#if GCC_VERSION >= 3004
# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
# define CLZ_HWI __builtin_clzl # define CLZ_HWI __builtin_clzl
# define CTZ_HWI __builtin_ctzl # define CTZ_HWI __builtin_ctzl
...@@ -188,17 +191,18 @@ extern int floor_log2 (unsigned HOST_WIDE_INT); ...@@ -188,17 +191,18 @@ extern int floor_log2 (unsigned HOST_WIDE_INT);
# define CTZ_HWI __builtin_ctz # define CTZ_HWI __builtin_ctz
# endif # endif
extern inline int static inline int
floor_log2 (unsigned HOST_WIDE_INT x) floor_log2 (unsigned HOST_WIDE_INT x)
{ {
return x ? HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x) : -1; return x ? HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x) : -1;
} }
extern inline int static inline int
exact_log2 (unsigned HOST_WIDE_INT x) exact_log2 (unsigned HOST_WIDE_INT x)
{ {
return x == (x & -x) && x ? (int) CTZ_HWI (x) : -1; return x == (x & -x) && x ? (int) CTZ_HWI (x) : -1;
} }
#endif /* GCC_VERSION >= 3004 */ #endif /* GCC_VERSION >= 3004 */
/* Functions used to get and set GCC's notion of in what directory /* Functions used to get and set GCC's notion of in what directory
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment