[TableGen] Use raw_svector_ostream and ListSeparator to simplify some code. NFC
authorCraig Topper <craig.topper@sifive.com>
Mon, 27 Feb 2023 03:36:34 +0000 (19:36 -0800)
committerCraig Topper <craig.topper@sifive.com>
Mon, 27 Feb 2023 03:36:34 +0000 (19:36 -0800)
llvm/utils/TableGen/CodeGenDAGPatterns.cpp

index fe5766f..56cf9c7 100644 (file)
@@ -1523,22 +1523,17 @@ std::string PatternToMatch::getPredicateCheck() const {
   getPredicateRecords(PredicateRecs);
 
   SmallString<128> PredicateCheck;
+  raw_svector_ostream OS(PredicateCheck);
+  ListSeparator LS(" && ");
   for (Record *Pred : PredicateRecs) {
     StringRef CondString = Pred->getValueAsString("CondString");
     if (CondString.empty())
       continue;
-    if (!PredicateCheck.empty())
-      PredicateCheck += " && ";
-    PredicateCheck += "(";
-    PredicateCheck += CondString;
-    PredicateCheck += ")";
+    OS << LS << '(' << CondString << ')';
   }
 
-  if (!HwModeFeatures.empty()) {
-    if (!PredicateCheck.empty())
-      PredicateCheck += " && ";
-    PredicateCheck += HwModeFeatures;
-  }
+  if (!HwModeFeatures.empty())
+    OS << LS << HwModeFeatures;
 
   return std::string(PredicateCheck);
 }