[llvm] Gate CSR defined by experimental and vendor extensions (PR #104424)

Jesse Huang via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 15 04:31:12 PDT 2024


================
@@ -1923,8 +1923,26 @@ ParseStatus RISCVAsmParser::parseCSRSystemRegister(OperandVector &Operands) {
 
     // Accept a named Sys Reg if the required features are present.
     if (SysReg) {
-      if (!SysReg->haveRequiredFeatures(getSTI().getFeatureBits()))
-        return Error(S, "system register use requires an option to be enabled");
+      const auto &FeatureBits = getSTI().getFeatureBits();
+      if (!SysReg->haveRequiredFeatures(FeatureBits)) {
+        const auto *Feature = std::find_if(
+            RISCVFeatureKV, RISCVFeatureKV + RISCV::NumSubtargetFeatures,
+            [&](auto Feature) {
+              return SysReg->FeaturesRequired[Feature.Value];
+            });
+        auto ErrorMsg = std::string("system register '") + SysReg->Name + "' ";
+        if (SysReg->isRV32Only && FeatureBits[RISCV::Feature64Bit]) {
+          ErrorMsg += "is 32-bit only";
+          if (Feature != RISCVFeatureKV + RISCV::NumSubtargetFeatures)
----------------
jaidTw wrote:

Missed them, thanks!

https://github.com/llvm/llvm-project/pull/104424


More information about the llvm-commits mailing list