From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from cstnet.cn (smtp80.cstnet.cn [159.226.251.80]) by sourceware.org (Postfix) with ESMTP id 5AAA43858D39 for ; Thu, 6 Apr 2023 06:22:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5AAA43858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from localhost.localdomain (unknown [47.113.87.88]) by APP-01 (Coremail) with SMTP id qwCowAC3v3vrZC5keSobAA--.1590S3; Thu, 06 Apr 2023 14:21:33 +0800 (CST) From: Jiawei To: gcc-patches@gcc.gnu.org Cc: kito.cheng@sifive.com, palmer@dabbelt.com, christoph.muellner@vrull.eu, jeremy.bennett@embecosm.com, mary.bennett@embecosm.com, nandni.jamnadas@embecosm.com, charlie.keaney@embecosm.com, simon.cook@embecosm.com, tariq.kurd@codasip.com, ibrahim.abu.kharmeh1@huawei.com, sinan.lin@linux.alibaba.com, wuwei2016@iscas.ac.cn, shihua@iscas.ac.cn, shiyulong@iscas.ac.cn, chenyixuan@iscas.ac.cn, Jiawei Subject: [PATCH 1/5] RISC-V: Minimal support for ZC extensions. Date: Thu, 6 Apr 2023 14:21:14 +0800 Message-Id: <20230406062118.47431-2-jiawei@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230406062118.47431-1-jiawei@iscas.ac.cn> References: <20230406062118.47431-1-jiawei@iscas.ac.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:qwCowAC3v3vrZC5keSobAA--.1590S3 X-Coremail-Antispam: 1UD129KBjvJXoWxuw4UZF4DKFWxGr1DGF15Jwb_yoW7CF4fpF s5Ca90v3yrWF43Wa1ftry8G34Ykw1Fgwn3JF4rZr47AayDA3yrA3Z09343ur1kXF4FvrnF y3WUW34j9w4UWFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPv14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCY02Avz4vE174l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2Iq xVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r 4a6rW5MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY 6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67 AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuY vjTRChF4DUUUU X-Originating-IP: [47.113.87.88] X-CM-SenderInfo: 5mld4v3l6l2u1dvotugofq/1tbiCggNAGQuGjjM8wABsZ X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This patch is the minimal support for ZC* extensions, include the extension name, mask and target defination. Also define the dependencies with Zca and Zce extension. Notes that all ZC* extensions depend on the Zca extension. Zce includes all relevant ZC* extensions for microcontrollers using. Zce will imply zcf when 'f' extension enabled in rv32. Co-Authored by: Charlie Keaney Co-Authored by: Mary Bennett Co-Authored by: Nandni Jamnadas Co-Authored by: Simon Cook Co-Authored by: Sinan Lin Co-Authored by: Shihua Liao Co-Authored by: Yulong Shi gcc/ChangeLog: * common/config/riscv/riscv-common.cc (riscv_subset_list::parse): New extensions. * config/riscv/riscv-opts.h (MASK_ZCA): New mask. (MASK_ZCB): Ditto. (MASK_ZCE): Ditto. (MASK_ZCF): Ditto. (MASK_ZCD): Ditto. (MASK_ZCMP): Ditto. (MASK_ZCMT): Ditto. (TARGET_ZCA): New target. (TARGET_ZCB): Ditto. (TARGET_ZCE): Ditto. (TARGET_ZCF): Ditto. (TARGET_ZCD): Ditto. (TARGET_ZCMP): Ditto. (TARGET_ZCMT): Ditto. * config/riscv/riscv.opt: New target variable. --- gcc/common/config/riscv/riscv-common.cc | 39 +++++++++++++++++++++++++ gcc/config/riscv/riscv-opts.h | 16 ++++++++++ gcc/config/riscv/riscv.opt | 3 ++ 3 files changed, 58 insertions(+) diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 2fc0f8bffc1..933c54edded 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -108,6 +108,16 @@ static const riscv_implied_info_t riscv_implied_info[] = {"zhinx", "zhinxmin"}, {"zhinxmin", "zfinx"}, + {"zce", "zca"}, + {"zce", "zcb"}, + {"zce", "zcmp"}, + {"zce", "zcmt"}, + {"zcf", "zca"}, + {"zcd", "zca"}, + {"zcb", "zca"}, + {"zcmp", "zca"}, + {"zcmt", "zca"}, + {NULL, NULL} }; @@ -219,6 +229,14 @@ static const struct riscv_ext_version riscv_ext_version_table[] = {"zmmul", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zca", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zcb", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zce", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zcf", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zcd", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zcmp", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zcmt", ISA_SPEC_CLASS_NONE, 1, 0}, + {"svinval", ISA_SPEC_CLASS_NONE, 1, 0}, {"svnapot", ISA_SPEC_CLASS_NONE, 1, 0}, @@ -1151,14 +1169,26 @@ riscv_subset_list::parse (const char *arch, location_t loc) subset_list->handle_implied_ext (itr); } + /* Zce only imply zcf when 'f' extension exist. */ + if (subset_list->lookup ("zce") != NULL + && subset_list->lookup ("f") != NULL + && subset_list->lookup ("zcf") == NULL) + subset_list->add ("zcf", false); + subset_list->handle_combine_ext (); + if (subset_list->lookup ("zcf") && subset_list->m_xlen == 64) + error_at (loc, "%<-march=%s%>: zcf extension supports in rv32 only" + , arch); + if (subset_list->lookup ("zfinx") && subset_list->lookup ("f")) error_at (loc, "%<-march=%s%>: z*inx conflicts with floating-point " "extensions", arch); return subset_list; + + fail: delete subset_list; return NULL; @@ -1262,6 +1292,15 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] = {"zmmul", &gcc_options::x_riscv_zm_subext, MASK_ZMMUL}, + /* Code-size reduction extensions. */ + {"zca", &gcc_options::x_riscv_zc_subext, MASK_ZCA}, + {"zcb", &gcc_options::x_riscv_zc_subext, MASK_ZCB}, + {"zce", &gcc_options::x_riscv_zc_subext, MASK_ZCE}, + {"zcf", &gcc_options::x_riscv_zc_subext, MASK_ZCF}, + {"zcd", &gcc_options::x_riscv_zc_subext, MASK_ZCD}, + {"zcmp", &gcc_options::x_riscv_zc_subext, MASK_ZCMP}, + {"zcmt", &gcc_options::x_riscv_zc_subext, MASK_ZCMT}, + {"svinval", &gcc_options::x_riscv_sv_subext, MASK_SVINVAL}, {"svnapot", &gcc_options::x_riscv_sv_subext, MASK_SVNAPOT}, diff --git a/gcc/config/riscv/riscv-opts.h b/gcc/config/riscv/riscv-opts.h index cf0cd669be4..101d87d38b1 100644 --- a/gcc/config/riscv/riscv-opts.h +++ b/gcc/config/riscv/riscv-opts.h @@ -175,6 +175,22 @@ enum stack_protector_guard { #define MASK_ZMMUL (1 << 0) #define TARGET_ZMMUL ((riscv_zm_subext & MASK_ZMMUL) != 0) +#define MASK_ZCA (1 << 0) +#define MASK_ZCB (1 << 1) +#define MASK_ZCE (1 << 2) +#define MASK_ZCF (1 << 3) +#define MASK_ZCD (1 << 4) +#define MASK_ZCMP (1 << 5) +#define MASK_ZCMT (1 << 6) + +#define TARGET_ZCA ((riscv_zc_subext & MASK_ZCA) != 0) +#define TARGET_ZCB ((riscv_zc_subext & MASK_ZCB) != 0) +#define TARGET_ZCE ((riscv_zc_subext & MASK_ZCE) != 0) +#define TARGET_ZCF ((riscv_zc_subext & MASK_ZCF) != 0) +#define TARGET_ZCD ((riscv_zc_subext & MASK_ZCD) != 0) +#define TARGET_ZCMP ((riscv_zc_subext & MASK_ZCMP) != 0) +#define TARGET_ZCMT ((riscv_zc_subext & MASK_ZCMT) != 0) + #define MASK_SVINVAL (1 << 0) #define MASK_SVNAPOT (1 << 1) diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt index ff1dd4ddd4f..60c07b3b614 100644 --- a/gcc/config/riscv/riscv.opt +++ b/gcc/config/riscv/riscv.opt @@ -232,6 +232,9 @@ int riscv_zf_subext TargetVariable int riscv_zm_subext +TargetVariable +int riscv_zc_subext + TargetVariable int riscv_sv_subext -- 2.25.1