public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Do not include rtl.h in tree-phinodes.c
@ 2012-06-06 15:16 Steven Bosscher
  2012-06-11  8:51 ` Richard Guenther
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Bosscher @ 2012-06-06 15:16 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 226 bytes --]

Hello,

tree-phinodes.c includes rtl.h for ... ceil_log2 (?!).

Moving ceil_log2 to hwint.c/hwint.h to join its sibling floor_log2
breaks this dependency.

Bootstrapped on x86_64-unknown-linux-gnu. OK for trunk?

Ciao!
Steven

[-- Attachment #2: tree_phinodes_no_rtl_h.diff --]
[-- Type: application/octet-stream, Size: 4495 bytes --]

	* expmed.c (ceil_log2): Move from here...
	* hwint.c: ... to here for older GCCs...
	* hwint.h: ... and here for newer GCCs.
	* rtl.h (ceil_log2): Remove prototype.

	* tree-phinodes.c: Do not include rtl.h.
	* Makefile.in (tree-phinodes.o): Do not depend on RTL_H.

Index: expmed.c
===================================================================
--- expmed.c	(revision 188268)
+++ expmed.c	(working copy)
@@ -3269,14 +3269,6 @@ expand_widening_mult (enum machine_mode mode, rtx
 		       unsignedp, OPTAB_LIB_WIDEN);
 }
 \f
-/* Return the smallest n such that 2**n >= X.  */
-
-int
-ceil_log2 (unsigned HOST_WIDE_INT x)
-{
-  return floor_log2 (x - 1) + 1;
-}
-
 /* Choose a minimal N + 1 bit approximation to 1/D that can be used to
    replace division by D, and put the least significant N bits of the result
    in *MULTIPLIER_PTR and return the most significant bit.
Index: hwint.c
===================================================================
--- hwint.c	(revision 188268)
+++ hwint.c	(working copy)
@@ -25,10 +25,11 @@ along with GCC; see the file COPYING3.  If not see
 
 #if GCC_VERSION < 3004
 
-/* The functions clz_hwi, ctz_hwi, ffs_hwi, floor_log2 and exact_log2
-   are defined as inline functions in hwint.h if GCC_VERSION >= 3004.
-   The definitions here are used for older versions of GCC and non-GCC
-   bootstrap compilers.  */
+/* The functions clz_hwi, ctz_hwi, ffs_hwi, floor_log2, ceil_log2,
+   and exact_log2 are defined as inline functions in hwint.h
+   if GCC_VERSION >= 3004.
+   The definitions here are used for older versions of GCC and
+   non-GCC bootstrap compilers.  */
 
 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
    If X is 0, return -1.  */
@@ -61,6 +62,14 @@ floor_log2 (unsigned HOST_WIDE_INT x)
   return t;
 }
 
+/* Given X, an unsigned number, return the largest Y such that 2**Y >= X.  */
+
+int
+ceil_log2 (unsigned HOST_WIDE_INT x)
+{
+  return floor_log2 (x - 1) + 1;
+}
+
 /* Return the logarithm of X, base 2, considering X unsigned,
    if X is a power of 2.  Otherwise, returns -1.  */
 
Index: hwint.h
===================================================================
--- hwint.h	(revision 188268)
+++ hwint.h	(working copy)
@@ -179,6 +179,9 @@ extern int exact_log2                  (unsigned H
 /* Return floor of log2, with -1 for zero.  */
 extern int floor_log2                  (unsigned HOST_WIDE_INT);
 
+/* Return the smallest n such that 2**n >= X.  */
+extern int ceil_log2			(unsigned HOST_WIDE_INT);
+
 #else /* GCC_VERSION >= 3004 */
 
 /* For convenience, define 0 -> word_size.  */
@@ -229,6 +232,12 @@ floor_log2 (unsigned HOST_WIDE_INT x)
 }
 
 static inline int
+ceil_log2 (unsigned HOST_WIDE_INT x)
+{
+  return floor_log2 (x - 1) + 1;
+}
+
+static inline int
 exact_log2 (unsigned HOST_WIDE_INT x)
 {
   return x == (x & -x) && x ? ctz_hwi (x) : -1;
Index: rtl.h
===================================================================
--- rtl.h	(revision 188268)
+++ rtl.h	(working copy)
@@ -1638,9 +1638,6 @@ extern int currently_expanding_to_rtl;
 
 /* Generally useful functions.  */
 
-/* In expmed.c */
-extern int ceil_log2 (unsigned HOST_WIDE_INT);
-
 /* In explow.c */
 extern HOST_WIDE_INT trunc_int_for_mode	(HOST_WIDE_INT, enum machine_mode);
 extern rtx plus_constant (enum machine_mode, rtx, HOST_WIDE_INT);
Index: tree-phinodes.c
===================================================================
--- tree-phinodes.c	(revision 188268)
+++ tree-phinodes.c	(working copy)
@@ -23,7 +23,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
-#include "rtl.h"	/* FIXME: Only for ceil_log2, of all things...  */
 #include "ggc.h"
 #include "basic-block.h"
 #include "tree-flow.h"
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 188268)
+++ Makefile.in	(working copy)
@@ -2409,7 +2409,7 @@ tree-ssanames.o : tree-ssanames.c $(CONFIG_H) $(SY
    $(TM_H) $(TREE_H) $(TREE_FLOW_H) $(TREE_PASS_H)
 tree-phinodes.o : tree-phinodes.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(TM_H) $(TREE_H) $(GGC_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) \
-   gt-tree-phinodes.h $(RTL_H) $(DIAGNOSTIC_CORE_H)  $(GIMPLE_H)
+   gt-tree-phinodes.h $(DIAGNOSTIC_CORE_H) $(GIMPLE_H)
 domwalk.o : domwalk.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
    $(BASIC_BLOCK_H) domwalk.h sbitmap.h
 tree-ssa-live.o : tree-ssa-live.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] Do not include rtl.h in tree-phinodes.c
  2012-06-06 15:16 [patch] Do not include rtl.h in tree-phinodes.c Steven Bosscher
@ 2012-06-11  8:51 ` Richard Guenther
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2012-06-11  8:51 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: GCC Patches

On Wed, Jun 6, 2012 at 5:16 PM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> Hello,
>
> tree-phinodes.c includes rtl.h for ... ceil_log2 (?!).
>
> Moving ceil_log2 to hwint.c/hwint.h to join its sibling floor_log2
> breaks this dependency.
>
> Bootstrapped on x86_64-unknown-linux-gnu. OK for trunk?

Ok.

Thanks,
Richard.

> Ciao!
> Steven

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-06-11  8:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-06 15:16 [patch] Do not include rtl.h in tree-phinodes.c Steven Bosscher
2012-06-11  8:51 ` Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).