OSDN Git Service

Ugly hack! Add helper functions InsertInFlightSetEntry and
authorEvan Cheng <evan.cheng@apple.com>
Thu, 29 Jun 2006 23:57:05 +0000 (23:57 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 29 Jun 2006 23:57:05 +0000 (23:57 +0000)
RemoveInFlightSetEntry. They are used in place of direct set operators to
reduce instruction selection function stack size.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28987 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/SelectionDAG.h
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
utils/TableGen/DAGISelEmitter.cpp

index f05b5b9..473021a 100644 (file)
@@ -18,8 +18,9 @@
 #include "llvm/CodeGen/SelectionDAGNodes.h"
 #include "llvm/ADT/ilist"
 
-#include <map>
 #include <list>
+#include <map>
+#include <set>
 #include <string>
 
 namespace llvm {
@@ -429,6 +430,16 @@ public:
   static void InsertISelMapEntry(std::map<SDOperand, SDOperand> &Map,
                                  SDNode *Key, unsigned KeyResNo,
                                  SDNode *Element, unsigned ElementResNo);
+
+  /// InsertInFlightSetEntry - A helper function to insert a SDNode* to a
+  /// SDNode* set. This is added to avoid the set insertion operator from being
+  /// inlined.
+  static void InsertInFlightSetEntry(std::set<SDNode*> &Set, SDNode *N);
+
+  /// RemoveInFlightSetEntry - A helper function to remove a SDNode* from a
+  /// SDNode* set. This is added to avoid the set removal operator from being
+  /// inlined.
+  static void RemoveInFlightSetEntry(std::set<SDNode*> &Set, SDNode *N);
   
 private:
   void RemoveNodeFromCSEMaps(SDNode *N);
index f0c61e7..13f0c49 100644 (file)
@@ -3099,3 +3099,17 @@ void SelectionDAG::InsertISelMapEntry(std::map<SDOperand, SDOperand> &Map,
   Map.insert(std::make_pair(SDOperand(Key, KeyResNo),
                             SDOperand(Element, ElementResNo)));
 }
+
+/// InsertInFlightSetEntry - A helper function to insert a SDNode* to a
+/// SDNode* set. This is added to avoid the set insertion operator from being
+/// inlined.
+void SelectionDAG::InsertInFlightSetEntry(std::set<SDNode*> &Set, SDNode *N) {
+  Set.insert(N);
+}
+
+/// RemoveInFlightSetEntry - A helper function to remove a SDNode* from a
+/// SDNode* set. This is added to avoid the set removal operator from being
+/// inlined.
+void SelectionDAG::RemoveInFlightSetEntry(std::set<SDNode*> &Set, SDNode *N) {
+  Set.erase(N);
+}
index d478a1e..bf9c27a 100644 (file)
@@ -2450,14 +2450,16 @@ public:
           emitCode("if (!Match) {");
           for (std::vector<std::string>::iterator AI = InflightNodes.begin(),
                  AE = InflightNodes.end(); AI != AE; ++AI)
-            emitCode("  InFlightSet.erase(" + *AI + ".Val);");
+            emitCode("  SelectionDAG::RemoveInFlightSetEntry(InFlightSet, " +
+                     *AI + ".Val);");
           emitCode("}");
         }
 
         emitCheck("Match");
 
         for (unsigned i = 0; i < NumRes; ++i) {
-          emitCode("InFlightSet.insert(CPTmp" + utostr(i+ResNo) + ".Val);");
+          emitCode("SelectionDAG::InsertInFlightSetEntry(InFlightSet, CPTmp" +
+                   utostr(i+ResNo) + ".Val);");
           InflightNodes.push_back("CPTmp" + utostr(i+ResNo));
         }
         for (unsigned i = 0; i < NumRes; ++i) {
@@ -2579,7 +2581,8 @@ public:
           assert(!Val.empty() &&
                  "Variable referenced but not defined and not caught earlier!");
           if (Child->isLeaf() && !NodeGetComplexPattern(Child, ISE)) {
-            emitCode("InFlightSet.insert(" + Val + ".Val);");
+            emitCode("SelectionDAG::InsertInFlightSetEntry(InFlightSet, " +
+                     Val + ".Val);");
             InflightNodes.push_back(Val);
           }
         }
@@ -2616,7 +2619,8 @@ public:
         // The operands have been selected. Remove them from InFlightSet.
         for (std::vector<std::string>::iterator AI = InflightNodes.begin(),
                AE = InflightNodes.end(); AI != AE; ++AI)
-          emitCode("InFlightSet.erase(" + *AI + ".Val);");
+          emitCode("SelectionDAG::RemoveInFlightSetEntry(InFlightSet, " +
+                   *AI + ".Val);");
       }
 
       unsigned NumResults = Inst.getNumResults();