Changes in directory llvm/lib/CodeGen/SelectionDAG:
ScheduleDAG.cpp updated: 1.38 -> 1.39 --- Log message: 1. Embed and not inherit vector for NodeGroup. 2. Iterate operands and not uses (performance.) 3. Some long pending comment changes. --- Diffs of the changes: (+39 -20) ScheduleDAG.cpp | 59 +++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 39 insertions(+), 20 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.38 llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.39 --- llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.38 Sun Oct 30 12:54:27 2005 +++ llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp Mon Oct 31 06:49:09 2005 @@ -2,7 +2,7 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by Chris Lattner and is distributed under the +// This file was developed by James M. Laskey and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// @@ -192,15 +192,17 @@ // Forward class NodeInfo; -typedef std::vector<NodeInfo *> NIVector; -typedef std::vector<NodeInfo *>::iterator NIIterator; +typedef NodeInfo *NodeInfoPtr; +typedef std::vector<NodeInfoPtr> NIVector; +typedef std::vector<NodeInfoPtr>::iterator NIIterator; //===----------------------------------------------------------------------===// /// /// Node group - This struct is used to manage flagged node groups. /// -class NodeGroup : public NIVector { +class NodeGroup { private: + NIVector Members; // Group member nodes int Pending; // Number of visits pending before // adding to order @@ -209,10 +211,24 @@ NodeGroup() : Pending(0) {} // Accessors - inline NodeInfo *getLeader() { return empty() ? NULL : front(); } + inline NodeInfo *getLeader() { + return Members.empty() ? NULL : Members.front(); + } inline int getPending() const { return Pending; } inline void setPending(int P) { Pending = P; } inline int addPending(int I) { return Pending += I; } + + // Pass thru + inline bool group_empty() { return Members.empty(); } + inline NIIterator group_begin() { return Members.begin(); } + inline NIIterator group_end() { return Members.end(); } + inline void group_push_back(const NodeInfoPtr &NI) { Members.push_back(NI); } + inline NIIterator group_insert(NIIterator Pos, const NodeInfoPtr &NI) { + return Members.insert(Pos, NI); + } + inline void group_insert(NIIterator Pos, NIIterator First, NIIterator Last) { + Members.insert(Pos, First, Last); + } static void Add(NodeInfo *D, NodeInfo *U); static unsigned CountInternalUses(NodeInfo *D, NodeInfo *U); @@ -257,7 +273,7 @@ // Accessors inline bool isInGroup() const { - assert(!Group || !Group->empty() && "Group with no members"); + assert(!Group || !Group->group_empty() && "Group with no members"); return Group != NULL; } inline bool isGroupLeader() const { @@ -298,8 +314,8 @@ if (N->isInGroup()) { // get Group NodeGroup *Group = NI->Group; - NGI = Group->begin(); - NGE = Group->end(); + NGI = Group->group_begin(); + NGE = Group->group_end(); // Prevent this node from being used (will be in members list NI = NULL; } @@ -491,7 +507,8 @@ } } // Merge the two lists - DGroup->insert(DGroup->end(), UGroup->begin(), UGroup->end()); + DGroup->group_insert(DGroup->group_end(), + UGroup->group_begin(), UGroup->group_end()); } else if (DGroup) { // Make user member of definers group U->Group = DGroup; @@ -503,7 +520,7 @@ // Remove internal edges DGroup->addPending(-CountInternalUses(DNI, U)); } - DGroup->push_back(U); + DGroup->group_push_back(U); } else if (UGroup) { // Make definer member of users group D->Group = UGroup; @@ -515,13 +532,13 @@ // Remove internal edges UGroup->addPending(-CountInternalUses(D, UNI)); } - UGroup->insert(UGroup->begin(), D); + UGroup->group_insert(UGroup->group_begin(), D); } else { D->Group = U->Group = DGroup = new NodeGroup(); DGroup->addPending(D->Node->use_size() + U->Node->use_size() - CountInternalUses(D, U)); - DGroup->push_back(D); - DGroup->push_back(U); + DGroup->group_push_back(D); + DGroup->group_push_back(U); } } @@ -529,10 +546,11 @@ /// unsigned NodeGroup::CountInternalUses(NodeInfo *D, NodeInfo *U) { unsigned N = 0; - for (SDNode:: use_iterator UI = D->Node->use_begin(), - E = D->Node->use_end(); UI != E; UI++) { - if (*UI == U->Node) N++; + for (unsigned M = U->Node->getNumOperands(); 0 < M--;) { + SDOperand Op = U->Node->getOperand(M); + if (Op.Val == D->Node) N++; } + return N; } //===----------------------------------------------------------------------===// @@ -743,7 +761,7 @@ unsigned ResourceSet = 0; bool IsCall = false; - for (NIIterator NGI = Group->begin(), NGE = Group->end(); + for (NIIterator NGI = Group->group_begin(), NGE = Group->group_end(); NGI != NGE; NGI++) { NodeInfo* NGNI = *NGI; Latency += NGNI->Latency; @@ -798,7 +816,8 @@ } /// isWeakDependency Return true if node A produces a result that will -/// conflict with operands of B. +/// conflict with operands of B. It is assumed that we have called +/// isStrongDependency prior. bool SimpleSched::isWeakDependency(NodeInfo *A, NodeInfo *B) { // TODO check for conflicting real registers and aliases #if 0 // FIXME - Since we are in SSA form and not checking register aliasing @@ -1225,7 +1244,7 @@ std::cerr << "\n"; if (NI->isGroupLeader()) { NodeGroup *Group = NI->Group; - for (NIIterator NII = Group->begin(), E = Group->end(); + for (NIIterator NII = Group->group_begin(), E = Group->group_end(); NII != E; NII++) { std::cerr << " "; printSI(std::cerr, *NII); @@ -1269,7 +1288,7 @@ O << "\n"; if (NI->isGroupLeader()) { NodeGroup *Group = NI->Group; - for (NIIterator NII = Group->begin(), E = Group->end(); + for (NIIterator NII = Group->group_begin(), E = Group->group_end(); NII != E; NII++) { O << " "; printSI(O, *NII); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits