[TableGen] Don't convert types to strings to query what they are. Just use 'isa'
authorCraig Topper <craig.topper@gmail.com>
Thu, 28 May 2015 06:38:28 +0000 (06:38 +0000)
committerCraig Topper <craig.topper@gmail.com>
Thu, 28 May 2015 06:38:28 +0000 (06:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238398 91177308-0d34-0410-b5e6-96231b3b80d8

lib/TableGen/Record.cpp

index 9783922..9f71e13 100644 (file)
@@ -717,7 +717,7 @@ UnOpInit *UnOpInit::get(UnaryOp opc, Init *lhs, RecTy *Type) {
 Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
   switch (getOpcode()) {
   case CAST: {
-    if (getType()->getAsString() == "string") {
+    if (isa<StringRecTy>(getType())) {
       if (StringInit *LHSs = dyn_cast<StringInit>(LHS))
         return LHSs;
 
@@ -987,7 +987,7 @@ static Init *EvaluateOperation(OpInit *RHSo, Init *LHS, Init *Arg,
                                MultiClass *CurMultiClass) {
   // If this is a dag, recurse
   if (auto *TArg = dyn_cast<TypedInit>(Arg))
-    if (TArg->getType()->getAsString() == "dag")
+    if (isa<DagRecTy>(TArg->getType()))
       return ForeachHelper(LHS, Arg, RHSo, Type, CurRec, CurMultiClass);
 
   std::vector<Init *> NewOperands;