public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v5] genemit.c (main): split insn-emit.c for compiling parallelly
@ 2020-08-27 12:47 Jojo R
  2020-08-27 20:40 ` Segher Boessenkool
  2020-08-28  9:52 ` Richard Sandiford
  0 siblings, 2 replies; 5+ messages in thread
From: Jojo R @ 2020-08-27 12:47 UTC (permalink / raw)
  To: jiejie_rong, segher, ro, richard.guenther, joseph, gcc-patches,
	yunhai.syh

gcc/ChangeLog:

	* genemit.c (main): Print 'split line'.
	* Makefile.in (insn-emit.c): Define split count and file

---
 gcc/Makefile.in | 15 +++++++++
 gcc/genemit.c   | 87 ++++++++++++++++++++++++++++---------------------
 2 files changed, 64 insertions(+), 38 deletions(-)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 79e854aa938..08e4aa7ef6f 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1258,6 +1258,17 @@ ANALYZER_OBJS = \
 # We put the *-match.o and insn-*.o files first so that a parallel make
 # will build them sooner, because they are large and otherwise tend to be
 # the last objects to finish building.
+
+# target overrides
+-include $(tmake_file)
+
+INSN-GENERATED-SPLIT-NUM ?= 0
+insn-generated-split-num = $(shell expr $(INSN-GENERATED-SPLIT-NUM) + 1)
+
+insn-emit-split-c = $(foreach o, $(shell for i in {1..$(insn-generated-split-num)}; do echo $$i; done), insn-emit$(o).c)
+insn-emit-split-obj = $(patsubst %.c,%.o, $(insn-emit-split-c))
+$(insn-emit-split-c): insn-emit.c
+
 OBJS = \
 	gimple-match.o \
 	generic-match.o \
@@ -1265,6 +1276,7 @@ OBJS = \
 	insn-automata.o \
 	insn-dfatab.o \
 	insn-emit.o \
+	$(insn-emit-split-obj) \
 	insn-extract.o \
 	insn-latencytab.o \
 	insn-modes.o \
@@ -2365,6 +2377,9 @@ $(simple_generated_c:insn-%.c=s-%): s-%: build/gen%$(build_exeext)
 	$(RUN_GEN) build/gen$*$(build_exeext) $(md_file) \
 	  $(filter insn-conditions.md,$^) > tmp-$*.c
 	$(SHELL) $(srcdir)/../move-if-change tmp-$*.c insn-$*.c
+	$*v=$$(echo $$(csplit insn-$*.c /parallel\ compilation/ -k -s {$(INSN-GENERATED-SPLIT-NUM)} -f insn-$* -b "%d.c" 2>&1));\
+	[ ! "$$$*v" ] || grep "match not found" <<< $$$*v
+	[ -s insn-$*0.c ] || (for i in {1..$(insn-generated-split-num)}; do touch insn-$*$$i.c; done && echo "" > insn-$*.c)
 	$(STAMP) s-$*
 
 # gencheck doesn't read the machine description, and the file produced
diff --git a/gcc/genemit.c b/gcc/genemit.c
index 84d07d388ee..3aaaeb62b0a 100644
--- a/gcc/genemit.c
+++ b/gcc/genemit.c
@@ -847,6 +847,46 @@ handle_overloaded_gen (overloaded_name *oname)
     }
 }
 
+#define printf_include() do { \
+  printf ("/* Generated automatically by the program `genemit'\n\
+from the machine description file `md'.  */\n\n");      \
+  printf ("#define IN_TARGET_CODE 1\n");                \
+  printf ("#include \"config.h\"\n");                   \
+  printf ("#include \"system.h\"\n");                   \
+  printf ("#include \"coretypes.h\"\n");                \
+  printf ("#include \"backend.h\"\n");                  \
+  printf ("#include \"predict.h\"\n");                  \
+  printf ("#include \"tree.h\"\n");                     \
+  printf ("#include \"rtl.h\"\n");                      \
+  printf ("#include \"alias.h\"\n");                    \
+  printf ("#include \"varasm.h\"\n");                   \
+  printf ("#include \"stor-layout.h\"\n");              \
+  printf ("#include \"calls.h\"\n");                    \
+  printf ("#include \"memmodel.h\"\n");                 \
+  printf ("#include \"tm_p.h\"\n");                     \
+  printf ("#include \"flags.h\"\n");                    \
+  printf ("#include \"insn-config.h\"\n");              \
+  printf ("#include \"expmed.h\"\n");                   \
+  printf ("#include \"dojump.h\"\n");                   \
+  printf ("#include \"explow.h\"\n");                   \
+  printf ("#include \"emit-rtl.h\"\n");                 \
+  printf ("#include \"stmt.h\"\n");                     \
+  printf ("#include \"expr.h\"\n");                     \
+  printf ("#include \"insn-codes.h\"\n");               \
+  printf ("#include \"optabs.h\"\n");                   \
+  printf ("#include \"dfp.h\"\n");                      \
+  printf ("#include \"output.h\"\n");                   \
+  printf ("#include \"recog.h\"\n");                    \
+  printf ("#include \"df.h\"\n");                       \
+  printf ("#include \"resource.h\"\n");                 \
+  printf ("#include \"reload.h\"\n");                   \
+  printf ("#include \"diagnostic-core.h\"\n");          \
+  printf ("#include \"regs.h\"\n");                     \
+  printf ("#include \"tm-constrs.h\"\n");               \
+  printf ("#include \"ggc.h\"\n");                      \
+  printf ("#include \"target.h\"\n\n");                 \
+} while (0)
+
 int
 main (int argc, const char **argv)
 {
@@ -862,49 +902,19 @@ main (int argc, const char **argv)
   /* Assign sequential codes to all entries in the machine description
      in parallel with the tables in insn-output.c.  */
 
-  printf ("/* Generated automatically by the program `genemit'\n\
-from the machine description file `md'.  */\n\n");
-
-  printf ("#define IN_TARGET_CODE 1\n");
-  printf ("#include \"config.h\"\n");
-  printf ("#include \"system.h\"\n");
-  printf ("#include \"coretypes.h\"\n");
-  printf ("#include \"backend.h\"\n");
-  printf ("#include \"predict.h\"\n");
-  printf ("#include \"tree.h\"\n");
-  printf ("#include \"rtl.h\"\n");
-  printf ("#include \"alias.h\"\n");
-  printf ("#include \"varasm.h\"\n");
-  printf ("#include \"stor-layout.h\"\n");
-  printf ("#include \"calls.h\"\n");
-  printf ("#include \"memmodel.h\"\n");
-  printf ("#include \"tm_p.h\"\n");
-  printf ("#include \"flags.h\"\n");
-  printf ("#include \"insn-config.h\"\n");
-  printf ("#include \"expmed.h\"\n");
-  printf ("#include \"dojump.h\"\n");
-  printf ("#include \"explow.h\"\n");
-  printf ("#include \"emit-rtl.h\"\n");
-  printf ("#include \"stmt.h\"\n");
-  printf ("#include \"expr.h\"\n");
-  printf ("#include \"insn-codes.h\"\n");
-  printf ("#include \"optabs.h\"\n");
-  printf ("#include \"dfp.h\"\n");
-  printf ("#include \"output.h\"\n");
-  printf ("#include \"recog.h\"\n");
-  printf ("#include \"df.h\"\n");
-  printf ("#include \"resource.h\"\n");
-  printf ("#include \"reload.h\"\n");
-  printf ("#include \"diagnostic-core.h\"\n");
-  printf ("#include \"regs.h\"\n");
-  printf ("#include \"tm-constrs.h\"\n");
-  printf ("#include \"ggc.h\"\n");
-  printf ("#include \"target.h\"\n\n");
+  long long read_count = 0;
 
   /* Read the machine description.  */
 
   md_rtx_info info;
   while (read_md_rtx (&info))
+    {
+    if (!(read_count++ % 10000))
+      {
+        printf ("/* Split file into separate compilation units for parallel compilation %lld */\n\n", read_count);
+        printf_include();
+      }
+
     switch (GET_CODE (info.def))
       {
       case DEFINE_INSN:
@@ -929,6 +939,7 @@ from the machine description file `md'.  */\n\n");
       default:
 	break;
       }
+    }
 
   /* Write out the routines to add CLOBBERs to a pattern and say whether they
      clobber a hard reg.  */
-- 
2.24.3 (Apple Git-128)


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

* Re: [PATCH v5] genemit.c (main): split insn-emit.c for compiling parallelly
  2020-08-27 12:47 [PATCH v5] genemit.c (main): split insn-emit.c for compiling parallelly Jojo R
@ 2020-08-27 20:40 ` Segher Boessenkool
  2020-09-11  7:19   ` Jojo R
  2020-08-28  9:52 ` Richard Sandiford
  1 sibling, 1 reply; 5+ messages in thread
From: Segher Boessenkool @ 2020-08-27 20:40 UTC (permalink / raw)
  To: Jojo R; +Cc: ro, richard.guenther, joseph, gcc-patches, yunhai.syh

Hi!

On Thu, Aug 27, 2020 at 08:47:19PM +0800, Jojo R wrote:
> +insn-emit-split-c = $(foreach o, $(shell for i in {1..$(insn-generated-split-num)}; do echo $$i; done), insn-emit$(o).c)

If you use a variable for the result of that "seq", this will be more
readable / maintainable / etc.

(Should this use := instead of = ?  What about the assignment to
insn-generated-split-num itself?)

> +  long long read_count = 0;

We use "int" in many other places for similar counts.  2**31 should be
enough for anybody.

>    md_rtx_info info;
>    while (read_md_rtx (&info))
> +    {
> +    if (!(read_count++ % 10000))

Wrong indent.  "== 0" is more typical for testing if numbers are zero.

> +      {
> +        printf ("/* Split file into separate compilation units for parallel compilation %lld */\n\n", read_count);

Please split this (at least the source line, but probably the target
line is too long a well).


All that are details.  This does look like it fixes the problems in the
previous versions.  Thanks!


Segher

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

* Re: [PATCH v5] genemit.c (main): split insn-emit.c for compiling parallelly
  2020-08-27 12:47 [PATCH v5] genemit.c (main): split insn-emit.c for compiling parallelly Jojo R
  2020-08-27 20:40 ` Segher Boessenkool
@ 2020-08-28  9:52 ` Richard Sandiford
  2020-09-11  7:20   ` Jojo R
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Sandiford @ 2020-08-28  9:52 UTC (permalink / raw)
  To: Jojo R; +Cc: segher, ro, richard.guenther, joseph, gcc-patches, yunhai.syh

Thanks for doing this.  In addition to what Segher said:

Jojo R <jiejie_rong@c-sky.com> writes:
> gcc/ChangeLog:
>
> 	* genemit.c (main): Print 'split line'.
> 	* Makefile.in (insn-emit.c): Define split count and file
>
> ---
>  gcc/Makefile.in | 15 +++++++++
>  gcc/genemit.c   | 87 ++++++++++++++++++++++++++++---------------------
>  2 files changed, 64 insertions(+), 38 deletions(-)
>
> diff --git a/gcc/Makefile.in b/gcc/Makefile.in
> index 79e854aa938..08e4aa7ef6f 100644
> --- a/gcc/Makefile.in
> +++ b/gcc/Makefile.in
> @@ -1258,6 +1258,17 @@ ANALYZER_OBJS = \
>  # We put the *-match.o and insn-*.o files first so that a parallel make
>  # will build them sooner, because they are large and otherwise tend to be
>  # the last objects to finish building.
> +
> +# target overrides
> +-include $(tmake_file)
> +
> +INSN-GENERATED-SPLIT-NUM ?= 0
> +insn-generated-split-num = $(shell expr $(INSN-GENERATED-SPLIT-NUM) + 1)
> +
> +insn-emit-split-c = $(foreach o, $(shell for i in {1..$(insn-generated-split-num)}; do echo $$i; done), insn-emit$(o).c)

The {a..b} construct isn't portable: this needs to be runnable with
a plain Bourne shell like /bin/dash.

I think we should use the same wordlist technique as check_p_numbers[0-6].
So I guess the first step would be to rename check_p_numbers[0-6] to
something more general and use it both here and in check_p_numbers.

Thanks,
Richard

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

* Re: [PATCH v5] genemit.c (main): split insn-emit.c for compiling parallelly
  2020-08-27 20:40 ` Segher Boessenkool
@ 2020-09-11  7:19   ` Jojo R
  0 siblings, 0 replies; 5+ messages in thread
From: Jojo R @ 2020-09-11  7:19 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: ro, richard.guenther, joseph, gcc-patches, yunhai.syh

Hi,

	Ok & Thanks,

	It’s fixed in patch v6.

Jojo
在 2020年8月28日 +0800 AM4:40,Segher Boessenkool <segher@kernel.crashing.org>,写道:
> Hi!
>
> On Thu, Aug 27, 2020 at 08:47:19PM +0800, Jojo R wrote:
> > +insn-emit-split-c = $(foreach o, $(shell for i in {1..$(insn-generated-split-num)}; do echo $$i; done), insn-emit$(o).c)
>
> If you use a variable for the result of that "seq", this will be more
> readable / maintainable / etc.
>
> (Should this use := instead of = ? What about the assignment to
> insn-generated-split-num itself?)
>
> > + long long read_count = 0;
>
> We use "int" in many other places for similar counts. 2**31 should be
> enough for anybody.
>
> > md_rtx_info info;
> > while (read_md_rtx (&info))
> > + {
> > + if (!(read_count++ % 10000))
>
> Wrong indent. "== 0" is more typical for testing if numbers are zero.
>
> > + {
> > + printf ("/* Split file into separate compilation units for parallel compilation %lld */\n\n", read_count);
>
> Please split this (at least the source line, but probably the target
> line is too long a well).
>
>
> All that are details. This does look like it fixes the problems in the
> previous versions. Thanks!
>
>
> Segher

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

* Re: [PATCH v5] genemit.c (main): split insn-emit.c for compiling parallelly
  2020-08-28  9:52 ` Richard Sandiford
@ 2020-09-11  7:20   ` Jojo R
  0 siblings, 0 replies; 5+ messages in thread
From: Jojo R @ 2020-09-11  7:20 UTC (permalink / raw)
  To: Richard Sandiford
  Cc: segher, ro, richard.guenther, joseph, gcc-patches, yunhai.syh

Hi,

	Ok & Thanks,

	It’s fixed in patch v6.

Jojo
在 2020年8月28日 +0800 PM5:52,Richard Sandiford <richard.sandiford@arm.com>,写道:
> Thanks for doing this. In addition to what Segher said:
>
> Jojo R <jiejie_rong@c-sky.com> writes:
> > gcc/ChangeLog:
> >
> > * genemit.c (main): Print 'split line'.
> > * Makefile.in (insn-emit.c): Define split count and file
> >
> > ---
> > gcc/Makefile.in | 15 +++++++++
> > gcc/genemit.c | 87 ++++++++++++++++++++++++++++---------------------
> > 2 files changed, 64 insertions(+), 38 deletions(-)
> >
> > diff --git a/gcc/Makefile.in b/gcc/Makefile.in
> > index 79e854aa938..08e4aa7ef6f 100644
> > --- a/gcc/Makefile.in
> > +++ b/gcc/Makefile.in
> > @@ -1258,6 +1258,17 @@ ANALYZER_OBJS = \
> > # We put the *-match.o and insn-*.o files first so that a parallel make
> > # will build them sooner, because they are large and otherwise tend to be
> > # the last objects to finish building.
> > +
> > +# target overrides
> > +-include $(tmake_file)
> > +
> > +INSN-GENERATED-SPLIT-NUM ?= 0
> > +insn-generated-split-num = $(shell expr $(INSN-GENERATED-SPLIT-NUM) + 1)
> > +
> > +insn-emit-split-c = $(foreach o, $(shell for i in {1..$(insn-generated-split-num)}; do echo $$i; done), insn-emit$(o).c)
>
> The {a..b} construct isn't portable: this needs to be runnable with
> a plain Bourne shell like /bin/dash.
>
> I think we should use the same wordlist technique as check_p_numbers[0-6].
> So I guess the first step would be to rename check_p_numbers[0-6] to
> something more general and use it both here and in check_p_numbers.
>
> Thanks,
> Richard

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

end of thread, other threads:[~2020-09-11  7:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-27 12:47 [PATCH v5] genemit.c (main): split insn-emit.c for compiling parallelly Jojo R
2020-08-27 20:40 ` Segher Boessenkool
2020-09-11  7:19   ` Jojo R
2020-08-28  9:52 ` Richard Sandiford
2020-09-11  7:20   ` Jojo R

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