[PATCH] D88832: [TableGen] Add new getAllDerivedDefinitionsTwo function to RecordKeeper

Jessica Clarke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 7 15:16:54 PDT 2020


jrtc27 added inline comments.


================
Comment at: llvm/lib/TableGen/Record.cpp:2322-2325
+std::vector<Record *>
 Record::getValueAsListOfDefs(StringRef FieldName) const {
   ListInit *List = getValueAsListInit(FieldName);
+  std::vector<Record *> Defs;
----------------
If you're not touching this function leave the formatting alone.


================
Comment at: llvm/lib/TableGen/Record.cpp:2477
+RecordKeeper::getAllDerivedDefinitions(
+                  const SmallVectorImpl<std::string> &ClassNames) const {
+  SmallVector<Record *, 2> ClassRecs;
----------------
This really should be ArrayRef, it should not be a specific array-like implementation, and it should have StringRef's in it not require std::string.


================
Comment at: llvm/utils/TableGen/RISCVCompressInstEmitter.cpp:887
 void RISCVCompressInstEmitter::run(raw_ostream &o) {
-  Record *CompressClass = Records.getClass("CompressPat");
-  assert(CompressClass && "Compress class definition missing!");
-  std::vector<Record *> Insts;
-  for (const auto &D : Records.getDefs()) {
-    if (D.second->isSubClassOf(CompressClass))
-      Insts.push_back(D.second.get());
-  }
+  std::vector<Record *> Insts = Records.getAllDerivedDefinitions("CompressPat");
 
----------------
Please split this out into a separate commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88832



More information about the llvm-commits mailing list