mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-27 14:34:58 +00:00
Remove ScheduleDAG's SUnitMap altogether. Instead, use SDNode's NodeId
field, which is otherwise unused after instruction selection, as an index into the SUnit array. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52583 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3627e34486
commit
94d7a5f815
@ -214,8 +214,7 @@ namespace llvm {
|
||||
public:
|
||||
virtual ~SchedulingPriorityQueue() {}
|
||||
|
||||
virtual void initNodes(DenseMap<SDNode*, SUnit*> &SUMap,
|
||||
std::vector<SUnit> &SUnits) = 0;
|
||||
virtual void initNodes(std::vector<SUnit> &SUnits) = 0;
|
||||
virtual void addNode(const SUnit *SU) = 0;
|
||||
virtual void updateNode(const SUnit *SU) = 0;
|
||||
virtual void releaseState() = 0;
|
||||
@ -250,7 +249,6 @@ namespace llvm {
|
||||
MachineConstantPool *ConstPool; // Target constant pool
|
||||
std::vector<SUnit*> Sequence; // The schedule. Null SUnit*'s
|
||||
// represent noop instructions.
|
||||
DenseMap<SDNode*, SUnit*> SUnitMap; // SDNode to SUnit mapping (n -> n).
|
||||
std::vector<SUnit> SUnits; // The scheduling units.
|
||||
SmallSet<SDNode*, 16> CommuteSet; // Nodes that should be commuted.
|
||||
|
||||
|
@ -97,13 +97,20 @@ void ScheduleDAG::BuildSchedUnits() {
|
||||
// invalidated.
|
||||
SUnits.reserve(DAG.allnodes_size());
|
||||
|
||||
// During scheduling, the NodeId field of SDNode is used to map SDNodes
|
||||
// to their associated SUnits by holding SUnits table indices. A value
|
||||
// of -1 means the SDNode does not yet have an associated SUnit.
|
||||
for (SelectionDAG::allnodes_iterator NI = DAG.allnodes_begin(),
|
||||
E = DAG.allnodes_end(); NI != E; ++NI)
|
||||
NI->setNodeId(-1);
|
||||
|
||||
for (SelectionDAG::allnodes_iterator NI = DAG.allnodes_begin(),
|
||||
E = DAG.allnodes_end(); NI != E; ++NI) {
|
||||
if (isPassiveNode(NI)) // Leaf node, e.g. a TargetImmediate.
|
||||
continue;
|
||||
|
||||
// If this node has already been processed, stop now.
|
||||
if (SUnitMap.count(NI)) continue;
|
||||
if (NI->getNodeId() != -1) continue;
|
||||
|
||||
SUnit *NodeSUnit = NewSUnit(NI);
|
||||
|
||||
@ -118,9 +125,8 @@ void ScheduleDAG::BuildSchedUnits() {
|
||||
do {
|
||||
N = N->getOperand(N->getNumOperands()-1).Val;
|
||||
NodeSUnit->FlaggedNodes.push_back(N);
|
||||
bool isNew = SUnitMap.insert(std::make_pair(N, NodeSUnit));
|
||||
isNew = isNew;
|
||||
assert(isNew && "Node already inserted!");
|
||||
assert(N->getNodeId() == -1 && "Node already inserted!");
|
||||
N->setNodeId(NodeSUnit->NodeNum);
|
||||
} while (N->getNumOperands() &&
|
||||
N->getOperand(N->getNumOperands()-1).getValueType()== MVT::Flag);
|
||||
std::reverse(NodeSUnit->FlaggedNodes.begin(),
|
||||
@ -140,9 +146,8 @@ void ScheduleDAG::BuildSchedUnits() {
|
||||
if (FlagVal.isOperandOf(UI->getUser())) {
|
||||
HasFlagUse = true;
|
||||
NodeSUnit->FlaggedNodes.push_back(N);
|
||||
bool isNew = SUnitMap.insert(std::make_pair(N, NodeSUnit));
|
||||
isNew = isNew;
|
||||
assert(isNew && "Node already inserted!");
|
||||
assert(N->getNodeId() == -1 && "Node already inserted!");
|
||||
N->setNodeId(NodeSUnit->NodeNum);
|
||||
N = UI->getUser();
|
||||
break;
|
||||
}
|
||||
@ -152,9 +157,8 @@ void ScheduleDAG::BuildSchedUnits() {
|
||||
// Now all flagged nodes are in FlaggedNodes and N is the bottom-most node.
|
||||
// Update the SUnit
|
||||
NodeSUnit->Node = N;
|
||||
bool isNew = SUnitMap.insert(std::make_pair(N, NodeSUnit));
|
||||
isNew = isNew;
|
||||
assert(isNew && "Node already inserted!");
|
||||
assert(N->getNodeId() == -1 && "Node already inserted!");
|
||||
N->setNodeId(NodeSUnit->NodeNum);
|
||||
|
||||
ComputeLatency(NodeSUnit);
|
||||
}
|
||||
@ -191,7 +195,7 @@ void ScheduleDAG::BuildSchedUnits() {
|
||||
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
|
||||
SDNode *OpN = N->getOperand(i).Val;
|
||||
if (isPassiveNode(OpN)) continue; // Not scheduled.
|
||||
SUnit *OpSU = SUnitMap[OpN];
|
||||
SUnit *OpSU = &SUnits[OpN->getNodeId()];
|
||||
assert(OpSU && "Node has no SUnit!");
|
||||
if (OpSU == SU) continue; // In the same group.
|
||||
|
||||
|
@ -94,7 +94,7 @@ void ScheduleDAGList::Schedule() {
|
||||
// Build scheduling units.
|
||||
BuildSchedUnits();
|
||||
|
||||
AvailableQueue->initNodes(SUnitMap, SUnits);
|
||||
AvailableQueue->initNodes(SUnits);
|
||||
|
||||
ListScheduleTopDown();
|
||||
|
||||
@ -320,8 +320,7 @@ public:
|
||||
LatencyPriorityQueue() : Queue(latency_sort(this)) {
|
||||
}
|
||||
|
||||
void initNodes(DenseMap<SDNode*, SUnit*> &sumap,
|
||||
std::vector<SUnit> &sunits) {
|
||||
void initNodes(std::vector<SUnit> &sunits) {
|
||||
SUnits = &sunits;
|
||||
// Calculate node priorities.
|
||||
CalculatePriorities();
|
||||
|
@ -216,7 +216,7 @@ void ScheduleDAGRRList::Schedule() {
|
||||
CalculateHeights();
|
||||
InitDAGTopologicalSorting();
|
||||
|
||||
AvailableQueue->initNodes(SUnitMap, SUnits);
|
||||
AvailableQueue->initNodes(SUnits);
|
||||
|
||||
// Execute the actual scheduling loop Top-Down or Bottom-Up as appropriate.
|
||||
if (isBottomUp)
|
||||
@ -255,7 +255,7 @@ void ScheduleDAGRRList::CommuteNodesToReducePressure() {
|
||||
continue;
|
||||
|
||||
SDNode *OpN = SU->Node->getOperand(j).Val;
|
||||
SUnit *OpSU = isPassiveNode(OpN) ? NULL : SUnitMap[OpN];
|
||||
SUnit *OpSU = isPassiveNode(OpN) ? NULL : &SUnits[OpN->getNodeId()];
|
||||
if (OpSU && OperandSeen.count(OpSU) == 1) {
|
||||
// Ok, so SU is not the last use of OpSU, but SU is two-address so
|
||||
// it will clobber OpSU. Try to commute SU if no other source operands
|
||||
@ -264,7 +264,7 @@ void ScheduleDAGRRList::CommuteNodesToReducePressure() {
|
||||
for (unsigned k = 0; k < NumOps; ++k) {
|
||||
if (k != j) {
|
||||
OpN = SU->Node->getOperand(k).Val;
|
||||
OpSU = isPassiveNode(OpN) ? NULL : SUnitMap[OpN];
|
||||
OpSU = isPassiveNode(OpN) ? NULL : &SUnits[OpN->getNodeId()];
|
||||
if (OpSU && OperandSeen.count(OpSU) == 1) {
|
||||
DoCommute = false;
|
||||
break;
|
||||
@ -678,9 +678,8 @@ SUnit *ScheduleDAGRRList::CopyAndMoveSuccessors(SUnit *SU) {
|
||||
SDOperand(LoadNode, 1));
|
||||
|
||||
SUnit *NewSU = CreateNewSUnit(N);
|
||||
bool isNew = SUnitMap.insert(std::make_pair(N, NewSU));
|
||||
isNew = isNew;
|
||||
assert(isNew && "Node already inserted!");
|
||||
assert(N->getNodeId() == -1 && "Node already inserted!");
|
||||
N->setNodeId(NewSU->NodeNum);
|
||||
|
||||
const TargetInstrDesc &TID = TII->get(N->getTargetOpcode());
|
||||
for (unsigned i = 0; i != TID.getNumOperands(); ++i) {
|
||||
@ -701,15 +700,12 @@ SUnit *ScheduleDAGRRList::CopyAndMoveSuccessors(SUnit *SU) {
|
||||
// but it has different alignment or volatileness.
|
||||
bool isNewLoad = true;
|
||||
SUnit *LoadSU;
|
||||
DenseMap<SDNode*, SUnit*>::iterator SMI = SUnitMap.find(LoadNode);
|
||||
if (SMI != SUnitMap.end()) {
|
||||
LoadSU = SMI->second;
|
||||
if (LoadNode->getNodeId() != -1) {
|
||||
LoadSU = &SUnits[LoadNode->getNodeId()];
|
||||
isNewLoad = false;
|
||||
} else {
|
||||
LoadSU = CreateNewSUnit(LoadNode);
|
||||
bool isNew = SUnitMap.insert(std::make_pair(LoadNode, LoadSU));
|
||||
isNew = isNew;
|
||||
assert(isNew && "Node already inserted!");
|
||||
LoadNode->setNodeId(LoadSU->NodeNum);
|
||||
|
||||
LoadSU->Depth = SU->Depth;
|
||||
LoadSU->Height = SU->Height;
|
||||
@ -948,7 +944,7 @@ void ScheduleDAGRRList::ListScheduleBottomUp() {
|
||||
unsigned CurCycle = 0;
|
||||
// Add root to Available queue.
|
||||
if (!SUnits.empty()) {
|
||||
SUnit *RootSU = SUnitMap[DAG.getRoot().Val];
|
||||
SUnit *RootSU = &SUnits[DAG.getRoot().Val->getNodeId()];
|
||||
assert(RootSU->Succs.empty() && "Graph root shouldn't have successors!");
|
||||
RootSU->isAvailable = true;
|
||||
AvailableQueue->push(RootSU);
|
||||
@ -1284,8 +1280,7 @@ namespace {
|
||||
RegReductionPriorityQueue() :
|
||||
Queue(SF(this)), currentQueueId(0) {}
|
||||
|
||||
virtual void initNodes(DenseMap<SDNode*, SUnit*> &sumap,
|
||||
std::vector<SUnit> &sunits) {}
|
||||
virtual void initNodes(std::vector<SUnit> &sunits) {}
|
||||
|
||||
virtual void addNode(const SUnit *SU) {}
|
||||
|
||||
@ -1330,9 +1325,6 @@ namespace {
|
||||
|
||||
class VISIBILITY_HIDDEN BURegReductionPriorityQueue
|
||||
: public RegReductionPriorityQueue<bu_ls_rr_sort> {
|
||||
// SUnitMap SDNode to SUnit mapping (n -> n).
|
||||
DenseMap<SDNode*, SUnit*> *SUnitMap;
|
||||
|
||||
// SUnits - The SUnits for the current graph.
|
||||
const std::vector<SUnit> *SUnits;
|
||||
|
||||
@ -1347,9 +1339,7 @@ namespace {
|
||||
const TargetRegisterInfo *tri)
|
||||
: TII(tii), TRI(tri), scheduleDAG(NULL) {}
|
||||
|
||||
void initNodes(DenseMap<SDNode*, SUnit*> &sumap,
|
||||
std::vector<SUnit> &sunits) {
|
||||
SUnitMap = &sumap;
|
||||
void initNodes(std::vector<SUnit> &sunits) {
|
||||
SUnits = &sunits;
|
||||
// Add pseudo dependency edges for two-address nodes.
|
||||
AddPseudoTwoAddrDeps();
|
||||
@ -1417,9 +1407,6 @@ namespace {
|
||||
|
||||
class VISIBILITY_HIDDEN TDRegReductionPriorityQueue
|
||||
: public RegReductionPriorityQueue<td_ls_rr_sort> {
|
||||
// SUnitMap SDNode to SUnit mapping (n -> n).
|
||||
DenseMap<SDNode*, SUnit*> *SUnitMap;
|
||||
|
||||
// SUnits - The SUnits for the current graph.
|
||||
const std::vector<SUnit> *SUnits;
|
||||
|
||||
@ -1429,9 +1416,7 @@ namespace {
|
||||
public:
|
||||
TDRegReductionPriorityQueue() {}
|
||||
|
||||
void initNodes(DenseMap<SDNode*, SUnit*> &sumap,
|
||||
std::vector<SUnit> &sunits) {
|
||||
SUnitMap = &sumap;
|
||||
void initNodes(std::vector<SUnit> &sunits) {
|
||||
SUnits = &sunits;
|
||||
// Calculate node priorities.
|
||||
CalculateSethiUllmanNumbers();
|
||||
@ -1563,8 +1548,8 @@ BURegReductionPriorityQueue::canClobber(const SUnit *SU, const SUnit *Op) {
|
||||
for (unsigned i = 0; i != NumOps; ++i) {
|
||||
if (TID.getOperandConstraint(i+NumRes, TOI::TIED_TO) != -1) {
|
||||
SDNode *DU = SU->Node->getOperand(i).Val;
|
||||
if ((*SUnitMap).find(DU) != (*SUnitMap).end() &&
|
||||
Op->OrigNode == (*SUnitMap)[DU])
|
||||
if (DU->getNodeId() != -1 &&
|
||||
Op->OrigNode == &(*SUnits)[DU->getNodeId()])
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1638,12 +1623,12 @@ void BURegReductionPriorityQueue::AddPseudoTwoAddrDeps() {
|
||||
for (unsigned j = 0; j != NumOps; ++j) {
|
||||
if (TID.getOperandConstraint(j+NumRes, TOI::TIED_TO) != -1) {
|
||||
SDNode *DU = SU->Node->getOperand(j).Val;
|
||||
if ((*SUnitMap).find(DU) == (*SUnitMap).end())
|
||||
if (DU->getNodeId() == -1)
|
||||
continue;
|
||||
SUnit *DUSU = (*SUnitMap)[DU];
|
||||
const SUnit *DUSU = &(*SUnits)[DU->getNodeId()];
|
||||
if (!DUSU) continue;
|
||||
for (SUnit::succ_iterator I = DUSU->Succs.begin(),E = DUSU->Succs.end();
|
||||
I != E; ++I) {
|
||||
for (SUnit::const_succ_iterator I = DUSU->Succs.begin(),
|
||||
E = DUSU->Succs.end(); I != E; ++I) {
|
||||
if (I->isCtrl) continue;
|
||||
SUnit *SuccSU = I->Dep;
|
||||
if (SuccSU == SU)
|
||||
|
@ -301,9 +301,9 @@ namespace llvm {
|
||||
static void addCustomGraphFeatures(ScheduleDAG *G,
|
||||
GraphWriter<ScheduleDAG*> &GW) {
|
||||
GW.emitSimpleNode(0, "plaintext=circle", "GraphRoot");
|
||||
if (G->DAG.getRoot().Val &&
|
||||
G->SUnitMap.find(G->DAG.getRoot().Val) != G->SUnitMap.end())
|
||||
GW.emitEdge(0, -1, G->SUnitMap[G->DAG.getRoot().Val], -1, "");
|
||||
const SDNode *N = G->DAG.getRoot().Val;
|
||||
if (N && N->getNodeId() != -1)
|
||||
GW.emitEdge(0, -1, &G->SUnits[N->getNodeId()], -1, "");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user