mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-22 10:36:10 +00:00
Use struct SDep instead of std::pair for SUnit pred and succ lists. First step
in tracking physical register output dependencies. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42125 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dcfa73fe3c
commit
713a98dee8
include/llvm/CodeGen
lib/CodeGen/SelectionDAG
@ -22,6 +22,7 @@
|
||||
|
||||
namespace llvm {
|
||||
struct InstrStage;
|
||||
struct SUnit;
|
||||
class MachineConstantPool;
|
||||
class MachineModuleInfo;
|
||||
class MachineInstr;
|
||||
@ -74,7 +75,18 @@ namespace llvm {
|
||||
virtual void EmitNoop() {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// SDep - Scheduling dependency. It keeps track of dependent nodes,
|
||||
/// cost of the depdenency, etc.
|
||||
struct SDep {
|
||||
SUnit *Dep; // Dependent - either a predecessor or a successor.
|
||||
bool isCtrl; // True iff it's a control dependency.
|
||||
unsigned PhyReg; // If non-zero, this dep is a phy register dependency.
|
||||
int Cost; // Cost of the dependency.
|
||||
SDep(SUnit *d, bool c, unsigned r, int t)
|
||||
: Dep(d), isCtrl(c), PhyReg(r), Cost(t) {}
|
||||
};
|
||||
|
||||
/// SUnit - Scheduling unit. It's an wrapper around either a single SDNode or
|
||||
/// a group of nodes flagged together.
|
||||
struct SUnit {
|
||||
@ -83,15 +95,13 @@ namespace llvm {
|
||||
|
||||
// Preds/Succs - The SUnits before/after us in the graph. The boolean value
|
||||
// is true if the edge is a token chain edge, false if it is a value edge.
|
||||
SmallVector<std::pair<SUnit*,bool>, 4> Preds; // All sunit predecessors.
|
||||
SmallVector<std::pair<SUnit*,bool>, 4> Succs; // All sunit successors.
|
||||
SmallVector<SDep, 4> Preds; // All sunit predecessors.
|
||||
SmallVector<SDep, 4> Succs; // All sunit successors.
|
||||
|
||||
typedef SmallVector<std::pair<SUnit*,bool>, 4>::iterator pred_iterator;
|
||||
typedef SmallVector<std::pair<SUnit*,bool>, 4>::iterator succ_iterator;
|
||||
typedef SmallVector<std::pair<SUnit*,bool>, 4>::const_iterator
|
||||
const_pred_iterator;
|
||||
typedef SmallVector<std::pair<SUnit*,bool>, 4>::const_iterator
|
||||
const_succ_iterator;
|
||||
typedef SmallVector<SDep, 4>::iterator pred_iterator;
|
||||
typedef SmallVector<SDep, 4>::iterator succ_iterator;
|
||||
typedef SmallVector<SDep, 4>::const_iterator const_pred_iterator;
|
||||
typedef SmallVector<SDep, 4>::const_iterator const_succ_iterator;
|
||||
|
||||
short NumPreds; // # of preds.
|
||||
short NumSuccs; // # of sucss.
|
||||
@ -121,21 +131,21 @@ namespace llvm {
|
||||
|
||||
/// addPred - This adds the specified node as a pred of the current node if
|
||||
/// not already. This returns true if this is a new pred.
|
||||
bool addPred(SUnit *N, bool isChain) {
|
||||
bool addPred(SUnit *N, bool isCtrl, unsigned PhyReg = 0, int Cost = 1) {
|
||||
for (unsigned i = 0, e = Preds.size(); i != e; ++i)
|
||||
if (Preds[i].first == N && Preds[i].second == isChain)
|
||||
if (Preds[i].Dep == N && Preds[i].isCtrl == isCtrl)
|
||||
return false;
|
||||
Preds.push_back(std::make_pair(N, isChain));
|
||||
Preds.push_back(SDep(N, isCtrl, PhyReg, Cost));
|
||||
return true;
|
||||
}
|
||||
|
||||
/// addSucc - This adds the specified node as a succ of the current node if
|
||||
/// not already. This returns true if this is a new succ.
|
||||
bool addSucc(SUnit *N, bool isChain) {
|
||||
bool addSucc(SUnit *N, bool isCtrl, unsigned PhyReg = 0, int Cost = 1) {
|
||||
for (unsigned i = 0, e = Succs.size(); i != e; ++i)
|
||||
if (Succs[i].first == N && Succs[i].second == isChain)
|
||||
if (Succs[i].Dep == N && Succs[i].isCtrl == isCtrl)
|
||||
return false;
|
||||
Succs.push_back(std::make_pair(N, isChain));
|
||||
Succs.push_back(SDep(N, isCtrl, PhyReg, Cost));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -340,7 +350,7 @@ namespace llvm {
|
||||
}
|
||||
|
||||
pointer operator*() const {
|
||||
return Node->Preds[Operand].first;
|
||||
return Node->Preds[Operand].Dep;
|
||||
}
|
||||
pointer operator->() const { return operator*(); }
|
||||
|
||||
@ -359,7 +369,7 @@ namespace llvm {
|
||||
|
||||
unsigned getOperand() const { return Operand; }
|
||||
const SUnit *getNode() const { return Node; }
|
||||
bool isChain() const { return Node->Preds[Operand].second; }
|
||||
bool isCtrlDep() const { return Node->Preds[Operand].isCtrl; }
|
||||
};
|
||||
|
||||
template <> struct GraphTraits<SUnit*> {
|
||||
|
@ -193,7 +193,7 @@ void ScheduleDAG::CalculateDepths() {
|
||||
SU->Depth = Depth;
|
||||
for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
|
||||
I != E; ++I)
|
||||
WorkList.push_back(std::make_pair(I->first, Depth+1));
|
||||
WorkList.push_back(std::make_pair(I->Dep, Depth+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -211,7 +211,7 @@ void ScheduleDAG::CalculateHeights() {
|
||||
SU->Height = Height;
|
||||
for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
|
||||
I != E; ++I)
|
||||
WorkList.push_back(std::make_pair(I->first, Height+1));
|
||||
WorkList.push_back(std::make_pair(I->Dep, Height+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -865,22 +865,22 @@ void SUnit::dumpAll(const SelectionDAG *G) const {
|
||||
cerr << " Predecessors:\n";
|
||||
for (SUnit::const_succ_iterator I = Preds.begin(), E = Preds.end();
|
||||
I != E; ++I) {
|
||||
if (I->second)
|
||||
if (I->isCtrl)
|
||||
cerr << " ch #";
|
||||
else
|
||||
cerr << " val #";
|
||||
cerr << I->first << " - SU(" << I->first->NodeNum << ")\n";
|
||||
cerr << I->Dep << " - SU(" << I->Dep->NodeNum << ")\n";
|
||||
}
|
||||
}
|
||||
if (Succs.size() != 0) {
|
||||
cerr << " Successors:\n";
|
||||
for (SUnit::const_succ_iterator I = Succs.begin(), E = Succs.end();
|
||||
I != E; ++I) {
|
||||
if (I->second)
|
||||
if (I->isCtrl)
|
||||
cerr << " ch #";
|
||||
else
|
||||
cerr << " val #";
|
||||
cerr << I->first << " - SU(" << I->first->NodeNum << ")\n";
|
||||
cerr << I->Dep << " - SU(" << I->Dep->NodeNum << ")\n";
|
||||
}
|
||||
}
|
||||
cerr << "\n";
|
||||
|
@ -134,9 +134,9 @@ void ScheduleDAGList::ReleaseSucc(SUnit *SuccSU, bool isChain) {
|
||||
// If this is a token edge, we don't need to wait for the latency of the
|
||||
// preceeding instruction (e.g. a long-latency load) unless there is also
|
||||
// some other data dependence.
|
||||
SUnit &Pred = *I->first;
|
||||
SUnit &Pred = *I->Dep;
|
||||
unsigned PredDoneCycle = Pred.Cycle;
|
||||
if (!I->second)
|
||||
if (!I->isCtrl)
|
||||
PredDoneCycle += Pred.Latency;
|
||||
else if (Pred.Latency)
|
||||
PredDoneCycle += 1;
|
||||
@ -161,7 +161,7 @@ void ScheduleDAGList::ScheduleNodeTopDown(SUnit *SU, unsigned CurCycle) {
|
||||
// Bottom up: release successors.
|
||||
for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
|
||||
I != E; ++I)
|
||||
ReleaseSucc(I->first, I->second);
|
||||
ReleaseSucc(I->Dep, I->isCtrl);
|
||||
}
|
||||
|
||||
/// ListScheduleTopDown - The main loop of list scheduling for top-down
|
||||
@ -436,7 +436,7 @@ int LatencyPriorityQueue::CalcLatency(const SUnit &SU) {
|
||||
int MaxSuccLatency = 0;
|
||||
for (SUnit::const_succ_iterator I = SU.Succs.begin(), E = SU.Succs.end();
|
||||
I != E; ++I)
|
||||
MaxSuccLatency = std::max(MaxSuccLatency, CalcLatency(*I->first));
|
||||
MaxSuccLatency = std::max(MaxSuccLatency, CalcLatency(*I->Dep));
|
||||
|
||||
return Latency = MaxSuccLatency + SU.Latency;
|
||||
}
|
||||
@ -456,7 +456,7 @@ SUnit *LatencyPriorityQueue::getSingleUnscheduledPred(SUnit *SU) {
|
||||
SUnit *OnlyAvailablePred = 0;
|
||||
for (SUnit::const_pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
|
||||
I != E; ++I) {
|
||||
SUnit &Pred = *I->first;
|
||||
SUnit &Pred = *I->Dep;
|
||||
if (!Pred.isScheduled) {
|
||||
// We found an available, but not scheduled, predecessor. If it's the
|
||||
// only one we have found, keep track of it... otherwise give up.
|
||||
@ -475,7 +475,7 @@ void LatencyPriorityQueue::push_impl(SUnit *SU) {
|
||||
unsigned NumNodesBlocking = 0;
|
||||
for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
|
||||
I != E; ++I)
|
||||
if (getSingleUnscheduledPred(I->first) == SU)
|
||||
if (getSingleUnscheduledPred(I->Dep) == SU)
|
||||
++NumNodesBlocking;
|
||||
NumNodesSolelyBlocking[SU->NodeNum] = NumNodesBlocking;
|
||||
|
||||
@ -490,7 +490,7 @@ void LatencyPriorityQueue::push_impl(SUnit *SU) {
|
||||
void LatencyPriorityQueue::ScheduledNode(SUnit *SU) {
|
||||
for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
|
||||
I != E; ++I)
|
||||
AdjustPriorityOfUnscheduledPreds(I->first);
|
||||
AdjustPriorityOfUnscheduledPreds(I->Dep);
|
||||
}
|
||||
|
||||
/// AdjustPriorityOfUnscheduledPreds - One of the predecessors of SU was just
|
||||
|
@ -157,8 +157,8 @@ void ScheduleDAGRRList::CommuteNodesToReducePressure() {
|
||||
|
||||
for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
|
||||
I != E; ++I) {
|
||||
if (!I->second)
|
||||
OperandSeen.insert(I->first);
|
||||
if (!I->isCtrl)
|
||||
OperandSeen.insert(I->Dep);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -214,7 +214,7 @@ void ScheduleDAGRRList::ScheduleNodeBottomUp(SUnit *SU, unsigned CurCycle) {
|
||||
// Bottom up: release predecessors
|
||||
for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
|
||||
I != E; ++I)
|
||||
ReleasePred(I->first, I->second, CurCycle);
|
||||
ReleasePred(I->Dep, I->isCtrl, CurCycle);
|
||||
SU->isScheduled = true;
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ void ScheduleDAGRRList::ScheduleNodeTopDown(SUnit *SU, unsigned CurCycle) {
|
||||
// Top down: release successors
|
||||
for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
|
||||
I != E; ++I)
|
||||
ReleaseSucc(I->first, I->second, CurCycle);
|
||||
ReleaseSucc(I->Dep, I->isCtrl, CurCycle);
|
||||
SU->isScheduled = true;
|
||||
}
|
||||
|
||||
@ -584,11 +584,11 @@ static unsigned closestSucc(const SUnit *SU) {
|
||||
unsigned MaxCycle = 0;
|
||||
for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
|
||||
I != E; ++I) {
|
||||
unsigned Cycle = I->first->Cycle;
|
||||
unsigned Cycle = I->Dep->Cycle;
|
||||
// If there are bunch of CopyToRegs stacked up, they should be considered
|
||||
// to be at the same position.
|
||||
if (I->first->Node->getOpcode() == ISD::CopyToReg)
|
||||
Cycle = closestSucc(I->first)+1;
|
||||
if (I->Dep->Node->getOpcode() == ISD::CopyToReg)
|
||||
Cycle = closestSucc(I->Dep)+1;
|
||||
if (Cycle > MaxCycle)
|
||||
MaxCycle = Cycle;
|
||||
}
|
||||
@ -602,14 +602,14 @@ static unsigned calcMaxScratches(const SUnit *SU) {
|
||||
unsigned Scratches = 0;
|
||||
for (SUnit::const_pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
|
||||
I != E; ++I) {
|
||||
if (I->second) continue; // ignore chain preds
|
||||
if (I->first->Node->getOpcode() != ISD::CopyFromReg)
|
||||
if (I->isCtrl) continue; // ignore chain preds
|
||||
if (I->Dep->Node->getOpcode() != ISD::CopyFromReg)
|
||||
Scratches++;
|
||||
}
|
||||
for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
|
||||
I != E; ++I) {
|
||||
if (I->second) continue; // ignore chain succs
|
||||
if (I->first->Node->getOpcode() != ISD::CopyToReg)
|
||||
if (I->isCtrl) continue; // ignore chain succs
|
||||
if (I->Dep->Node->getOpcode() != ISD::CopyToReg)
|
||||
Scratches += 10;
|
||||
}
|
||||
return Scratches;
|
||||
@ -691,7 +691,7 @@ static void isReachable(SUnit *SU, SUnit *TargetSU,
|
||||
|
||||
for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end(); I != E;
|
||||
++I)
|
||||
isReachable(I->first, TargetSU, Visited, Reached);
|
||||
isReachable(I->Dep, TargetSU, Visited, Reached);
|
||||
}
|
||||
|
||||
static bool isReachable(SUnit *SU, SUnit *TargetSU) {
|
||||
@ -744,8 +744,8 @@ void BURegReductionPriorityQueue<SF>::AddPseudoTwoAddrDeps() {
|
||||
if (!DUSU) continue;
|
||||
for (SUnit::succ_iterator I = DUSU->Succs.begin(),E = DUSU->Succs.end();
|
||||
I != E; ++I) {
|
||||
if (I->second) continue;
|
||||
SUnit *SuccSU = I->first;
|
||||
if (I->isCtrl) continue;
|
||||
SUnit *SuccSU = I->Dep;
|
||||
if (SuccSU != SU &&
|
||||
(!canClobber(SuccSU, DUSU) ||
|
||||
(!SU->isCommutable && SuccSU->isCommutable))){
|
||||
@ -776,13 +776,13 @@ CalcNodeSethiUllmanNumber(const SUnit *SU) {
|
||||
unsigned Extra = 0;
|
||||
for (SUnit::const_pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
|
||||
I != E; ++I) {
|
||||
if (I->second) continue; // ignore chain preds
|
||||
SUnit *PredSU = I->first;
|
||||
if (I->isCtrl) continue; // ignore chain preds
|
||||
SUnit *PredSU = I->Dep;
|
||||
unsigned PredSethiUllman = CalcNodeSethiUllmanNumber(PredSU);
|
||||
if (PredSethiUllman > SethiUllmanNumber) {
|
||||
SethiUllmanNumber = PredSethiUllman;
|
||||
Extra = 0;
|
||||
} else if (PredSethiUllman == SethiUllmanNumber && !I->second)
|
||||
} else if (PredSethiUllman == SethiUllmanNumber && !I->isCtrl)
|
||||
Extra++;
|
||||
}
|
||||
|
||||
@ -808,10 +808,10 @@ static unsigned SumOfUnscheduledPredsOfSuccs(const SUnit *SU) {
|
||||
unsigned Sum = 0;
|
||||
for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
|
||||
I != E; ++I) {
|
||||
SUnit *SuccSU = I->first;
|
||||
SUnit *SuccSU = I->Dep;
|
||||
for (SUnit::const_pred_iterator II = SuccSU->Preds.begin(),
|
||||
EE = SuccSU->Preds.end(); II != EE; ++II) {
|
||||
SUnit *PredSU = II->first;
|
||||
SUnit *PredSU = II->Dep;
|
||||
if (!PredSU->isScheduled)
|
||||
Sum++;
|
||||
}
|
||||
@ -899,13 +899,13 @@ CalcNodeSethiUllmanNumber(const SUnit *SU) {
|
||||
int Extra = 0;
|
||||
for (SUnit::const_pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
|
||||
I != E; ++I) {
|
||||
if (I->second) continue; // ignore chain preds
|
||||
SUnit *PredSU = I->first;
|
||||
if (I->isCtrl) continue; // ignore chain preds
|
||||
SUnit *PredSU = I->Dep;
|
||||
unsigned PredSethiUllman = CalcNodeSethiUllmanNumber(PredSU);
|
||||
if (PredSethiUllman > SethiUllmanNumber) {
|
||||
SethiUllmanNumber = PredSethiUllman;
|
||||
Extra = 0;
|
||||
} else if (PredSethiUllman == SethiUllmanNumber && !I->second)
|
||||
} else if (PredSethiUllman == SethiUllmanNumber && !I->isCtrl)
|
||||
Extra++;
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ namespace llvm {
|
||||
/// edge, override this method.
|
||||
template<typename EdgeIter>
|
||||
static std::string getEdgeAttributes(const void *Node, EdgeIter EI) {
|
||||
if (EI.isChain())
|
||||
if (EI.isCtrlDep())
|
||||
return "color=blue,style=dashed";
|
||||
return "";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user