-namespace {
-
-/// SUnit - Scheduling unit. It's an wrapper around either a single SDNode or a
-/// group of nodes flagged together.
-struct SUnit {
- SDNode *Node; // Representative node.
- std::vector<SDNode*> FlaggedNodes; // All nodes flagged to Node.
- std::set<SUnit*> Preds; // All real predecessors.
- std::set<SUnit*> ChainPreds; // All chain predecessors.
- std::set<SUnit*> Succs; // All real successors.
- std::set<SUnit*> ChainSuccs; // All chain successors.
- int NumPredsLeft; // # of preds not scheduled.
- int NumSuccsLeft; // # of succs not scheduled.
- int NumChainPredsLeft; // # of chain preds not scheduled.
- int NumChainSuccsLeft; // # of chain succs not scheduled.
- int Priority1; // Scheduling priority 1.
- int Priority2; // Scheduling priority 2.
- bool isTwoAddress; // Is a two-address instruction.
- bool isDefNUseOperand; // Is a def&use operand.
- unsigned Latency; // Node latency.
- unsigned CycleBound; // Upper/lower cycle to be scheduled at.
- unsigned Slot; // Cycle node is scheduled at.
- SUnit *Next;
-
- SUnit(SDNode *node)
- : Node(node), NumPredsLeft(0), NumSuccsLeft(0),
- NumChainPredsLeft(0), NumChainSuccsLeft(0),
- Priority1(INT_MIN), Priority2(INT_MIN),
- isTwoAddress(false), isDefNUseOperand(false),
- Latency(0), CycleBound(0), Slot(0), Next(NULL) {}
-
- void dump(const SelectionDAG *G, bool All=true) const;
-};
-
-void SUnit::dump(const SelectionDAG *G, bool All) const {
- std::cerr << "SU: ";
- Node->dump(G);
- std::cerr << "\n";
- if (FlaggedNodes.size() != 0) {
- for (unsigned i = 0, e = FlaggedNodes.size(); i != e; i++) {
- std::cerr << " ";
- FlaggedNodes[i]->dump(G);
- std::cerr << "\n";
- }
- }
-
- if (All) {
- std::cerr << "# preds left : " << NumPredsLeft << "\n";
- std::cerr << "# succs left : " << NumSuccsLeft << "\n";
- std::cerr << "# chain preds left : " << NumChainPredsLeft << "\n";
- std::cerr << "# chain succs left : " << NumChainSuccsLeft << "\n";
- std::cerr << "Latency : " << Latency << "\n";
- std::cerr << "Priority : " << Priority1 << " , " << Priority2 << "\n";
-
- if (Preds.size() != 0) {
- std::cerr << "Predecessors :\n";
- for (std::set<SUnit*>::const_iterator I = Preds.begin(),
- E = Preds.end(); I != E; ++I) {
- std::cerr << " ";
- (*I)->dump(G, false);
- }
- }
- if (ChainPreds.size() != 0) {
- std::cerr << "Chained Preds :\n";
- for (std::set<SUnit*>::const_iterator I = ChainPreds.begin(),
- E = ChainPreds.end(); I != E; ++I) {
- std::cerr << " ";
- (*I)->dump(G, false);
- }
- }
- if (Succs.size() != 0) {
- std::cerr << "Successors :\n";
- for (std::set<SUnit*>::const_iterator I = Succs.begin(),
- E = Succs.end(); I != E; ++I) {
- std::cerr << " ";
- (*I)->dump(G, false);
- }
- }
- if (ChainSuccs.size() != 0) {
- std::cerr << "Chained succs :\n";
- for (std::set<SUnit*>::const_iterator I = ChainSuccs.begin(),
- E = ChainSuccs.end(); I != E; ++I) {
- std::cerr << " ";
- (*I)->dump(G, false);
- }
- }
- }
-}