[TableGen] Use ListSeparator (NFC)
authorKazu Hirata <kazu@google.com>
Sun, 28 Feb 2021 18:59:21 +0000 (10:59 -0800)
committerKazu Hirata <kazu@google.com>
Sun, 28 Feb 2021 18:59:22 +0000 (10:59 -0800)
llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
llvm/utils/TableGen/SubtargetFeatureInfo.cpp

index b5a280b..1c03296 100644 (file)
@@ -1210,14 +1210,9 @@ bool FilterChooser::emitPredicateMatch(raw_ostream &o, unsigned &Indentation,
     if (IsOr)
       o << "(";
 
-    bool First = true;
+    ListSeparator LS(IsOr ? " || " : " && ");
     for (auto *Arg : D->getArgs()) {
-      if (!First) {
-        if (IsOr)
-          o << " || ";
-        else
-          o << " && ";
-      }
+      o << LS;
       if (auto *NotArg = dyn_cast<DagInit>(Arg)) {
         if (NotArg->getOperator()->getAsString() != "not" ||
             NotArg->getNumArgs() != 1)
@@ -1230,8 +1225,6 @@ bool FilterChooser::emitPredicateMatch(raw_ostream &o, unsigned &Indentation,
         PrintFatalError(Pred->getLoc(), "Invalid AssemblerCondDag!");
       o << "Bits[" << Emitter->PredicateNamespace << "::" << Arg->getAsString()
         << "]";
-
-      First = false;
     }
 
     if (IsOr)
index 105ed82..33a2277 100644 (file)
@@ -130,14 +130,9 @@ void SubtargetFeatureInfo::emitComputeAssemblerAvailableFeatures(
     if (IsOr)
       OS << "(";
 
-    bool First = true;
+    ListSeparator LS(IsOr ? " || " : " && ");
     for (auto *Arg : D->getArgs()) {
-      if (!First) {
-        if (IsOr)
-          OS << " || ";
-        else
-          OS << " && ";
-      }
+      OS << LS;
       if (auto *NotArg = dyn_cast<DagInit>(Arg)) {
         if (NotArg->getOperator()->getAsString() != "not" ||
             NotArg->getNumArgs() != 1)
@@ -149,8 +144,6 @@ void SubtargetFeatureInfo::emitComputeAssemblerAvailableFeatures(
           !cast<DefInit>(Arg)->getDef()->isSubClassOf("SubtargetFeature"))
         PrintFatalError(SFI.TheDef->getLoc(), "Invalid AssemblerCondDag!");
       OS << "FB[" << TargetName << "::" << Arg->getAsString() << "]";
-
-      First = false;
     }
 
     if (IsOr)