public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew MacLeod <amacleod@redhat.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch] consolidate some includes into coretypes.h
Date: Tue, 02 Jun 2015 14:19:00 -0000	[thread overview]
Message-ID: <556DBB73.6070408@redhat.com> (raw)
In-Reply-To: <CAFiYyc3CQYuJP2=KsTUdZ1Gq1ZXrDjvJVcEOHiH47Fd8foj4tg@mail.gmail.com>

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

On 06/02/2015 09:30 AM, Richard Biener wrote:
> On Tue, Jun 2, 2015 at 2:34 PM, Andrew MacLeod <amacleod@redhat.com> wrote:
>> On 06/02/2015 04:26 AM, Richard Biener wrote:
>>> On Mon, Jun 1, 2015 at 11:02 PM, Andrew MacLeod <amacleod@redhat.com>
>>> wrote:
>>>>
>>>> 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?
>> Target files also use coretypes.h. In particular, libgcc includes it and
>> does not have GENERATOR_FILE set.  Rather than checking for GCC_CONFIG_H we
>> could check
>>
>> #if !defined (GENERATOR_FILE) && !defined (USED_FOR_TARGET)
>>
>> I think that should work OK.
>>> 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.
>>
>> This one is harder. I don't like the special case either, but you cant
>> really figure it out in coretypes.h.  The problem comes from some generator
>> files which compile rtl.c and and a couple of other files, and thus have
>> GENERATOR_FILE set... These run after the initial set of generators so
>> insn-modes.h and friends have been created, and these includes are now
>> required.   the presence of rtl.h seems to be the the litmus test and if it
>> occurs in the include chain after coretypes.h, then we'll need these files.
>>
>> I suppose you could just include those files in rtl.h directly without the
>> guard...  it is probably the cleanest solution. Otherwise we'd either have
>> to add a new identifying macro to a dozen generator files, or include these
>> headers there, or some other such thing.
> Well, then include the requirements in the generator files instead?  It looks
> backwards to add to the includes in rtl.h.
>
> Richard.
Except that it is rtl.h that actually has the compilation requirement.  
I could put those includes in each of the generator files which require 
it, but the list is non-trivial:
Each of these files can be compiled with bconfig.h instead of config.h, 
and they each include rtl.h which requires these headers:
genattr.c
genattr-common.c
genattrtab.c
genautomata.c
gencodes.c
genconditions.c
genconfig.c
genemit.c
genextract.c
genflags.c
genmddump.c
genopinit.c
genoutput.c
genpeep.c
genpreds.c
genrecog.c
gensupport.c
print-rtl.c
read-rtl.c
rtl.c


so there are 20 files which require these headers, and there are 11 
others which do not require rtl.h nor the headers (and will fail compile 
if they are included)
gencheck.c
genconstants.c
genenums.c
genmatch.c
genmddeps.c
genmodes.c
ggc-none.c
hash-table.c
inchash.c
read-md.c
vec.c


I suppose one could add something like:
#define EARLY_GENERATOR
in each of the 11 and check for that macro in coretypes.h instead of 
GENERATOR file.  ThIs appears to work fine:

Andrew



[-- Attachment #2: num4.diff --]
[-- Type: text/x-patch, Size: 6238 bytes --]

diff -cpN /numerical/coretypes.h /CMP/coretypes.h
*** /numerical/coretypes.h	2015-06-01 18:00:36.284376498 -0400
--- /CMP/coretypes.h	2015-06-02 10:15:12.427363555 -0400
*************** typedef unsigned char uchar;
*** 300,306 ****
  #endif
  
  /* Most host source files will require the following headers.  */
! #ifdef GCC_CONFIG_H
  #include "machmode.h"
  #include "signop.h"
  #include "wide-int.h" 
--- 300,306 ----
  #endif
  
  /* Most host source files will require the following headers.  */
! #if !defined (EARLY_GENERATOR_FILE) && !defined (USED_FOR_TARGET)
  #include "machmode.h"
  #include "signop.h"
  #include "wide-int.h" 
diff -cpN /numerical/gencheck.c /CMP/gencheck.c
*** /numerical/gencheck.c	2015-06-01 18:00:36.290376342 -0400
--- /CMP/gencheck.c	2015-06-02 10:15:12.434363374 -0400
*************** along with GCC; see the file COPYING3.
*** 20,25 ****
--- 20,26 ----
  /* We don't have insn-modes.h, but we include tm.h.  */
  #define BITS_PER_UNIT 8
  
+ #define EARLY_GENERATOR_FILE
  #include "bconfig.h"
  #include "system.h"
  #include "coretypes.h"
diff -cpN /numerical/genconstants.c /CMP/genconstants.c
*** /numerical/genconstants.c	2015-06-01 18:00:36.290376342 -0400
--- /CMP/genconstants.c	2015-06-02 10:15:12.435363348 -0400
*************** along with GCC; see the file COPYING3.
*** 24,29 ****
--- 24,30 ----
     look at insn patterns, only (define_constants), and we want to
     minimize dependencies.  */
  
+ #define EARLY_GENERATOR_FILE
  #include "bconfig.h"
  #include "system.h"
  #include "coretypes.h"
diff -cpN /numerical/genenums.c /CMP/genenums.c
*** /numerical/genenums.c	2015-06-01 18:00:36.290376342 -0400
--- /CMP/genenums.c	2015-06-02 10:15:12.435363348 -0400
*************** You should have received a copy of the G
*** 17,22 ****
--- 17,23 ----
  along with GCC; see the file COPYING3.  If not see
  <http://www.gnu.org/licenses/>.  */
  
+ #define EARLY_GENERATOR_FILE
  #include "bconfig.h"
  #include "system.h"
  #include "coretypes.h"
diff -cpN /numerical/genmatch.c /CMP/genmatch.c
*** /numerical/genmatch.c	2015-06-01 18:00:36.291376316 -0400
--- /CMP/genmatch.c	2015-06-02 10:15:12.435363348 -0400
*************** You should have received a copy of the G
*** 21,26 ****
--- 21,27 ----
  along with GCC; see the file COPYING3.  If not see
  <http://www.gnu.org/licenses/>.  */
  
+ #define EARLY_GENERATOR_FILE
  #include "bconfig.h"
  #include <new>
  #include "system.h"
diff -cpN /numerical/genmddeps.c /CMP/genmddeps.c
*** /numerical/genmddeps.c	2015-06-01 18:00:36.291376316 -0400
--- /CMP/genmddeps.c	2015-06-02 10:15:12.435363348 -0400
***************
*** 15,20 ****
--- 15,21 ----
     along with this program; see the file COPYING3.  If not see
     <http://www.gnu.org/licenses/>.  */
  
+ #define EARLY_GENERATOR_FILE
  #include "bconfig.h"
  #include "system.h"
  #include "coretypes.h"
diff -cpN /numerical/genmodes.c /CMP/genmodes.c
*** /numerical/genmodes.c	2015-06-01 18:00:36.291376316 -0400
--- /CMP/genmodes.c	2015-06-02 10:15:12.436363323 -0400
*************** You should have received a copy of the G
*** 17,22 ****
--- 17,23 ----
  along with GCC; see the file COPYING3.  If not see
  <http://www.gnu.org/licenses/>.  */
  
+ #define EARLY_GENERATOR_FILE
  #include "bconfig.h"
  #include "system.h"
  #include "errors.h"
diff -cpN /numerical/ggc-none.c /CMP/ggc-none.c
*** /numerical/ggc-none.c	2015-06-01 18:00:36.292376290 -0400
--- /CMP/ggc-none.c	2015-06-02 10:15:12.436363323 -0400
***************
*** 21,26 ****
--- 21,27 ----
     targets (such as java), where we don't really need GC at all.
     This prevents problems with pulling in all the tree stuff.  */
  
+ #define EARLY_GENERATOR_FILE
  #ifdef GENERATOR_FILE
  #include "bconfig.h"
  #else
diff -cpN /numerical/hash-table.c /CMP/hash-table.c
*** /numerical/hash-table.c	2015-06-01 18:00:36.295376212 -0400
--- /CMP/hash-table.c	2015-06-02 10:15:12.440363220 -0400
*************** along with GCC; see the file COPYING3.
*** 22,27 ****
--- 22,28 ----
  /* This file implements a typed hash table.
     The implementation borrows from libiberty's hashtab.  */
  
+ #define EARLY_GENERATOR_FILE
  #ifdef GENERATOR_FILE
  #include "bconfig.h"
  #else
diff -cpN /numerical/inchash.c /CMP/inchash.c
*** /numerical/inchash.c	2015-06-01 18:00:36.296376186 -0400
--- /CMP/inchash.c	2015-06-02 10:15:12.440363220 -0400
*************** You should have received a copy of the G
*** 17,22 ****
--- 17,23 ----
  along with GCC; see the file COPYING3.  If not see
  <http://www.gnu.org/licenses/>.  */
  
+ #define EARLY_GENERATOR_FILE
  #ifdef GENERATOR_FILE
  #include "bconfig.h"
  #else
diff -cpN /numerical/read-md.c /CMP/read-md.c
*** /numerical/read-md.c	2015-06-01 18:00:36.302376030 -0400
--- /CMP/read-md.c	2015-06-02 10:15:12.450362962 -0400
*************** You should have received a copy of the G
*** 17,22 ****
--- 17,23 ----
  along with GCC; see the file COPYING3.  If not see
  <http://www.gnu.org/licenses/>.  */
  
+ #define EARLY_GENERATOR_FILE
  #include "bconfig.h"
  #include "system.h"
  #include "coretypes.h"
diff -cpN /numerical/rtl.h /CMP/rtl.h
*** /numerical/rtl.h	2015-06-01 18:00:36.303376004 -0400
--- /CMP/rtl.h	2015-06-02 10:15:12.454362858 -0400
*************** along with GCC; see the file COPYING3.
*** 20,37 ****
  #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 "input.h"
  #include "vec.h"
--- 20,25 ----
diff -cpN /numerical/vec.c /CMP/vec.c
*** /numerical/vec.c	2015-06-01 18:00:36.314375718 -0400
--- /CMP/vec.c	2015-06-02 10:15:12.471362420 -0400
*************** along with GCC; see the file COPYING3.
*** 22,27 ****
--- 22,28 ----
  /* This file is compiled twice: once for the generator programs
     once for the compiler.  */
  #ifdef GENERATOR_FILE
+ #define EARLY_GENERATOR_FILE
  #include "bconfig.h"
  #else
  #include "config.h"

  reply	other threads:[~2015-06-02 14:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01 21:09 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 [this message]
2015-06-03 11:53         ` Richard Biener
2015-06-03 13:40           ` Andrew MacLeod
2015-06-04 12:29             ` Andrew MacLeod

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=556DBB73.6070408@redhat.com \
    --to=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).