[PATCH v9] genemit.c (main): split insn-emit.c for compiling parallelly

Richard Sandiford richard.sandiford@arm.com
Fri Nov 6 10:12:06 GMT 2020


Sorry, going it over it again before committing, I spotted a couple
of things…

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 |  35 +++++++++++-----
>  gcc/genemit.c   | 104 +++++++++++++++++++++++++++++-------------------
>  2 files changed, 90 insertions(+), 49 deletions(-)
>
> diff --git a/gcc/Makefile.in b/gcc/Makefile.in
> index 978a08f7b04..de846c0fcd4 100644
> --- a/gcc/Makefile.in
> +++ b/gcc/Makefile.in
> @@ -1154,6 +1154,15 @@ export STRIP_FOR_TARGET
>  export RANLIB_FOR_TARGET
>  export libsubdir
>  
> +number_series0:=1 2 3 4 5 6 7 8 9
> +number_series1:=0 $(number_series0)
> +number_series2:=$(foreach i,$(number_series0),$(addprefix $(i),$(number_series1)))
> +number_series3:=$(addprefix 0,$(number_series1)) $(number_series2)
> +number_series4:=$(foreach i,$(number_series0),$(addprefix $(i),$(number_series3)))
> +number_series5:=$(addprefix 0,$(number_series3)) $(number_series4)
> +number_series6:=$(foreach i,$(number_series0),$(addprefix $(i),$(number_series5)))
> +number_series:=$(number_series0) $(number_series2) $(number_series4) $(number_series6)
> +
>  FLAGS_TO_PASS = \
>  	"ADA_CFLAGS=$(ADA_CFLAGS)" \
>  	"BISON=$(BISON)" \
> @@ -1259,6 +1268,18 @@ 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 = $(wordlist 1,$(shell expr $(INSN-GENERATED-SPLIT-NUM) + 1),$(number_series))

I think it would be better to make SPLIT-NUM 1-based rather than
0-based and not have the shell expr.

> +
> +insn-emit-split-c := $(foreach o, $(insn-generated-split-num), 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 \
> @@ -1266,6 +1287,7 @@ OBJS = \
>  	insn-automata.o \
>  	insn-dfatab.o \
>  	insn-emit.o \
> +	$(insn-emit-split-obj) \
>  	insn-extract.o \
>  	insn-latencytab.o \
>  	insn-modes.o \
> @@ -2376,6 +2398,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 $(insn-generated-split-num); do touch insn-$*$$i.c; done && echo "" > insn-$*.c)

This still uses bashisms.  Also, I don't think we can require csplit.

genemit itself is quite fast, so it would probably be simpler to run
it multiple times, passing a new command-line parameter to say which
output file we want.

In other words, rather than generate a monolithic insn-emit.c and
then split it later, we should just generate the separate insn-emit.cs
directly.

Thanks,
Richard


More information about the Gcc-patches mailing list