Fixed bug in searchPath function for finding nodes between two recurrences.

Changed dependence analyzer to only use dep distances of 2 or less.
This is experimental.

Changed MSchedGraph to be able to represent more then one BB (first steps).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21641 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Tanya Lattner
2005-04-30 23:07:59 +00:00
parent 50d91d71a5
commit c50156360a
5 changed files with 215 additions and 183 deletions

View File

@@ -218,6 +218,8 @@ void DependenceAnalyzer::advancedDepAnalysis(GetElementPtrInst *gp1,
//Find constant index difference
int diff = A1->getValue()->getRawValue() - A2->getValue()->getRawValue();
std::cerr << diff << "\n";
if(diff > 5)
diff = 2;
if(diff > 0)
createDep(deps, valLoad, val2Load, srcBeforeDest, diff);

View File

@@ -153,12 +153,12 @@ MSchedGraph::MSchedGraph(const MachineBasicBlock *bb,
std::map<const MachineInstr*, unsigned> &ignoreInstrs,
DependenceAnalyzer &DA,
std::map<MachineInstr*, Instruction*> &machineTollvm)
: BB(bb), Target(targ) {
: Target(targ) {
//Make sure BB is not null,
assert(BB != NULL && "Basic Block is null");
assert(bb != NULL && "Basic Block is null");
//DEBUG(std::cerr << "Constructing graph for " << bb << "\n");
BBs.push_back(bb);
//Create nodes and edges for this BB
buildNodesAndEdges(ignoreInstrs, DA, machineTollvm);
@@ -170,7 +170,9 @@ MSchedGraph::MSchedGraph(const MachineBasicBlock *bb,
//Copies the graph and keeps a map from old to new nodes
MSchedGraph::MSchedGraph(const MSchedGraph &G,
std::map<MSchedGraphNode*, MSchedGraphNode*> &newNodes)
: BB(G.BB), Target(G.Target) {
: Target(G.Target) {
BBs = G.BBs;
std::map<MSchedGraphNode*, MSchedGraphNode*> oldToNew;
//Copy all nodes
@@ -336,6 +338,11 @@ void MSchedGraph::buildNodesAndEdges(std::map<const MachineInstr*, unsigned> &ig
std::vector<const MachineInstr*> phiInstrs;
unsigned index = 0;
for(std::vector<const MachineBasicBlock*>::iterator B = BBs.begin(),
BE = BBs.end(); B != BE; ++B) {
const MachineBasicBlock *BB = *B;
//Loop over instructions in MBB and add nodes and edges
for (MachineBasicBlock::const_iterator MI = BB->begin(), e = BB->end();
MI != e; ++MI) {
@@ -508,7 +515,7 @@ void MSchedGraph::buildNodesAndEdges(std::map<const MachineInstr*, unsigned> &ig
}
}
}
}
//Add dependencies for Value*s
void MSchedGraph::addValueEdges(std::vector<OpIndexNodePair> &NodesInMap,
MSchedGraphNode *destNode, bool nodeIsUse,

View File

@@ -233,7 +233,7 @@ namespace llvm {
//Graph class to represent dependence graph
class MSchedGraph {
const MachineBasicBlock *BB; //Machine basic block
std::vector<const MachineBasicBlock *> BBs; //Machine basic block
const TargetMachine &Target; //Target Machine
//Nodes
@@ -283,7 +283,7 @@ namespace llvm {
//Get Target or original machine basic block
const TargetMachine* getTarget() { return &Target; }
const MachineBasicBlock* getBB() { return BB; }
std::vector<const MachineBasicBlock*> getBBs() { return BBs; }
};

View File

@@ -1218,7 +1218,8 @@ void ModuloSchedulingPass::findAllReccurrences(MSchedGraphNode *node,
void ModuloSchedulingPass::searchPath(MSchedGraphNode *node,
std::vector<MSchedGraphNode*> &path,
std::set<MSchedGraphNode*> &nodesToAdd) {
std::set<MSchedGraphNode*> &nodesToAdd,
std::set<MSchedGraphNode*> &new_reccurrence) {
//Push node onto the path
path.push_back(node);
@@ -1227,22 +1228,31 @@ void ModuloSchedulingPass::searchPath(MSchedGraphNode *node,
for(MSchedGraphNode::succ_iterator S = node->succ_begin(), SE = node->succ_end(); S != SE;
++S) {
//If this node exists in a recurrence already in the partial order, then add all
//nodes in the path to the set of nodes to add
//Check if its already in our partial order, if not add it to the final vector
for(std::vector<std::set<MSchedGraphNode*> >::iterator PO = partialOrder.begin(),
PE = partialOrder.end(); PO != PE; ++PO) {
//Check if we should ignore this edge first
if(ignoreEdge(node,*S))
continue;
//check if successor is in this recurrence, we will get to it eventually
if(new_reccurrence.count(*S))
continue;
//If this node exists in a recurrence already in the partial
//order, then add all nodes in the path to the set of nodes to add
//Check if its already in our partial order, if not add it to the
//final vector
bool found = false;
for(std::vector<std::set<MSchedGraphNode*> >::iterator PO = partialOrder.begin(),
PE = partialOrder.end(); PO != PE; ++PO) {
if(PO->count(*S)) {
nodesToAdd.insert(*S);
found = true;
break;
}
//terminate
else
searchPath(*S, path, nodesToAdd);
}
if(!found) {
nodesToAdd.insert(*S);
searchPath(*S, path, nodesToAdd, new_reccurrence);
}
}
@@ -1344,7 +1354,7 @@ void ModuloSchedulingPass::computePartialOrder() {
//Add nodes that connect this recurrence to recurrences in the partial path
for(std::set<MSchedGraphNode*>::iterator N = new_recurrence.begin(),
NE = new_recurrence.end(); N != NE; ++N)
searchPath(*N, path, nodesToAdd);
searchPath(*N, path, nodesToAdd, new_recurrence);
//Add nodes to this recurrence if they are not already in the partial order
for(std::set<MSchedGraphNode*>::iterator N = nodesToAdd.begin(), NE = nodesToAdd.end();
@@ -1723,8 +1733,10 @@ bool ModuloSchedulingPass::computeSchedule(const MachineBasicBlock *BB, MSchedGr
E = FinalNodeOrder.end(); I != E; ++I) {
//CalculateEarly and Late start
int EarlyStart = -1;
int LateStart = 99999; //Set to something higher then we would ever expect (FIXME)
bool initialLSVal = false;
bool initialESVal = false;
int EarlyStart = 0;
int LateStart = 0;
bool hasSucc = false;
bool hasPred = false;
bool sched;
@@ -1751,7 +1763,12 @@ bool ModuloSchedulingPass::computeSchedule(const MachineBasicBlock *BB, MSchedGr
int ES_Temp = nodesByCycle->first + (*schedNode)->getLatency() - diff * II;
DEBUG(std::cerr << "Diff: " << diff << " Cycle: " << nodesByCycle->first << "\n");
DEBUG(std::cerr << "Temp EarlyStart: " << ES_Temp << " Prev EarlyStart: " << EarlyStart << "\n");
if(initialESVal)
EarlyStart = std::max(EarlyStart, ES_Temp);
else {
EarlyStart = ES_Temp;
initialESVal = true;
}
hasPred = true;
}
if((*I)->isSuccessor(*schedNode)) {
@@ -1759,7 +1776,12 @@ bool ModuloSchedulingPass::computeSchedule(const MachineBasicBlock *BB, MSchedGr
int LS_Temp = nodesByCycle->first - (*I)->getLatency() + diff * II;
DEBUG(std::cerr << "Diff: " << diff << " Cycle: " << nodesByCycle->first << "\n");
DEBUG(std::cerr << "Temp LateStart: " << LS_Temp << " Prev LateStart: " << LateStart << "\n");
if(initialLSVal)
LateStart = std::min(LateStart, LS_Temp);
else {
LateStart = LS_Temp;
initialLSVal = true;
}
hasSucc = true;
}
}
@@ -1772,7 +1794,7 @@ bool ModuloSchedulingPass::computeSchedule(const MachineBasicBlock *BB, MSchedGr
//Check if this node is a pred or succ to a branch, and restrict its placement
//even though the branch is not in the schedule
int count = branches.size();
/*int count = branches.size();
for(std::vector<MSchedGraphNode*>::iterator B = branches.begin(), BE = branches.end();
B != BE; ++B) {
if((*I)->isPredecessor(*B)) {
@@ -1794,7 +1816,7 @@ bool ModuloSchedulingPass::computeSchedule(const MachineBasicBlock *BB, MSchedGr
}
count--;
}
}*/
//Check if the node has no pred or successors and set Early Start to its ASAP
if(!hasSucc && !hasPred)

View File

@@ -113,7 +113,8 @@ namespace llvm {
void searchPath(MSchedGraphNode *node,
std::vector<MSchedGraphNode*> &path,
std::set<MSchedGraphNode*> &nodesToAdd);
std::set<MSchedGraphNode*> &nodesToAdd,
std::set<MSchedGraphNode*> &new_reccurence);
void pathToRecc(MSchedGraphNode *node,
std::vector<MSchedGraphNode*> &path,