diff mbox series

[5/5] match.pd: Use splits in makefile and make configurable.

Message ID patch-17230-tamar@arm.com
State New
Headers show
Series None | expand

Commit Message

Tamar Christina April 28, 2023, 10:44 a.m. UTC
Hi All,

This updates the build system to split up match.pd files into chunks of 10.
This also introduces a new flag --with-matchpd-partitions which can be used to
change the number of partitions.

For the analysis of why 10 please look at the previous patch in the series.

Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.

Ok for master?

Thanks,
Tamar

gcc/ChangeLog:

	PR bootstrap/84402
	* Makefile.in (NUM_MATCH_SPLITS, MATCH_SPLITS_SEQ,
	GIMPLE_MATCH_PD_SEQ_SRC, GIMPLE_MATCH_PD_SEQ_O,
	GENERIC_MATCH_PD_SEQ_SRC, GENERIC_MATCH_PD_SEQ_O): New.
	(OBJS, MOSTLYCLEANFILES, .PRECIOUS): Use them.
	(s-match): Split into s-generic-match and s-gimple-match.
	* configure.ac (with-matchpd-partitions,
	DEFAULT_MATCHPD_PARTITIONS): New.
	* configure: Regenerate.

--- inline copy of patch -- 
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 70559a014c0e32d8d825766e0c1516fc2ee05421..f3343eea3339e9dc054e83cfb899799c7d784963 100644




--
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 70559a014c0e32d8d825766e0c1516fc2ee05421..f3343eea3339e9dc054e83cfb899799c7d784963 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -214,6 +214,14 @@ rtl-ssa-warn = $(STRICT_WARN)
 GCC_WARN_CFLAGS = $(LOOSE_WARN) $(C_LOOSE_WARN) $($(@D)-warn) $(if $(filter-out $(STRICT_WARN),$($(@D)-warn)),,$(C_STRICT_WARN)) $(NOCOMMON_FLAG) $($@-warn)
 GCC_WARN_CXXFLAGS = $(LOOSE_WARN) $($(@D)-warn) $(NOCOMMON_FLAG) $($@-warn)
 
+# The number of splits to be made for the match.pd files.
+NUM_MATCH_SPLITS = @DEFAULT_MATCHPD_PARTITIONS@
+MATCH_SPLITS_SEQ = $(shell seq 1 $(NUM_MATCH_SPLITS))
+GIMPLE_MATCH_PD_SEQ_SRC = $(patsubst %, gimple-match-%.cc, $(MATCH_SPLITS_SEQ))
+GIMPLE_MATCH_PD_SEQ_O = $(patsubst %, gimple-match-%.o, $(MATCH_SPLITS_SEQ))
+GENERIC_MATCH_PD_SEQ_SRC = $(patsubst %, generic-match-%.cc, $(MATCH_SPLITS_SEQ))
+GENERIC_MATCH_PD_SEQ_O = $(patsubst %, generic-match-%.o, $(MATCH_SPLITS_SEQ))
+
 # These files are to have specific diagnostics suppressed, or are not to
 # be subject to -Werror:
 # flex output may yield harmless "no previous prototype" warnings
@@ -222,9 +230,8 @@ gengtype-lex.o-warn = -Wno-error
 libgcov-util.o-warn = -Wno-error
 libgcov-driver-tool.o-warn = -Wno-error
 libgcov-merge-tool.o-warn = -Wno-error
-gimple-match.o-warn = -Wno-unused
+gimple-match-head.o-warn = -Wno-unused
 gimple-match-exports.o-warn = -Wno-unused
-generic-match.o-warn = -Wno-unused
 dfp.o-warn = -Wno-strict-aliasing
 
 # All warnings have to be shut off in stage1 if the compiler used then
@@ -1310,9 +1317,9 @@ ANALYZER_OBJS = \
 # will build them sooner, because they are large and otherwise tend to be
 # the last objects to finish building.
 OBJS = \
-	gimple-match.o \
+	$(GIMPLE_MATCH_PD_SEQ_O) \
 	gimple-match-exports.o \
-	generic-match.o \
+	$(GENERIC_MATCH_PD_SEQ_O) \
 	insn-attrtab.o \
 	insn-automata.o \
 	insn-dfatab.o \
@@ -1805,7 +1812,8 @@ MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
  insn-output.cc insn-recog.cc insn-emit.cc insn-extract.cc insn-peep.cc \
  insn-attr.h insn-attr-common.h insn-attrtab.cc insn-dfatab.cc \
  insn-latencytab.cc insn-opinit.cc insn-opinit.h insn-preds.cc insn-constants.h \
- tm-preds.h tm-constrs.h checksum-options gimple-match.cc generic-match.cc \
+ tm-preds.h tm-constrs.h checksum-options $(GIMPLE_MATCH_PD_SEQ_SRC) \
+ $(GENERIC_MATCH_PD_SEQ_SRC) gimple-match-auto.h generic-match-auto.h \
  tree-check.h min-insn-modes.cc insn-modes.cc insn-modes.h insn-modes-inline.h \
  genrtl.h gt-*.h gtype-*.h gtype-desc.cc gtyp-input.list \
  case-cfn-macros.h cfn-operators.pd \
@@ -2420,7 +2428,8 @@ $(common_out_object_file): $(common_out_file)
 .PRECIOUS: insn-config.h insn-flags.h insn-codes.h insn-constants.h \
   insn-emit.cc insn-recog.cc insn-extract.cc insn-output.cc insn-peep.cc \
   insn-attr.h insn-attr-common.h insn-attrtab.cc insn-dfatab.cc \
-  insn-latencytab.cc insn-preds.cc gimple-match.cc generic-match.cc \
+  insn-latencytab.cc insn-preds.cc $(GIMPLE_MATCH_PD_SEQ_SRC) \
+  $(GENERIC_MATCH_PD_SEQ_SRC) gimple-match-auto.h generic-match-auto.h \
   insn-target-def.h
 
 # Dependencies for the md file.  The first time through, we just assume
@@ -2663,19 +2672,36 @@ s-tm-texi: build/genhooks$(build_exeext) $(srcdir)/doc/tm.texi.in
 	  false; \
 	fi
 
-gimple-match.cc: s-match gimple-match-head.cc gimple-match-exports.cc ; @true
-generic-match.cc: s-match generic-match-head.cc ; @true
-
-s-match: build/genmatch$(build_exeext) $(srcdir)/match.pd cfn-operators.pd
-	$(RUN_GEN) build/genmatch$(build_exeext) --gimple $(srcdir)/match.pd \
-	    > tmp-gimple-match.cc
-	$(RUN_GEN) build/genmatch$(build_exeext) --generic $(srcdir)/match.pd \
-	    > tmp-generic-match.cc
-	$(SHELL) $(srcdir)/../move-if-change tmp-gimple-match.cc \
-	    					gimple-match.cc
-	$(SHELL) $(srcdir)/../move-if-change tmp-generic-match.cc \
-	    					generic-match.cc
-	$(STAMP) s-match
+$(GIMPLE_MATCH_PD_SEQ_SRC): s-gimple-match gimple-match-head.cc \
+		    gimple-match-exports.cc; @true
+gimple-match-auto.h: s-gimple-match gimple-match-head.cc \
+		    gimple-match-exports.cc; @true
+$(GENERIC_MATCH_PD_SEQ_SRC): s-generic-match generic-match-head.cc; @true
+generic-match-auto.h: s-generic-match generic-match-head.cc; @true
+
+s-gimple-match: build/genmatch$(build_exeext) \
+	    $(srcdir)/match.pd cfn-operators.pd
+	$(RUN_GEN) build/genmatch$(build_exeext) --gimple \
+	    --header=tmp-gimple-match-auto.h --include=gimple-match-auto.h \
+	    $(srcdir)/match.pd $(patsubst %, tmp-%, $(GIMPLE_MATCH_PD_SEQ_SRC))
+	$(foreach id, $(MATCH_SPLITS_SEQ), \
+	  $(SHELL) $(srcdir)/../move-if-change tmp-gimple-match-$(id).cc \
+	    gimple-match-$(id).cc;)
+	$(SHELL) $(srcdir)/../move-if-change tmp-gimple-match-auto.h \
+						gimple-match-auto.h
+	$(STAMP) s-gimple-match
+
+s-generic-match: build/genmatch$(build_exeext) \
+	    $(srcdir)/match.pd cfn-operators.pd
+	$(RUN_GEN) build/genmatch$(build_exeext) --generic \
+	    --header=tmp-generic-match-auto.h --include=generic-match-auto.h \
+	    $(srcdir)/match.pd $(patsubst %, tmp-%, $(GENERIC_MATCH_PD_SEQ_SRC))
+	$(foreach id, $(MATCH_SPLITS_SEQ), \
+	  $(SHELL) $(srcdir)/../move-if-change tmp-generic-match-$(id).cc \
+	    generic-match-$(id).cc;)
+	$(SHELL) $(srcdir)/../move-if-change tmp-generic-match-auto.h \
+						generic-match-auto.h
+	$(STAMP) s-generic-match
 
 GTFILES = $(CPPLIB_H) $(srcdir)/input.h $(srcdir)/coretypes.h \
   $(host_xm_file_list) \
@@ -2810,7 +2836,8 @@ generated_files = config.h tm.h $(TM_P_H) $(TM_D_H) $(TM_H) multilib.h \
        $(ALL_GTFILES_H) gtype-desc.cc gtype-desc.h version.h \
        options.h target-hooks-def.h insn-opinit.h \
        common/common-target-hooks-def.h pass-instances.def \
-       gimple-match.cc generic-match.cc \
+       $(GIMPLE_MATCH_PD_SEQ_SRC) $(GENERIC_MATCH_PD_SEQ_SRC) \
+       gimple-match-auto.h generic-match-auto.h \
        c-family/c-target-hooks-def.h d/d-target-hooks-def.h \
        case-cfn-macros.h \
        cfn-operators.pd omp-device-properties.h
diff --git a/gcc/configure b/gcc/configure
index c7b26d1927de62d7b3a49ea9ac0a998979659cf2..843fd5449dd3c82fd5f7fc869ce951e89446ff6b 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -838,6 +838,7 @@ enable_gcov
 enable_shared
 enable_fixed_point
 enable_decimal_float
+DEFAULT_MATCHPD_PARTITIONS
 with_float
 with_cpu
 enable_multiarch
@@ -965,6 +966,7 @@ enable_valgrind_annotations
 enable_multilib
 enable_multiarch
 with_stack_clash_protection_guard_size
+with_matchpd_partitions
 enable___cxa_atexit
 enable_decimal_float
 enable_fixed_point
@@ -1826,6 +1828,9 @@ Optional Packages:
   --with-stack-clash-protection-guard-size=size
                           Set the default stack clash protection guard size
                           for specific targets as a power of two in bytes.
+  --with-matchpd-partitions=num
+                          Set the number of partitions to make for gimple and
+                          generic when splitting match.pd. [default=10]
   --with-dwarf2           force the default debug format to be DWARF 2 (or
                           later)
   --with-specs=SPECS      add SPECS to driver command-line processing
@@ -7889,6 +7894,26 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+# Specify the number of splits of match.pd to generate.
+
+# Check whether --with-matchpd-partitions was given.
+if test "${with_matchpd_partitions+set}" = set; then :
+  withval=$with_matchpd_partitions; DEFAULT_MATCHPD_PARTITIONS="$with_matchpd_partitions"
+else
+  DEFAULT_MATCHPD_PARTITIONS=10
+fi
+
+if (test $DEFAULT_MATCHPD_PARTITIONS -lt 1); then
+  as_fn_error $? "Invalid value $DEFAULT_MATCHPD_PARTITIONS for --with-matchpd-partitions. Cannot be negative." "$LINENO" 5
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_MATCHPD_PARTITIONS $DEFAULT_MATCHPD_PARTITIONS
+_ACEOF
+
+
+
 # Enable __cxa_atexit for C++.
 # Check whether --enable-__cxa_atexit was given.
 if test "${enable___cxa_atexit+set}" = set; then :
@@ -19825,7 +19850,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19828 "configure"
+#line 19853 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19931,7 +19956,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19934 "configure"
+#line 19959 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 09082e8ccae395b902a3ef79eb4f27a1186a331e..de5e3aef2c81e1465198f903bfcd1219363c78d8 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -921,6 +921,21 @@ fi
 AC_DEFINE_UNQUOTED(DEFAULT_STK_CLASH_GUARD_SIZE, $DEFAULT_STK_CLASH_GUARD_SIZE,
 	[Define to larger than zero set the default stack clash protector size.])
 
+# Specify the number of splits of match.pd to generate.
+AC_ARG_WITH(matchpd-partitions,
+[AS_HELP_STRING([--with-matchpd-partitions=num],
+[Set the number of partitions to make for gimple and generic when splitting match.pd. [default=10]])],
+[DEFAULT_MATCHPD_PARTITIONS="$with_matchpd_partitions"], [DEFAULT_MATCHPD_PARTITIONS=10])
+if (test $DEFAULT_MATCHPD_PARTITIONS -lt 1); then
+  AC_MSG_ERROR(m4_normalize([
+		Invalid value $DEFAULT_MATCHPD_PARTITIONS for --with-matchpd-partitions. \
+		Cannot be negative.]))
+fi
+
+AC_DEFINE_UNQUOTED(DEFAULT_MATCHPD_PARTITIONS, $DEFAULT_MATCHPD_PARTITIONS,
+	[Define to larger than one set the number of match.pd partitions to make.])
+AC_SUBST(DEFAULT_MATCHPD_PARTITIONS)
+
 # Enable __cxa_atexit for C++.
 AC_ARG_ENABLE(__cxa_atexit,
 [AS_HELP_STRING([--enable-__cxa_atexit], [enable __cxa_atexit for C++])],

Comments

Jeff Law April 30, 2023, 7:46 p.m. UTC | #1
On 4/28/23 04:44, Tamar Christina via Gcc-patches wrote:
> Hi All,
> 
> This updates the build system to split up match.pd files into chunks of 10.
> This also introduces a new flag --with-matchpd-partitions which can be used to
> change the number of partitions.
> 
> For the analysis of why 10 please look at the previous patch in the series.
> 
> Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
> 
> Ok for master?
> 
> Thanks,
> Tamar
> 
> gcc/ChangeLog:
> 
> 	PR bootstrap/84402
> 	* Makefile.in (NUM_MATCH_SPLITS, MATCH_SPLITS_SEQ,
> 	GIMPLE_MATCH_PD_SEQ_SRC, GIMPLE_MATCH_PD_SEQ_O,
> 	GENERIC_MATCH_PD_SEQ_SRC, GENERIC_MATCH_PD_SEQ_O): New.
> 	(OBJS, MOSTLYCLEANFILES, .PRECIOUS): Use them.
> 	(s-match): Split into s-generic-match and s-gimple-match.
> 	* configure.ac (with-matchpd-partitions,
> 	DEFAULT_MATCHPD_PARTITIONS): New.
> 	* configure: Regenerate.
This looks pretty reasonable to me.  Are there any patches left in this 
series that need review?  I'm very much looking forward to build time 
provements related to this patch, particularly for targets that I 
bootstrap with qemu emulation -- we take multiple hours to build 
gimple-match and the ability to parallelize those component builds 
should be a significant win.

jeff
Tamar Christina May 2, 2023, 7:08 a.m. UTC | #2
> -----Original Message-----
> From: Jeff Law <jeffreyalaw@gmail.com>
> Sent: Sunday, April 30, 2023 8:46 PM
> To: Tamar Christina <Tamar.Christina@arm.com>; gcc-patches@gcc.gnu.org
> Cc: nd <nd@arm.com>; bonzini@gnu.org; neroden@gcc.gnu.org;
> aoliva@gcc.gnu.org; Ralf.Wildenhues@gmx.de
> Subject: Re: [PATCH 5/5] match.pd: Use splits in makefile and make
> configurable.
> 
> 
> 
> On 4/28/23 04:44, Tamar Christina via Gcc-patches wrote:
> > Hi All,
> >
> > This updates the build system to split up match.pd files into chunks of 10.
> > This also introduces a new flag --with-matchpd-partitions which can be
> > used to change the number of partitions.
> >
> > For the analysis of why 10 please look at the previous patch in the series.
> >
> > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
> >
> > Ok for master?
> >
> > Thanks,
> > Tamar
> >
> > gcc/ChangeLog:
> >
> > 	PR bootstrap/84402
> > 	* Makefile.in (NUM_MATCH_SPLITS, MATCH_SPLITS_SEQ,
> > 	GIMPLE_MATCH_PD_SEQ_SRC, GIMPLE_MATCH_PD_SEQ_O,
> > 	GENERIC_MATCH_PD_SEQ_SRC, GENERIC_MATCH_PD_SEQ_O): New.
> > 	(OBJS, MOSTLYCLEANFILES, .PRECIOUS): Use them.
> > 	(s-match): Split into s-generic-match and s-gimple-match.
> > 	* configure.ac (with-matchpd-partitions,
> > 	DEFAULT_MATCHPD_PARTITIONS): New.
> > 	* configure: Regenerate.
> This looks pretty reasonable to me.  Are there any patches left in this series
> that need review?  I'm very much looking forward to build time provements
> related to this patch, particularly for targets that I bootstrap with qemu
> emulation -- we take multiple hours to build gimple-match and the ability to
> parallelize those component builds should be a significant win.

Hi,

No this is the last one, Richi already approved the rest but he didn't feel he had
enough knowledge about the build system to say if this code was portable enough.

So just waiting on this one and can commit the series.

Cheers,
Tamar
> 
> jeff
Kyrylo Tkachov May 3, 2023, 3:18 p.m. UTC | #3
> -----Original Message-----
> From: Gcc-patches <gcc-patches-
> bounces+kyrylo.tkachov=arm.com@gcc.gnu.org> On Behalf Of Tamar
> Christina via Gcc-patches
> Sent: Tuesday, May 2, 2023 8:08 AM
> To: Jeff Law <jeffreyalaw@gmail.com>; gcc-patches@gcc.gnu.org
> Cc: nd <nd@arm.com>; bonzini@gnu.org; neroden@gcc.gnu.org;
> aoliva@gcc.gnu.org; Ralf.Wildenhues@gmx.de
> Subject: RE: [PATCH 5/5] match.pd: Use splits in makefile and make
> configurable.
> 
> > -----Original Message-----
> > From: Jeff Law <jeffreyalaw@gmail.com>
> > Sent: Sunday, April 30, 2023 8:46 PM
> > To: Tamar Christina <Tamar.Christina@arm.com>; gcc-patches@gcc.gnu.org
> > Cc: nd <nd@arm.com>; bonzini@gnu.org; neroden@gcc.gnu.org;
> > aoliva@gcc.gnu.org; Ralf.Wildenhues@gmx.de
> > Subject: Re: [PATCH 5/5] match.pd: Use splits in makefile and make
> > configurable.
> >
> >
> >
> > On 4/28/23 04:44, Tamar Christina via Gcc-patches wrote:
> > > Hi All,
> > >
> > > This updates the build system to split up match.pd files into chunks of 10.
> > > This also introduces a new flag --with-matchpd-partitions which can be
> > > used to change the number of partitions.
> > >
> > > For the analysis of why 10 please look at the previous patch in the series.
> > >
> > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
> > >
> > > Ok for master?
> > >
> > > Thanks,
> > > Tamar
> > >
> > > gcc/ChangeLog:
> > >
> > > 	PR bootstrap/84402
> > > 	* Makefile.in (NUM_MATCH_SPLITS, MATCH_SPLITS_SEQ,
> > > 	GIMPLE_MATCH_PD_SEQ_SRC, GIMPLE_MATCH_PD_SEQ_O,
> > > 	GENERIC_MATCH_PD_SEQ_SRC, GENERIC_MATCH_PD_SEQ_O): New.
> > > 	(OBJS, MOSTLYCLEANFILES, .PRECIOUS): Use them.
> > > 	(s-match): Split into s-generic-match and s-gimple-match.
> > > 	* configure.ac (with-matchpd-partitions,
> > > 	DEFAULT_MATCHPD_PARTITIONS): New.
> > > 	* configure: Regenerate.
> > This looks pretty reasonable to me.  Are there any patches left in this series
> > that need review?  I'm very much looking forward to build time provements
> > related to this patch, particularly for targets that I bootstrap with qemu
> > emulation -- we take multiple hours to build gimple-match and the ability to
> > parallelize those component builds should be a significant win.
> 
> Hi,
> 
> No this is the last one, Richi already approved the rest but he didn't feel he
> had
> enough knowledge about the build system to say if this code was portable
> enough.

I'm looking forward to this going as well for improved bootstrap times, thanks for working on this!

> 
> So just waiting on this one and can commit the series.

Can we treat Jeff's LGTM above as an ok given his global reviewer position?
Thanks,
Kyrill

> 
> Cheers,
> Tamar
> >
> > jeff
Tamar Christina May 4, 2023, 9:56 a.m. UTC | #4
> -----Original Message-----
> From: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>
> Sent: Wednesday, May 3, 2023 4:19 PM
> To: Tamar Christina <Tamar.Christina@arm.com>; Jeff Law
> <jeffreyalaw@gmail.com>; gcc-patches@gcc.gnu.org
> Cc: nd <nd@arm.com>; bonzini@gnu.org; neroden@gcc.gnu.org;
> aoliva@gcc.gnu.org; Ralf.Wildenhues@gmx.de
> Subject: RE: [PATCH 5/5] match.pd: Use splits in makefile and make
> configurable.
> 
> 
> 
> > -----Original Message-----
> > From: Gcc-patches <gcc-patches-
> > bounces+kyrylo.tkachov=arm.com@gcc.gnu.org> On Behalf Of Tamar
> > Christina via Gcc-patches
> > Sent: Tuesday, May 2, 2023 8:08 AM
> > To: Jeff Law <jeffreyalaw@gmail.com>; gcc-patches@gcc.gnu.org
> > Cc: nd <nd@arm.com>; bonzini@gnu.org; neroden@gcc.gnu.org;
> > aoliva@gcc.gnu.org; Ralf.Wildenhues@gmx.de
> > Subject: RE: [PATCH 5/5] match.pd: Use splits in makefile and make
> > configurable.
> >
> > > -----Original Message-----
> > > From: Jeff Law <jeffreyalaw@gmail.com>
> > > Sent: Sunday, April 30, 2023 8:46 PM
> > > To: Tamar Christina <Tamar.Christina@arm.com>;
> > > gcc-patches@gcc.gnu.org
> > > Cc: nd <nd@arm.com>; bonzini@gnu.org; neroden@gcc.gnu.org;
> > > aoliva@gcc.gnu.org; Ralf.Wildenhues@gmx.de
> > > Subject: Re: [PATCH 5/5] match.pd: Use splits in makefile and make
> > > configurable.
> > >
> > >
> > >
> > > On 4/28/23 04:44, Tamar Christina via Gcc-patches wrote:
> > > > Hi All,
> > > >
> > > > This updates the build system to split up match.pd files into chunks of
> 10.
> > > > This also introduces a new flag --with-matchpd-partitions which
> > > > can be used to change the number of partitions.
> > > >
> > > > For the analysis of why 10 please look at the previous patch in the series.
> > > >
> > > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
> > > >
> > > > Ok for master?
> > > >
> > > > Thanks,
> > > > Tamar
> > > >
> > > > gcc/ChangeLog:
> > > >
> > > > 	PR bootstrap/84402
> > > > 	* Makefile.in (NUM_MATCH_SPLITS, MATCH_SPLITS_SEQ,
> > > > 	GIMPLE_MATCH_PD_SEQ_SRC, GIMPLE_MATCH_PD_SEQ_O,
> > > > 	GENERIC_MATCH_PD_SEQ_SRC, GENERIC_MATCH_PD_SEQ_O): New.
> > > > 	(OBJS, MOSTLYCLEANFILES, .PRECIOUS): Use them.
> > > > 	(s-match): Split into s-generic-match and s-gimple-match.
> > > > 	* configure.ac (with-matchpd-partitions,
> > > > 	DEFAULT_MATCHPD_PARTITIONS): New.
> > > > 	* configure: Regenerate.
> > > This looks pretty reasonable to me.  Are there any patches left in
> > > this series that need review?  I'm very much looking forward to
> > > build time provements related to this patch, particularly for
> > > targets that I bootstrap with qemu emulation -- we take multiple
> > > hours to build gimple-match and the ability to parallelize those component
> builds should be a significant win.
> >
> > Hi,
> >
> > No this is the last one, Richi already approved the rest but he didn't
> > feel he had enough knowledge about the build system to say if this
> > code was portable enough.
> 
> I'm looking forward to this going as well for improved bootstrap times, thanks
> for working on this!
> 
> >
> > So just waiting on this one and can commit the series.
> 
> Can we treat Jeff's LGTM above as an ok given his global reviewer position?

Ah I didn't treat it as such as it wasn't in reply to the "ok for master" part. But
perhaps I misunderstood.  In case it wasn't, this is also a PING for the *.in files
maintainers.

Regards,
Tamar

> Thanks,
> Kyrill
> 
> >
> > Cheers,
> > Tamar
> > >
> > > jeff
Jeff Law May 4, 2023, 11:25 p.m. UTC | #5
On 5/4/23 03:56, Tamar Christina wrote:
>> -----Original Message-----
>> From: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>
>> Sent: Wednesday, May 3, 2023 4:19 PM
>> To: Tamar Christina <Tamar.Christina@arm.com>; Jeff Law
>> <jeffreyalaw@gmail.com>; gcc-patches@gcc.gnu.org
>> Cc: nd <nd@arm.com>; bonzini@gnu.org; neroden@gcc.gnu.org;
>> aoliva@gcc.gnu.org; Ralf.Wildenhues@gmx.de
>> Subject: RE: [PATCH 5/5] match.pd: Use splits in makefile and make
>> configurable.
>>
>>
>>
>>> -----Original Message-----
>>> From: Gcc-patches <gcc-patches-
>>> bounces+kyrylo.tkachov=arm.com@gcc.gnu.org> On Behalf Of Tamar
>>> Christina via Gcc-patches
>>> Sent: Tuesday, May 2, 2023 8:08 AM
>>> To: Jeff Law <jeffreyalaw@gmail.com>; gcc-patches@gcc.gnu.org
>>> Cc: nd <nd@arm.com>; bonzini@gnu.org; neroden@gcc.gnu.org;
>>> aoliva@gcc.gnu.org; Ralf.Wildenhues@gmx.de
>>> Subject: RE: [PATCH 5/5] match.pd: Use splits in makefile and make
>>> configurable.
>>>
>>>> -----Original Message-----
>>>> From: Jeff Law <jeffreyalaw@gmail.com>
>>>> Sent: Sunday, April 30, 2023 8:46 PM
>>>> To: Tamar Christina <Tamar.Christina@arm.com>;
>>>> gcc-patches@gcc.gnu.org
>>>> Cc: nd <nd@arm.com>; bonzini@gnu.org; neroden@gcc.gnu.org;
>>>> aoliva@gcc.gnu.org; Ralf.Wildenhues@gmx.de
>>>> Subject: Re: [PATCH 5/5] match.pd: Use splits in makefile and make
>>>> configurable.
>>>>
>>>>
>>>>
>>>> On 4/28/23 04:44, Tamar Christina via Gcc-patches wrote:
>>>>> Hi All,
>>>>>
>>>>> This updates the build system to split up match.pd files into chunks of
>> 10.
>>>>> This also introduces a new flag --with-matchpd-partitions which
>>>>> can be used to change the number of partitions.
>>>>>
>>>>> For the analysis of why 10 please look at the previous patch in the series.
>>>>>
>>>>> Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
>>>>>
>>>>> Ok for master?
>>>>>
>>>>> Thanks,
>>>>> Tamar
>>>>>
>>>>> gcc/ChangeLog:
>>>>>
>>>>> 	PR bootstrap/84402
>>>>> 	* Makefile.in (NUM_MATCH_SPLITS, MATCH_SPLITS_SEQ,
>>>>> 	GIMPLE_MATCH_PD_SEQ_SRC, GIMPLE_MATCH_PD_SEQ_O,
>>>>> 	GENERIC_MATCH_PD_SEQ_SRC, GENERIC_MATCH_PD_SEQ_O): New.
>>>>> 	(OBJS, MOSTLYCLEANFILES, .PRECIOUS): Use them.
>>>>> 	(s-match): Split into s-generic-match and s-gimple-match.
>>>>> 	* configure.ac (with-matchpd-partitions,
>>>>> 	DEFAULT_MATCHPD_PARTITIONS): New.
>>>>> 	* configure: Regenerate.
>>>> This looks pretty reasonable to me.  Are there any patches left in
>>>> this series that need review?  I'm very much looking forward to
>>>> build time provements related to this patch, particularly for
>>>> targets that I bootstrap with qemu emulation -- we take multiple
>>>> hours to build gimple-match and the ability to parallelize those component
>> builds should be a significant win.
>>>
>>> Hi,
>>>
>>> No this is the last one, Richi already approved the rest but he didn't
>>> feel he had enough knowledge about the build system to say if this
>>> code was portable enough.
>>
>> I'm looking forward to this going as well for improved bootstrap times, thanks
>> for working on this!
>>
>>>
>>> So just waiting on this one and can commit the series.
>>
>> Can we treat Jeff's LGTM above as an ok given his global reviewer position?
> 
> Ah I didn't treat it as such as it wasn't in reply to the "ok for master" part. But
> perhaps I misunderstood.  In case it wasn't, this is also a PING for the *.in files
> maintainers.
My message was a fairly ambiguous.   I just gave it another once over 
and I'll give an explicit OK for the trunk.

Jeff
Tamar Christina May 5, 2023, 12:51 p.m. UTC | #6
> >>>> This looks pretty reasonable to me.  Are there any patches left in
> >>>> this series that need review?  I'm very much looking forward to
> >>>> build time provements related to this patch, particularly for
> >>>> targets that I bootstrap with qemu emulation -- we take multiple
> >>>> hours to build gimple-match and the ability to parallelize those
> >>>> component
> >> builds should be a significant win.
> >>>
> >>> Hi,
> >>>
> >>> No this is the last one, Richi already approved the rest but he
> >>> didn't feel he had enough knowledge about the build system to say if
> >>> this code was portable enough.
> >>
> >> I'm looking forward to this going as well for improved bootstrap
> >> times, thanks for working on this!
> >>
> >>>
> >>> So just waiting on this one and can commit the series.
> >>
> >> Can we treat Jeff's LGTM above as an ok given his global reviewer position?
> >
> > Ah I didn't treat it as such as it wasn't in reply to the "ok for
> > master" part. But perhaps I misunderstood.  In case it wasn't, this is
> > also a PING for the *.in files maintainers.
> My message was a fairly ambiguous.   I just gave it another once over
> and I'll give an explicit OK for the trunk.
> 

Merci!

I'll go to the next bottleneck then.

Thanks!
Tamar

> Jeff
diff mbox series

Patch

--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -214,6 +214,14 @@  rtl-ssa-warn = $(STRICT_WARN)
 GCC_WARN_CFLAGS = $(LOOSE_WARN) $(C_LOOSE_WARN) $($(@D)-warn) $(if $(filter-out $(STRICT_WARN),$($(@D)-warn)),,$(C_STRICT_WARN)) $(NOCOMMON_FLAG) $($@-warn)
 GCC_WARN_CXXFLAGS = $(LOOSE_WARN) $($(@D)-warn) $(NOCOMMON_FLAG) $($@-warn)
 
+# The number of splits to be made for the match.pd files.
+NUM_MATCH_SPLITS = @DEFAULT_MATCHPD_PARTITIONS@
+MATCH_SPLITS_SEQ = $(shell seq 1 $(NUM_MATCH_SPLITS))
+GIMPLE_MATCH_PD_SEQ_SRC = $(patsubst %, gimple-match-%.cc, $(MATCH_SPLITS_SEQ))
+GIMPLE_MATCH_PD_SEQ_O = $(patsubst %, gimple-match-%.o, $(MATCH_SPLITS_SEQ))
+GENERIC_MATCH_PD_SEQ_SRC = $(patsubst %, generic-match-%.cc, $(MATCH_SPLITS_SEQ))
+GENERIC_MATCH_PD_SEQ_O = $(patsubst %, generic-match-%.o, $(MATCH_SPLITS_SEQ))
+
 # These files are to have specific diagnostics suppressed, or are not to
 # be subject to -Werror:
 # flex output may yield harmless "no previous prototype" warnings
@@ -222,9 +230,8 @@  gengtype-lex.o-warn = -Wno-error
 libgcov-util.o-warn = -Wno-error
 libgcov-driver-tool.o-warn = -Wno-error
 libgcov-merge-tool.o-warn = -Wno-error
-gimple-match.o-warn = -Wno-unused
+gimple-match-head.o-warn = -Wno-unused
 gimple-match-exports.o-warn = -Wno-unused
-generic-match.o-warn = -Wno-unused
 dfp.o-warn = -Wno-strict-aliasing
 
 # All warnings have to be shut off in stage1 if the compiler used then
@@ -1310,9 +1317,9 @@  ANALYZER_OBJS = \
 # will build them sooner, because they are large and otherwise tend to be
 # the last objects to finish building.
 OBJS = \
-	gimple-match.o \
+	$(GIMPLE_MATCH_PD_SEQ_O) \
 	gimple-match-exports.o \
-	generic-match.o \
+	$(GENERIC_MATCH_PD_SEQ_O) \
 	insn-attrtab.o \
 	insn-automata.o \
 	insn-dfatab.o \
@@ -1805,7 +1812,8 @@  MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
  insn-output.cc insn-recog.cc insn-emit.cc insn-extract.cc insn-peep.cc \
  insn-attr.h insn-attr-common.h insn-attrtab.cc insn-dfatab.cc \
  insn-latencytab.cc insn-opinit.cc insn-opinit.h insn-preds.cc insn-constants.h \
- tm-preds.h tm-constrs.h checksum-options gimple-match.cc generic-match.cc \
+ tm-preds.h tm-constrs.h checksum-options $(GIMPLE_MATCH_PD_SEQ_SRC) \
+ $(GENERIC_MATCH_PD_SEQ_SRC) gimple-match-auto.h generic-match-auto.h \
  tree-check.h min-insn-modes.cc insn-modes.cc insn-modes.h insn-modes-inline.h \
  genrtl.h gt-*.h gtype-*.h gtype-desc.cc gtyp-input.list \
  case-cfn-macros.h cfn-operators.pd \
@@ -2420,7 +2428,8 @@  $(common_out_object_file): $(common_out_file)
 .PRECIOUS: insn-config.h insn-flags.h insn-codes.h insn-constants.h \
   insn-emit.cc insn-recog.cc insn-extract.cc insn-output.cc insn-peep.cc \
   insn-attr.h insn-attr-common.h insn-attrtab.cc insn-dfatab.cc \
-  insn-latencytab.cc insn-preds.cc gimple-match.cc generic-match.cc \
+  insn-latencytab.cc insn-preds.cc $(GIMPLE_MATCH_PD_SEQ_SRC) \
+  $(GENERIC_MATCH_PD_SEQ_SRC) gimple-match-auto.h generic-match-auto.h \
   insn-target-def.h
 
 # Dependencies for the md file.  The first time through, we just assume
@@ -2663,19 +2672,36 @@  s-tm-texi: build/genhooks$(build_exeext) $(srcdir)/doc/tm.texi.in
 	  false; \
 	fi
 
-gimple-match.cc: s-match gimple-match-head.cc gimple-match-exports.cc ; @true
-generic-match.cc: s-match generic-match-head.cc ; @true
-
-s-match: build/genmatch$(build_exeext) $(srcdir)/match.pd cfn-operators.pd
-	$(RUN_GEN) build/genmatch$(build_exeext) --gimple $(srcdir)/match.pd \
-	    > tmp-gimple-match.cc
-	$(RUN_GEN) build/genmatch$(build_exeext) --generic $(srcdir)/match.pd \
-	    > tmp-generic-match.cc
-	$(SHELL) $(srcdir)/../move-if-change tmp-gimple-match.cc \
-	    					gimple-match.cc
-	$(SHELL) $(srcdir)/../move-if-change tmp-generic-match.cc \
-	    					generic-match.cc
-	$(STAMP) s-match
+$(GIMPLE_MATCH_PD_SEQ_SRC): s-gimple-match gimple-match-head.cc \
+		    gimple-match-exports.cc; @true
+gimple-match-auto.h: s-gimple-match gimple-match-head.cc \
+		    gimple-match-exports.cc; @true
+$(GENERIC_MATCH_PD_SEQ_SRC): s-generic-match generic-match-head.cc; @true
+generic-match-auto.h: s-generic-match generic-match-head.cc; @true
+
+s-gimple-match: build/genmatch$(build_exeext) \
+	    $(srcdir)/match.pd cfn-operators.pd
+	$(RUN_GEN) build/genmatch$(build_exeext) --gimple \
+	    --header=tmp-gimple-match-auto.h --include=gimple-match-auto.h \
+	    $(srcdir)/match.pd $(patsubst %, tmp-%, $(GIMPLE_MATCH_PD_SEQ_SRC))
+	$(foreach id, $(MATCH_SPLITS_SEQ), \
+	  $(SHELL) $(srcdir)/../move-if-change tmp-gimple-match-$(id).cc \
+	    gimple-match-$(id).cc;)
+	$(SHELL) $(srcdir)/../move-if-change tmp-gimple-match-auto.h \
+						gimple-match-auto.h
+	$(STAMP) s-gimple-match
+
+s-generic-match: build/genmatch$(build_exeext) \
+	    $(srcdir)/match.pd cfn-operators.pd
+	$(RUN_GEN) build/genmatch$(build_exeext) --generic \
+	    --header=tmp-generic-match-auto.h --include=generic-match-auto.h \
+	    $(srcdir)/match.pd $(patsubst %, tmp-%, $(GENERIC_MATCH_PD_SEQ_SRC))
+	$(foreach id, $(MATCH_SPLITS_SEQ), \
+	  $(SHELL) $(srcdir)/../move-if-change tmp-generic-match-$(id).cc \
+	    generic-match-$(id).cc;)
+	$(SHELL) $(srcdir)/../move-if-change tmp-generic-match-auto.h \
+						generic-match-auto.h
+	$(STAMP) s-generic-match
 
 GTFILES = $(CPPLIB_H) $(srcdir)/input.h $(srcdir)/coretypes.h \
   $(host_xm_file_list) \
@@ -2810,7 +2836,8 @@  generated_files = config.h tm.h $(TM_P_H) $(TM_D_H) $(TM_H) multilib.h \
        $(ALL_GTFILES_H) gtype-desc.cc gtype-desc.h version.h \
        options.h target-hooks-def.h insn-opinit.h \
        common/common-target-hooks-def.h pass-instances.def \
-       gimple-match.cc generic-match.cc \
+       $(GIMPLE_MATCH_PD_SEQ_SRC) $(GENERIC_MATCH_PD_SEQ_SRC) \
+       gimple-match-auto.h generic-match-auto.h \
        c-family/c-target-hooks-def.h d/d-target-hooks-def.h \
        case-cfn-macros.h \
        cfn-operators.pd omp-device-properties.h
diff --git a/gcc/configure b/gcc/configure
index c7b26d1927de62d7b3a49ea9ac0a998979659cf2..843fd5449dd3c82fd5f7fc869ce951e89446ff6b 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -838,6 +838,7 @@  enable_gcov
 enable_shared
 enable_fixed_point
 enable_decimal_float
+DEFAULT_MATCHPD_PARTITIONS
 with_float
 with_cpu
 enable_multiarch
@@ -965,6 +966,7 @@  enable_valgrind_annotations
 enable_multilib
 enable_multiarch
 with_stack_clash_protection_guard_size
+with_matchpd_partitions
 enable___cxa_atexit
 enable_decimal_float
 enable_fixed_point
@@ -1826,6 +1828,9 @@  Optional Packages:
   --with-stack-clash-protection-guard-size=size
                           Set the default stack clash protection guard size
                           for specific targets as a power of two in bytes.
+  --with-matchpd-partitions=num
+                          Set the number of partitions to make for gimple and
+                          generic when splitting match.pd. [default=10]
   --with-dwarf2           force the default debug format to be DWARF 2 (or
                           later)
   --with-specs=SPECS      add SPECS to driver command-line processing
@@ -7889,6 +7894,26 @@  cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+# Specify the number of splits of match.pd to generate.
+
+# Check whether --with-matchpd-partitions was given.
+if test "${with_matchpd_partitions+set}" = set; then :
+  withval=$with_matchpd_partitions; DEFAULT_MATCHPD_PARTITIONS="$with_matchpd_partitions"
+else
+  DEFAULT_MATCHPD_PARTITIONS=10
+fi
+
+if (test $DEFAULT_MATCHPD_PARTITIONS -lt 1); then
+  as_fn_error $? "Invalid value $DEFAULT_MATCHPD_PARTITIONS for --with-matchpd-partitions. Cannot be negative." "$LINENO" 5
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_MATCHPD_PARTITIONS $DEFAULT_MATCHPD_PARTITIONS
+_ACEOF
+
+
+
 # Enable __cxa_atexit for C++.
 # Check whether --enable-__cxa_atexit was given.
 if test "${enable___cxa_atexit+set}" = set; then :
@@ -19825,7 +19850,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19828 "configure"
+#line 19853 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19931,7 +19956,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19934 "configure"
+#line 19959 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 09082e8ccae395b902a3ef79eb4f27a1186a331e..de5e3aef2c81e1465198f903bfcd1219363c78d8 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -921,6 +921,21 @@  fi
 AC_DEFINE_UNQUOTED(DEFAULT_STK_CLASH_GUARD_SIZE, $DEFAULT_STK_CLASH_GUARD_SIZE,
 	[Define to larger than zero set the default stack clash protector size.])
 
+# Specify the number of splits of match.pd to generate.
+AC_ARG_WITH(matchpd-partitions,
+[AS_HELP_STRING([--with-matchpd-partitions=num],
+[Set the number of partitions to make for gimple and generic when splitting match.pd. [default=10]])],
+[DEFAULT_MATCHPD_PARTITIONS="$with_matchpd_partitions"], [DEFAULT_MATCHPD_PARTITIONS=10])
+if (test $DEFAULT_MATCHPD_PARTITIONS -lt 1); then
+  AC_MSG_ERROR(m4_normalize([
+		Invalid value $DEFAULT_MATCHPD_PARTITIONS for --with-matchpd-partitions. \
+		Cannot be negative.]))
+fi
+
+AC_DEFINE_UNQUOTED(DEFAULT_MATCHPD_PARTITIONS, $DEFAULT_MATCHPD_PARTITIONS,
+	[Define to larger than one set the number of match.pd partitions to make.])
+AC_SUBST(DEFAULT_MATCHPD_PARTITIONS)
+
 # Enable __cxa_atexit for C++.
 AC_ARG_ENABLE(__cxa_atexit,
 [AS_HELP_STRING([--enable-__cxa_atexit], [enable __cxa_atexit for C++])],