[llvm-commits] [llvm] r61249 - /llvm/trunk/utils/TableGen/DAGISelEmitter.cpp

Dan Gohman gohman at apple.com
Fri Dec 19 10:13:48 PST 2008


Author: djg
Date: Fri Dec 19 12:13:39 2008
New Revision: 61249

URL: http://llvm.org/viewvc/llvm-project?rev=61249&view=rev
Log:
Use dyn_cast intead of isa + cast in the generated DAGISel code. This
reduces the amount of code slightly when assertions are enabled.

Modified:
    llvm/trunk/utils/TableGen/DAGISelEmitter.cpp

Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=61249&r1=61248&r2=61249&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Fri Dec 19 12:13:39 2008
@@ -583,11 +583,14 @@
           emitInit("SDValue " + RootName + "1" + " = " +
                    RootName + ".getOperand(" + utostr(1) + ");");
 
-          emitCheck("isa<ConstantSDNode>(" + RootName + "1)");
+          unsigned NTmp = TmpNo++;
+          emitCode("ConstantSDNode *Tmp" + utostr(NTmp) +
+                   " = dyn_cast<ConstantSDNode>(" + RootName + "1);");
+          emitCheck("Tmp" + utostr(NTmp));
           const char *MaskPredicate = N->getOperator()->getName() == "or"
             ? "CheckOrMask(" : "CheckAndMask(";
-          emitCheck(MaskPredicate + RootName + "0, cast<ConstantSDNode>(" +
-                    RootName + "1), INT64_C(" + itostr(II->getValue()) + "))");
+          emitCheck(MaskPredicate + RootName + "0, Tmp" + utostr(NTmp) +
+                    ", INT64_C(" + itostr(II->getValue()) + "))");
           
           EmitChildMatchCode(N->getChild(0), N, RootName + utostr(0), RootName,
                              ChainSuffix + utostr(0), FoundChain);
@@ -738,11 +741,14 @@
                     ".getNode())");
       } else if (IntInit *II =
                  dynamic_cast<IntInit*>(Child->getLeafValue())) {
-        emitCheck("isa<ConstantSDNode>(" + RootName + ")");
+        unsigned NTmp = TmpNo++;
+        emitCode("ConstantSDNode *Tmp"+ utostr(NTmp) +
+                 " = dyn_cast<ConstantSDNode>("+
+                 RootName + ");");
+        emitCheck("Tmp" + utostr(NTmp));
         unsigned CTmp = TmpNo++;
-        emitCode("int64_t CN"+utostr(CTmp)+" = cast<ConstantSDNode>("+
-                 RootName + ")->getSExtValue();");
-        
+        emitCode("int64_t CN"+ utostr(CTmp) +
+                 " = Tmp" + utostr(NTmp) + "->getSExtValue();");
         emitCheck("CN" + utostr(CTmp) + " == "
                   "INT64_C(" +itostr(II->getValue()) + ")");
       } else {





More information about the llvm-commits mailing list