isel load folding is disabled at -fast. Now hoist the check up to the top level to...
authorEvan Cheng <evan.cheng@apple.com>
Thu, 3 Jul 2008 08:39:51 +0000 (08:39 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 3 Jul 2008 08:39:51 +0000 (08:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53096 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/DAGISelEmitter.cpp

index 890df90003a4e8fe6d6c03d9356ae4ede08c3a2c..c6cac7d16a8bd40355a62ac5b9f47e71d8210302 100644 (file)
@@ -206,6 +206,28 @@ static bool PatternHasProperty(TreePatternNode *N, SDNP Property,
   return false;
 }
 
+static std::string getOpcodeName(Record *Op, CodeGenDAGPatterns &CGP) {
+  return CGP.getSDNodeInfo(Op).getEnumName();
+}
+
+static
+bool DisablePatternForFastISel(TreePatternNode *N, CodeGenDAGPatterns &CGP) {
+  bool isStore = !N->isLeaf() &&
+    getOpcodeName(N->getOperator(), CGP) == "ISD::STORE";
+  if (!isStore && NodeHasProperty(N, SDNPHasChain, CGP))
+    return false;
+
+  bool HasChain = false;
+  for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) {
+    TreePatternNode *Child = N->getChild(i);
+    if (PatternHasProperty(Child, SDNPHasChain, CGP)) {
+      HasChain = true;
+      break;
+    }
+  }
+  return HasChain;
+}
+
 //===----------------------------------------------------------------------===//
 // Node Transformation emitter implementation.
 //
@@ -404,6 +426,9 @@ public:
       // Record input varargs info.
       NumInputRootOps = N->getNumChildren();
 
+      if (DisablePatternForFastISel(N, CGP))
+        emitCheck("!FastISel");
+
       std::string PredicateCheck;
       for (unsigned i = 0, e = Predicates->getSize(); i != e; ++i) {
         if (DefInit *Pred = dynamic_cast<DefInit*>(Predicates->getElement(i))) {
@@ -480,10 +505,8 @@ public:
           //      /        [YY]
           //      |         ^
           //     [XX]-------|
-          bool NeedCheck = false;
-          if (P != Pattern)
-            NeedCheck = true;
-          else {
+          bool NeedCheck = P != Pattern;
+          if (!NeedCheck) {
             const SDNodeInfo &PInfo = CGP.getSDNodeInfo(P->getOperator());
             NeedCheck =
               P->getOperator() == CGP.get_intrinsic_void_sdnode() ||
@@ -1548,10 +1571,6 @@ void DAGISelEmitter::EmitPatterns(std::vector<std::pair<const PatternToMatch*,
     OS << std::string(Indent-2, ' ') << "}\n";
 }
 
-static std::string getOpcodeName(Record *Op, CodeGenDAGPatterns &CGP) {
-  return CGP.getSDNodeInfo(Op).getEnumName();
-}
-
 static std::string getLegalCName(std::string OpName) {
   std::string::size_type pos = OpName.find("::");
   if (pos != std::string::npos)