From patchwork Mon Sep 8 01:09:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhongyao Chen X-Patchwork-Id: 119707 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 9DAEB3858C42 for ; Mon, 8 Sep 2025 02:01:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9DAEB3858C42 X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by sourceware.org (Postfix) with ESMTPS id C39123858D1E for ; Mon, 8 Sep 2025 02:00:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C39123858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=zte.com.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zte.com.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C39123858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=183.62.165.209 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757296856; cv=none; b=iYm38VWTWddDkxhqg72QFsGb+EGbUJuS+gBaQVDd0SG0O7oI8Vt8DOVnUcqnSZrfkJS1VVPdcvxKcvfCHPXUyTKvu0M7xGvMNErtZYqkukP9rtjDlRxGK9afeOYmhaAPFokKhL5DgO0ptNXLCcezWZfw2aoPnlJ4mlFroDOnDAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757296856; c=relaxed/simple; bh=+gREuMbOb1Z7DH4WI3tGUHDTwS1t5DqP12ExBDgoJYg=; h=Message-Id:Date:Mime-Version:From:To:Subject; b=qoy4wH4u87ozX2RsLyCwLPYgzK0u/+/4VhpLqpBBS8MotW9n8XM7XZtWYQApFXblZXgCSe8AhAGSCPeaA9eHEgllRsjnbDd9+ehK0QHIFY8zJ+L3cDAuwlfg8Hw5dfJP7TrtW63ntiud/hjCXJvDAh3ODO1YucDI279EfHAACbo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C39123858D1E Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mxct.zte.com.cn (FangMail) with ESMTPS id 4cKqtC28yQz59ys8; Mon, 08 Sep 2025 10:00:51 +0800 (CST) Received: (from root@localhost) by mse-fl2.zte.com.cn id 58820pV5021876; Mon, 8 Sep 2025 10:00:51 +0800 (+08) (envelope-from chen.zhongyao@zte.com.cn) Message-Id: <202509080200.58820pV5021876@mse-fl2.zte.com.cn> Received: from szxl2zmapp07.zte.com.cn ([10.1.32.52]) by mse-fl2.zte.com.cn with SMTP id 58819AXN033517; Mon, 8 Sep 2025 09:09:10 +0800 (+08) (envelope-from chen.zhongyao@zte.com.cn) Received: from mapi (szxlzmapp04[null]) by mapi (Zmail) with MAPI id mid18; Mon, 8 Sep 2025 09:09:11 +0800 (CST) Date: Mon, 8 Sep 2025 09:09:11 +0800 (CST) X-Zmail-TransId: 2b0668be2cb75a1-344d7 X-Mailer: Zmail v1.0 Mime-Version: 1.0 From: To: Cc: , Subject: =?utf-8?q?=5BPATCH=5D_RISC-V=3A_Add_experimental_support_for_Zvabd_?= =?utf-8?q?extension?= X-MAIL: mse-fl2.zte.com.cn 58820pV5021876 X-MSS: AUDITRELEASE@mse-fl2.zte.com.cn X-TLS: YES X-SPF-DOMAIN: zte.com.cn X-ENVELOPE-SENDER: chen.zhongyao@zte.com.cn X-SPF: None X-SOURCE-IP: 10.5.228.133 unknown Mon, 08 Sep 2025 10:00:51 +0800 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 68BE38D3.002/4cKqtC28yQz59ys8 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, MSGID_FROM_MTA_HEADER, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE, SPF_PASS, TXREP, UNPARSEABLE_RELAY 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 From 621ed351372b8f20c8fade8cab89734f17a9dc72 Mon Sep 17 00:00:00 2001 From: Zhongyao Chen Date: Sun, 7 Sep 2025 04:35:51 +0000 Subject: [PATCH] RISC-V: Add experimental support for Zvabd extension This patch adds experimental support for the RISC-V Zvabd (Vector Absolute Difference) extension, based on version 0.5 of the proposal. The Zvabd instruction set specification can be found in the fast-track proposal: https://lf-riscv.atlassian.net/wiki/spaces/VXXX/pages/166690866/Fast-Track+Proposal+for+integer+vector+absolute+difference+instructions Note: This patch is just an initial prototype, mainly for early evaluation (e.g. on FPGA) and to support fast-track proposal progress; it is not meant for merging yet. Co-authored-by: Yuke Tang Signed-off-by: Zhongyao Chen --- bfd/elfxx-riscv.c | 6 ++++++ include/opcode/riscv-opc.h | 12 ++++++++++++ include/opcode/riscv.h | 1 + opcodes/riscv-opc.c | 7 +++++++ 4 files changed, 26 insertions(+) -- 2.50.1 diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index 9163712967d..9fbd772260b 100644 --- a/bfd/elfxx-riscv.c +++ b/bfd/elfxx-riscv.c @@ -1302,6 +1302,7 @@ static const struct riscv_implicit_subset riscv_implicit_subsets[] = {"zvksg", "+zvks,+zvkg", check_implicit_always}, {"zvksc", "+zvks,+zvbc", check_implicit_always}, {"zvks", "+zvksed,+zvksh,+zvkb,+zvkt", check_implicit_always}, + {"zvabd", "+zvabd", check_implicit_always}, {"smaia", "+ssaia", check_implicit_always}, {"smcdeleg", "+ssccfg", check_implicit_always}, @@ -1546,6 +1547,7 @@ static const struct riscv_supported_ext riscv_supported_std_z_ext[] = {"zcmop", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, {"zcmp", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, {"zcmt", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, + {"zvabd", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, {"zclsd", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, {NULL, 0, 0, 0, 0} }; @@ -2977,6 +2979,8 @@ 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_ZVABD: + return riscv_subset_supports (rps, "zvabd"); case INSN_CLASS_SMCTR_OR_SSCTR: return (riscv_subset_supports (rps, "smctr") || riscv_subset_supports (rps, "ssctr")); @@ -3280,6 +3284,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps, return "zcmp"; case INSN_CLASS_ZCMT: return "zcmt"; + case INSN_CLASS_ZVABD: + return "zvabd"; case INSN_CLASS_SMCTR_OR_SSCTR: return _("smctr' or `ssctr"); case INSN_CLASS_ZILSD: diff --git a/include/opcode/riscv-opc.h b/include/opcode/riscv-opc.h index 1c649628390..20685ca6eff 100644 --- a/include/opcode/riscv-opc.h +++ b/include/opcode/riscv-opc.h @@ -1867,6 +1867,18 @@ #define MASK_VNCLIPWX 0xfc00707f #define MATCH_VNCLIPWI 0xbc003057 #define MASK_VNCLIPWI 0xfc00707f +//abs +#define MATCH_VABS 0x48082057 +#define MASK_VABS 0xfc0ff07f +#define MATCH_VABD 0x44002057 +#define MASK_VABD 0xfc00707f +#define MATCH_VABDU 0x4c002057 +#define MASK_VABD 0xfc00707f +#define MATCH_VWABDACC 0x54002057 +#define MASK_VWABDACC 0xfc00707f +#define MATCH_VWABDACCU 0x58002057 +#define MASK_VWABDACC 0xfc00707f + #define MATCH_VFADDVV 0x00001057 #define MASK_VFADDVV 0xfc00707f #define MATCH_VFADDVF 0x00005057 diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h index 858fcce6871..8007bf09973 100644 --- a/include/opcode/riscv.h +++ b/include/opcode/riscv.h @@ -573,6 +573,7 @@ enum riscv_insn_class INSN_CLASS_ZABHA, INSN_CLASS_ZACAS, INSN_CLASS_ZABHA_AND_ZACAS, + INSN_CLASS_ZVABD, INSN_CLASS_H, INSN_CLASS_XCVALU, INSN_CLASS_XCVBI, diff --git a/opcodes/riscv-opc.c b/opcodes/riscv-opc.c index e6fe5e9afba..19dd1c512e0 100644 --- a/opcodes/riscv-opc.c +++ b/opcodes/riscv-opc.c @@ -2024,6 +2024,13 @@ const struct riscv_opcode riscv_opcodes[] = {"vnclip.wx", 0, INSN_CLASS_V, "Vd,Vt,sVm", MATCH_VNCLIPWX, MASK_VNCLIPWX, match_opcode, 0 }, {"vnclip.wi", 0, INSN_CLASS_V, "Vd,Vt,VjVm", MATCH_VNCLIPWI, MASK_VNCLIPWI, match_opcode, 0 }, +/*zvabd instructions.*/ +{"vabs.v", 0, INSN_CLASS_ZVABD, "Vd,VtVm", MATCH_VABS, MASK_VABS, match_opcode, 0 }, +{"vabd.vv", 0, INSN_CLASS_ZVABD, "Vd,Vt,VsVm", MATCH_VABD, MASK_VABD, match_opcode, 0 }, +{"vabdu.vv", 0, INSN_CLASS_ZVABD, "Vd,Vt,VsVm", MATCH_VABDU, MASK_VABD, match_opcode, 0 }, +{"vwabdacc.vv", 0, INSN_CLASS_ZVABD, "Vd,Vt,VsVm", MATCH_VWABDACC, MASK_VWABDACC, match_opcode, 0 }, +{"vwabdaccu.vv", 0, INSN_CLASS_ZVABD, "Vd,Vt,VsVm", MATCH_VWABDACCU, MASK_VWABDACC, match_opcode, 0 }, + {"vfadd.vv", 0, INSN_CLASS_ZVEF, "Vd,Vt,VsVm", MATCH_VFADDVV, MASK_VFADDVV, match_opcode, 0}, {"vfadd.vf", 0, INSN_CLASS_ZVEF, "Vd,Vt,SVm", MATCH_VFADDVF, MASK_VFADDVF, match_opcode, 0}, {"vfsub.vv", 0, INSN_CLASS_ZVEF, "Vd,Vt,VsVm", MATCH_VFSUBVV, MASK_VFSUBVV, match_opcode, 0},