diff options
author | Craig Topper <craig.topper@gmail.com> | 2015-05-30 07:36:01 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2015-05-30 07:36:01 +0000 |
commit | 15864f1518c6b15b6936cd746227d61530f92427 (patch) | |
tree | 79c208d82389beb4add3fb2fda1a105ad1a17c08 /llvm/lib/TableGen | |
parent | 974ed6d3e7da01d5ea5ba2bb95400e1121d22059 (diff) | |
download | bcm5719-llvm-15864f1518c6b15b6936cd746227d61530f92427.tar.gz bcm5719-llvm-15864f1518c6b15b6936cd746227d61530f92427.zip |
[TableGen] Merge RecTy::typeIsConvertibleTo and RecTy::baseClassOf. NFC
typeIsConvertibleTo was just calling baseClassOf(this) on the argument passed to it, but there weren't different signatures for baseClassOf so passing 'this' didn't really do anything interesting. typeIsConvertibleTo could have just been a non-virtual method in RecTy. But since that would be kind of a silly method, I instead re-distributed the logic from baseClassOf into typeIsConvertibleTo.
llvm-svn: 238648
Diffstat (limited to 'llvm/lib/TableGen')
-rw-r--r-- | llvm/lib/TableGen/Record.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index b050000500e..6c7a66fcba1 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -86,7 +86,6 @@ IntRecTy IntRecTy::Shared; StringRecTy StringRecTy::Shared; DagRecTy DagRecTy::Shared; -void RecTy::anchor() { } void RecTy::dump() const { print(errs()); } void StringRecTy::anchor() { } @@ -98,13 +97,13 @@ ListRecTy *RecTy::getListTy() { return ListTy.get(); } -bool RecTy::baseClassOf(const RecTy *RHS) const { - assert (RHS && "NULL pointer"); +bool RecTy::typeIsConvertibleTo(const RecTy *RHS) const { + assert(RHS && "NULL pointer"); return Kind == RHS->getRecTyKind(); } -bool BitRecTy::baseClassOf(const RecTy *RHS) const{ - if(RecTy::baseClassOf(RHS) || RHS->getRecTyKind() == IntRecTyKind) +bool BitRecTy::typeIsConvertibleTo(const RecTy *RHS) const{ + if(RecTy::typeIsConvertibleTo(RHS) || RHS->getRecTyKind() == IntRecTyKind) return true; if(const BitsRecTy *BitsTy = dyn_cast<BitsRecTy>(RHS)) return BitsTy->getNumBits() == 1; @@ -125,14 +124,14 @@ std::string BitsRecTy::getAsString() const { return "bits<" + utostr(Size) + ">"; } -bool BitsRecTy::baseClassOf(const RecTy *RHS) const{ - if (RecTy::baseClassOf(RHS)) //argument and the receiver are the same type +bool BitsRecTy::typeIsConvertibleTo(const RecTy *RHS) const { + if (RecTy::typeIsConvertibleTo(RHS)) //argument and the sender are same type return cast<BitsRecTy>(RHS)->Size == Size; RecTyKind kind = RHS->getRecTyKind(); return (kind == BitRecTyKind && Size == 1) || (kind == IntRecTyKind); } -bool IntRecTy::baseClassOf(const RecTy *RHS) const{ +bool IntRecTy::typeIsConvertibleTo(const RecTy *RHS) const { RecTyKind kind = RHS->getRecTyKind(); return kind==BitRecTyKind || kind==BitsRecTyKind || kind==IntRecTyKind; } @@ -142,9 +141,9 @@ std::string ListRecTy::getAsString() const { return "list<" + Ty->getAsString() + ">"; } -bool ListRecTy::baseClassOf(const RecTy *RHS) const{ - if(const ListRecTy* ListTy = dyn_cast<ListRecTy>(RHS)) - return ListTy->getElementType()->typeIsConvertibleTo(Ty); +bool ListRecTy::typeIsConvertibleTo(const RecTy *RHS) const { + if (const auto *ListTy = dyn_cast<ListRecTy>(RHS)) + return Ty->typeIsConvertibleTo(ListTy->getElementType()); return false; } @@ -156,17 +155,16 @@ std::string RecordRecTy::getAsString() const { return Rec->getName(); } -bool RecordRecTy::baseClassOf(const RecTy *RHS) const{ +bool RecordRecTy::typeIsConvertibleTo(const RecTy *RHS) const { const RecordRecTy *RTy = dyn_cast<RecordRecTy>(RHS); if (!RTy) return false; - if (Rec == RTy->getRecord() || RTy->getRecord()->isSubClassOf(Rec)) + if (RTy->getRecord() == Rec || Rec->isSubClassOf(RTy->getRecord())) return true; - const std::vector<Record*> &SC = Rec->getSuperClasses(); - for (unsigned i = 0, e = SC.size(); i != e; ++i) - if (RTy->getRecord()->isSubClassOf(SC[i])) + for (Record *SC : RTy->getRecord()->getSuperClasses()) + if (Rec->isSubClassOf(SC)) return true; return false; |