File tree Expand file tree Collapse file tree 4 files changed +33
-24
lines changed Expand file tree Collapse file tree 4 files changed +33
-24
lines changed Original file line number Diff line number Diff line change @@ -569,9 +569,9 @@ The ``RecordKeeper`` class provides four functions for getting the
569
569
``Record `` references for the concrete records that derive from the
570
570
given class.
571
571
572
- * ``getAllDerivedDefinitionsTwo ( ``\ *classname1 * \ `` , `` * classname2 *\ ``) `` returns
572
+ * ``getAllDerivedDefinitions ( ``\ *classnames *\ ``) `` returns
573
573
a vector of ``Record `` references for the concrete records that derive from
574
- *both * of the given classes. [function to come]
574
+ *all * of the given classes.
575
575
576
576
This statement obtains all the records that derive from the ``Attribute ``
577
577
class and iterates over them.
Original file line number Diff line number Diff line change @@ -1784,9 +1784,17 @@ class RecordKeeper {
1784
1784
// ===--------------------------------------------------------------------===//
1785
1785
// High-level helper methods, useful for tablegen backends.
1786
1786
1787
- // / Get all the concrete records that inherit from the specified
1787
+ // / Get all the concrete records that inherit from all the specified
1788
+ // / classes. The classes must be defined.
1789
+ std::vector<Record *> getAllDerivedDefinitions (
1790
+ const ArrayRef<StringRef> ClassNames) const ;
1791
+
1792
+ // / Get all the concrete records that inherit from the one specified
1788
1793
// / class. The class must be defined.
1789
- std::vector<Record *> getAllDerivedDefinitions (StringRef ClassName) const ;
1794
+ std::vector<Record *> getAllDerivedDefinitions (StringRef ClassName) const {
1795
+
1796
+ return getAllDerivedDefinitions (makeArrayRef (ClassName));
1797
+ }
1790
1798
1791
1799
void dump () const ;
1792
1800
};
Original file line number Diff line number Diff line change @@ -2470,16 +2470,25 @@ Init *RecordKeeper::getNewAnonymousName() {
2470
2470
return StringInit::get (" anonymous_" + utostr (AnonCounter++));
2471
2471
}
2472
2472
2473
- std::vector<Record *>
2474
- RecordKeeper::getAllDerivedDefinitions (StringRef ClassName) const {
2475
- Record *Class = getClass (ClassName);
2476
- if (!Class)
2477
- PrintFatalError (" ERROR: Couldn't find the `" + ClassName + " ' class!\n " );
2473
+ std::vector<Record *> RecordKeeper::getAllDerivedDefinitions (
2474
+ const ArrayRef<StringRef> ClassNames) const {
2475
+ SmallVector<Record *, 2 > ClassRecs;
2476
+ std::vector<Record *> Defs;
2478
2477
2479
- std::vector<Record*> Defs;
2480
- for (const auto &D : getDefs ())
2481
- if (D.second ->isSubClassOf (Class))
2482
- Defs.push_back (D.second .get ());
2478
+ assert (ClassNames.size () > 0 && " At least one class must be passed." );
2479
+ for (const auto &ClassName : ClassNames) {
2480
+ Record *Class = getClass (ClassName);
2481
+ if (!Class)
2482
+ PrintFatalError (" The class '" + ClassName + " ' is not defined\n " );
2483
+ ClassRecs.push_back (Class);
2484
+ }
2485
+
2486
+ for (const auto &OneDef : getDefs ()) {
2487
+ if (all_of (ClassRecs, [&OneDef](const Record *Class) {
2488
+ return OneDef.second ->isSubClassOf (Class);
2489
+ }))
2490
+ Defs.push_back (OneDef.second .get ());
2491
+ }
2483
2492
2484
2493
return Defs;
2485
2494
}
Original file line number Diff line number Diff line change @@ -293,17 +293,9 @@ void PseudoLoweringEmitter::emitLoweringEmitter(raw_ostream &o) {
293
293
}
294
294
295
295
void PseudoLoweringEmitter::run (raw_ostream &o) {
296
- Record *ExpansionClass = Records.getClass (" PseudoInstExpansion" );
297
- Record *InstructionClass = Records.getClass (" Instruction" );
298
- assert (ExpansionClass && " PseudoInstExpansion class definition missing!" );
299
- assert (InstructionClass && " Instruction class definition missing!" );
300
-
301
- std::vector<Record*> Insts;
302
- for (const auto &D : Records.getDefs ()) {
303
- if (D.second ->isSubClassOf (ExpansionClass) &&
304
- D.second ->isSubClassOf (InstructionClass))
305
- Insts.push_back (D.second .get ());
306
- }
296
+ StringRef Classes[] = {" PseudoInstExpansion" , " Instruction" };
297
+ std::vector<Record *> Insts =
298
+ Records.getAllDerivedDefinitions (makeArrayRef (Classes));
307
299
308
300
// Process the pseudo expansion definitions, validating them as we do so.
309
301
for (unsigned i = 0 , e = Insts.size (); i != e; ++i)
You can’t perform that action at this time.
0 commit comments