From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 118080 invoked by alias); 2 Jun 2015 08:26:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 118067 invoked by uid 89); 2 Jun 2015 08:26:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f177.google.com Received: from mail-ob0-f177.google.com (HELO mail-ob0-f177.google.com) (209.85.214.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 02 Jun 2015 08:26:27 +0000 Received: by obew15 with SMTP id w15so122867165obe.1 for ; Tue, 02 Jun 2015 01:26:24 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.182.102.2 with SMTP id fk2mr21842878obb.35.1433233584743; Tue, 02 Jun 2015 01:26:24 -0700 (PDT) Received: by 10.76.115.167 with HTTP; Tue, 2 Jun 2015 01:26:24 -0700 (PDT) In-Reply-To: <556CC87F.2090305@redhat.com> References: <556CC87F.2090305@redhat.com> Date: Tue, 02 Jun 2015 08:28:00 -0000 Message-ID: Subject: Re: [patch] consolidate some includes into coretypes.h From: Richard Biener To: Andrew MacLeod Cc: gcc-patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg00158.txt.bz2 On Mon, Jun 1, 2015 at 11:02 PM, Andrew MacLeod wrote: > 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? Generally the idea is sound (amend coretypes.h), but I don't like the GCC_CONFIG_H guard, why does !GENERATOR_FILE not work? Furthermore I don't like the special-casing in rtl.h, instead have coretypes.h contain sth like #ifdef GENERATOR_FILE ... rtl.h special-case #else ... GCC_CONFIG_H stuff #endif Thanks, Richard. > 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. >