[llvm] b2fad80 - [RISCV][NFC] Small refactor in RISCVISAInfo::parseArchString

Alex Bradbury via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 14 09:38:06 PDT 2023


Author: Alex Bradbury
Date: 2023-03-14T16:37:34Z
New Revision: b2fad8027ae630db6310fb925303643d4da35365

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

LOG: [RISCV][NFC] Small refactor in RISCVISAInfo::parseArchString

Slightly refactor handling of version extraction for the 'baseline' ISA,
to make an upcoming patch easier to review.

Added: 
    

Modified: 
    llvm/lib/Support/RISCVISAInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp
index ed91a41c56c00..520dff68c3f3c 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -644,12 +644,10 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
   }
 
   unsigned Major, Minor, ConsumeLength;
-  if (auto E = getExtensionVersion(std::string(1, Baseline), Exts, Major, Minor,
-                                   ConsumeLength, EnableExperimentalExtension,
-                                   ExperimentalExtensionVersionCheck))
-    return std::move(E);
-
   if (Baseline == 'g') {
+    // Versions for g are disallowed, and this was checked for previously.
+    ConsumeLength = 0;
+
     // No matter which version is given to `g`, we always set imafd to default
     // version since the we don't have clear version scheme for that on
     // ISA spec.
@@ -658,9 +656,15 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
         ISAInfo->addExtension(Ext, Version->Major, Version->Minor);
       else
         llvm_unreachable("Default extension version not found?");
-  } else
+  } else {
     // Baseline is `i` or `e`
+    if (auto E = getExtensionVersion(std::string(1, Baseline), Exts, Major, Minor,
+                                     ConsumeLength, EnableExperimentalExtension,
+                                     ExperimentalExtensionVersionCheck))
+      return std::move(E);
+
     ISAInfo->addExtension(std::string(1, Baseline), Major, Minor);
+  }
 
   // Consume the base ISA version number and any '_' between rvxxx and the
   // first extension


        


More information about the llvm-commits mailing list