[llvm-commits] [llvm] r165291 - in /llvm/trunk: include/llvm/TableGen/Record.h lib/TableGen/Record.cpp lib/TableGen/TGParser.cpp utils/TableGen/FixedLenDecoderEmitter.cpp

Sean Silva silvas at purdue.edu
Thu Oct 4 20:31:58 PDT 2012


Author: silvas
Date: Thu Oct  4 22:31:58 2012
New Revision: 165291

URL: http://llvm.org/viewvc/llvm-project?rev=165291&view=rev
Log:
tblgen: Replace uses of dynamic_cast<XXXRecTy> 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.

Modified:
    llvm/trunk/include/llvm/TableGen/Record.h
    llvm/trunk/lib/TableGen/Record.cpp
    llvm/trunk/lib/TableGen/TGParser.cpp
    llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp

Modified: llvm/trunk/include/llvm/TableGen/Record.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/Record.h?rev=165291&r1=165290&r2=165291&view=diff
==============================================================================
--- llvm/trunk/include/llvm/TableGen/Record.h (original)
+++ llvm/trunk/include/llvm/TableGen/Record.h Thu Oct  4 22:31:58 2012
@@ -1085,9 +1085,9 @@
 
   VarBitInit(TypedInit *T, unsigned B) : TI(T), Bit(B) {
     assert(T->getType() &&
-           (dynamic_cast<IntRecTy*>(T->getType()) ||
-            (dynamic_cast<BitsRecTy*>(T->getType()) &&
-             dynamic_cast<BitsRecTy*>(T->getType())->getNumBits() > B)) &&
+           (dyn_cast<IntRecTy>(T->getType()) ||
+            (dyn_cast<BitsRecTy>(T->getType()) &&
+             dyn_cast<BitsRecTy>(T->getType())->getNumBits() > B)) &&
            "Illegal VarBitInit expression!");
   }
 
@@ -1120,9 +1120,9 @@
   unsigned Element;
 
   VarListElementInit(TypedInit *T, unsigned E)
-      : TypedInit(dynamic_cast<ListRecTy*>(T->getType())->getElementType()),
+      : TypedInit(dyn_cast<ListRecTy>(T->getType())->getElementType()),
           TI(T), Element(E) {
-    assert(T->getType() && dynamic_cast<ListRecTy*>(T->getType()) &&
+    assert(T->getType() && dyn_cast<ListRecTy>(T->getType()) &&
            "Illegal VarBitInit expression!");
   }
 

Modified: llvm/trunk/lib/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=165291&r1=165290&r2=165291&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Record.cpp (original)
+++ llvm/trunk/lib/TableGen/Record.cpp Thu Oct  4 22:31:58 2012
@@ -113,9 +113,9 @@
 
 Init *BitRecTy::convertValue(TypedInit *VI) {
   RecTy *Ty = VI->getType();
-  if (dynamic_cast<BitRecTy*>(Ty) ||
-      dynamic_cast<BitsRecTy*>(Ty) ||
-      dynamic_cast<IntRecTy*>(Ty))
+  if (dyn_cast<BitRecTy>(Ty) ||
+      dyn_cast<BitsRecTy>(Ty) ||
+      dyn_cast<IntRecTy>(Ty))
     return VI;  // Accept variable if it is already of bit type!
   return 0;
 }
@@ -181,7 +181,7 @@
 }
 
 Init *BitsRecTy::convertValue(TypedInit *VI) {
-  if (Size == 1 && dynamic_cast<BitRecTy*>(VI->getType()))
+  if (Size == 1 && dyn_cast<BitRecTy>(VI->getType()))
     return BitsInit::get(VI);
 
   if (VI->getType()->typeIsConvertibleTo(this)) {
@@ -243,7 +243,7 @@
 
 
 Init *StringRecTy::convertValue(TypedInit *TI) {
-  if (dynamic_cast<StringRecTy*>(TI->getType()))
+  if (dyn_cast<StringRecTy>(TI->getType()))
     return TI;  // Accept variable if already of the right type!
   return 0;
 }
@@ -263,7 +263,7 @@
     else
       return 0;
 
-  ListRecTy *LType = dynamic_cast<ListRecTy*>(LI->getType());
+  ListRecTy *LType = dyn_cast<ListRecTy>(LI->getType());
   if (LType == 0) {
     return 0;
   }
@@ -273,7 +273,7 @@
 
 Init *ListRecTy::convertValue(TypedInit *TI) {
   // Ensure that TI is compatible with our class.
-  if (ListRecTy *LRT = dynamic_cast<ListRecTy*>(TI->getType()))
+  if (ListRecTy *LRT = dyn_cast<ListRecTy>(TI->getType()))
     if (LRT->getElementType()->typeIsConvertibleTo(getElementType()))
       return TI;
   return 0;
@@ -309,7 +309,7 @@
 }
 
 RecordRecTy *RecordRecTy::get(Record *R) {
-  return &dynamic_cast<RecordRecTy&>(*R->getDefInit()->getType());
+  return dyn_cast<RecordRecTy>(R->getDefInit()->getType());
 }
 
 std::string RecordRecTy::getAsString() const {
@@ -325,7 +325,7 @@
 
 Init *RecordRecTy::convertValue(TypedInit *TI) {
   // Ensure that TI is compatible with Rec.
-  if (RecordRecTy *RRT = dynamic_cast<RecordRecTy*>(TI->getType()))
+  if (RecordRecTy *RRT = dyn_cast<RecordRecTy>(TI->getType()))
     if (RRT->getRecord()->isSubClassOf(getRecord()) ||
         RRT->getRecord() == getRecord())
       return TI;
@@ -354,7 +354,7 @@
     return T1;
 
   // If one is a Record type, check superclasses
-  if (RecordRecTy *RecTy1 = dynamic_cast<RecordRecTy*>(T1)) {
+  if (RecordRecTy *RecTy1 = dyn_cast<RecordRecTy>(T1)) {
     // See if T2 inherits from a type T1 also inherits from
     const std::vector<Record *> &T1SuperClasses =
       RecTy1->getRecord()->getSuperClasses();
@@ -372,7 +372,7 @@
       }
     }
   }
-  if (RecordRecTy *RecTy2 = dynamic_cast<RecordRecTy*>(T2)) {
+  if (RecordRecTy *RecTy2 = dyn_cast<RecordRecTy>(T2)) {
     // See if T1 inherits from a type T2 also inherits from
     const std::vector<Record *> &T2SuperClasses =
       RecTy2->getRecord()->getSuperClasses();
@@ -599,7 +599,7 @@
 }
 
 void ListInit::Profile(FoldingSetNodeID &ID) const {
-  ListRecTy *ListType = dynamic_cast<ListRecTy *>(getType());
+  ListRecTy *ListType = dyn_cast<ListRecTy>(getType());
   assert(ListType && "Bad type for ListInit!");
   RecTy *EltTy = ListType->getElementType();
 
@@ -1039,8 +1039,8 @@
   DagInit *MHSd = dynamic_cast<DagInit*>(MHS);
   ListInit *MHSl = dynamic_cast<ListInit*>(MHS);
 
-  DagRecTy *DagType = dynamic_cast<DagRecTy*>(Type);
-  ListRecTy *ListType = dynamic_cast<ListRecTy*>(Type);
+  DagRecTy *DagType = dyn_cast<DagRecTy>(Type);
+  ListRecTy *ListType = dyn_cast<ListRecTy>(Type);
 
   OpInit *RHSo = dynamic_cast<OpInit*>(RHS);
 
@@ -1235,7 +1235,7 @@
 }
 
 RecTy *TypedInit::getFieldType(const std::string &FieldName) const {
-  RecordRecTy *RecordType = dynamic_cast<RecordRecTy *>(getType());
+  RecordRecTy *RecordType = dyn_cast<RecordRecTy>(getType());
   if (RecordType) {
     RecordVal *Field = RecordType->getRecord()->getValue(FieldName);
     if (Field) {
@@ -1247,7 +1247,7 @@
 
 Init *
 TypedInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
-  BitsRecTy *T = dynamic_cast<BitsRecTy*>(getType());
+  BitsRecTy *T = dyn_cast<BitsRecTy>(getType());
   if (T == 0) return 0;  // Cannot subscript a non-bits variable.
   unsigned NumBits = T->getNumBits();
 
@@ -1263,7 +1263,7 @@
 
 Init *
 TypedInit::convertInitListSlice(const std::vector<unsigned> &Elements) const {
-  ListRecTy *T = dynamic_cast<ListRecTy*>(getType());
+  ListRecTy *T = dyn_cast<ListRecTy>(getType());
   if (T == 0) return 0;  // Cannot subscript a non-list variable.
 
   if (Elements.size() == 1)
@@ -1336,7 +1336,7 @@
 
 
 RecTy *VarInit::getFieldType(const std::string &FieldName) const {
-  if (RecordRecTy *RTy = dynamic_cast<RecordRecTy*>(getType()))
+  if (RecordRecTy *RTy = dyn_cast<RecordRecTy>(getType()))
     if (const RecordVal *RV = RTy->getRecord()->getValue(FieldName))
       return RV->getType();
   return 0;
@@ -1344,7 +1344,7 @@
 
 Init *VarInit::getFieldInit(Record &R, const RecordVal *RV,
                             const std::string &FieldName) const {
-  if (dynamic_cast<RecordRecTy*>(getType()))
+  if (dyn_cast<RecordRecTy>(getType()))
     if (const RecordVal *Val = R.getValue(VarName)) {
       if (RV != Val && (RV || dynamic_cast<UnsetInit*>(Val->getValue())))
         return 0;
@@ -1655,7 +1655,7 @@
   const TypedInit *TypedName = dynamic_cast<const TypedInit *>(Name);
   assert(TypedName && "Record name is not typed!");
   RecTy *Type = TypedName->getType();
-  if (dynamic_cast<StringRecTy *>(Type) == 0) {
+  if (dyn_cast<StringRecTy>(Type) == 0) {
     throw TGError(getLoc(), "Record name is not a string!");
   }
 }

Modified: llvm/trunk/lib/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=165291&r1=165290&r2=165291&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)
+++ llvm/trunk/lib/TableGen/TGParser.cpp Thu Oct  4 22:31:58 2012
@@ -864,8 +864,8 @@
         return 0;
       }
       if (LHSt) {
-        ListRecTy *LType = dynamic_cast<ListRecTy*>(LHSt->getType());
-        StringRecTy *SType = dynamic_cast<StringRecTy*>(LHSt->getType());
+        ListRecTy *LType = dyn_cast<ListRecTy>(LHSt->getType());
+        StringRecTy *SType = dyn_cast<StringRecTy>(LHSt->getType());
         if (LType == 0 && SType == 0) {
           TokError("expected list or string type argumnet in unary operator");
           return 0;
@@ -897,7 +897,7 @@
           }
         } else {
           assert(LHSt && "expected list type argument in unary operator");
-          ListRecTy *LType = dynamic_cast<ListRecTy*>(LHSt->getType());
+          ListRecTy *LType = dyn_cast<ListRecTy>(LHSt->getType());
           if (LType == 0) {
             TokError("expected list type argumnet in unary operator");
             return 0;
@@ -1271,7 +1271,7 @@
     ListRecTy *GivenListTy = 0;
 
     if (ItemType != 0) {
-      ListRecTy *ListType = dynamic_cast<ListRecTy*>(ItemType);
+      ListRecTy *ListType = dyn_cast<ListRecTy>(ItemType);
       if (ListType == 0) {
         std::stringstream s;
         s << "Type mismatch for list, expected list type, got "
@@ -1723,7 +1723,7 @@
       return 0;
     }
     RecTy *ValueType = ForeachListValue->getType();
-    ListRecTy *ListType = dynamic_cast<ListRecTy *>(ValueType);
+    ListRecTy *ListType = dyn_cast<ListRecTy>(ValueType);
     if (ListType == 0) {
       TokError("Value list is not of list type");
       return 0;

Modified: llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp?rev=165291&r1=165290&r2=165291&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp Thu Oct  4 22:31:58 2012
@@ -1758,7 +1758,7 @@
     // FIXME: This need to be extended to handle instructions with custom
     // decoder methods, and operands with (simple) MIOperandInfo's.
     TypedInit *TI = dynamic_cast<TypedInit*>(NI->first);
-    RecordRecTy *Type = dynamic_cast<RecordRecTy*>(TI->getType());
+    RecordRecTy *Type = dyn_cast<RecordRecTy>(TI->getType());
     Record *TypeRecord = Type->getRecord();
     bool isReg = false;
     if (TypeRecord->isSubClassOf("RegisterOperand"))





More information about the llvm-commits mailing list