diff mbox

Reorganise machmode.h headers

Message ID 874m37s7vf.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford Nov. 16, 2016, 4:32 p.m. UTC
Later patches will make machmode.h rely on wide-int.h and the
new poly-int.h, so it needs to appear later in the coretypes.h
include list.

Previously machmode.h included insn-modes.h, which as well as
the main mode enum contains configuration information like
MAX_BITSIZE_MODE_ANY_INT.  This still needs to come first,
since files like wide-int.h depend on the configuration
information.

Similarly, later patches will make the auto-generated inline
mode size functions use poly-int.h, so the patch splits them
out into their own header file and includes it after the
integer utilities.

The patch also makes the generator files include machmode.h
via coretypes.h.  Previously they did it by more indirect means.

Finally, the patch makes wide-int-print.h available via coretypes.h
too.  There didn't seem to be any reason to force only the print
routines to be included directly, and it would be painful to extend
that approach to the new polynomial integer classes.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Thanks,
Richard


[ This patch is part of the SVE series posted here:
  https://gcc.gnu.org/ml/gcc/2016-11/msg00030.html ]

gcc/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

	* Makefile.in (MACHMODE_H): Remove insn-modes.h
	(CORETYPES_H): New define.
	(MOSTLYCLEANFILES): Add insn-modes-inline.h.
	(insn-modes-inline.h, s-modes-inline-h): New rules.
	(generated_files): Add insn-modes-inline.h.
	(RTL_BASE_H, TREE_CORE_H): Use CORETYPES_H instead of coretypes.h.
	(build/gensupport.o, build/print-rtl.o, build/read-md.o): Likewise.
	(build/read-rtl.o, build/rtl.o, build/vec.o, build/hash-table.o)
	(build/inchash.o, build/gencondmd.o, build/genattr.o): Likewise.
	(build/genattr-common.o, build/genattrtab.o, build/genautomata.o)
	(build/gencheck.o, build/gencodes.o, build/genconditions.o): Likewise.
	(build/genconfig.o, build/genconstants.o, build/genemit.o): Likewise.
	(build/genenums.o, build/genextract.o, build/genflags.o): Likewise.
	(build/gentarget-def.o, build/genmddeps.o, build/genopinit.o)
	(build/genoutput.o, build/genpeep.o, build/genpreds.o): Likewise.
	(build/genrecog.o, build/genmddump.o, build/genmatch.o): Likewise.
	(build/gencfn-macros.o, build/gcov-iov.o): Likewise.
	* coretypes.h: Include everything up to real.h for generators.
	Include insn-modes.h first.  Include wide-int-print.h after
	wide-int.h.  Include insn-modes-inline.h and then machmode.h.
	* machmode.h: Don't include insn-modes.h here.
	* function-tests.c: Remove includes of signop.h, machmode.h,
	double-int.h and wide-int.h.
	* rtl.h: Likewise.
	* gcc-rich-location.c: Remove includes of machmode.h, double-int.h
	and wide-int.h.
	* optc-save-gen.awk: Likewise.
	* gencheck.c (BITS_PER_UNIT): Delete dummy definition.
	* godump.c: Remove include of wide-int-print.h.
	* pretty-print.h: Likewise.
	* wide-int-print.cc: Likewise.
	* wide-int.cc: Likewise.
	* hash-map-tests.c: Remove include of signop.h.
	* hash-set-tests.c: Likewise.
	* rtl-tests.c: Likewise.
	* mkconfig.sh: Remove include of machmode.h.
	* genmodes.c (emit_insn_modes_h): Split emission of inline functions
	into...
	(emit_insn_modes_inline_h): ...this new function.  Emit the code
	into an insn-modes-inline.h header file, adding appropriate
	include guards and end comments.
	(emit_insn_modes_c_header): Remove include of machmode.h.
	(emit_min_insn_modes_c_header): Include coretypes.h rather than
	machmode.h.
	(main): Handle -i flag and call emit_insn_modes_inline_h when
	it is passed.

Comments

Jeff Law Dec. 19, 2016, 11:30 p.m. UTC | #1
On 11/16/2016 09:32 AM, Richard Sandiford wrote:
> Later patches will make machmode.h rely on wide-int.h and the
> new poly-int.h, so it needs to appear later in the coretypes.h
> include list.
>
> Previously machmode.h included insn-modes.h, which as well as
> the main mode enum contains configuration information like
> MAX_BITSIZE_MODE_ANY_INT.  This still needs to come first,
> since files like wide-int.h depend on the configuration
> information.
>
> Similarly, later patches will make the auto-generated inline
> mode size functions use poly-int.h, so the patch splits them
> out into their own header file and includes it after the
> integer utilities.
>
> The patch also makes the generator files include machmode.h
> via coretypes.h.  Previously they did it by more indirect means.
>
> Finally, the patch makes wide-int-print.h available via coretypes.h
> too.  There didn't seem to be any reason to force only the print
> routines to be included directly, and it would be painful to extend
> that approach to the new polynomial integer classes.
>
> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?
>
> Thanks,
> Richard
>
>
> [ This patch is part of the SVE series posted here:
>   https://gcc.gnu.org/ml/gcc/2016-11/msg00030.html ]
>
> gcc/
> 2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
> 	    Alan Hayward  <alan.hayward@arm.com>
> 	    David Sherwood  <david.sherwood@arm.com>
>
> 	* Makefile.in (MACHMODE_H): Remove insn-modes.h
> 	(CORETYPES_H): New define.
> 	(MOSTLYCLEANFILES): Add insn-modes-inline.h.
> 	(insn-modes-inline.h, s-modes-inline-h): New rules.
> 	(generated_files): Add insn-modes-inline.h.
> 	(RTL_BASE_H, TREE_CORE_H): Use CORETYPES_H instead of coretypes.h.
> 	(build/gensupport.o, build/print-rtl.o, build/read-md.o): Likewise.
> 	(build/read-rtl.o, build/rtl.o, build/vec.o, build/hash-table.o)
> 	(build/inchash.o, build/gencondmd.o, build/genattr.o): Likewise.
> 	(build/genattr-common.o, build/genattrtab.o, build/genautomata.o)
> 	(build/gencheck.o, build/gencodes.o, build/genconditions.o): Likewise.
> 	(build/genconfig.o, build/genconstants.o, build/genemit.o): Likewise.
> 	(build/genenums.o, build/genextract.o, build/genflags.o): Likewise.
> 	(build/gentarget-def.o, build/genmddeps.o, build/genopinit.o)
> 	(build/genoutput.o, build/genpeep.o, build/genpreds.o): Likewise.
> 	(build/genrecog.o, build/genmddump.o, build/genmatch.o): Likewise.
> 	(build/gencfn-macros.o, build/gcov-iov.o): Likewise.
> 	* coretypes.h: Include everything up to real.h for generators.
> 	Include insn-modes.h first.  Include wide-int-print.h after
> 	wide-int.h.  Include insn-modes-inline.h and then machmode.h.
> 	* machmode.h: Don't include insn-modes.h here.
> 	* function-tests.c: Remove includes of signop.h, machmode.h,
> 	double-int.h and wide-int.h.
> 	* rtl.h: Likewise.
> 	* gcc-rich-location.c: Remove includes of machmode.h, double-int.h
> 	and wide-int.h.
> 	* optc-save-gen.awk: Likewise.
> 	* gencheck.c (BITS_PER_UNIT): Delete dummy definition.
> 	* godump.c: Remove include of wide-int-print.h.
> 	* pretty-print.h: Likewise.
> 	* wide-int-print.cc: Likewise.
> 	* wide-int.cc: Likewise.
> 	* hash-map-tests.c: Remove include of signop.h.
> 	* hash-set-tests.c: Likewise.
> 	* rtl-tests.c: Likewise.
> 	* mkconfig.sh: Remove include of machmode.h.
> 	* genmodes.c (emit_insn_modes_h): Split emission of inline functions
> 	into...
> 	(emit_insn_modes_inline_h): ...this new function.  Emit the code
> 	into an insn-modes-inline.h header file, adding appropriate
> 	include guards and end comments.
> 	(emit_insn_modes_c_header): Remove include of machmode.h.
> 	(emit_min_insn_modes_c_header): Include coretypes.h rather than
> 	machmode.h.
> 	(main): Handle -i flag and call emit_insn_modes_inline_h when
> 	it is passed.
So I don't see anything here particularly problematical.  My question is 
whether or not there's anything significant to be gained to moving 
forward with this kit, assuming the 67 piece kit is not likely to move 
forward.

I do think you'll need some tweaks to the contrib/header-tools which 
know about the core headers and dependencies.  Hopefully what's in there 
is easy enough to figure out how to twiddle appropriately.


Jeff
Richard Sandiford Dec. 22, 2016, 4:01 p.m. UTC | #2
Jeff Law <law@redhat.com> writes:
> On 11/16/2016 09:32 AM, Richard Sandiford wrote:
>> Later patches will make machmode.h rely on wide-int.h and the
>> new poly-int.h, so it needs to appear later in the coretypes.h
>> include list.
>>
>> Previously machmode.h included insn-modes.h, which as well as
>> the main mode enum contains configuration information like
>> MAX_BITSIZE_MODE_ANY_INT.  This still needs to come first,
>> since files like wide-int.h depend on the configuration
>> information.
>>
>> Similarly, later patches will make the auto-generated inline
>> mode size functions use poly-int.h, so the patch splits them
>> out into their own header file and includes it after the
>> integer utilities.
>>
>> The patch also makes the generator files include machmode.h
>> via coretypes.h.  Previously they did it by more indirect means.
>>
>> Finally, the patch makes wide-int-print.h available via coretypes.h
>> too.  There didn't seem to be any reason to force only the print
>> routines to be included directly, and it would be painful to extend
>> that approach to the new polynomial integer classes.
>>
>> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?
>>
>> Thanks,
>> Richard
>>
>>
>> [ This patch is part of the SVE series posted here:
>>   https://gcc.gnu.org/ml/gcc/2016-11/msg00030.html ]
>>
>> gcc/
>> 2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
>> 	    Alan Hayward  <alan.hayward@arm.com>
>> 	    David Sherwood  <david.sherwood@arm.com>
>>
>> 	* Makefile.in (MACHMODE_H): Remove insn-modes.h
>> 	(CORETYPES_H): New define.
>> 	(MOSTLYCLEANFILES): Add insn-modes-inline.h.
>> 	(insn-modes-inline.h, s-modes-inline-h): New rules.
>> 	(generated_files): Add insn-modes-inline.h.
>> 	(RTL_BASE_H, TREE_CORE_H): Use CORETYPES_H instead of coretypes.h.
>> 	(build/gensupport.o, build/print-rtl.o, build/read-md.o): Likewise.
>> 	(build/read-rtl.o, build/rtl.o, build/vec.o, build/hash-table.o)
>> 	(build/inchash.o, build/gencondmd.o, build/genattr.o): Likewise.
>> 	(build/genattr-common.o, build/genattrtab.o, build/genautomata.o)
>> 	(build/gencheck.o, build/gencodes.o, build/genconditions.o): Likewise.
>> 	(build/genconfig.o, build/genconstants.o, build/genemit.o): Likewise.
>> 	(build/genenums.o, build/genextract.o, build/genflags.o): Likewise.
>> 	(build/gentarget-def.o, build/genmddeps.o, build/genopinit.o)
>> 	(build/genoutput.o, build/genpeep.o, build/genpreds.o): Likewise.
>> 	(build/genrecog.o, build/genmddump.o, build/genmatch.o): Likewise.
>> 	(build/gencfn-macros.o, build/gcov-iov.o): Likewise.
>> 	* coretypes.h: Include everything up to real.h for generators.
>> 	Include insn-modes.h first.  Include wide-int-print.h after
>> 	wide-int.h.  Include insn-modes-inline.h and then machmode.h.
>> 	* machmode.h: Don't include insn-modes.h here.
>> 	* function-tests.c: Remove includes of signop.h, machmode.h,
>> 	double-int.h and wide-int.h.
>> 	* rtl.h: Likewise.
>> 	* gcc-rich-location.c: Remove includes of machmode.h, double-int.h
>> 	and wide-int.h.
>> 	* optc-save-gen.awk: Likewise.
>> 	* gencheck.c (BITS_PER_UNIT): Delete dummy definition.
>> 	* godump.c: Remove include of wide-int-print.h.
>> 	* pretty-print.h: Likewise.
>> 	* wide-int-print.cc: Likewise.
>> 	* wide-int.cc: Likewise.
>> 	* hash-map-tests.c: Remove include of signop.h.
>> 	* hash-set-tests.c: Likewise.
>> 	* rtl-tests.c: Likewise.
>> 	* mkconfig.sh: Remove include of machmode.h.
>> 	* genmodes.c (emit_insn_modes_h): Split emission of inline functions
>> 	into...
>> 	(emit_insn_modes_inline_h): ...this new function.  Emit the code
>> 	into an insn-modes-inline.h header file, adding appropriate
>> 	include guards and end comments.
>> 	(emit_insn_modes_c_header): Remove include of machmode.h.
>> 	(emit_min_insn_modes_c_header): Include coretypes.h rather than
>> 	machmode.h.
>> 	(main): Handle -i flag and call emit_insn_modes_inline_h when
>> 	it is passed.
> So I don't see anything here particularly problematical.  My question is 
> whether or not there's anything significant to be gained to moving 
> forward with this kit, assuming the 67 piece kit is not likely to move 
> forward.

Yeah, I agree it's not worth it now that those patches won't go in.

> I do think you'll need some tweaks to the contrib/header-tools which 
> know about the core headers and dependencies.  Hopefully what's in there 
> is easy enough to figure out how to twiddle appropriately.

Thanks for the pointer, will make a note to look at that for GCC 8.

Richard
diff mbox

Patch

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 7ecd1e4..2daa6a6 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -896,14 +896,15 @@  COMMON_TARGET_DEF = common/common-target.def target-hooks-macros.h
 TARGET_H = $(TM_H) target.h $(TARGET_DEF) insn-modes.h insn-codes.h
 C_TARGET_H = c-family/c-target.h $(C_TARGET_DEF)
 COMMON_TARGET_H = common/common-target.h $(INPUT_H) $(COMMON_TARGET_DEF)
-MACHMODE_H = machmode.h mode-classes.def insn-modes.h
+MACHMODE_H = machmode.h mode-classes.def
 HOOKS_H = hooks.h $(MACHMODE_H)
 HOSTHOOKS_DEF_H = hosthooks-def.h $(HOOKS_H)
 LANGHOOKS_DEF_H = langhooks-def.h $(HOOKS_H)
 TARGET_DEF_H = target-def.h target-hooks-def.h $(HOOKS_H) targhooks.h
 C_TARGET_DEF_H = c-family/c-target-def.h c-family/c-target-hooks-def.h \
   $(TREE_H) $(C_COMMON_H) $(HOOKS_H) common/common-targhooks.h
-RTL_BASE_H = coretypes.h rtl.h rtl.def $(MACHMODE_H) reg-notes.def \
+CORETYPES_H = coretypes.h insn-modes.h insn-modes-inline.h
+RTL_BASE_H = $(CORETYPES_H) rtl.h rtl.def $(MACHMODE_H) reg-notes.def \
   insn-notes.def $(INPUT_H) $(REAL_H) statistics.h $(VEC_H) \
   $(FIXED_VALUE_H) alias.h $(HASHTAB_H)
 FIXED_VALUE_H = fixed-value.h $(MACHMODE_H) double-int.h
@@ -914,7 +915,7 @@  BUILTINS_DEF = builtins.def sync-builtins.def omp-builtins.def \
 	gtm-builtins.def sanitizer.def cilkplus.def cilk-builtins.def
 INTERNAL_FN_DEF = internal-fn.def
 INTERNAL_FN_H = internal-fn.h $(INTERNAL_FN_DEF)
-TREE_CORE_H = tree-core.h coretypes.h all-tree.def tree.def \
+TREE_CORE_H = tree-core.h $(CORETYPES_H) all-tree.def tree.def \
 	c-family/c-common.def $(lang_tree_files) $(MACHMODE_H) \
 	$(BUILTINS_DEF) $(INPUT_H) statistics.h \
 	$(VEC_H) treestruct.def $(HASHTAB_H) \
@@ -1615,7 +1616,7 @@  MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
  insn-attr.h insn-attr-common.h insn-attrtab.c insn-dfatab.c \
  insn-latencytab.c insn-opinit.c insn-opinit.h insn-preds.c insn-constants.h \
  tm-preds.h tm-constrs.h checksum-options gimple-match.c generic-match.c \
- tree-check.h min-insn-modes.c insn-modes.c insn-modes.h \
+ tree-check.h min-insn-modes.c insn-modes.c insn-modes.h insn-modes-inline.h \
  genrtl.h gt-*.h gtype-*.h gtype-desc.c gtyp-input.list \
  case-cfn-macros.h cfn-operators.pd \
  xgcc$(exeext) cpp$(exeext) $(FULL_DRIVER_NAME) \
@@ -2293,6 +2294,7 @@  s-genrtl-h: build/gengenrtl$(build_exeext)
 
 insn-modes.c: s-modes; @true
 insn-modes.h: s-modes-h; @true
+insn-modes-inline.h: s-modes-inline-h; @true
 min-insn-modes.c: s-modes-m; @true
 
 s-modes: build/genmodes$(build_exeext)
@@ -2305,6 +2307,12 @@  s-modes-h: build/genmodes$(build_exeext)
 	$(SHELL) $(srcdir)/../move-if-change tmp-modes.h insn-modes.h
 	$(STAMP) s-modes-h
 
+s-modes-inline-h: build/genmodes$(build_exeext)
+	$(RUN_GEN) build/genmodes$(build_exeext) -i > tmp-modes-inline.h
+	$(SHELL) $(srcdir)/../move-if-change tmp-modes-inline.h \
+	  insn-modes-inline.h
+	$(STAMP) s-modes-inline-h
+
 s-modes-m: build/genmodes$(build_exeext)
 	$(RUN_GEN) build/genmodes$(build_exeext) -m > tmp-min-modes.c
 	$(SHELL) $(srcdir)/../move-if-change tmp-min-modes.c min-insn-modes.c
@@ -2537,7 +2545,8 @@  s-gtype: build/gengtype$(build_exeext) $(filter-out [%], $(GTFILES)) \
 
 generated_files = config.h tm.h $(TM_P_H) $(TM_H) multilib.h \
        $(simple_generated_h) specs.h \
-       tree-check.h genrtl.h insn-modes.h tm-preds.h tm-constrs.h \
+       tree-check.h genrtl.h insn-modes.h insn-modes-inline.h \
+       tm-preds.h tm-constrs.h \
        $(ALL_GTFILES_H) gtype-desc.c gtype-desc.h gcov-iov.h \
        options.h target-hooks-def.h insn-opinit.h \
        common/common-target-hooks-def.h pass-instances.def \
@@ -2564,30 +2573,30 @@  build/version.o:  version.c version.h \
 # Header dependencies for the programs that generate source code.
 # These are library modules...
 build/errors.o : errors.c $(BCONFIG_H) $(SYSTEM_H) errors.h
-build/gensupport.o: gensupport.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h	\
-  $(GTM_H) $(RTL_BASE_H) $(OBSTACK_H) errors.h $(HASHTAB_H)		\
-  $(READ_MD_H) $(GENSUPPORT_H)
-build/ggc-none.o : ggc-none.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h 	\
+build/gensupport.o: gensupport.c $(BCONFIG_H) $(SYSTEM_H) 		\
+  $(CORETYPES_H) $(GTM_H) $(RTL_BASE_H) $(OBSTACK_H) errors.h		\
+  $(HASHTAB_H) $(READ_MD_H) $(GENSUPPORT_H)
+build/ggc-none.o : ggc-none.c $(BCONFIG_H) $(SYSTEM_H) $(CORETYPES_H) 	\
   $(GGC_H)
 build/min-insn-modes.o : min-insn-modes.c $(BCONFIG_H) $(SYSTEM_H)	\
   $(MACHMODE_H)
-build/print-rtl.o: print-rtl.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h	\
+build/print-rtl.o: print-rtl.c $(BCONFIG_H) $(SYSTEM_H) $(CORETYPES_H)	\
   $(GTM_H) $(RTL_BASE_H)
-build/read-md.o: read-md.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h		\
+build/read-md.o: read-md.c $(BCONFIG_H) $(SYSTEM_H) $(CORETYPES_H)	\
   $(HASHTAB_H) errors.h $(READ_MD_H)
-build/read-rtl.o: read-rtl.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h	\
+build/read-rtl.o: read-rtl.c $(BCONFIG_H) $(SYSTEM_H) $(CORETYPES_H)	\
   $(GTM_H) $(RTL_BASE_H) $(OBSTACK_H) $(HASHTAB_H) $(READ_MD_H)		\
   $(GENSUPPORT_H)
-build/rtl.o: rtl.c $(BCONFIG_H) coretypes.h $(GTM_H) $(SYSTEM_H)	\
+build/rtl.o: rtl.c $(BCONFIG_H) $(CORETYPES_H) $(GTM_H) $(SYSTEM_H)	\
   $(RTL_H) $(GGC_H) errors.h
-build/vec.o : vec.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(VEC_H)	\
-   $(GGC_H) toplev.h $(DIAGNOSTIC_CORE_H)
-build/hash-table.o : hash-table.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h  \
-   $(HASH_TABLE_H) $(GGC_H) toplev.h $(DIAGNOSTIC_CORE_H)
-build/inchash.o : inchash.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h  \
-   $(HASHTAB_H) inchash.h
+build/vec.o : vec.c $(BCONFIG_H) $(SYSTEM_H) $(CORETYPES_H) $(VEC_H)	\
+  $(GGC_H) toplev.h $(DIAGNOSTIC_CORE_H)
+build/hash-table.o : hash-table.c $(BCONFIG_H) $(SYSTEM_H)		\
+  $(CORETYPES_H) $(HASH_TABLE_H) $(GGC_H) toplev.h $(DIAGNOSTIC_CORE_H)
+build/inchash.o : inchash.c $(BCONFIG_H) $(SYSTEM_H) $(CORETYPES_H)	\
+  $(HASHTAB_H) inchash.h
 build/gencondmd.o : build/gencondmd.c $(BCONFIG_H) $(SYSTEM_H)		\
-  coretypes.h $(GTM_H) insn-constants.h					\
+  $(CORETYPES_H) $(GTM_H) insn-constants.h				\
   $(filter-out insn-flags.h, $(RTL_H) $(TM_P_H) $(FUNCTION_H) $(REGS_H) \
   $(RECOG_H) output.h $(FLAGS_H) $(RESOURCE_H) toplev.h $(DIAGNOSTIC_CORE_H) reload.h 	\
   $(EXCEPT_H) tm-constrs.h)
@@ -2599,39 +2608,39 @@  build/gencondmd.o : \
 
 # ...these are the programs themselves.
 build/genattr.o : genattr.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
-  coretypes.h $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)
+  $(CORETYPES_H) $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)
 build/genattr-common.o : genattr-common.c $(RTL_BASE_H) $(BCONFIG_H)	\
-  $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)
+  $(SYSTEM_H) $(CORETYPES_H) $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)
 build/genattrtab.o : genattrtab.c $(RTL_BASE_H) $(OBSTACK_H)		\
-  $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(GGC_H)	\
+  $(BCONFIG_H) $(SYSTEM_H) $(CORETYPES_H) $(GTM_H) errors.h $(GGC_H)	\
   $(READ_MD_H) $(GENSUPPORT_H) $(FNMATCH_H)
 build/genautomata.o : genautomata.c $(RTL_BASE_H) $(OBSTACK_H)		\
-  $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(VEC_H)	\
+  $(BCONFIG_H) $(SYSTEM_H) $(CORETYPES_H) $(GTM_H) errors.h $(VEC_H)	\
   $(HASHTAB_H) $(GENSUPPORT_H) $(FNMATCH_H)
 build/gencheck.o : gencheck.c all-tree.def $(BCONFIG_H) $(GTM_H)	\
-	$(SYSTEM_H) coretypes.h tree.def c-family/c-common.def		\
+	$(SYSTEM_H) $(CORETYPES_H) tree.def c-family/c-common.def	\
 	$(lang_tree_files) gimple.def
 build/genchecksum.o : genchecksum.c $(BCONFIG_H) $(SYSTEM_H) $(MD5_H)
 build/gencodes.o : gencodes.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
-  coretypes.h $(GTM_H) errors.h $(GENSUPPORT_H)
+  $(CORETYPES_H) $(GTM_H) errors.h $(GENSUPPORT_H)
 build/genconditions.o : genconditions.c $(RTL_BASE_H) $(BCONFIG_H)	\
-  $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(HASHTAB_H) $(READ_MD_H)	\
-  $(GENSUPPORT_H)
+  $(SYSTEM_H) $(CORETYPES_H) $(GTM_H) errors.h $(HASHTAB_H)		\
+  $(READ_MD_H) $(GENSUPPORT_H)
 build/genconfig.o : genconfig.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
-  coretypes.h $(GTM_H) errors.h $(GENSUPPORT_H)
+  $(CORETYPES_H) $(GTM_H) errors.h $(GENSUPPORT_H)
 build/genconstants.o : genconstants.c $(BCONFIG_H) $(SYSTEM_H)		\
-  coretypes.h errors.h $(READ_MD_H)
+  $(CORETYPES_H) errors.h $(READ_MD_H)
 build/genemit.o : genemit.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
-  coretypes.h $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H) internal-fn.def
+  $(CORETYPES_H) $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H) internal-fn.def
 build/genenums.o : genenums.c $(BCONFIG_H) $(SYSTEM_H)			\
-  coretypes.h errors.h $(READ_MD_H)
+  $(CORETYPES_H) errors.h $(READ_MD_H)
 build/genextract.o : genextract.c $(RTL_BASE_H) $(BCONFIG_H)		\
-  $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)
+  $(SYSTEM_H) $(CORETYPES_H) $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)
 build/genflags.o : genflags.c $(RTL_BASE_H) $(OBSTACK_H) $(BCONFIG_H)	\
-  $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)
+  $(SYSTEM_H) $(CORETYPES_H) $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)
 build/gentarget-def.o : gentarget-def.c $(BCONFIG_H) $(SYSTEM_H)	\
-  coretypes.h $(GTM_H) $(RTL_BASE_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)	\
-  $(HASH_TABLE_H) target-insns.def
+  $(CORETYPES_H) $(GTM_H) $(RTL_BASE_H) errors.h $(READ_MD_H)		\
+  $(GENSUPPORT_H) $(HASH_TABLE_H) target-insns.def
 build/gengenrtl.o : gengenrtl.c $(BCONFIG_H) $(SYSTEM_H) rtl.def
 
 # The gengtype generator program is special: Two versions are built.
@@ -2667,30 +2676,32 @@  build/gengtype.o: $(BCONFIG_H)
 
 CFLAGS-errors.o += -DHOST_GENERATOR_FILE
 
-build/genmddeps.o: genmddeps.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h	\
+build/genmddeps.o: genmddeps.c $(BCONFIG_H) $(SYSTEM_H) $(CORETYPES_H)	\
   errors.h $(READ_MD_H)
 build/genmodes.o : genmodes.c $(BCONFIG_H) $(SYSTEM_H) errors.h		\
   $(HASHTAB_H) machmode.def $(extra_modes_file)
 build/genopinit.o : genopinit.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
-  coretypes.h $(GTM_H) errors.h $(GENSUPPORT_H) optabs.def
+  $(CORETYPES_H) $(GTM_H) errors.h $(GENSUPPORT_H) optabs.def
 build/genoutput.o : genoutput.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
-  coretypes.h $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)
+  $(CORETYPES_H) $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)
 build/genpeep.o : genpeep.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
-  coretypes.h $(GTM_H) errors.h $(GENSUPPORT_H) toplev.h $(DIAGNOSTIC_CORE_H)
+  $(CORETYPES_H) $(GTM_H) errors.h $(GENSUPPORT_H) toplev.h		\
+  $(DIAGNOSTIC_CORE_H)
 build/genpreds.o : genpreds.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
-  coretypes.h $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H) $(OBSTACK_H)
+  $(CORETYPES_H) $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H) $(OBSTACK_H)
 build/genrecog.o : genrecog.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
-  coretypes.h $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)		\
+  $(CORETYPES_H) $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)		\
   $(HASH_TABLE_H) inchash.h
 build/genhooks.o : genhooks.c $(TARGET_DEF) $(C_TARGET_DEF)		\
   $(COMMON_TARGET_DEF) $(BCONFIG_H) $(SYSTEM_H) errors.h
 build/genmddump.o : genmddump.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
-  coretypes.h $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)
+  $(CORETYPES_H) $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)
 build/genmatch.o : genmatch.c $(BCONFIG_H) $(SYSTEM_H) \
-  coretypes.h errors.h $(HASH_TABLE_H) hash-map.h $(GGC_H) is-a.h \
+  $(CORETYPES_H) errors.h $(HASH_TABLE_H) hash-map.h $(GGC_H) is-a.h \
   tree.def builtins.def internal-fn.def
 build/gencfn-macros.o : gencfn-macros.c $(BCONFIG_H) $(SYSTEM_H)	\
-  coretypes.h errors.h $(HASH_TABLE_H) hash-set.h builtins.def internal-fn.def
+  $(CORETYPES_H) errors.h $(HASH_TABLE_H) hash-set.h builtins.def	\
+  internal-fn.def
 
 # Compile the programs that generate insn-* from the machine description.
 # They are compiled with $(COMPILER_FOR_BUILD), and associated libraries,
@@ -2788,8 +2799,8 @@  CFLAGS-cppdefault.o += $(PREPROCESSOR_DEFINES)
 # having an empty command (nothing following the semicolon).
 
 # gcov-iov.c is run on the build machine to generate gcov-iov.h from version.c
-build/gcov-iov.o: gcov-iov.c $(BCONFIG_H) coretypes.h $(GTM_H) \
-  $(SYSTEM_H) coretypes.h $(TM_H)
+build/gcov-iov.o: gcov-iov.c $(BCONFIG_H) $(CORETYPES_H) $(GTM_H) \
+  $(SYSTEM_H) $(CORETYPES_H) $(TM_H)
 
 build/gcov-iov$(build_exeext): build/gcov-iov.o
 	+$(LINKER_FOR_BUILD) $(BUILD_LINKERFLAGS) $(BUILD_LDFLAGS) \
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 6d78a25..e77c9dc 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -340,12 +340,17 @@  typedef void (*gt_pointer_operator) (void *, void *);
 typedef unsigned char uchar;
 #endif
 
-/* Most host source files will require the following headers.  */
-#if !defined (GENERATOR_FILE) && !defined (USED_FOR_TARGET)
-#include "machmode.h"
+/* Most source files will require the following headers.  */
+#if !defined (USED_FOR_TARGET)
+#include "insn-modes.h"
 #include "signop.h"
 #include "wide-int.h" 
+#include "wide-int-print.h"
+#include "insn-modes-inline.h"
+#include "machmode.h"
 #include "double-int.h"
+/* Most host source files will require the following headers.  */
+#if !defined (GENERATOR_FILE)
 #include "real.h"
 #include "fixed-value.h"
 #include "hash-table.h"
@@ -353,6 +358,7 @@  typedef unsigned char uchar;
 #include "input.h"
 #include "is-a.h"
 #include "memory-block.h"
+#endif
 #endif /* GENERATOR_FILE && !USED_FOR_TARGET */
 
 #endif /* coretypes.h */
diff --git a/gcc/function-tests.c b/gcc/function-tests.c
index b0c44cf..c2d5a81 100644
--- a/gcc/function-tests.c
+++ b/gcc/function-tests.c
@@ -22,7 +22,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "opts.h"
-#include "signop.h"
 #include "hash-set.h"
 #include "fixed-value.h"
 #include "alias.h"
@@ -38,7 +37,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "vec.h"
 #include "hashtab.h"
 #include "hash-set.h"
-#include "machmode.h"
 #include "hard-reg-set.h"
 #include "input.h"
 #include "function.h"
@@ -56,10 +54,8 @@  along with GCC; see the file COPYING3.  If not see
 #include "gimplify.h"
 #include "tree-cfg.h"
 #include "basic-block.h"
-#include "double-int.h"
 #include "alias.h"
 #include "symtab.h"
-#include "wide-int.h"
 #include "inchash.h"
 #include "tree.h"
 #include "fold-const.h"
diff --git a/gcc/gcc-rich-location.c b/gcc/gcc-rich-location.c
index b8787b4..3408c11 100644
--- a/gcc/gcc-rich-location.c
+++ b/gcc/gcc-rich-location.c
@@ -23,13 +23,10 @@  along with GCC; see the file COPYING3.  If not see
 #include "tm.h"
 #include "rtl.h"
 #include "hash-set.h"
-#include "machmode.h"
 #include "vec.h"
-#include "double-int.h"
 #include "input.h"
 #include "alias.h"
 #include "symtab.h"
-#include "wide-int.h"
 #include "inchash.h"
 #include "tree-core.h"
 #include "tree.h"
diff --git a/gcc/gencheck.c b/gcc/gencheck.c
index 23be4a8..5673d18 100644
--- a/gcc/gencheck.c
+++ b/gcc/gencheck.c
@@ -17,9 +17,6 @@  You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-/* We don't have insn-modes.h, but we include tm.h.  */
-#define BITS_PER_UNIT 8
-
 #include "bconfig.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/genmodes.c b/gcc/genmodes.c
index 92ca055..2088939 100644
--- a/gcc/genmodes.c
+++ b/gcc/genmodes.c
@@ -1204,6 +1204,24 @@  enum machine_mode\n{");
 
   printf ("#define NUM_INT_N_ENTS %d\n", n_int_n_ents);
 
+  puts ("\
+\n\
+#endif /* insn-modes.h */");
+}
+
+static void
+emit_insn_modes_inline_h (void)
+{
+  printf ("/* Generated automatically from machmode.def%s%s\n",
+	   HAVE_EXTRA_MODES ? " and " : "",
+	   EXTRA_MODES_FILE);
+
+  puts ("\
+   by genmodes.  */\n\
+\n\
+#ifndef GCC_INSN_MODES_INLINE_H\n\
+#define GCC_INSN_MODES_INLINE_H");
+
   puts ("\n#if !defined (USED_FOR_TARGET) && GCC_VERSION >= 4001\n");
   emit_mode_size_inline ();
   emit_mode_nunits_inline ();
@@ -1214,7 +1232,7 @@  enum machine_mode\n{");
 
   puts ("\
 \n\
-#endif /* insn-modes.h */");
+#endif /* insn-modes-inline.h */");
 }
 
 static void
@@ -1231,7 +1249,6 @@  emit_insn_modes_c_header (void)
 #include \"system.h\"\n\
 #include \"coretypes.h\"\n\
 #include \"tm.h\"\n\
-#include \"machmode.h\"\n\
 #include \"real.h\"");
 }
 
@@ -1247,7 +1264,7 @@  emit_min_insn_modes_c_header (void)
 \n\
 #include \"bconfig.h\"\n\
 #include \"system.h\"\n\
-#include \"machmode.h\"");
+#include \"coretypes.h\"");
 }
 
 static void
@@ -1797,18 +1814,20 @@  emit_min_insn_modes_c (void)
 int
 main (int argc, char **argv)
 {
-  bool gen_header = false, gen_min = false;
+  bool gen_header = false, gen_inlines = false, gen_min = false;
   progname = argv[0];
 
   if (argc == 1)
     ;
   else if (argc == 2 && !strcmp (argv[1], "-h"))
     gen_header = true;
+  else if (argc == 2 && !strcmp (argv[1], "-i"))
+    gen_inlines = true;
   else if (argc == 2 && !strcmp (argv[1], "-m"))
     gen_min = true;
   else
     {
-      error ("usage: %s [-h|-m] > file", progname);
+      error ("usage: %s [-h|-i|-m] > file", progname);
       return FATAL_EXIT_CODE;
     }
 
@@ -1824,6 +1843,8 @@  main (int argc, char **argv)
 
   if (gen_header)
     emit_insn_modes_h ();
+  else if (gen_inlines)
+    emit_insn_modes_inline_h ();
   else if (gen_min)
     emit_min_insn_modes_c ();
   else
diff --git a/gcc/godump.c b/gcc/godump.c
index 608542c..f3d8710 100644
--- a/gcc/godump.c
+++ b/gcc/godump.c
@@ -31,7 +31,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "tree.h"
-#include "wide-int-print.h"
 #include "diagnostic-core.h"
 #include "debug.h"
 #include "stor-layout.h"
diff --git a/gcc/hash-map-tests.c b/gcc/hash-map-tests.c
index fd1bb95..d06b31a 100644
--- a/gcc/hash-map-tests.c
+++ b/gcc/hash-map-tests.c
@@ -22,7 +22,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "opts.h"
-#include "signop.h"
 #include "hash-set.h"
 #include "fixed-value.h"
 #include "alias.h"
diff --git a/gcc/hash-set-tests.c b/gcc/hash-set-tests.c
index db408f2..965b409 100644
--- a/gcc/hash-set-tests.c
+++ b/gcc/hash-set-tests.c
@@ -22,7 +22,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "opts.h"
-#include "signop.h"
 #include "hash-set.h"
 #include "selftest.h"
 
diff --git a/gcc/machmode.h b/gcc/machmode.h
index 3dcadd8..e64c5f6 100644
--- a/gcc/machmode.h
+++ b/gcc/machmode.h
@@ -20,9 +20,6 @@  along with GCC; see the file COPYING3.  If not see
 #ifndef HAVE_MACHINE_MODES
 #define HAVE_MACHINE_MODES
 
-/* Make an enum class that gives all the machine modes.  */
-#include "insn-modes.h"
-
 /* Get the name of mode MODE as a string.  */
 
 extern const char * const mode_name[NUM_MACHINE_MODES];
diff --git a/gcc/mkconfig.sh b/gcc/mkconfig.sh
index 67dfac6..a9658f7 100644
--- a/gcc/mkconfig.sh
+++ b/gcc/mkconfig.sh
@@ -100,9 +100,6 @@  case $output in
 #if defined IN_GCC && !defined GENERATOR_FILE
 # include "insn-modes.h"
 #endif
-#if defined IN_GCC && defined GENERATOR_FILE && !defined BITS_PER_UNIT
-#include "machmode.h"
-#endif
 EOF
     ;;
 esac
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 8ce4248..8b534ae 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -41,13 +41,10 @@  print "#include " quote "flags.h" quote
 print "#include " quote "target.h" quote
 print "#include " quote "inchash.h" quote
 print "#include " quote "hash-set.h" quote
-print "#include " quote "machmode.h" quote
 print "#include " quote "vec.h" quote
-print "#include " quote "double-int.h" quote
 print "#include " quote "input.h" quote
 print "#include " quote "alias.h" quote
 print "#include " quote "symtab.h" quote
-print "#include " quote "wide-int.h" quote
 print "#include " quote "inchash.h" quote
 print "#include " quote "tree.h" quote
 print "#include " quote "fold-const.h" quote
diff --git a/gcc/pretty-print.h b/gcc/pretty-print.h
index f49f35a..d84e9f4 100644
--- a/gcc/pretty-print.h
+++ b/gcc/pretty-print.h
@@ -22,7 +22,6 @@  along with GCC; see the file COPYING3.  If not see
 #define GCC_PRETTY_PRINT_H
 
 #include "obstack.h"
-#include "wide-int-print.h"
 
 /* Maximum number of format string arguments.  */
 #define PP_NL_ARGMAX   30
diff --git a/gcc/rtl-tests.c b/gcc/rtl-tests.c
index 228226b..c6cbed8 100644
--- a/gcc/rtl-tests.c
+++ b/gcc/rtl-tests.c
@@ -22,7 +22,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "opts.h"
-#include "signop.h"
 #include "hash-set.h"
 #include "fixed-value.h"
 #include "alias.h"
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 3a7a007..28bc328 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -24,10 +24,6 @@  along with GCC; see the file COPYING3.  If not see
    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"
 #include "statistics.h"
diff --git a/gcc/wide-int-print.cc b/gcc/wide-int-print.cc
index 70f2fb4..40fa488 100644
--- a/gcc/wide-int-print.cc
+++ b/gcc/wide-int-print.cc
@@ -21,7 +21,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
-#include "wide-int-print.h"
 
 /*
  * public printing routines.
diff --git a/gcc/wide-int.cc b/gcc/wide-int.cc
index 1a209bb..5856967 100644
--- a/gcc/wide-int.cc
+++ b/gcc/wide-int.cc
@@ -24,7 +24,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "tm.h"
 #include "tree.h"
 #include "selftest.h"
-#include "wide-int-print.h"
 
 
 #define HOST_BITS_PER_HALF_WIDE_INT 32