[PATCH 4/7] RISC-V: Add support for XAndesVPackFPH extension

Ethan Y. C. Liang ycl669@andestech.com
Tue Nov 18 09:13:47 GMT 2025


Spec: https://github.com/andestech/andes-v5-isa/releases/download/ast-v5_4_0-release/AndeStar_V5_ISA_Spec_UM165-v1.5.08-20250317.pdf

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_multi_subset_supports): Add support for
	XAndesVPackFPH extension.
	(riscv_multi_subset_supports_ext): Likewise.

gas/ChangeLog:

	* doc/c-riscv.texi: Note XAndesVPackFPH as an additional ISA extension
	for Andes.
	* testsuite/gas/riscv/march-help.l: Add xandesvpackfph string.
	* testsuite/gas/riscv/x-andes-vpackfph.d: New test.
	* testsuite/gas/riscv/x-andes-vpackfph.s: New test.

include/ChangeLog:

	* opcode/riscv-opc.h: Add corresponding MATCH and MASK instruction
	opcode macros.
	* opcode/riscv.h (riscv_insn_class): Add INSN_CLASS_XANDESVPACKFPH

opcodes/ChangeLog:

	* riscv-opc.c (riscv_opcode): Add vector packed FP16 fused multiply-add
	instructions.

Signed-off-by: Ethan Y. C. Liang <ycl669@andestech.com>
---
 bfd/elfxx-riscv.c                          |  5 +++++
 gas/doc/c-riscv.texi                       |  5 +++++
 gas/testsuite/gas/riscv/march-help.l       |  1 +
 gas/testsuite/gas/riscv/x-andes-vpackfph.d | 14 ++++++++++++++
 gas/testsuite/gas/riscv/x-andes-vpackfph.s |  5 +++++
 include/opcode/riscv-opc.h                 |  8 ++++++++
 include/opcode/riscv.h                     |  1 +
 opcodes/riscv-opc.c                        |  4 ++++
 8 files changed, 43 insertions(+)
 create mode 100644 gas/testsuite/gas/riscv/x-andes-vpackfph.d
 create mode 100644 gas/testsuite/gas/riscv/x-andes-vpackfph.s

diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index c09e81c8e45..3fbc9bd8332 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1612,6 +1612,7 @@ static const struct riscv_supported_ext riscv_supported_vendor_x_ext[] =
   {"xandesbfhcvt",	ISA_SPEC_CLASS_DRAFT,	5, 0, 0 },
   {"xandesvbfhcvt",	ISA_SPEC_CLASS_DRAFT,	5, 0, 0 },
   {"xandesvsintload",	ISA_SPEC_CLASS_DRAFT,	5, 0, 0 },
+  {"xandesvpackfph",	ISA_SPEC_CLASS_DRAFT,	5, 0, 0 },
   {"xcvalu",		ISA_SPEC_CLASS_DRAFT,	1, 0, 0 },
   {"xcvbi",		ISA_SPEC_CLASS_DRAFT,	1, 0, 0 },
   {"xcvbitmanip",	ISA_SPEC_CLASS_DRAFT,   1, 0, 0 },
@@ -3004,6 +3005,8 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
       return riscv_subset_supports (rps, "xandesvbfhcvt");
     case INSN_CLASS_XANDESVSINTLOAD:
       return riscv_subset_supports (rps, "xandesvsintload");
+    case INSN_CLASS_XANDESVPACKFPH:
+      return riscv_subset_supports (rps, "xandesvpackfph");
     case INSN_CLASS_XCVALU:
       return riscv_subset_supports (rps, "xcvalu");
     case INSN_CLASS_XCVBI:
@@ -3321,6 +3324,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
       return "xandesvbfhcvt";
     case INSN_CLASS_XANDESVSINTLOAD:
       return "xandesvsintload";
+    case INSN_CLASS_XANDESVPACKFPH:
+      return "xandesvpackfph";
     case INSN_CLASS_XCVALU:
       return "xcvalu";
     case INSN_CLASS_XCVBI:
diff --git a/gas/doc/c-riscv.texi b/gas/doc/c-riscv.texi
index 7878c520d35..216ddd8a895 100644
--- a/gas/doc/c-riscv.texi
+++ b/gas/doc/c-riscv.texi
@@ -782,6 +782,11 @@ The XAndesVSIntLoad extension provides vector load instructions for INT4 data in
 
 It is documented in @url{https://github.com/andestech/andes-v5-isa/releases/download/ast-v5_4_0-release/AndeStar_V5_ISA_Spec_UM165-v1.5.08-20250317.pdf}.
 
+@item XAndesVPackFPH
+The XAndesVPackFPH extension provides vector packed FP16 fused multiply-add instructions.
+
+It is documented in @url{https://github.com/andestech/andes-v5-isa/releases/download/ast-v5_4_0-release/AndeStar_V5_ISA_Spec_UM165-v1.5.08-20250317.pdf}.
+
 @item XCvAlu
 The XCvAlu extension provides instructions for general ALU operations.
 
diff --git a/gas/testsuite/gas/riscv/march-help.l b/gas/testsuite/gas/riscv/march-help.l
index 8b907260af9..73d63828adf 100644
--- a/gas/testsuite/gas/riscv/march-help.l
+++ b/gas/testsuite/gas/riscv/march-help.l
@@ -157,6 +157,7 @@ All available -march extensions for RISC-V:
 	xandesbfhcvt                            5.0
 	xandesvbfhcvt                           5.0
 	xandesvsintload                         5.0
+	xandesvpackfph                          5.0
 	xcvalu                                  1.0
 	xcvbi                                   1.0
 	xcvbitmanip                             1.0
diff --git a/gas/testsuite/gas/riscv/x-andes-vpackfph.d b/gas/testsuite/gas/riscv/x-andes-vpackfph.d
new file mode 100644
index 00000000000..693c486048a
--- /dev/null
+++ b/gas/testsuite/gas/riscv/x-andes-vpackfph.d
@@ -0,0 +1,14 @@
+#as: -march=rv32i_xandesvpackfph
+#source: x-andes-vpackfph.s
+#objdump: -d
+
+.*:[ 	]+file format .*
+
+
+Disassembly of section .text:
+
+0+000 <target>:
+[ 	]+[0-9a-f]+:[ 	]+0a86425b[ 	]+nds\.vfpmadt\.vf[ 	]+v4,fa2,v8
+[ 	]+[0-9a-f]+:[ 	]+0886425b[ 	]+nds\.vfpmadt\.vf[ 	]+v4,fa2,v8,v0\.t
+[ 	]+[0-9a-f]+:[ 	]+0e86425b[ 	]+nds\.vfpmadb\.vf[ 	]+v4,fa2,v8
+[ 	]+[0-9a-f]+:[ 	]+0c86425b[ 	]+nds\.vfpmadb\.vf[ 	]+v4,fa2,v8,v0\.t
diff --git a/gas/testsuite/gas/riscv/x-andes-vpackfph.s b/gas/testsuite/gas/riscv/x-andes-vpackfph.s
new file mode 100644
index 00000000000..67214aee48a
--- /dev/null
+++ b/gas/testsuite/gas/riscv/x-andes-vpackfph.s
@@ -0,0 +1,5 @@
+target:
+	nds.vfpmadt.vf v4, fa2, v8
+	nds.vfpmadt.vf v4, fa2, v8, v0.t
+	nds.vfpmadb.vf v4, fa2, v8
+	nds.vfpmadb.vf v4, fa2, v8, v0.t
diff --git a/include/opcode/riscv-opc.h b/include/opcode/riscv-opc.h
index d47e5f871e1..2180b20fd63 100644
--- a/include/opcode/riscv-opc.h
+++ b/include/opcode/riscv-opc.h
@@ -2535,6 +2535,11 @@
 #define MASK_NDS_VLN8_V 0xfdf0707f
 #define MATCH_NDS_VLNU8_V 0x430405b
 #define MASK_NDS_VLNU8_V 0xfdf0707f
+/* Vendor-specific (Andes) XAndesVPackFPH instructions.  */
+#define MATCH_NDS_VFPMADT_VF 0x800405b
+#define MASK_NDS_VFPMADT_VF 0xfc00707f
+#define MATCH_NDS_VFPMADB_VF 0xc00405b
+#define MASK_NDS_VFPMADB_VF 0xfc00707f
 /* Vendor-specific (CORE-V) Xcvmac instructions.  */
 #define MATCH_CV_MAC       0x9000302b
 #define MASK_CV_MAC        0xfe00707f
@@ -4860,6 +4865,9 @@ DECLARE_INSN(nds_vfncvt_bf16_s, MATCH_NDS_VFNCVT_BF16_S, MASK_NDS_VFNCVT_BF16_S)
 /* Vendor-specific (Andes) XAndesVSIntLoad instructions.  */
 DECLARE_INSN(nds_vln8_v, MATCH_NDS_VLN8_V, MASK_NDS_VLN8_V)
 DECLARE_INSN(nds_vlnu8_v, MATCH_NDS_VLNU8_V, MASK_NDS_VLNU8_V)
+/* Vendor-specific (Andes) XAndesVPackFPH instructions.  */
+DECLARE_INSN(nds_vfpmadt_vf, MATCH_NDS_VFPMADT_VF, MASK_NDS_VFPMADT_VF)
+DECLARE_INSN(nds_vfpmadb_vf, MATCH_NDS_VFPMADB_VF, MASK_NDS_VFPMADB_VF)
 /* Vendor-specific (T-Head) XTheadBa instructions.  */
 DECLARE_INSN(th_addsl, MATCH_TH_ADDSL, MASK_TH_ADDSL)
 /* Vendor-specific (T-Head) XTheadBb instructions.  */
diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h
index 788029d4240..8308bcd8c41 100644
--- a/include/opcode/riscv.h
+++ b/include/opcode/riscv.h
@@ -577,6 +577,7 @@ enum riscv_insn_class
   INSN_CLASS_XANDESBFHCVT,
   INSN_CLASS_XANDESVBFHCVT,
   INSN_CLASS_XANDESVSINTLOAD,
+  INSN_CLASS_XANDESVPACKFPH,
   INSN_CLASS_XCVALU,
   INSN_CLASS_XCVBI,
   INSN_CLASS_XCVBITMANIP,
diff --git a/opcodes/riscv-opc.c b/opcodes/riscv-opc.c
index 0f7d8f00825..80dc2221288 100644
--- a/opcodes/riscv-opc.c
+++ b/opcodes/riscv-opc.c
@@ -2390,6 +2390,10 @@ const struct riscv_opcode riscv_opcodes[] =
 {"nds.vln8.v",  0, INSN_CLASS_XANDESVSINTLOAD, "Vd,0(s)Vm", MATCH_NDS_VLN8_V, MASK_NDS_VLN8_V, match_opcode, INSN_DREF},
 {"nds.vlnu8.v", 0, INSN_CLASS_XANDESVSINTLOAD, "Vd,0(s)Vm", MATCH_NDS_VLNU8_V, MASK_NDS_VLNU8_V, match_opcode, INSN_DREF},
 
+/* Vendor-specific (Andes) XAndesVPackFPH instructions.  */
+{"nds.vfpmadt.vf", 0, INSN_CLASS_XANDESVPACKFPH, "Vd,S,VtVm", MATCH_NDS_VFPMADT_VF, MASK_NDS_VFPMADT_VF, match_opcode, 0},
+{"nds.vfpmadb.vf", 0, INSN_CLASS_XANDESVPACKFPH, "Vd,S,VtVm", MATCH_NDS_VFPMADB_VF, MASK_NDS_VFPMADB_VF, match_opcode, 0},
+
 /* Vendor-specific (CORE-V) Xcvmac instructions.  */
 {"cv.mac",      0, INSN_CLASS_XCVMAC, "d,s,t",     MATCH_CV_MAC,      MASK_CV_MAC, match_opcode, 0},
 {"cv.msu",      0, INSN_CLASS_XCVMAC, "d,s,t",     MATCH_CV_MSU,      MASK_CV_MSU, match_opcode, 0},
-- 
2.49.0



More information about the Binutils mailing list