public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] RISC-V: Add support for zilsd and zclsd extensions.
@ 2025-02-03  7:31 chendongyan
  0 siblings, 0 replies; only message in thread
From: chendongyan @ 2025-02-03  7:31 UTC (permalink / raw)
  To: binutils
  Cc: kito.cheng, nelson, Jan Beulich, wuwei2016, jiawei, shihua,
	chenyixuan, shiyulong, cyy, Dongyan Chen

[-- Attachment #1: Type: text/plain, Size: 9021 bytes --]

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,
--
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-02-03  7:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-03  7:31 [PATCH v2] RISC-V: Add support for zilsd and zclsd extensions chendongyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).