/// Node group - This struct is used to manage flagged node groups.
///
class NodeGroup {
+ public:
+ NodeGroup *Next;
private:
NIVector Members; // Group member nodes
NodeInfo *Dominator; // Node with highest latency
public:
// Ctor.
- NodeGroup() : Dominator(NULL), Pending(0) {}
+ NodeGroup() : Next(NULL), Dominator(NULL), Pending(0) {}
// Accessors
inline void setDominator(NodeInfo *D) { Dominator = D; }
bool HasGroups; // True if there are any groups
NodeInfo *Info; // Info for nodes being scheduled
NIVector Ordering; // Emit ordering of nodes
+ NodeGroup *HeadNG, *TailNG; // Keep track of allocated NodeGroups
ScheduleDAG(SchedHeuristics hstc, SelectionDAG &dag, MachineBasicBlock *bb,
const TargetMachine &tm)
- : Heuristic(hstc), DAG(dag), BB(bb), TM(tm),
- NodeCount(0), HasGroups(false), Info(NULL) {}
-
- virtual ~ScheduleDAG() {};
+ : Heuristic(hstc), DAG(dag), BB(bb), TM(tm), NodeCount(0),
+ HasGroups(false), Info(NULL), HeadNG(NULL), TailNG(NULL) {}
+
+ virtual ~ScheduleDAG() {
+ if (Info)
+ delete[] Info;
+
+ NodeGroup *NG = HeadNG;
+ while (NG) {
+ NodeGroup *NextSU = NG->Next;
+ delete NG;
+ NG = NextSU;
+ }
+ };
/// Run - perform scheduling.
///
/// IdentifyGroups - Put flagged nodes into groups.
///
void IdentifyGroups();
+
+ void AddToGroup(NodeInfo *D, NodeInfo *U);
};
/// createSimpleDAGScheduler - This creates a simple two pass instruction
// No more flags to walk
if (Op.getValueType() != MVT::Flag) break;
// Add to node group
- NodeGroup::Add(getNI(Op.Val), NI);
+ AddToGroup(getNI(Op.Val), NI);
// Let everyone else know
HasGroups = true;
}
//===----------------------------------------------------------------------===//
/// Add - Adds a definer and user pair to a node group.
///
-void NodeGroup::Add(NodeInfo *D, NodeInfo *U) {
+void ScheduleDAG::AddToGroup(NodeInfo *D, NodeInfo *U) {
// Get current groups
NodeGroup *DGroup = D->Group;
NodeGroup *UGroup = U->Group;
CountInternalUses(D, U));
DGroup->group_push_back(D);
DGroup->group_push_back(U);
+
+ if (HeadNG == NULL)
+ HeadNG = DGroup;
+ if (TailNG != NULL)
+ TailNG->Next = DGroup;
+ TailNG = DGroup;
}
}