[llvm] 87360d6 - [TableGen] Use ListSeparator (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 28 10:59:53 PST 2021


Author: Kazu Hirata
Date: 2021-02-28T10:59:22-08:00
New Revision: 87360d6ff71a36704b4fa5ccab2dedd6e70f10e2

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

LOG: [TableGen] Use ListSeparator (NFC)

Added: 
    

Modified: 
    llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
    llvm/utils/TableGen/SubtargetFeatureInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
index b5a280ba1a5a..1c03296fe411 100644
--- a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
+++ b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
@@ -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)

diff  --git a/llvm/utils/TableGen/SubtargetFeatureInfo.cpp b/llvm/utils/TableGen/SubtargetFeatureInfo.cpp
index 105ed82c9d02..33a22776f2df 100644
--- a/llvm/utils/TableGen/SubtargetFeatureInfo.cpp
+++ b/llvm/utils/TableGen/SubtargetFeatureInfo.cpp
@@ -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)


        


More information about the llvm-commits mailing list