From d19938834b58240ac339fe93cda7d9b5fca415f6 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Thu, 29 Jun 2006 23:57:05 +0000 Subject: [PATCH] Ugly hack! Add helper functions InsertInFlightSetEntry and RemoveInFlightSetEntry. They are used in place of direct set operators to reduce instruction selection function stack size. llvm-svn: 28987 --- llvm/include/llvm/CodeGen/SelectionDAG.h | 13 ++++++++++++- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 14 ++++++++++++++ llvm/utils/TableGen/DAGISelEmitter.cpp | 12 ++++++++---- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h index f05b5b96bd05..473021afad9a 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAG.h +++ b/llvm/include/llvm/CodeGen/SelectionDAG.h @@ -18,8 +18,9 @@ #include "llvm/CodeGen/SelectionDAGNodes.h" #include "llvm/ADT/ilist" -#include #include +#include +#include #include namespace llvm { @@ -429,6 +430,16 @@ public: static void InsertISelMapEntry(std::map &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 &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 &Set, SDNode *N); private: void RemoveNodeFromCSEMaps(SDNode *N); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index f0c61e77a94d..13f0c491aa9f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -3099,3 +3099,17 @@ void SelectionDAG::InsertISelMapEntry(std::map &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 &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 &Set, SDNode *N) { + Set.erase(N); +} diff --git a/llvm/utils/TableGen/DAGISelEmitter.cpp b/llvm/utils/TableGen/DAGISelEmitter.cpp index d478a1e680da..bf9c27a6ac02 100644 --- a/llvm/utils/TableGen/DAGISelEmitter.cpp +++ b/llvm/utils/TableGen/DAGISelEmitter.cpp @@ -2450,14 +2450,16 @@ public: emitCode("if (!Match) {"); for (std::vector::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::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();