From 98c61711c6c5239b68e33a975090542d9731bdbc Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Fri, 5 Oct 2012 03:31:58 +0000 Subject: [PATCH] tblgen: Replace uses of dynamic_cast with dyn_cast<>. This is a mechanical change of dynamic_cast<> to dyn_cast<>. A number of these uses are actually more like isa<> or cast<>, and will be changed to the semanticaly appropriate one in a future patch. llvm-svn: 165291 --- llvm/include/llvm/TableGen/Record.h | 10 +++---- llvm/lib/TableGen/Record.cpp | 40 +++++++++++++------------- llvm/lib/TableGen/TGParser.cpp | 10 +++---- llvm/utils/TableGen/FixedLenDecoderEmitter.cpp | 2 +- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h index a4ec966..0e75cf4 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() && - (dynamic_cast(T->getType()) || - (dynamic_cast(T->getType()) && - dynamic_cast(T->getType())->getNumBits() > B)) && + (dyn_cast(T->getType()) || + (dyn_cast(T->getType()) && + dyn_cast(T->getType())->getNumBits() > B)) && "Illegal VarBitInit expression!"); } @@ -1120,9 +1120,9 @@ class VarListElementInit : public TypedInit { unsigned Element; VarListElementInit(TypedInit *T, unsigned E) - : TypedInit(dynamic_cast(T->getType())->getElementType()), + : TypedInit(dyn_cast(T->getType())->getElementType()), TI(T), Element(E) { - assert(T->getType() && dynamic_cast(T->getType()) && + assert(T->getType() && dyn_cast(T->getType()) && "Illegal VarBitInit expression!"); } diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index 9955617..e51ae44 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -113,9 +113,9 @@ Init *BitRecTy::convertValue(IntInit *II) { Init *BitRecTy::convertValue(TypedInit *VI) { RecTy *Ty = VI->getType(); - if (dynamic_cast(Ty) || - dynamic_cast(Ty) || - dynamic_cast(Ty)) + if (dyn_cast(Ty) || + dyn_cast(Ty) || + dyn_cast(Ty)) return VI; // Accept variable if it is already of bit type! return 0; } @@ -181,7 +181,7 @@ Init *BitsRecTy::convertValue(BitsInit *BI) { } Init *BitsRecTy::convertValue(TypedInit *VI) { - if (Size == 1 && dynamic_cast(VI->getType())) + if (Size == 1 && dyn_cast(VI->getType())) return BitsInit::get(VI); if (VI->getType()->typeIsConvertibleTo(this)) { @@ -243,7 +243,7 @@ Init *StringRecTy::convertValue(BinOpInit *BO) { Init *StringRecTy::convertValue(TypedInit *TI) { - if (dynamic_cast(TI->getType())) + if (dyn_cast(TI->getType())) return TI; // Accept variable if already of the right type! return 0; } @@ -263,7 +263,7 @@ Init *ListRecTy::convertValue(ListInit *LI) { else return 0; - ListRecTy *LType = dynamic_cast(LI->getType()); + ListRecTy *LType = dyn_cast(LI->getType()); if (LType == 0) { return 0; } @@ -273,7 +273,7 @@ Init *ListRecTy::convertValue(ListInit *LI) { Init *ListRecTy::convertValue(TypedInit *TI) { // Ensure that TI is compatible with our class. - if (ListRecTy *LRT = dynamic_cast(TI->getType())) + if (ListRecTy *LRT = dyn_cast(TI->getType())) if (LRT->getElementType()->typeIsConvertibleTo(getElementType())) return TI; return 0; @@ -309,7 +309,7 @@ Init *DagRecTy::convertValue(BinOpInit *BO) { } RecordRecTy *RecordRecTy::get(Record *R) { - return &dynamic_cast(*R->getDefInit()->getType()); + return dyn_cast(R->getDefInit()->getType()); } std::string RecordRecTy::getAsString() const { @@ -325,7 +325,7 @@ Init *RecordRecTy::convertValue(DefInit *DI) { Init *RecordRecTy::convertValue(TypedInit *TI) { // Ensure that TI is compatible with Rec. - if (RecordRecTy *RRT = dynamic_cast(TI->getType())) + if (RecordRecTy *RRT = dyn_cast(TI->getType())) if (RRT->getRecord()->isSubClassOf(getRecord()) || RRT->getRecord() == getRecord()) return TI; @@ -354,7 +354,7 @@ RecTy *llvm::resolveTypes(RecTy *T1, RecTy *T2) { return T1; // If one is a Record type, check superclasses - if (RecordRecTy *RecTy1 = dynamic_cast(T1)) { + if (RecordRecTy *RecTy1 = dyn_cast(T1)) { // See if T2 inherits from a type T1 also inherits from const std::vector &T1SuperClasses = RecTy1->getRecord()->getSuperClasses(); @@ -372,7 +372,7 @@ RecTy *llvm::resolveTypes(RecTy *T1, RecTy *T2) { } } } - if (RecordRecTy *RecTy2 = dynamic_cast(T2)) { + if (RecordRecTy *RecTy2 = dyn_cast(T2)) { // See if T1 inherits from a type T2 also inherits from const std::vector &T2SuperClasses = RecTy2->getRecord()->getSuperClasses(); @@ -599,7 +599,7 @@ ListInit *ListInit::get(ArrayRef Range, RecTy *EltTy) { } void ListInit::Profile(FoldingSetNodeID &ID) const { - ListRecTy *ListType = dynamic_cast(getType()); + ListRecTy *ListType = dyn_cast(getType()); assert(ListType && "Bad type for ListInit!"); RecTy *EltTy = ListType->getElementType(); @@ -1039,8 +1039,8 @@ static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, DagInit *MHSd = dynamic_cast(MHS); ListInit *MHSl = dynamic_cast(MHS); - DagRecTy *DagType = dynamic_cast(Type); - ListRecTy *ListType = dynamic_cast(Type); + DagRecTy *DagType = dyn_cast(Type); + ListRecTy *ListType = dyn_cast(Type); OpInit *RHSo = dynamic_cast(RHS); @@ -1235,7 +1235,7 @@ std::string TernOpInit::getAsString() const { } RecTy *TypedInit::getFieldType(const std::string &FieldName) const { - RecordRecTy *RecordType = dynamic_cast(getType()); + RecordRecTy *RecordType = dyn_cast(getType()); if (RecordType) { RecordVal *Field = RecordType->getRecord()->getValue(FieldName); if (Field) { @@ -1247,7 +1247,7 @@ RecTy *TypedInit::getFieldType(const std::string &FieldName) const { Init * TypedInit::convertInitializerBitRange(const std::vector &Bits) const { - BitsRecTy *T = dynamic_cast(getType()); + BitsRecTy *T = dyn_cast(getType()); if (T == 0) return 0; // Cannot subscript a non-bits variable. unsigned NumBits = T->getNumBits(); @@ -1263,7 +1263,7 @@ TypedInit::convertInitializerBitRange(const std::vector &Bits) const { Init * TypedInit::convertInitListSlice(const std::vector &Elements) const { - ListRecTy *T = dynamic_cast(getType()); + ListRecTy *T = dyn_cast(getType()); if (T == 0) return 0; // Cannot subscript a non-list variable. if (Elements.size() == 1) @@ -1336,7 +1336,7 @@ Init *VarInit::resolveListElementReference(Record &R, RecTy *VarInit::getFieldType(const std::string &FieldName) const { - if (RecordRecTy *RTy = dynamic_cast(getType())) + if (RecordRecTy *RTy = dyn_cast(getType())) if (const RecordVal *RV = RTy->getRecord()->getValue(FieldName)) return RV->getType(); return 0; @@ -1344,7 +1344,7 @@ RecTy *VarInit::getFieldType(const std::string &FieldName) const { Init *VarInit::getFieldInit(Record &R, const RecordVal *RV, const std::string &FieldName) const { - if (dynamic_cast(getType())) + if (dyn_cast(getType())) if (const RecordVal *Val = R.getValue(VarName)) { if (RV != Val && (RV || dynamic_cast(Val->getValue()))) return 0; @@ -1655,7 +1655,7 @@ void Record::checkName() { const TypedInit *TypedName = dynamic_cast(Name); assert(TypedName && "Record name is not typed!"); RecTy *Type = TypedName->getType(); - if (dynamic_cast(Type) == 0) { + if (dyn_cast(Type) == 0) { throw TGError(getLoc(), "Record name is not a string!"); } } diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index aee93e76..82d1957 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -864,8 +864,8 @@ Init *TGParser::ParseOperation(Record *CurRec) { return 0; } if (LHSt) { - ListRecTy *LType = dynamic_cast(LHSt->getType()); - StringRecTy *SType = dynamic_cast(LHSt->getType()); + ListRecTy *LType = dyn_cast(LHSt->getType()); + StringRecTy *SType = dyn_cast(LHSt->getType()); if (LType == 0 && SType == 0) { TokError("expected list or string type argumnet in unary operator"); return 0; @@ -897,7 +897,7 @@ Init *TGParser::ParseOperation(Record *CurRec) { } } else { assert(LHSt && "expected list type argument in unary operator"); - ListRecTy *LType = dynamic_cast(LHSt->getType()); + ListRecTy *LType = dyn_cast(LHSt->getType()); if (LType == 0) { TokError("expected list type argumnet in unary operator"); return 0; @@ -1271,7 +1271,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType, ListRecTy *GivenListTy = 0; if (ItemType != 0) { - ListRecTy *ListType = dynamic_cast(ItemType); + ListRecTy *ListType = dyn_cast(ItemType); if (ListType == 0) { std::stringstream s; s << "Type mismatch for list, expected list type, got " @@ -1723,7 +1723,7 @@ VarInit *TGParser::ParseForeachDeclaration(ListInit *&ForeachListValue) { return 0; } RecTy *ValueType = ForeachListValue->getType(); - ListRecTy *ListType = dynamic_cast(ValueType); + ListRecTy *ListType = dyn_cast(ValueType); if (ListType == 0) { TokError("Value list is not of list type"); return 0; diff --git a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp index e755c1c..b5f62d8 100644 --- a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -1758,7 +1758,7 @@ static bool populateInstruction(const CodeGenInstruction &CGI, unsigned Opc, // FIXME: This need to be extended to handle instructions with custom // decoder methods, and operands with (simple) MIOperandInfo's. TypedInit *TI = dynamic_cast(NI->first); - RecordRecTy *Type = dynamic_cast(TI->getType()); + RecordRecTy *Type = dyn_cast(TI->getType()); Record *TypeRecord = Type->getRecord(); bool isReg = false; if (TypeRecord->isSubClassOf("RegisterOperand")) -- 2.7.4