Add and use a new method

llvm-svn: 7682
This commit is contained in:
Chris Lattner 2003-08-07 19:41:59 +00:00
parent 4d0c647dec
commit 69b1d7c0d6
2 changed files with 8 additions and 2 deletions

View File

@ -703,6 +703,13 @@ public:
return false;
}
bool isSubClassOf(const std::string &Name) const {
for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i)
if (SuperClasses[i]->getName() == Name)
return true;
return false;
}
void addSuperClass(Record *R) {
assert(!isSubClassOf(R) && "Already subclassing record!");
SuperClasses.push_back(R);

View File

@ -73,7 +73,6 @@ void RegisterInfoEmitter::run(std::ostream &OS) {
Records.getAllDerivedDefinitions("RegisterClass");
std::vector<Record*> Registers = Records.getAllDerivedDefinitions("Register");
Record *RegisterClass = Records.getClass("Register");
std::set<Record*> RegistersFound;
std::vector<std::string> RegClassNames;
@ -99,7 +98,7 @@ void RegisterInfoEmitter::run(std::ostream &OS) {
DefInit *RegDef = dynamic_cast<DefInit*>(RegList->getElement(i));
if (!RegDef) throw "Register class member is not a record!";
Record *Reg = RegDef->getDef();
if (!Reg->isSubClassOf(RegisterClass))
if (!Reg->isSubClassOf("Register"))
throw "Register Class member '" + Reg->getName() +
" does not derive from the Register class!";
if (RegistersFound.count(Reg))