From patchwork Tue Dec 17 10:03:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongyan Chen X-Patchwork-Id: 103251 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0F4DE3858D33 for ; Tue, 17 Dec 2024 10:04:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F4DE3858D33 X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81]) by sourceware.org (Postfix) with ESMTPS id 7457D3858CDB for ; Tue, 17 Dec 2024 10:03:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7457D3858CDB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=isrc.iscas.ac.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7457D3858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=159.226.251.81 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734429832; cv=none; b=QTSpyAkuNfV2iY6+W6Qtj9xvkBfTtXcgTEOJAIXWqP1ti2jU/tHBMgiKYpufXoiUIretkZn+q4LcqIpeJWFKcttv0+PCHBAJowk6seZWuQIU++zkmvD4RzGWx0yPkTAR1B1fXCdmtiG14zNMTcp57phzbFI0t5Mq+HE1sA3+jDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734429832; c=relaxed/simple; bh=erjSsJy0svv4WOPyzFU17VmZXlo6RAp6K9XUwiIQ+qQ=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=TIYg91C5CahyxsvtNVZV9KgyuiFkBKGTtWLFBlpoAGvGpCGmSfhTFMd3ZApOzTBtsdijMaor/MFFs1Bq4kDgxGwsfbZ95F4+oC21l+6Pf78gKFCGggT0zc8JyM4MGV9GnP1LE6MlLvGJu/YloSJlf1sj8LALp0CQZY5Mo2LVd64= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7457D3858CDB Received: from GNU.. (unknown [8.129.0.173]) by APP-03 (Coremail) with SMTP id rQCowADHrzJ+TGFnkH9jAg--.9630S2; Tue, 17 Dec 2024 18:03:44 +0800 (CST) From: Dongyan Chen To: binutils@sourceware.org Cc: kito.cheng@gmail.com, nelson@rivosinc.com, jbeulich@suse.com, wuwei2016@iscas.ac.cn, jiawei@iscas.ac.cn, shihua@iscas.ac.cn, chenyixuan@iscas.ac.cn, shiyulong@iscas.ac.cn, cyy@cyyself.name, Dongyan Chen Subject: [PATCH] RISC-V: Add support for zilsd and zclsd extensions. Date: Tue, 17 Dec 2024 18:03:21 +0800 Message-ID: <20241217100321.890290-1-chendongyan@isrc.iscas.ac.cn> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CM-TRANSID: rQCowADHrzJ+TGFnkH9jAg--.9630S2 X-Coremail-Antispam: 1UD129KBjvJXoW3Gw13ZF43WFW7KF15AryxZrb_yoW3KFWkpF Wfuw4jkrZ5tFnrJrnakr1UWa1xJw409rnI9ryftw42krWfKrZ8Xw1kJw13AF45JF4UWw1f uay3Xry5u3WDJa7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9014x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWUuVWrJwAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Jr0_Gr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4j6r 4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCY1x0262kKe7AKxVWUtVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7x kEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E 67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCw CI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1x MIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIda VFxhVjvjDU0xZFpf9x0JUd-B_UUUUU= X-Originating-IP: [8.129.0.173] X-CM-SenderInfo: hfkh0v5rqj5tnq6l223fol2u1dvotugofq/ X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org This implements the zilsd extensons and the zclsd extensions, version1.0[1]. The code was expanded and modified based on the GitHub link[2], incorporating the following changes: 1. According to the manual specifications, zcmlsd was changed to zclsd. 2. Constraints were added for zilsd and zclsd. 3. Testsuites were included. [1] https://github.com/riscv/riscv-zilsd [2] https://github.com/nxp-auto-tools/binutils_zilsd/tree/zilsd bfd/ChangeLog: * elfxx-riscv.c (riscv_parse_check_conflicts): Added implicit rules for zclsd extensions. (riscv_multi_subset_supports): Handle zilsd and zclsd. (riscv_multi_subset_supports_ext): Ditto. gas/ChangeLog: * NEWS: Updated. * testsuite/gas/riscv/march-help.l: Ditto * testsuite/gas/riscv/march-fail-zclsd-01.d: New test. * testsuite/gas/riscv/march-fail-zclsd-01.l: New test. * testsuite/gas/riscv/march-fail-zclsd-02.d: New test. * testsuite/gas/riscv/march-fail-zclsd-02.l: New test. * testsuite/gas/riscv/march-fail-zilsd.d: New test. * testsuite/gas/riscv/march-fail-zilsd.l: New test. include/ChangeLog: * opcode/riscv.h (enum riscv_insn_class): --- bfd/elfxx-riscv.c | 36 +++++++++++++++++++ gas/NEWS | 2 ++ gas/testsuite/gas/riscv/march-fail-zclsd-01.d | 3 ++ gas/testsuite/gas/riscv/march-fail-zclsd-01.l | 2 ++ gas/testsuite/gas/riscv/march-fail-zclsd-02.d | 3 ++ gas/testsuite/gas/riscv/march-fail-zclsd-02.l | 2 ++ gas/testsuite/gas/riscv/march-fail-zilsd.d | 3 ++ gas/testsuite/gas/riscv/march-fail-zilsd.l | 2 ++ gas/testsuite/gas/riscv/march-help.l | 2 ++ include/opcode/riscv.h | 2 ++ 10 files changed, 57 insertions(+) create mode 100644 gas/testsuite/gas/riscv/march-fail-zclsd-01.d create mode 100644 gas/testsuite/gas/riscv/march-fail-zclsd-01.l create mode 100644 gas/testsuite/gas/riscv/march-fail-zclsd-02.d create mode 100644 gas/testsuite/gas/riscv/march-fail-zclsd-02.l create mode 100644 gas/testsuite/gas/riscv/march-fail-zilsd.d create mode 100644 gas/testsuite/gas/riscv/march-fail-zilsd.l diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index a6511f6558d..36081bbfc04 100644 --- a/bfd/elfxx-riscv.c +++ b/bfd/elfxx-riscv.c @@ -1221,6 +1221,9 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] = {"zcmop", "+zca", check_implicit_always}, {"zcmt", "+zca,+zicsr", check_implicit_always}, + {"zclsd", "+zca,+zilsd", check_implicit_always}, + {"zilsd", "+zicsr", check_implicit_always}, + {"shcounterenw", "+h", check_implicit_always}, {"shgatpa", "+h", check_implicit_always}, {"shtvala", "+h", check_implicit_always}, @@ -1354,6 +1357,8 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] = {"zihintpause", ISA_SPEC_CLASS_DRAFT, 2, 0, 0 }, {"zihpm", ISA_SPEC_CLASS_DRAFT, 2, 0, 0 }, {"zimop", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, + {"zilsd", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, + {"zclsd", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, {"zmmul", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, {"za64rs", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, {"za128rs", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, @@ -2108,6 +2113,29 @@ riscv_parse_check_conflicts (riscv_parse_subset_t *rps) (_("`zfinx' is conflict with the `f/d/q/zfh/zfhmin' extension")); no_conflict = false; } + if (riscv_lookup_subset (rps->subset_list, "zilsd", &subset) + && xlen > 32) + { + rps->error_handler + (_("rv%d does not support the `zilsd' extension"), xlen); + no_conflict = false; + } + if (riscv_lookup_subset (rps->subset_list, "zclsd", &subset) + && xlen > 32) + { + rps->error_handler + (_("rv%d does not support the `zclsd' extension"), xlen); + no_conflict = false; + } + if (riscv_lookup_subset (rps->subset_list, "zclsd", &subset) + && ((riscv_lookup_subset (rps->subset_list, "c", &subset) + && riscv_lookup_subset (rps->subset_list, "f", &subset)) + || riscv_lookup_subset (rps->subset_list, "zcf", &subset))) + { + rps->error_handler + (_("`zclsd' is conflict with the `c+f'/ `zcf' extension")); + no_conflict = false; + } if (riscv_lookup_subset (rps->subset_list, "xtheadvector", &subset) && riscv_lookup_subset (rps->subset_list, "v", &subset)) { @@ -2736,6 +2764,10 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps, return riscv_subset_supports (rps, "zcmp"); case INSN_CLASS_ZCMT: return riscv_subset_supports (rps, "zcmt"); + case INSN_CLASS_ZILSD: + return riscv_subset_supports (rps, "zilsd"); + case INSN_CLASS_ZCLSD: + return riscv_subset_supports (rps, "zclsd"); case INSN_CLASS_SVINVAL: return riscv_subset_supports (rps, "svinval"); case INSN_CLASS_H: @@ -3026,6 +3058,10 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps, return "zcmp"; case INSN_CLASS_ZCMT: return "zcmt"; + case INSN_CLASS_ZILSD: + return "zilsd"; + case INSN_CLASS_ZCLSD: + return "zclsd"; case INSN_CLASS_SVINVAL: return "svinval"; case INSN_CLASS_H: diff --git a/gas/NEWS b/gas/NEWS index 269b63e2056..92b535c391f 100644 --- a/gas/NEWS +++ b/gas/NEWS @@ -13,6 +13,8 @@ CORE-V (xcvbitmanip, xcvsimd) extensions with version 1.0 and more SiFive extensions (xsfvqmaccdod, xsfvqmaccqoq and xsfvfnrclipxfqf). + Add support for RISC-V z[i/c]lsd extension, version 1.0. + Changes in 2.43: * Add support for LoongArch .option for fine-grained control of assembly diff --git a/gas/testsuite/gas/riscv/march-fail-zclsd-01.d b/gas/testsuite/gas/riscv/march-fail-zclsd-01.d new file mode 100644 index 00000000000..a98b1f03bbf --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-zclsd-01.d @@ -0,0 +1,3 @@ +#as: -march=rv64i_zca_zclsd +#source: empty.s +#error_output: march-fail-zclsd-01.l diff --git a/gas/testsuite/gas/riscv/march-fail-zclsd-01.l b/gas/testsuite/gas/riscv/march-fail-zclsd-01.l new file mode 100644 index 00000000000..0af9281f284 --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-zclsd-01.l @@ -0,0 +1,2 @@ +.*Assembler messages: +.*Error: .*rv64 does not support the `zclsd' extension diff --git a/gas/testsuite/gas/riscv/march-fail-zclsd-02.d b/gas/testsuite/gas/riscv/march-fail-zclsd-02.d new file mode 100644 index 00000000000..6d8d19e6093 --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-zclsd-02.d @@ -0,0 +1,3 @@ +#as: -march=rv32i_zcf_zclsd +#source: empty.s +#error_output: march-fail-zclsd-02.l diff --git a/gas/testsuite/gas/riscv/march-fail-zclsd-02.l b/gas/testsuite/gas/riscv/march-fail-zclsd-02.l new file mode 100644 index 00000000000..68812c7d3dc --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-zclsd-02.l @@ -0,0 +1,2 @@ +.*Assembler messages: +.*Error: .*`zclsd' is conflict with the `c+f'/ `zcf' extension diff --git a/gas/testsuite/gas/riscv/march-fail-zilsd.d b/gas/testsuite/gas/riscv/march-fail-zilsd.d new file mode 100644 index 00000000000..951ae6324d4 --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-zilsd.d @@ -0,0 +1,3 @@ +#as: -march=rv64i_zilsd +#source: empty.s +#error_output: march-fail-zilsd.l diff --git a/gas/testsuite/gas/riscv/march-fail-zilsd.l b/gas/testsuite/gas/riscv/march-fail-zilsd.l new file mode 100644 index 00000000000..e40a89bdc07 --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-zilsd.l @@ -0,0 +1,2 @@ +.*Assembler messages: +.*Error: .*rv64 does not support the `zilsd' extension diff --git a/gas/testsuite/gas/riscv/march-help.l b/gas/testsuite/gas/riscv/march-help.l index fd1174059e5..7fa95d171d2 100644 --- a/gas/testsuite/gas/riscv/march-help.l +++ b/gas/testsuite/gas/riscv/march-help.l @@ -26,6 +26,8 @@ All available -march extensions for RISC-V: zihintpause 2.0 zihpm 2.0 zimop 1.0 + zilsd 1.0 + zclsd 1.0 zmmul 1.0 za64rs 1.0 za128rs 1.0 diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h index fedfdd24468..39043601cc0 100644 --- a/include/opcode/riscv.h +++ b/include/opcode/riscv.h @@ -522,6 +522,8 @@ enum riscv_insn_class INSN_CLASS_ZCMOP, INSN_CLASS_ZCMP, INSN_CLASS_ZCMT, + INSN_CLASS_ZILSD, + INSN_CLASS_ZCLSD, INSN_CLASS_SVINVAL, INSN_CLASS_ZICBOM, INSN_CLASS_ZICBOP,