std::vector<Record*> Insts;
const std::map<std::string, Record*> &Defs = Records.getDefs();
- Record *Inst = Records.getClass("Instruction");
- assert(Inst && "Couldn't find Instruction class!");
- for (std::map<std::string, Record*>::const_iterator I = Defs.begin(),
- E = Defs.end(); I != E; ++I)
- if (I->second->isSubClassOf(Inst))
- Insts.push_back(I->second);
+ Records.getAllDerivedDefinitions("Instruction", Insts);
std::string Namespace = "V9::";
std::string ClassName = "SparcV9CodeEmitter::";
OS << "def " << *I->second;
return OS;
}
+
+
+/// getAllDerivedDefinitions - This method returns all concrete definitions
+/// that derive from the specified class name. If a class with the specified
+/// name does not exist, an error is printed and true is returned.
+bool RecordKeeper::getAllDerivedDefinitions(const std::string &ClassName,
+ std::vector<Record*> &Defs) const {
+ Record *Class = Records.getClass(ClassName);
+ if (!Class) {
+ std::cerr << "ERROR: Couldn't find the '" << ClassName << "' class!\n";
+ return true;
+ }
+
+ for (std::map<std::string, Record*>::const_iterator I = getDefs().begin(),
+ E = getDefs().end(); I != E; ++I)
+ if (I->second->isSubClassOf(Class))
+ Defs.push_back(I->second);
+
+ return false;
+}
Defs.insert(std::make_pair(R->getName(), R));
}
+ //===--------------------------------------------------------------------===//
+ // High-level helper methods, useful for tablegen backends...
+
+ /// getAllDerivedDefinitions - This method returns all concrete definitions
+ /// that derive from the specified class name. If a class with the specified
+ /// name does not exist, an error is printed and true is returned.
+ bool getAllDerivedDefinitions(const std::string &ClassName,
+ std::vector<Record*> &ReturnDefs) const;
+
+
void dump() const;
};
std::vector<Record*> Insts;
const std::map<std::string, Record*> &Defs = Records.getDefs();
- Record *Inst = Records.getClass("Instruction");
- assert(Inst && "Couldn't find Instruction class!");
- for (std::map<std::string, Record*>::const_iterator I = Defs.begin(),
- E = Defs.end(); I != E; ++I)
- if (I->second->isSubClassOf(Inst))
- Insts.push_back(I->second);
+ Records.getAllDerivedDefinitions("Instruction", Insts);
std::string Namespace = "V9::";
std::string ClassName = "SparcV9CodeEmitter::";
OS << "def " << *I->second;
return OS;
}
+
+
+/// getAllDerivedDefinitions - This method returns all concrete definitions
+/// that derive from the specified class name. If a class with the specified
+/// name does not exist, an error is printed and true is returned.
+bool RecordKeeper::getAllDerivedDefinitions(const std::string &ClassName,
+ std::vector<Record*> &Defs) const {
+ Record *Class = Records.getClass(ClassName);
+ if (!Class) {
+ std::cerr << "ERROR: Couldn't find the '" << ClassName << "' class!\n";
+ return true;
+ }
+
+ for (std::map<std::string, Record*>::const_iterator I = getDefs().begin(),
+ E = getDefs().end(); I != E; ++I)
+ if (I->second->isSubClassOf(Class))
+ Defs.push_back(I->second);
+
+ return false;
+}
Defs.insert(std::make_pair(R->getName(), R));
}
+ //===--------------------------------------------------------------------===//
+ // High-level helper methods, useful for tablegen backends...
+
+ /// getAllDerivedDefinitions - This method returns all concrete definitions
+ /// that derive from the specified class name. If a class with the specified
+ /// name does not exist, an error is printed and true is returned.
+ bool getAllDerivedDefinitions(const std::string &ClassName,
+ std::vector<Record*> &ReturnDefs) const;
+
+
void dump() const;
};