[llvm] [RISCV] Report error if Zilsd is used on RV32. (PR #136577)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 21 09:30:05 PDT 2025


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/136577

Fixes #136564.

>From 15e848a5a8600ae6743304bd65d2b49cf09f95c7 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Mon, 21 Apr 2025 09:28:37 -0700
Subject: [PATCH] [RISCV] Report error if Zilsd is used on RV32.

Fixes #136564.
---
 llvm/lib/TargetParser/RISCVISAInfo.cpp           |  3 +++
 llvm/unittests/TargetParser/RISCVISAInfoTest.cpp | 10 ++++++++++
 2 files changed, 13 insertions(+)

diff --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index 524d6dc01e8aa..1e7144ce6d22b 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -789,6 +789,9 @@ Error RISCVISAInfo::checkDependency() {
       return getIncompatibleError("zclsd", "zcf");
   }
 
+  if (XLen != 32 && Exts.count("zilsd") != 0)
+    return getError("'zilsd' is only supported for 'rv32'");
+
   for (auto Ext : XqciExts)
     if (Exts.count(Ext.str()) && (XLen != 32))
       return getError("'" + Twine(Ext) + "'" + " is only supported for 'rv32'");
diff --git a/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp b/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp
index ff0a5e64ab3e1..6e190ad3e7969 100644
--- a/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp
+++ b/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp
@@ -658,6 +658,16 @@ TEST(ParseArchString, RejectsConflictingExtensions) {
               "'xwchc' and 'zcb' extensions are incompatible");
   }
 
+  for (StringRef Input : {"rv64i_zilsd"}) {
+    EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
+              "'zilsd' is only supported for 'rv32'");
+  }
+
+  for (StringRef Input : {"rv64i_zclsd"}) {
+    EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
+              "'zclsd' is only supported for 'rv32'");
+  }
+
   for (StringRef Input : {"rv32i_zcf_zclsd"}) {
     EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
               "'zclsd' and 'zcf' extensions are incompatible");



More information about the llvm-commits mailing list