[llvm] 05d04f0 - [RISCV] Make RISCVISAInfo::updateMaxELen extension checking more robust. Add inference from V extension. (#90650)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 30 13:49:09 PDT 2024


Author: Craig Topper
Date: 2024-04-30T13:49:05-07:00
New Revision: 05d04f0a057bc06324c02e00c2c73ee354999dde

URL: https://github.com/llvm/llvm-project/commit/05d04f0a057bc06324c02e00c2c73ee354999dde
DIFF: https://github.com/llvm/llvm-project/commit/05d04f0a057bc06324c02e00c2c73ee354999dde.diff

LOG: [RISCV] Make RISCVISAInfo::updateMaxELen extension checking more robust. Add inference from V extension. (#90650)

We weren't fully checking that we parsed Zve*x/f/d correctly. This could
break if new extension is added that starts with Zve.

We were assuming the Zve64d is present whenever V is so we only
inferred from Zve*. It's more correct to infer ELEN from V itself too.

Added: 
    

Modified: 
    llvm/lib/TargetParser/RISCVISAInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index 5aff936dd993fb..3b0cf8fab25f46 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -929,6 +929,12 @@ void RISCVISAInfo::updateMinVLen() {
 }
 
 void RISCVISAInfo::updateMaxELen() {
+  assert(MaxELenFp == 0 && MaxELen == 0);
+  if (Exts.count("v")) {
+    MaxELenFp = std::max(MaxELenFp, 64u);
+    MaxELen = std::max(MaxELen, 64u);
+  }
+
   // handles EEW restriction by sub-extension zve
   for (auto const &Ext : Exts) {
     StringRef ExtName = Ext.first;
@@ -936,12 +942,15 @@ void RISCVISAInfo::updateMaxELen() {
     if (IsZveExt) {
       if (ExtName.back() == 'f')
         MaxELenFp = std::max(MaxELenFp, 32u);
-      if (ExtName.back() == 'd')
+      else if (ExtName.back() == 'd')
         MaxELenFp = std::max(MaxELenFp, 64u);
+      else if (ExtName.back() != 'x')
+        continue;
+
       ExtName = ExtName.drop_back();
       unsigned ZveELen;
-      ExtName.getAsInteger(10, ZveELen);
-      MaxELen = std::max(MaxELen, ZveELen);
+      if (!ExtName.getAsInteger(10, ZveELen))
+        MaxELen = std::max(MaxELen, ZveELen);
     }
   }
 }


        


More information about the llvm-commits mailing list