public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] consolidate some includes into coretypes.h
@ 2015-06-01 21:09 Andrew MacLeod
  2015-06-02  8:28 ` Richard Biener
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew MacLeod @ 2015-06-01 21:09 UTC (permalink / raw)
  To: gcc-patches

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

I've begun looking at cleaning up the include files. Before removing 
unnecessary includes, I'd like to get a few other cleanups out of the 
way to simplify the dependency web. This is the first.

There are some interrelated numerical definition headers (double-int.h, 
fixed-value.h, real.h and wide-int.h) .  Virtually every gcc source file 
ends up including them indirectly one or more times.  They also end up 
including signop.h and machmode.h as prerequisites as well.

first,

#include "machmode.h"
#include "signop.h"
#include "wide-int.h"
#include "double-int.h"

any source file  which includes tree.h, gimple.h *or* rtl.h will require 
all of these to compile.  That is basically the entire compiler.

then there are:

#include "real.h"
#include "fixed-value.h"     /* require real.h to compile */

rtl.h has a hard dependency on these 2 files to compile, and although 
tree.h still parses and compiles when they are not included, it does 
provide some macros which access tree fields which return a FIXED_VALUE. 
   Any file which includes tree.h could therefore require real.h and 
fixed-value.h if they use the results of those macros.

That said, I tried flattening these includes throughout the compiler to 
see exactly which other source files really need real.h and 
fixed-value.h.  I changbed it such that those 2 files were included by 
rtl.h, realmpfr.h, and dfp.h which have hard requirements.  I found 
about 37 of the remaining source files required real.h and about 16 
required fixed-value.h

Personally given those numbers and since tree.h exposes potential uses 
of FIXED_VALUE, the simple and cleanest thing to do is just add all 6 of 
these includes to the basic pre-requisites for source files.

Currently, all source files start with
#include "config.h"
#include "system.h"
#include "coretypes.h"

The first include can be different for generator (bconfig.h) and target 
(tconfig.h) files,  so with a small tweak to coretypes.h to include 
these 6 header files when config.h has been included (by checking if 
GCC_CONFIG_H is defined),  everything pretty much magically works.  I 
think it makes sense to put them there since they are core types and is 
already included everywhere its needed. If that is not satisfactory, I 
could create a new include file which comes after coretypes when 
appropriate...

The only exception is the cases where rtl.h is included by some 
generator file. These generator files are used late enough in the build  
that insn-modes.h exists and can safely include all these files.  I 
added a condition to rtl.h to include these files when GENERATOR_FILE is 
defined since they wouldn't have been included by coretypes.h normally.

With that change I can remove *all* other #includes of these 6 files, 
and simplify the initial part of the include web quite nicely.  I also 
used the opportunity to remove coretypes.h from a couple of includes 
that no longer need to include it.

there are 2 patches. The first is short and has the interesting changes, 
the second is purely automated and removes all the extraneous #includes 
of these files which are now all encapsulated in coretypes.h.

Bootstraps from scratch on x86_64-unknown-linux-gnu with no new test 
regressions.  I also built it on all the config-list.mk targets with no 
additional compilation errors.

OK for trunk?

Andrew

-  I do have a functioning patch which moves real.h and fixed-value.h to 
the required source files, I just dont like it as well so propose this 
one first.


[-- Attachment #2: num1.patch --]
[-- Type: text/x-patch, Size: 4752 bytes --]



	* coretypes.h: Include machmode.h, signop.h, wide-int.h, double-int.h,
	real.h, and fixed-value.h when included in host source files, identified
	by the presence of config.h in the include chain.
	* double-int.h: Remove redundant #includes listed above.
	* fixed-value.h: Likewise.
	* real.h: Likewise.
	* wide-int.h: Likewise.
	* inchash.h: Likewise.
	* rtl.h: Add some include files When included from a generator file.
	* target.h: Remove wide-int.h and insn-modes.h from the include list.
	* internal-fn.h: Don't include coretypes.h.


Index: coretypes.h
===================================================================
--- coretypes.h	(revision 223875)
+++ coretypes.h	(working copy)
@@ -299,4 +299,14 @@
 typedef unsigned char uchar;
 #endif
 
+/* Most host source files will require the following headers.  */
+#ifdef GCC_CONFIG_H
+#include "machmode.h"
+#include "signop.h"
+#include "wide-int.h" 
+#include "double-int.h"
+#include "real.h"
+#include "fixed-value.h"
+#endif
+
 #endif /* coretypes.h */
Index: double-int.h
===================================================================
--- double-int.h	(revision 223875)
+++ double-int.h	(working copy)
@@ -20,8 +20,6 @@
 #ifndef DOUBLE_INT_H
 #define DOUBLE_INT_H
 
-#include "wide-int.h"
-
 /* A large integer is currently represented as a pair of HOST_WIDE_INTs.
    It therefore represents a number with precision of
    2 * HOST_BITS_PER_WIDE_INT bits (it is however possible that the
Index: fixed-value.h
===================================================================
--- fixed-value.h	(revision 223875)
+++ fixed-value.h	(working copy)
@@ -20,10 +20,6 @@
 #ifndef GCC_FIXED_VALUE_H
 #define GCC_FIXED_VALUE_H
 
-#include "machmode.h"
-#include "real.h"
-#include "double-int.h"
-
 struct GTY(()) fixed_value
 {
   double_int data;		/* Store data up to 2 wide integers.  */
Index: real.h
===================================================================
--- real.h	(revision 223875)
+++ real.h	(working copy)
@@ -20,11 +20,6 @@
 #ifndef GCC_REAL_H
 #define GCC_REAL_H
 
-#include "machmode.h"
-#include "signop.h"
-#include "wide-int.h"
-#include "insn-modes.h"
-
 /* An expanded form of the represented number.  */
 
 /* Enumerate the special cases of numbers that we encounter.  */
Index: wide-int.h
===================================================================
--- wide-int.h	(revision 223875)
+++ wide-int.h	(working copy)
@@ -216,11 +216,6 @@
    the same result as X + X; the precision of the shift amount Y
    can be arbitrarily different from X.  */
 
-#include "system.h"
-#include "hwint.h"
-#include "signop.h"
-#include "insn-modes.h"
-
 /* The MAX_BITSIZE_MODE_ANY_INT is automatically generated by a very
    early examination of the target's mode file.  The WIDE_INT_MAX_ELTS
    can accomodate at least 1 more bit so that unsigned numbers of that
Index: inchash.h
===================================================================
--- inchash.h	(revision 223875)
+++ inchash.h	(working copy)
@@ -20,13 +20,6 @@
 #ifndef INCHASH_H
 #define INCHASH_H 1
 
-#ifdef GENERATOR_FILE
-#include "bconfig.h"
-#else
-#include "config.h"
-#endif
-#include "system.h"
-#include "coretypes.h"
 #include "hashtab.h"
 
 /* This file implements an incremential hash function ADT, to be used
Index: rtl.h
===================================================================
--- rtl.h	(revision 223875)
+++ rtl.h	(working copy)
@@ -20,15 +20,23 @@
 #ifndef GCC_RTL_H
 #define GCC_RTL_H
 
+/* This file is occasionally included by generator files which expect
+   machmode.h and other files to exist and would not normally have been
+   included by coretypes.h.  */
+#ifdef GENERATOR_FILE
+#include "machmode.h"     
+#include "signop.h"
+#include "wide-int.h"
+#include "double-int.h"
+#include "real.h"
+#include "fixed-value.h"
+#endif  /* GENERATOR_FILE */
+
 #include "statistics.h"
-#include "machmode.h"
 #include "input.h"
-#include "real.h"
 #include "vec.h"
-#include "fixed-value.h"
 #include "alias.h"
 #include "hashtab.h"
-#include "wide-int.h"
 #include "flags.h"
 #include "is-a.h"
 
Index: target.h
===================================================================
--- target.h	(revision 223875)
+++ target.h	(working copy)
@@ -48,9 +48,7 @@
 #ifndef GCC_TARGET_H
 #define GCC_TARGET_H
 
-#include "insn-modes.h"
 #include "insn-codes.h"
-#include "wide-int.h"
 #include "tm.h"
 #include "hard-reg-set.h"
 
Index: internal-fn.h
===================================================================
--- internal-fn.h	(revision 223875)
+++ internal-fn.h	(working copy)
@@ -20,8 +20,6 @@
 #ifndef GCC_INTERNAL_FN_H
 #define GCC_INTERNAL_FN_H
 
-#include "coretypes.h"
-
 /* Initialize internal function tables.  */
 
 extern void init_internal_fns ();

[-- Attachment #3: num2.patch.Z --]
[-- Type: application/x-compress, Size: 46443 bytes --]

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

end of thread, other threads:[~2015-06-04 11:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-01 21:09 [patch] consolidate some includes into coretypes.h Andrew MacLeod
2015-06-02  8:28 ` Richard Biener
2015-06-02 12:47   ` Andrew MacLeod
2015-06-02 13:49     ` Richard Biener
2015-06-02 14:19       ` Andrew MacLeod
2015-06-03 11:53         ` Richard Biener
2015-06-03 13:40           ` Andrew MacLeod
2015-06-04 12:29             ` Andrew MacLeod

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).