From patchwork Fri Oct 30 09:42:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jojo R X-Patchwork-Id: 1390918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=c-sky.com Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CMy780jMxz9sTD for ; Fri, 30 Oct 2020 20:43:46 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 337953851C27; Fri, 30 Oct 2020 09:43:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp2200-217.mail.aliyun.com (smtp2200-217.mail.aliyun.com [121.197.200.217]) by sourceware.org (Postfix) with ESMTPS id 3BA6D3857822 for ; Fri, 30 Oct 2020 09:43:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3BA6D3857822 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=c-sky.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=jiejie_rong@c-sky.com X-Alimail-AntiSpam: AC=CONTINUE; BC=0.03712972|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_system_inform|0.00168916-0.000122717-0.998188; FP=0|0|0|0|0|-1|-1|-1; HT=ay29a033018047198; MF=jiejie_rong@c-sky.com; NM=1; PH=DS; RN=8; RT=8; SR=0; TI=SMTPD_---.IqSifa6_1604051014; Received: from localhost.localdomain(mailfrom:jiejie_rong@c-sky.com fp:SMTPD_---.IqSifa6_1604051014) by smtp.aliyun-inc.com(10.194.99.21); Fri, 30 Oct 2020 17:43:34 +0800 From: Jojo R To: jiejie_rong@c-sky.com, segher@kernel.crashing.org, richard.sandiford@arm.com, ro@CeBiTec.Uni-Bielefeld.DE, richard.guenther@gmail.com, joseph@codesourcery.com, gcc-patches@gcc.gnu.org, yunhai.syh@alibaba-inc.com Subject: [PATCH v8] genemit.c (main): split insn-emit.c for compiling parallelly Date: Fri, 30 Oct 2020 17:42:53 +0800 Message-Id: <20201030094253.61184-1-jiejie_rong@c-sky.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" gcc/ChangeLog: * genemit.c (main): Print 'split line'. * Makefile.in (insn-emit.c): Define split count and file --- gcc/Makefile.in | 33 +++++++++++---- gcc/genemit.c | 104 +++++++++++++++++++++++++++++------------------- 2 files changed, 89 insertions(+), 48 deletions(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 7fc03c8d946..974b65c560d 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1154,6 +1154,15 @@ export STRIP_FOR_TARGET export RANLIB_FOR_TARGET export libsubdir +check_p_numbers0:=1 2 3 4 5 6 7 8 9 +check_p_numbers1:=0 $(check_p_numbers0) +check_p_numbers2:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers1))) +check_p_numbers3:=$(addprefix 0,$(check_p_numbers1)) $(check_p_numbers2) +check_p_numbers4:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers3))) +check_p_numbers5:=$(addprefix 0,$(check_p_numbers3)) $(check_p_numbers4) +check_p_numbers6:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers5))) +check_p_numbers:=$(check_p_numbers0) $(check_p_numbers2) $(check_p_numbers4) $(check_p_numbers6) + 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),$(check_p_numbers)) + +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 \ @@ -2375,6 +2397,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) $(STAMP) s-$* # gencheck doesn't read the machine description, and the file produced @@ -4094,14 +4119,6 @@ $(patsubst %,%-subtargets,$(lang_checks)): check-%-subtargets: check_p_tool=$(firstword $(subst _, ,$*)) check_p_count=$(check_$(check_p_tool)_parallelize) check_p_subno=$(word 2,$(subst _, ,$*)) -check_p_numbers0:=1 2 3 4 5 6 7 8 9 -check_p_numbers1:=0 $(check_p_numbers0) -check_p_numbers2:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers1))) -check_p_numbers3:=$(addprefix 0,$(check_p_numbers1)) $(check_p_numbers2) -check_p_numbers4:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers3))) -check_p_numbers5:=$(addprefix 0,$(check_p_numbers3)) $(check_p_numbers4) -check_p_numbers6:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers5))) -check_p_numbers:=$(check_p_numbers0) $(check_p_numbers2) $(check_p_numbers4) $(check_p_numbers6) check_p_subdir=$(subst _,,$*) check_p_subdirs=$(wordlist 1,$(check_p_count),$(wordlist 1, \ $(if $(GCC_TEST_PARALLEL_SLOTS),$(GCC_TEST_PARALLEL_SLOTS),128), \ diff --git a/gcc/genemit.c b/gcc/genemit.c index 84d07d388ee..54a0d909d9d 100644 --- a/gcc/genemit.c +++ b/gcc/genemit.c @@ -847,24 +847,13 @@ handle_overloaded_gen (overloaded_name *oname) } } -int -main (int argc, const char **argv) -{ - progname = "genemit"; - - if (!init_rtx_reader_args (argc, argv)) - return (FATAL_EXIT_CODE); - -#define DEF_INTERNAL_OPTAB_FN(NAME, FLAGS, OPTAB, TYPE) \ - nofail_optabs[OPTAB##_optab] = true; -#include "internal-fn.def" - - /* 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"); +/* Print include header. */ +static void +printf_include (void) +{ + 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"); @@ -900,35 +889,70 @@ from the machine description file `md'. */\n\n"); printf ("#include \"tm-constrs.h\"\n"); printf ("#include \"ggc.h\"\n"); printf ("#include \"target.h\"\n\n"); +} - /* Read the machine description. */ +/* Generate the `gen_...' function from GET_CODE(). */ - md_rtx_info info; - while (read_md_rtx (&info)) - switch (GET_CODE (info.def)) - { - case DEFINE_INSN: - gen_insn (&info); - break; +static void +gen_md_rtx (md_rtx_info *info) +{ + switch (GET_CODE (info->def)) + { + case DEFINE_INSN: + gen_insn (info); + break; - case DEFINE_EXPAND: - printf ("/* %s:%d */\n", info.loc.filename, info.loc.lineno); - gen_expand (&info); - break; + case DEFINE_EXPAND: + printf ("/* %s:%d */\n", info->loc.filename, info->loc.lineno); + gen_expand (info); + break; - case DEFINE_SPLIT: - printf ("/* %s:%d */\n", info.loc.filename, info.loc.lineno); - gen_split (&info); - break; + case DEFINE_SPLIT: + printf ("/* %s:%d */\n", info->loc.filename, info->loc.lineno); + gen_split (info); + break; - case DEFINE_PEEPHOLE2: - printf ("/* %s:%d */\n", info.loc.filename, info.loc.lineno); - gen_split (&info); - break; + case DEFINE_PEEPHOLE2: + printf ("/* %s:%d */\n", info->loc.filename, info->loc.lineno); + gen_split (info); + break; - default: - break; - } + default: + break; + } +} + +int +main (int argc, const char **argv) +{ + progname = "genemit"; + + if (!init_rtx_reader_args (argc, argv)) + return (FATAL_EXIT_CODE); + +#define DEF_INTERNAL_OPTAB_FN(NAME, FLAGS, OPTAB, TYPE) \ + nofail_optabs[OPTAB##_optab] = true; +#include "internal-fn.def" + + /* Assign sequential codes to all entries in the machine description + in parallel with the tables in insn-output.c. */ + + int read_count = 0; + + /* Read the machine description. */ + + md_rtx_info info; + while (read_md_rtx (&info)) + { + if ((read_count++ % 10000) == 0) + { + printf ("/* Split file into separate compilation units " + "for parallel compilation %d */\n\n", read_count); + printf_include(); + } + + gen_md_rtx (&info); + } /* Write out the routines to add CLOBBERs to a pattern and say whether they clobber a hard reg. */