A bit more tweaking

llvm-svn: 26500
This commit is contained in:
Evan Cheng 2006-03-03 06:23:43 +00:00
parent f6e846eee8
commit 5e9a695026
1 changed files with 24 additions and 6 deletions

View File

@ -43,6 +43,7 @@ struct SUnit {
int NumChainSuccsLeft; // # of chain succs not scheduled. int NumChainSuccsLeft; // # of chain succs not scheduled.
int Priority1; // Scheduling priority 1. int Priority1; // Scheduling priority 1.
int Priority2; // Scheduling priority 2. int Priority2; // Scheduling priority 2.
bool isTwoAddress; // Is a two-address instruction.
bool isDefNUseOperand; // Is a def&use operand. bool isDefNUseOperand; // Is a def&use operand.
unsigned Latency; // Node latency. unsigned Latency; // Node latency.
unsigned CycleBound; // Upper/lower cycle to be scheduled at. unsigned CycleBound; // Upper/lower cycle to be scheduled at.
@ -52,7 +53,8 @@ struct SUnit {
SUnit(SDNode *node) SUnit(SDNode *node)
: Node(node), NumPredsLeft(0), NumSuccsLeft(0), : Node(node), NumPredsLeft(0), NumSuccsLeft(0),
NumChainPredsLeft(0), NumChainSuccsLeft(0), NumChainPredsLeft(0), NumChainSuccsLeft(0),
Priority1(INT_MIN), Priority2(INT_MIN), isDefNUseOperand(false), Priority1(INT_MIN), Priority2(INT_MIN),
isTwoAddress(false), isDefNUseOperand(false),
Latency(0), CycleBound(0), Slot(0), Next(NULL) {} Latency(0), CycleBound(0), Slot(0), Next(NULL) {}
void dump(const SelectionDAG *G, bool All=true) const; void dump(const SelectionDAG *G, bool All=true) const;
@ -120,6 +122,20 @@ struct ls_rr_sort : public std::binary_function<SUnit*, SUnit*, bool> {
bool RFloater = (right->Preds.size() == 0); bool RFloater = (right->Preds.size() == 0);
int LBonus = (int)left ->isDefNUseOperand; int LBonus = (int)left ->isDefNUseOperand;
int RBonus = (int)right->isDefNUseOperand; int RBonus = (int)right->isDefNUseOperand;
// Special tie breaker: if two nodes share a operand, the one that
// use it as a def&use operand is preferred.
if (left->isTwoAddress && !right->isTwoAddress) {
SDNode *DUNode = left->Node->getOperand(0).Val;
if (DUNode->isOperand(right->Node))
LBonus++;
}
if (!left->isTwoAddress && right->isTwoAddress) {
SDNode *DUNode = right->Node->getOperand(0).Val;
if (DUNode->isOperand(left->Node))
RBonus++;
}
int LPriority1 = left ->Priority1 - LBonus; int LPriority1 = left ->Priority1 - LBonus;
int RPriority1 = right->Priority1 - RBonus; int RPriority1 = right->Priority1 - RBonus;
int LPriority2 = left ->Priority2 + LBonus; int LPriority2 = left ->Priority2 + LBonus;
@ -138,8 +154,6 @@ struct ls_rr_sort : public std::binary_function<SUnit*, SUnit*, bool> {
else if (LPriority1 == RPriority1) else if (LPriority1 == RPriority1)
if (left->CycleBound > right->CycleBound) if (left->CycleBound > right->CycleBound)
return true; return true;
else
return left->Node->getNodeDepth() < right->Node->getNodeDepth();
return false; return false;
} }
@ -238,6 +252,9 @@ void ScheduleDAGList::ReleasePred(SUnit *PredSU, bool isChain) {
/// its predecessors. If a predecessor pending count is zero, add it to the /// its predecessors. If a predecessor pending count is zero, add it to the
/// Available queue. /// Available queue.
void ScheduleDAGList::ScheduleNode(SUnit *SU) { void ScheduleDAGList::ScheduleNode(SUnit *SU) {
DEBUG(std::cerr << "*** Scheduling: ");
DEBUG(SU->dump(&DAG, false));
Sequence.push_back(SU); Sequence.push_back(SU);
SU->Slot = CurrCycle; SU->Slot = CurrCycle;
@ -283,8 +300,6 @@ void ScheduleDAGList::ListSchedule() {
for (unsigned i = 0, e = NotReady.size(); i != e; ++i) for (unsigned i = 0, e = NotReady.size(); i != e; ++i)
Available.push(NotReady[i]); Available.push(NotReady[i]);
DEBUG(std::cerr << "*** Scheduling: ");
DEBUG(CurrNode->dump(&DAG, false));
ScheduleNode(CurrNode); ScheduleNode(CurrNode);
} }
@ -403,6 +418,9 @@ void ScheduleDAGList::BuildSchedUnits() {
SDNode *N = SU->Node; SDNode *N = SU->Node;
NodeInfo *NI = getNI(N); NodeInfo *NI = getNI(N);
if (N->isTargetOpcode() && TII->isTwoAddrInstr(N->getTargetOpcode()))
SU->isTwoAddress = true;
if (NI->isInGroup()) { if (NI->isInGroup()) {
// Find all predecessors (of the group). // Find all predecessors (of the group).
NodeGroupOpIterator NGOI(NI); NodeGroupOpIterator NGOI(NI);
@ -446,7 +464,7 @@ void ScheduleDAGList::BuildSchedUnits() {
SU->NumPredsLeft++; SU->NumPredsLeft++;
if (OpSU->Succs.insert(SU).second) if (OpSU->Succs.insert(SU).second)
OpSU->NumSuccsLeft++; OpSU->NumSuccsLeft++;
if (j == 0 && TII->isTwoAddrInstr(N->getTargetOpcode())) if (j == 0 && SU->isTwoAddress)
OpSU->isDefNUseOperand = true; OpSU->isDefNUseOperand = true;
} }
} }