This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: eliminate the "wide" functions/macros

Scattered around GCC, we have a few functions taking HOST_WIDE_INT
arguments and seperately we have macros that cast their arguments to
HOST_WIDE_INT and call these functions.  The macros seem to implement
a "poor man's prototyping".

I believe the only reason for this is for 64-bit HOST_WIDE_INT, with
which we either had a traditional C stage1 compiler or by chance there
was no prototype seen for the function.  In either case using the
macro ensured that the integer values were widened to the appropriate

Given that we no longer support traditional C to compile stage1, and
given that we use -Werror to catch missing prototypes, I'll posit that
these macros are never needed anymore.  Note we're very inconsistent
and have many other functions taking HOST_WIDE_INT and don't bother
with the macro casting.  So it can't still be a problem.  Also in a
few places, we were mistakenly calling the "wide" functions directly
instead of using the indirect macro.

This whole thing seems like it should be under the pre-approved ISO C
conversion, but I'd like a second opinion just in case.

Bootstrapped on sparc64-sun-solaris2.9, testsuite underway.
Assuming no regressions, ok for mainline?


2004-05-09  Kaveh R. Ghazi  <>

	* c-lex.c (interpret_integer): Use `build_int_2' not
	* explow.c (plus_constant): Renamed from `plus_constant_wide'.
	* fold-const.c (size_int_kind): Renamed from `size_int_wide'.
	(size_int_type): Renamed from `size_int_type_wide', callers
	* rtl.h (plus_constant): Delete macro.
	(plus_constant): Renamed prototype from `plus_constant_wide'.
	(plus_constant_for_output_wide): Delete.
	(GEN_INT): Remove cast.
	* toplev.c (exact_log2): Renamed from `exact_log2_wide'.
	(floor_log2): Renamed from `floor_log2_wide'.
	* toplev.h (exact_log2, floor_log2): Delete macros.
	(exact_log2): Renamed from `exact_log2_wide'.
	(floor_log2): Renamed from `floor_log2_wide'.
	* tree.c (build_int_2): Renamed from `build_int_2_wide'.
	* tree.h (build_int_2): Delete macro.
	(build_int_2): Renamed prototype from `build_int_2_wide'.
	(size_int_kind): Renamed from `size_int_wide'.
	(size_int_type): Renamed from `size_int_type_wide'.
	(size_int_type): Delete macro.
	(size_int, ssize_int, bitsize_int, sbitsize_int): Call
	`size_int_kind' instead of `size_int_wide'.
diff -rup orig/egcc-CVS20040509/gcc/c-lex.c egcc-CVS20040509/gcc/c-lex.c
--- orig/egcc-CVS20040509/gcc/c-lex.c	2004-02-27 20:01:11.000000000 -0500
+++ egcc-CVS20040509/gcc/c-lex.c	2004-05-09 11:49:03.665718000 -0400
@@ -496,7 +496,7 @@ interpret_integer (const cpp_token *toke
   integer = cpp_interpret_integer (parse_in, token, flags);
   integer = cpp_num_sign_extend (integer, options->precision);
-  value = build_int_2_wide (integer.low, integer.high);
+  value = build_int_2 (integer.low, integer.high);
   /* The type of a constant with a U suffix is straightforward.  */
   if (flags & CPP_N_UNSIGNED)
diff -rup orig/egcc-CVS20040509/gcc/explow.c egcc-CVS20040509/gcc/explow.c
--- orig/egcc-CVS20040509/gcc/explow.c	2004-04-08 20:03:58.000000000 -0400
+++ egcc-CVS20040509/gcc/explow.c	2004-05-09 11:12:47.336026000 -0400
@@ -71,12 +71,10 @@ trunc_int_for_mode (HOST_WIDE_INT c, enu
   return c;
-/* Return an rtx for the sum of X and the integer C.
-   This function should be used via the `plus_constant' macro.  */
+/* Return an rtx for the sum of X and the integer C.  */
-plus_constant_wide (rtx x, HOST_WIDE_INT c)
+plus_constant (rtx x, HOST_WIDE_INT c)
   RTX_CODE code;
   rtx y;
diff -rup orig/egcc-CVS20040509/gcc/fold-const.c egcc-CVS20040509/gcc/fold-const.c
--- orig/egcc-CVS20040509/gcc/fold-const.c	2004-05-09 10:51:28.000000000 -0400
+++ egcc-CVS20040509/gcc/fold-const.c	2004-05-09 11:12:47.416030000 -0400
@@ -1383,7 +1383,7 @@ int_const_binop (enum tree_code code, tr
       && ((hi == 0 && (HOST_WIDE_INT) low >= 0)
 	  || (hi == -1 && (HOST_WIDE_INT) low < 0))
       && overflow == 0 && ! TREE_OVERFLOW (arg1) && ! TREE_OVERFLOW (arg2))
-    return size_int_type_wide (low, type);
+    return size_int_type (low, type);
       t = build_int_2 (low, hi);
@@ -1587,9 +1587,9 @@ size_htab_eq (const void *x, const void 
    bits are given by NUMBER and of the sizetype represented by KIND.  */
-size_int_wide (HOST_WIDE_INT number, enum size_type_kind kind)
+size_int_kind (HOST_WIDE_INT number, enum size_type_kind kind)
-  return size_int_type_wide (number, sizetype_tab[(int) kind]);
+  return size_int_type (number, sizetype_tab[(int) kind]);
 /* Likewise, but the desired type is specified explicitly.  */
@@ -1599,7 +1599,7 @@ static GTY ((if_marked ("ggc_marked_p"),
      htab_t size_htab;
-size_int_type_wide (HOST_WIDE_INT number, tree type)
+size_int_type (HOST_WIDE_INT number, tree type)
   void **slot;
@@ -1736,7 +1736,7 @@ fold_convert_const (enum tree_code code,
 	  if (TREE_CODE (type) == INTEGER_TYPE && TYPE_IS_SIZETYPE (type)
 	      && !TREE_CONSTANT_OVERFLOW (arg1)
 	      && compare_tree_int (arg1, 10000) < 0)
-	    return size_int_type_wide (TREE_INT_CST_LOW (arg1), type);
+	    return size_int_type (TREE_INT_CST_LOW (arg1), type);
 	  /* Given an integer constant, make new constant with new type,
 	     appropriately sign-extended or truncated.  */
diff -rup orig/egcc-CVS20040509/gcc/rtl.h egcc-CVS20040509/gcc/rtl.h
--- orig/egcc-CVS20040509/gcc/rtl.h	2004-05-03 20:01:54.000000000 -0400
+++ egcc-CVS20040509/gcc/rtl.h	2004-05-09 11:12:47.575934000 -0400
@@ -1553,8 +1553,6 @@ extern int generating_concat_p;
 /* In expmed.c */
 extern int ceil_log2 (unsigned HOST_WIDE_INT);
-#define plus_constant(X, C) plus_constant_wide ((X), (HOST_WIDE_INT) (C))
 /* In builtins.c */
 extern rtx expand_builtin_expect_jump (tree, rtx, rtx);
 extern void purge_builtin_constant_p (void);
@@ -1562,8 +1560,7 @@ extern void purge_builtin_constant_p (vo
 /* In explow.c */
 extern void set_stack_check_libfunc (rtx);
 extern HOST_WIDE_INT trunc_int_for_mode	(HOST_WIDE_INT, enum machine_mode);
-extern rtx plus_constant_wide (rtx, HOST_WIDE_INT);
-extern rtx plus_constant_for_output_wide (rtx, HOST_WIDE_INT);
+extern rtx plus_constant (rtx, HOST_WIDE_INT);
 extern void optimize_save_area_alloca (rtx);
 /* In emit-rtl.c */
@@ -2011,7 +2008,7 @@ extern rtx gen_rtx_MEM (enum machine_mod
 /* We need the cast here to ensure that we get the same result both with
    and without prototypes.  */
-#define GEN_INT(N)  gen_rtx_CONST_INT (VOIDmode, (HOST_WIDE_INT) (N))
+#define GEN_INT(N)  gen_rtx_CONST_INT (VOIDmode, (N))
 /* Virtual registers are used during RTL generation to refer to locations into
    the stack frame when the actual location isn't known until RTL generation
diff -rup orig/egcc-CVS20040509/gcc/toplev.c egcc-CVS20040509/gcc/toplev.c
--- orig/egcc-CVS20040509/gcc/toplev.c	2004-04-20 20:08:42.000000000 -0400
+++ egcc-CVS20040509/gcc/toplev.c	2004-05-09 11:45:56.453828000 -0400
@@ -1179,12 +1179,10 @@ read_integral_parameter (const char *p, 
 /* Return the logarithm of X, base 2, considering X unsigned,
-   if X is a power of 2.  Otherwise, returns -1.
-   This should be used via the `exact_log2' macro.  */
+   if X is a power of 2.  Otherwise, returns -1.  */
-exact_log2_wide (unsigned HOST_WIDE_INT x)
+exact_log2 (unsigned HOST_WIDE_INT x)
   int log = 0;
   /* Test for 0 or a power of 2.  */
@@ -1196,12 +1194,10 @@ exact_log2_wide (unsigned HOST_WIDE_INT 
 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
-   If X is 0, return -1.
-   This should be used via the floor_log2 macro.  */
+   If X is 0, return -1.  */
-floor_log2_wide (unsigned HOST_WIDE_INT x)
+floor_log2 (unsigned HOST_WIDE_INT x)
   int log = -1;
   while (x != 0)
diff -rup orig/egcc-CVS20040509/gcc/toplev.h egcc-CVS20040509/gcc/toplev.h
--- orig/egcc-CVS20040509/gcc/toplev.h	2004-02-27 20:01:19.000000000 -0500
+++ egcc-CVS20040509/gcc/toplev.h	2004-05-09 11:12:47.595943000 -0400
@@ -146,15 +146,8 @@ extern void decode_d_option		(const char
 /* Return true iff flags are set as if -ffast-math.  */
 extern bool fast_math_flags_set_p	(void);
-/* The following functions accept a wide integer argument.  Rather
-   than having to cast on every function call, we use a macro instead.  */
-#ifndef exact_log2
-#define exact_log2(N) exact_log2_wide ((unsigned HOST_WIDE_INT) (N))
-#define floor_log2(N) floor_log2_wide ((unsigned HOST_WIDE_INT) (N))
-extern int exact_log2_wide             (unsigned HOST_WIDE_INT);
-extern int floor_log2_wide             (unsigned HOST_WIDE_INT);
+extern int exact_log2                  (unsigned HOST_WIDE_INT);
+extern int floor_log2                  (unsigned HOST_WIDE_INT);
 /* Functions used to get and set GCC's notion of in what directory
    compilation was started.  */
diff -rup orig/egcc-CVS20040509/gcc/tree.c egcc-CVS20040509/gcc/tree.c
--- orig/egcc-CVS20040509/gcc/tree.c	2004-05-05 20:01:43.000000000 -0400
+++ egcc-CVS20040509/gcc/tree.c	2004-05-09 11:12:47.625922000 -0400
@@ -398,12 +398,10 @@ copy_list (tree list)
 /* Return a newly constructed INTEGER_CST node whose constant value
    is specified by the two ints LOW and HI.
-   The TREE_TYPE is set to `int'.
-   This function should be used via the `build_int_2' macro.  */
+   The TREE_TYPE is set to `int'.  */
-build_int_2_wide (unsigned HOST_WIDE_INT low, HOST_WIDE_INT hi)
+build_int_2 (unsigned HOST_WIDE_INT low, HOST_WIDE_INT hi)
   tree t = make_node (INTEGER_CST);
diff -rup orig/egcc-CVS20040509/gcc/tree.h egcc-CVS20040509/gcc/tree.h
--- orig/egcc-CVS20040509/gcc/tree.h	2004-04-30 21:40:03.000000000 -0400
+++ egcc-CVS20040509/gcc/tree.h	2004-05-09 11:12:47.635945000 -0400
@@ -2209,9 +2209,6 @@ extern tree maybe_get_identifier (const 
 /* Construct various types of nodes.  */
-#define build_int_2(LO, HI)  \
-  build_int_2_wide ((unsigned HOST_WIDE_INT) (LO), (HOST_WIDE_INT) (HI))
 extern tree build (enum tree_code, tree, ...);
 extern tree build_nt (enum tree_code, ...);
@@ -2239,7 +2236,7 @@ extern tree build4_stat (enum tree_code,
 			 tree MEM_STAT_DECL);
 #define build4(c,t1,t2,t3,t4,t5) build4_stat (c,t1,t2,t3,t4,t5 MEM_STAT_INFO)
-extern tree build_int_2_wide (unsigned HOST_WIDE_INT, HOST_WIDE_INT);
+extern tree build_int_2 (unsigned HOST_WIDE_INT, HOST_WIDE_INT);
 extern tree build_vector (tree, tree);
 extern tree build_constructor (tree, tree);
 extern tree build_real_from_int_cst (tree, tree);
@@ -2572,14 +2569,13 @@ extern GTY(()) tree sizetype_tab[(int) T
 extern tree size_binop (enum tree_code, tree, tree);
 extern tree size_diffop (tree, tree);
-extern tree size_int_wide (HOST_WIDE_INT, enum size_type_kind);
-extern tree size_int_type_wide (HOST_WIDE_INT, tree);
+extern tree size_int_kind (HOST_WIDE_INT, enum size_type_kind);
+extern tree size_int_type (HOST_WIDE_INT, tree);
-#define size_int_type(L, T) size_int_type_wide ((HOST_WIDE_INT) (L), T)
-#define size_int(L) size_int_wide ((HOST_WIDE_INT) (L), SIZETYPE)
-#define ssize_int(L) size_int_wide ((HOST_WIDE_INT) (L), SSIZETYPE)
-#define bitsize_int(L) size_int_wide ((HOST_WIDE_INT) (L), BITSIZETYPE)
-#define sbitsize_int(L) size_int_wide ((HOST_WIDE_INT) (L), SBITSIZETYPE)
+#define size_int(L) size_int_kind ((L), SIZETYPE)
+#define ssize_int(L) size_int_kind ((L), SSIZETYPE)
+#define bitsize_int(L) size_int_kind ((L), BITSIZETYPE)
+#define sbitsize_int(L) size_int_kind ((L), SBITSIZETYPE)
 extern tree round_up (tree, int);
 extern tree round_down (tree, int);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]