[PATCH] D61412: [RISCV] Replace map with set in getReqFeatures

Sameer AbuAsal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 10 10:14:54 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL362968:  [RISCV] Replace map with set in getReqFeatures (authored by sabuasal, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61412?vs=197666&id=203858#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61412/new/

https://reviews.llvm.org/D61412

Files:
  llvm/trunk/utils/TableGen/RISCVCompressInstEmitter.cpp


Index: llvm/trunk/utils/TableGen/RISCVCompressInstEmitter.cpp
===================================================================
--- llvm/trunk/utils/TableGen/RISCVCompressInstEmitter.cpp
+++ llvm/trunk/utils/TableGen/RISCVCompressInstEmitter.cpp
@@ -64,6 +64,7 @@
 #include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
+#include <set>
 #include <vector>
 using namespace llvm;
 
@@ -474,7 +475,7 @@
                                          SourceOperandMap, DestOperandMap));
 }
 
-static void getReqFeatures(std::map<StringRef, int> &FeaturesMap,
+static void getReqFeatures(std::set<StringRef> &FeaturesSet,
                            const std::vector<Record *> &ReqFeatures) {
   for (auto &R : ReqFeatures) {
     StringRef AsmCondString = R->getValueAsString("AssemblerCondString");
@@ -483,11 +484,9 @@
     SmallVector<StringRef, 4> Ops;
     SplitString(AsmCondString, Ops, ",");
     assert(!Ops.empty() && "AssemblerCondString cannot be empty");
-
     for (auto &Op : Ops) {
       assert(!Op.empty() && "Empty operator");
-      if (FeaturesMap.find(Op) == FeaturesMap.end())
-        FeaturesMap[Op] = FeaturesMap.size();
+      FeaturesSet.insert(Op);
     }
   }
 }
@@ -620,9 +619,9 @@
       CaseStream.indent(4) << "case " + Namespace + "::" + CurOp + ": {\n";
     }
 
-    std::map<StringRef, int> FeaturesMap;
+    std::set<StringRef> FeaturesSet;
     // Add CompressPat required features.
-    getReqFeatures(FeaturesMap, CompressPat.PatReqFeatures);
+    getReqFeatures(FeaturesSet, CompressPat.PatReqFeatures);
 
     // Add Dest instruction required features.
     std::vector<Record *> ReqFeatures;
@@ -630,11 +629,10 @@
     copy_if(RF, std::back_inserter(ReqFeatures), [](Record *R) {
       return R->getValueAsBit("AssemblerMatcherPredicate");
     });
-    getReqFeatures(FeaturesMap, ReqFeatures);
+    getReqFeatures(FeaturesSet, ReqFeatures);
 
     // Emit checks for all required features.
-    for (auto &F : FeaturesMap) {
-      StringRef Op = F.first;
+    for (auto &Op : FeaturesSet) {
       if (Op[0] == '!')
         CondStream.indent(6) << ("!STI.getFeatureBits()[" + Namespace +
                                  "::" + Op.substr(1) + "]")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61412.203858.patch
Type: text/x-patch
Size: 2250 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190610/addc0813/attachment.bin>


More information about the llvm-commits mailing list