[llvm] 8d25c73 - Revert "[RISCV][TableGen] Move XLen detection into getMArch in RISCVTargetDefEmitter. NFC"

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 20 10:45:30 PST 2023


Author: Craig Topper
Date: 2023-01-20T10:45:13-08:00
New Revision: 8d25c73e3930c9347036a743cc0f952de386dbf7

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

LOG: Revert "[RISCV][TableGen] Move XLen detection into getMArch in RISCVTargetDefEmitter. NFC"

This reverts commit e58010f712ccac83194852fa95ed70ef76ba6a33.

Seems this is failing on the build bots.

Added: 
    

Modified: 
    llvm/utils/TableGen/RISCVTargetDefEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp b/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
index bfc5a780e23e..90d2b1817050 100644
--- a/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
+++ b/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
@@ -19,23 +19,30 @@ using namespace llvm;
 
 using ISAInfoTy = llvm::Expected<std::unique_ptr<RISCVISAInfo>>;
 
+static int getXLen(const Record &Rec) {
+  std::vector<Record *> Features = Rec.getValueAsListOfDefs("Features");
+  if (find_if(Features, [](const Record *R) {
+        return R->getName() == "Feature64Bit";
+      }) != Features.end())
+    return 64;
+
+  return 32;
+}
+
 // We can generate march string from target features as what has been described
 // in RISCV ISA specification (version 20191213) 'Chapter 27. ISA Extension
 // Naming Conventions'.
 //
 // This is almost the same as RISCVFeatures::parseFeatureBits, except that we
 // get feature name from feature records instead of feature bits.
-static std::string getMArch(const Record &Rec) {
+static std::string getMArch(int XLen, const Record &Rec) {
   std::vector<std::string> FeatureVector;
-  int XLen = 32;
 
   // Convert features to FeatureVector.
   for (auto *Feature : Rec.getValueAsListOfDefs("Features")) {
     StringRef FeatureName = Feature->getValueAsString("Name");
     if (llvm::RISCVISAInfo::isSupportedExtensionFeature(FeatureName))
       FeatureVector.push_back((Twine("+") + FeatureName).str());
-    else if (FeatureName == "Feature64Bit")
-      XLen = 64;
   }
 
   ISAInfoTy ISAInfo = llvm::RISCVISAInfo::parseFeatures(XLen, FeatureVector);
@@ -55,11 +62,12 @@ void llvm::EmitRISCVTargetDef(const RecordKeeper &RK, raw_ostream &OS) {
   OS << "PROC(INVALID, {\"invalid\"}, {\"\"})\n";
   // Iterate on all definition records.
   for (const Record *Rec : RK.getAllDerivedDefinitions("RISCVProcessorModel")) {
+    int XLen = getXLen(*Rec);
     std::string MArch = Rec->getValueAsString("DefaultMarch").str();
 
     // Compute MArch from features if we don't specify it.
     if (MArch.empty())
-      MArch = getMArch(*Rec);
+      MArch = getMArch(XLen, *Rec);
 
     OS << "PROC(" << Rec->getName() << ", "
        << "{\"" << Rec->getValueAsString("Name") << "\"}, "


        


More information about the llvm-commits mailing list