From: Sean Silva Date: Fri, 5 Oct 2012 03:32:00 +0000 (+0000) Subject: tblgen: Use appropriate LLVM-style RTTI functions. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a475e4338be2e8c96455d5d789446548cdb4dc20;p=platform%2Fupstream%2Fllvm.git tblgen: Use appropriate LLVM-style RTTI functions. Use isa<> or cast<> when semantically that is what is happening. Also some trivial "style" cleanups at fix sites. llvm-svn: 165292 --- diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h index 0e75cf4..079dc8c 100644 --- a/llvm/include/llvm/TableGen/Record.h +++ b/llvm/include/llvm/TableGen/Record.h @@ -1085,9 +1085,9 @@ class VarBitInit : public Init { VarBitInit(TypedInit *T, unsigned B) : TI(T), Bit(B) { assert(T->getType() && - (dyn_cast(T->getType()) || - (dyn_cast(T->getType()) && - dyn_cast(T->getType())->getNumBits() > B)) && + (isa(T->getType()) || + (isa(T->getType()) && + cast(T->getType())->getNumBits() > B)) && "Illegal VarBitInit expression!"); } @@ -1120,9 +1120,9 @@ class VarListElementInit : public TypedInit { unsigned Element; VarListElementInit(TypedInit *T, unsigned E) - : TypedInit(dyn_cast(T->getType())->getElementType()), + : TypedInit(cast(T->getType())->getElementType()), TI(T), Element(E) { - assert(T->getType() && dyn_cast(T->getType()) && + assert(T->getType() && isa(T->getType()) && "Illegal VarBitInit expression!"); } diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index e51ae44..83f2fff 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -113,9 +113,7 @@ Init *BitRecTy::convertValue(IntInit *II) { Init *BitRecTy::convertValue(TypedInit *VI) { RecTy *Ty = VI->getType(); - if (dyn_cast(Ty) || - dyn_cast(Ty) || - dyn_cast(Ty)) + if (isa(Ty) || isa(Ty) || isa(Ty)) return VI; // Accept variable if it is already of bit type! return 0; } @@ -181,7 +179,7 @@ Init *BitsRecTy::convertValue(BitsInit *BI) { } Init *BitsRecTy::convertValue(TypedInit *VI) { - if (Size == 1 && dyn_cast(VI->getType())) + if (Size == 1 && isa(VI->getType())) return BitsInit::get(VI); if (VI->getType()->typeIsConvertibleTo(this)) { @@ -243,7 +241,7 @@ Init *StringRecTy::convertValue(BinOpInit *BO) { Init *StringRecTy::convertValue(TypedInit *TI) { - if (dyn_cast(TI->getType())) + if (isa(TI->getType())) return TI; // Accept variable if already of the right type! return 0; } @@ -263,10 +261,8 @@ Init *ListRecTy::convertValue(ListInit *LI) { else return 0; - ListRecTy *LType = dyn_cast(LI->getType()); - if (LType == 0) { + if (!isa(LI->getType())) return 0; - } return ListInit::get(Elements, this); } @@ -1039,9 +1035,6 @@ static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, DagInit *MHSd = dynamic_cast(MHS); ListInit *MHSl = dynamic_cast(MHS); - DagRecTy *DagType = dyn_cast(Type); - ListRecTy *ListType = dyn_cast(Type); - OpInit *RHSo = dynamic_cast(RHS); if (!RHSo) { @@ -1054,7 +1047,7 @@ static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, throw TGError(CurRec->getLoc(), "!foreach requires typed variable\n"); } - if ((MHSd && DagType) || (MHSl && ListType)) { + if ((MHSd && isa(Type)) || (MHSl && isa(Type))) { if (MHSd) { Init *Val = MHSd->getOperator(); Init *Result = EvaluateOperation(RHSo, LHS, Val, @@ -1235,13 +1228,9 @@ std::string TernOpInit::getAsString() const { } RecTy *TypedInit::getFieldType(const std::string &FieldName) const { - RecordRecTy *RecordType = dyn_cast(getType()); - if (RecordType) { - RecordVal *Field = RecordType->getRecord()->getValue(FieldName); - if (Field) { + if (RecordRecTy *RecordType = dyn_cast(getType())) + if (RecordVal *Field = RecordType->getRecord()->getValue(FieldName)) return Field->getType(); - } - } return 0; } @@ -1344,7 +1333,7 @@ RecTy *VarInit::getFieldType(const std::string &FieldName) const { Init *VarInit::getFieldInit(Record &R, const RecordVal *RV, const std::string &FieldName) const { - if (dyn_cast(getType())) + if (isa(getType())) if (const RecordVal *Val = R.getValue(VarName)) { if (RV != Val && (RV || dynamic_cast(Val->getValue()))) return 0; @@ -1655,9 +1644,8 @@ void Record::checkName() { const TypedInit *TypedName = dynamic_cast(Name); assert(TypedName && "Record name is not typed!"); RecTy *Type = TypedName->getType(); - if (dyn_cast(Type) == 0) { + if (!isa(Type)) throw TGError(getLoc(), "Record name is not a string!"); - } } DefInit *Record::getDefInit() {