aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/SparcV9/ModuloScheduling
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/SparcV9/ModuloScheduling')
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp44
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.h26
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp74
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/MSSchedule.h2
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/MSScheduleSB.cpp76
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/MSScheduleSB.h2
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp516
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h56
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/MSchedGraphSB.cpp576
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/MSchedGraphSB.h64
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp1864
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h38
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/ModuloSchedulingSuperBlock.cpp2498
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/ModuloSchedulingSuperBlock.h166
14 files changed, 3001 insertions, 3001 deletions
diff --git a/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp b/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp
index d0b5db304a..db228b35c8 100644
--- a/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp
+++ b/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp
@@ -31,9 +31,9 @@ namespace llvm {
Statistic<> NoDeps("depanalyzer-nodeps", "Number of dependences eliminated");
Statistic<> NumDeps("depanalyzer-deps",
- "Number of dependences could not eliminate");
+ "Number of dependences could not eliminate");
Statistic<> AdvDeps("depanalyzer-advdeps",
- "Number of dependences using advanced techniques");
+ "Number of dependences using advanced techniques");
bool DependenceAnalyzer::runOnFunction(Function &F) {
AA = &getAnalysis<AliasAnalysis>();
@@ -44,7 +44,7 @@ bool DependenceAnalyzer::runOnFunction(Function &F) {
}
static RegisterAnalysis<DependenceAnalyzer>X("depanalyzer",
- "Dependence Analyzer");
+ "Dependence Analyzer");
// - Get inter and intra dependences between loads and stores
//
@@ -57,10 +57,10 @@ static RegisterAnalysis<DependenceAnalyzer>X("depanalyzer",
// further (Step 4)
// Step 4: do advanced analysis
void DependenceAnalyzer::AnalyzeDeps(Value *val, Value *val2, bool valLoad,
- bool val2Load,
- std::vector<Dependence> &deps,
- BasicBlock *BB,
- bool srcBeforeDest) {
+ bool val2Load,
+ std::vector<Dependence> &deps,
+ BasicBlock *BB,
+ bool srcBeforeDest) {
bool loopInvariant = true;
@@ -76,7 +76,7 @@ void DependenceAnalyzer::AnalyzeDeps(Value *val, Value *val2, bool valLoad,
//If Loop invariant, let AA decide
if(loopInvariant) {
if(AA->alias(val, (unsigned)TD->getTypeSize(val->getType()),
- val2,(unsigned)TD->getTypeSize(val2->getType()))
+ val2,(unsigned)TD->getTypeSize(val2->getType()))
!= AliasAnalysis::NoAlias) {
createDep(deps, valLoad, val2Load, srcBeforeDest);
}
@@ -102,7 +102,7 @@ void DependenceAnalyzer::AnalyzeDeps(Value *val, Value *val2, bool valLoad,
Value *GPop = GP->getOperand(0);
Value *GP2op = GP2->getOperand(0);
int alias = AA->alias(GPop, (unsigned)TD->getTypeSize(GPop->getType()),
- GP2op,(unsigned)TD->getTypeSize(GP2op->getType()));
+ GP2op,(unsigned)TD->getTypeSize(GP2op->getType()));
if(alias == AliasAnalysis::MustAlias) {
@@ -121,11 +121,11 @@ void DependenceAnalyzer::AnalyzeDeps(Value *val, Value *val2, bool valLoad,
// advancedDepAnalysis - Do advanced data dependence tests
void DependenceAnalyzer::advancedDepAnalysis(GetElementPtrInst *gp1,
- GetElementPtrInst *gp2,
- bool valLoad,
- bool val2Load,
- std::vector<Dependence> &deps,
- bool srcBeforeDest) {
+ GetElementPtrInst *gp2,
+ bool valLoad,
+ bool val2Load,
+ std::vector<Dependence> &deps,
+ bool srcBeforeDest) {
//Check if both GEPs are in a simple form: 3 ops, constant 0 as second arg
if(gp1->getNumOperands() != 3 || gp2->getNumOperands() != 3) {
@@ -138,7 +138,7 @@ void DependenceAnalyzer::advancedDepAnalysis(GetElementPtrInst *gp1,
if(Constant *c1 = dyn_cast<Constant>(gp1->getOperand(1)))
if(Constant *c2 = dyn_cast<Constant>(gp2->getOperand(1)))
if(c1->isNullValue() && c2->isNullValue())
- GPok = true;
+ GPok = true;
if(!GPok) {
createDep(deps, valLoad, val2Load, srcBeforeDest);
@@ -230,8 +230,8 @@ void DependenceAnalyzer::advancedDepAnalysis(GetElementPtrInst *gp1,
// Create dependences once its determined these two instructions
// references the same memory
void DependenceAnalyzer::createDep(std::vector<Dependence> &deps,
- bool valLoad, bool val2Load,
- bool srcBeforeDest, int diff) {
+ bool valLoad, bool val2Load,
+ bool srcBeforeDest, int diff) {
//If the source instruction occurs after the destination instruction
//(execution order), then this dependence is across iterations
@@ -269,8 +269,8 @@ void DependenceAnalyzer::createDep(std::vector<Dependence> &deps,
//Get Dependence Info for a pair of Instructions
DependenceResult DependenceAnalyzer::getDependenceInfo(Instruction *inst1,
- Instruction *inst2,
- bool srcBeforeDest) {
+ Instruction *inst2,
+ bool srcBeforeDest) {
std::vector<Dependence> deps;
DEBUG(std::cerr << "Inst1: " << *inst1 << "\n");
@@ -284,17 +284,17 @@ DependenceResult DependenceAnalyzer::getDependenceInfo(Instruction *inst1,
if(StoreInst *stInst = dyn_cast<StoreInst>(inst2))
AnalyzeDeps(ldInst->getOperand(0), stInst->getOperand(1),
- true, false, deps, ldInst->getParent(), srcBeforeDest);
+ true, false, deps, ldInst->getParent(), srcBeforeDest);
}
else if(StoreInst *stInst = dyn_cast<StoreInst>(inst1)) {
if(LoadInst *ldInst = dyn_cast<LoadInst>(inst2))
AnalyzeDeps(stInst->getOperand(1), ldInst->getOperand(0), false, true,
- deps, ldInst->getParent(), srcBeforeDest);
+ deps, ldInst->getParent(), srcBeforeDest);
else if(StoreInst *stInst2 = dyn_cast<StoreInst>(inst2))
AnalyzeDeps(stInst->getOperand(1), stInst2->getOperand(1), false, false,
- deps, stInst->getParent(), srcBeforeDest);
+ deps, stInst->getParent(), srcBeforeDest);
}
else
assert(0 && "Expected a load or a store\n");
diff --git a/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.h b/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.h
index 2440ea9d39..f9aac5c010 100644
--- a/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.h
+++ b/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.h
@@ -22,7 +22,7 @@
#include <vector>
namespace llvm {
-
+
//class to represent a dependence
struct Dependence {
@@ -49,22 +49,22 @@ namespace llvm {
class DependenceAnalyzer : public FunctionPass {
-
+
AliasAnalysis *AA;
TargetData *TD;
ScalarEvolution *SE;
- void advancedDepAnalysis(GetElementPtrInst *gp1, GetElementPtrInst *gp2,
- bool valLoad, bool val2Load,
- std::vector<Dependence> &deps, bool srcBeforeDest);
+ void advancedDepAnalysis(GetElementPtrInst *gp1, GetElementPtrInst *gp2,
+ bool valLoad, bool val2Load,
+ std::vector<Dependence> &deps, bool srcBeforeDest);
+
+ void AnalyzeDeps(Value *val, Value *val2, bool val1Load, bool val2Load,
+ std::vector<Dependence> &deps, BasicBlock *BB,
+ bool srcBeforeDest);
- void AnalyzeDeps(Value *val, Value *val2, bool val1Load, bool val2Load,
- std::vector<Dependence> &deps, BasicBlock *BB,
- bool srcBeforeDest);
-
- void createDep(std::vector<Dependence> &deps, bool valLoad, bool val2Load,
- bool srcBeforeDest, int diff = 0);
+ void createDep(std::vector<Dependence> &deps, bool valLoad, bool val2Load,
+ bool srcBeforeDest, int diff = 0);
public:
DependenceAnalyzer() { AA = 0; TD = 0; SE = 0; }
@@ -80,8 +80,8 @@ namespace llvm {
}
//get dependence info
- DependenceResult getDependenceInfo(Instruction *inst1, Instruction *inst2,
- bool srcBeforeDest);
+ DependenceResult getDependenceInfo(Instruction *inst1, Instruction *inst2,
+ bool srcBeforeDest);
};
diff --git a/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp b/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp
index 6e8a6db347..3513d5c9d3 100644
--- a/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp
+++ b/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp
@@ -33,10 +33,10 @@ bool MSSchedule::insert(MSchedGraphNode *node, int cycle, int II) {
if (schedule[cycle].size() < numIssue) {
//Now check if all the resources in their respective cycles are available
if(resourcesFree(node, cycle, II)) {
- //Insert to preserve dependencies
- addToSchedule(cycle,node);
- DEBUG(std::cerr << "Found spot in map, and there is an issue slot\n");
- return false;
+ //Insert to preserve dependencies
+ addToSchedule(cycle,node);
+ DEBUG(std::cerr << "Found spot in map, and there is an issue slot\n");
+ return false;
}
}
}
@@ -81,7 +81,7 @@ bool MSSchedule::resourceAvailable(int resourceNum, int cycle) {
if(resourceNumPerCycle[cycle].count(resourceNum)) {
int maxRes = CPUResource::getCPUResource(resourceNum)->maxNumUsers;
if(resourceNumPerCycle[cycle][resourceNum] >= maxRes)
- isFree = false;
+ isFree = false;
}
}
@@ -137,21 +137,21 @@ bool MSSchedule::resourcesFree(MSchedGraphNode *node, int cycle, int II) {
//Loop over resources in each cycle and increments their usage count
for(unsigned i=0; i < resources.size(); ++i) {
for(unsigned j=0; j < resources[i].size(); ++j) {
-
- //Get Resource to check its availability
- int resourceNum = resources[i][j];
-
- DEBUG(std::cerr << "Attempting to schedule Resource Num: " << resourceNum << " in cycle: " << currentCycle << "\n");
-
- success = resourceAvailable(resourceNum, currentCycle);
-
- if(!success)
- break;
-
+
+ //Get Resource to check its availability
+ int resourceNum = resources[i][j];
+
+ DEBUG(std::cerr << "Attempting to schedule Resource Num: " << resourceNum << " in cycle: " << currentCycle << "\n");
+
+ success = resourceAvailable(resourceNum, currentCycle);
+
+ if(!success)
+ break;
+
}
if(!success)
- break;
+ break;
//Increase cycle
currentCycle++;
@@ -172,8 +172,8 @@ bool MSSchedule::resourcesFree(MSchedGraphNode *node, int cycle, int II) {
//Loop over resources in each cycle and increments their usage count
for(unsigned i=0; i < resources.size(); ++i) {
for(unsigned j=0; j < resources[i].size(); ++j) {
- int resourceNum = resources[i][j];
- useResource(resourceNum, currentCycle);
+ int resourceNum = resources[i][j];
+ useResource(resourceNum, currentCycle);
}
currentCycle++;
}
@@ -205,15 +205,15 @@ bool MSSchedule::constructKernel(int II, std::vector<MSchedGraphNode*> &branches
int count = 0;
for(int i = index; i <= (schedule.rbegin()->first); i+=II) {
if(schedule.count(i)) {
- for(std::vector<MSchedGraphNode*>::iterator I = schedule[i].begin(),
- E = schedule[i].end(); I != E; ++I) {
- //Check if its a branch
- assert(!(*I)->isBranch() && "Branch should not be schedule!");
-
- tempKernel.push_back(std::make_pair(*I, count));
- maxSN = std::max(maxSN, count);
-
- }
+ for(std::vector<MSchedGraphNode*>::iterator I = schedule[i].begin(),
+ E = schedule[i].end(); I != E; ++I) {
+ //Check if its a branch
+ assert(!(*I)->isBranch() && "Branch should not be schedule!");
+
+ tempKernel.push_back(std::make_pair(*I, count));
+ maxSN = std::max(maxSN, count);
+
+ }
}
++count;
}
@@ -231,14 +231,14 @@ bool MSSchedule::constructKernel(int II, std::vector<MSchedGraphNode*> &branches
for(std::map<const MachineInstr*, unsigned>::iterator N = indVar.begin(), NE = indVar.end(); N != NE; ++N) {
- if(N->second < I->first->getIndex())
- tmpMap[N->second] = (MachineInstr*) N->first;
+ if(N->second < I->first->getIndex())
+ tmpMap[N->second] = (MachineInstr*) N->first;
}
//Add to kernel, and delete from indVar
for(std::map<unsigned, MachineInstr*>::iterator N = tmpMap.begin(), NE = tmpMap.end(); N != NE; ++N) {
- kernel.push_back(std::make_pair(N->second, 0));
- indVar.erase(N->second);
+ kernel.push_back(std::make_pair(N->second, 0));
+ indVar.erase(N->second);
}
}
@@ -278,10 +278,10 @@ bool MSSchedule::defPreviousStage(Value *def, int stage) {
const MachineOperand &mOp = inst->getOperand(i);
if(mOp.getType() == MachineOperand::MO_VirtualRegister && mOp.isDef()) {
if(def == mOp.getVRegValue()) {
- if(P->second >= stage)
- return false;
- else
- return true;
+ if(P->second >= stage)
+ return false;
+ else
+ return true;
}
}
}
@@ -302,7 +302,7 @@ void MSSchedule::print(std::ostream &os) const {
os << "Kernel:\n";
for(std::vector<std::pair<MachineInstr*, int> >::const_iterator I = kernel.begin(),
- E = kernel.end(); I != E; ++I)
+ E = kernel.end(); I != E; ++I)
os << "Node: " << *(I->first) << " Stage: " << I->second << "\n";
}
diff --git a/lib/Target/SparcV9/ModuloScheduling/MSSchedule.h b/lib/Target/SparcV9/ModuloScheduling/MSSchedule.h
index 92a942b43c..34a37db8b6 100644
--- a/lib/Target/SparcV9/ModuloScheduling/MSSchedule.h
+++ b/lib/Target/SparcV9/ModuloScheduling/MSSchedule.h
@@ -28,7 +28,7 @@ namespace llvm {
std::map<int, std::map<int, int> > resourceNumPerCycle;
//Check if all resources are free
- bool resourcesFree(MSchedGraphNode*, int, int II);
+ bool resourcesFree(MSchedGraphNode*, int, int II);
bool resourceAvailable(int resourceNum, int cycle);
void useResource(int resourceNum, int cycle);
diff --git a/lib/Target/SparcV9/ModuloScheduling/MSScheduleSB.cpp b/lib/Target/SparcV9/ModuloScheduling/MSScheduleSB.cpp
index baf66f58ad..ef21b80104 100644
--- a/lib/Target/SparcV9/ModuloScheduling/MSScheduleSB.cpp
+++ b/lib/Target/SparcV9/ModuloScheduling/MSScheduleSB.cpp
@@ -33,10 +33,10 @@ bool MSScheduleSB::insert(MSchedGraphSBNode *node, int cycle, int II) {
if (schedule[cycle].size() < numIssue) {
//Now check if all the resources in their respective cycles are available
if(resourcesFree(node, cycle, II)) {
- //Insert to preserve dependencies
- addToSchedule(cycle,node);
- DEBUG(std::cerr << "Found spot in map, and there is an issue slot\n");
- return false;
+ //Insert to preserve dependencies
+ addToSchedule(cycle,node);
+ DEBUG(std::cerr << "Found spot in map, and there is an issue slot\n");
+ return false;
}
}
}
@@ -81,7 +81,7 @@ bool MSScheduleSB::resourceAvailable(int resourceNum, int cycle) {
if(resourceNumPerCycle[cycle].count(resourceNum)) {
int maxRes = CPUResource::getCPUResource(resourceNum)->maxNumUsers;
if(resourceNumPerCycle[cycle][resourceNum] >= maxRes)
- isFree = false;
+ isFree = false;
}
}
@@ -137,21 +137,21 @@ bool MSScheduleSB::resourcesFree(MSchedGraphSBNode *node, int cycle, int II) {
//Loop over resources in each cycle and increments their usage count
for(unsigned i=0; i < resources.size(); ++i) {
for(unsigned j=0; j < resources[i].size(); ++j) {
-
- //Get Resource to check its availability
- int resourceNum = resources[i][j];
-
- DEBUG(std::cerr << "Attempting to schedule Resource Num: " << resourceNum << " in cycle: " << currentCycle << "\n");
-
- success = resourceAvailable(resourceNum, currentCycle);
-
- if(!success)
- break;
-
+
+ //Get Resource to check its availability
+ int resourceNum = resources[i][j];
+
+ DEBUG(std::cerr << "Attempting to schedule Resource Num: " << resourceNum << " in cycle: " << currentCycle << "\n");
+
+ success = resourceAvailable(resourceNum, currentCycle);
+
+ if(!success)
+ break;
+
}
if(!success)
- break;
+ break;
//Increase cycle
currentCycle++;
@@ -172,8 +172,8 @@ bool MSScheduleSB::resourcesFree(MSchedGraphSBNode *node, int cycle, int II) {
//Loop over resources in each cycle and increments their usage count
for(unsigned i=0; i < resources.size(); ++i) {
for(unsigned j=0; j < resources[i].size(); ++j) {
- int resourceNum = resources[i][j];
- useResource(resourceNum, currentCycle);
+ int resourceNum = resources[i][j];
+ useResource(resourceNum, currentCycle);
}
currentCycle++;
}
@@ -205,15 +205,15 @@ bool MSScheduleSB::constructKernel(int II, std::vector<MSchedGraphSBNode*> &bran
int count = 0;
for(int i = index; i <= (schedule.rbegin()->first); i+=II) {
if(schedule.count(i)) {
- for(std::vector<MSchedGraphSBNode*>::iterator I = schedule[i].begin(),
- E = schedule[i].end(); I != E; ++I) {
- //Check if its a branch
- assert(!(*I)->isBranch() && "Branch should not be schedule!");
-
- tempKernel.push_back(std::make_pair(*I, count));
- maxSN = std::max(maxSN, count);
-
- }
+ for(std::vector<MSchedGraphSBNode*>::iterator I = schedule[i].begin(),
+ E = schedule[i].end(); I != E; ++I) {
+ //Check if its a branch
+ assert(!(*I)->isBranch() && "Branch should not be schedule!");
+
+ tempKernel.push_back(std::make_pair(*I, count));
+ maxSN = std::max(maxSN, count);
+
+ }
}
++count;
}
@@ -231,14 +231,14 @@ bool MSScheduleSB::constructKernel(int II, std::vector<MSchedGraphSBNode*> &bran
for(std::map<const MachineInstr*, unsigned>::iterator N = indVar.begin(), NE = indVar.end(); N != NE; ++N) {
- if(N->second < I->first->getIndex())
- tmpMap[N->second] = (MachineInstr*) N->first;
+ if(N->second < I->first->getIndex())
+ tmpMap[N->second] = (MachineInstr*) N->first;
}
//Add to kernel, and delete from indVar
for(std::map<unsigned, MachineInstr*>::iterator N = tmpMap.begin(), NE = tmpMap.end(); N != NE; ++N) {
- kernel.push_back(std::make_pair(N->second, 0));
- indVar.erase(N->second);
+ kernel.push_back(std::make_pair(N->second, 0));
+ indVar.erase(N->second);
}
}
@@ -247,7 +247,7 @@ bool MSScheduleSB::constructKernel(int II, std::vector<MSchedGraphSBNode*> &bran
//assert(I->second == 0 && "Predicate node must be from current iteration\n");
std::vector<const MachineInstr*> otherInstrs = I->first->getOtherInstrs();
for(std::vector<const MachineInstr*>::iterator O = otherInstrs.begin(), OE = otherInstrs.end(); O != OE; ++O) {
- kernel.push_back(std::make_pair((MachineInstr*) *O, I->second));
+ kernel.push_back(std::make_pair((MachineInstr*) *O, I->second));
}
}
@@ -285,10 +285,10 @@ bool MSScheduleSB::defPreviousStage(Value *def, int stage) {
const MachineOperand &mOp = inst->getOperand(i);
if(mOp.getType() == MachineOperand::MO_VirtualRegister && mOp.isDef()) {
if(def == mOp.getVRegValue()) {
- if(P->second >= stage)
- return false;
- else
- return true;
+ if(P->second >= stage)
+ return false;
+ else
+ return true;
}
}
}
@@ -309,7 +309,7 @@ void MSScheduleSB::print(std::ostream &os) const {
os << "Kernel:\n";
for(std::vector<std::pair<MachineInstr*, int> >::const_iterator I = kernel.begin(),
- E = kernel.end(); I != E; ++I)
+ E = kernel.end(); I != E; ++I)
os << "Node: " << *(I->first) << " Stage: " << I->second << "\n";
}
diff --git a/lib/Target/SparcV9/ModuloScheduling/MSScheduleSB.h b/lib/Target/SparcV9/ModuloScheduling/MSScheduleSB.h
index 3d1ffc97df..40bcb873e2 100644
--- a/lib/Target/SparcV9/ModuloScheduling/MSScheduleSB.h
+++ b/lib/Target/SparcV9/ModuloScheduling/MSScheduleSB.h
@@ -28,7 +28,7 @@ namespace llvm {
std::map<int, std::map<int, int> > resourceNumPerCycle;
//Check if all resources are free
- bool resourcesFree(MSchedGraphSBNode*, int, int II);
+ bool resourcesFree(MSchedGraphSBNode*, int, int II);
bool resourceAvailable(int resourceNum, int cycle);
void useResource(int resourceNum, int cycle);
diff --git a/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp b/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp
index 97f047bbbf..055080a40b 100644
--- a/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp
+++ b/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp
@@ -33,8 +33,8 @@ using namespace llvm;
//MSchedGraphNode constructor
MSchedGraphNode::MSchedGraphNode(const MachineInstr* inst,
- MSchedGraph *graph, unsigned idx,
- unsigned late, bool isBranch)
+ MSchedGraph *graph, unsigned idx,
+ unsigned late, bool isBranch)
: Inst(inst), Parent(graph), index(idx), latency(late),
isBranchInstr(isBranch) {
@@ -76,7 +76,7 @@ MSchedGraphEdge MSchedGraphNode::getInEdge(MSchedGraphNode *pred) {
//Get the iteration difference for the edge from this node to its successor
unsigned MSchedGraphNode::getIteDiff(MSchedGraphNode *succ) {
for(std::vector<MSchedGraphEdge>::iterator I = Successors.begin(),
- E = Successors.end();
+ E = Successors.end();
I != E; ++I) {
if(I->getDest() == succ)
return I->getIteDiff();
@@ -90,7 +90,7 @@ unsigned MSchedGraphNode::getInEdgeNum(MSchedGraphNode *pred) {
//return the edge the corresponds to this in edge
int count = 0;
for(MSchedGraphNode::succ_iterator I = pred->succ_begin(),
- E = pred->succ_end();
+ E = pred->succ_end();
I != E; ++I) {
if(*I == this)
return count;
@@ -111,7 +111,7 @@ bool MSchedGraphNode::isSuccessor(MSchedGraphNode *succ) {
//Dtermine if pred is a predecessor of this node
bool MSchedGraphNode::isPredecessor(MSchedGraphNode *pred) {
if(std::find( Predecessors.begin(), Predecessors.end(),
- pred) != Predecessors.end())
+ pred) != Predecessors.end())
return true;
else
return false;
@@ -119,11 +119,11 @@ bool MSchedGraphNode::isPredecessor(MSchedGraphNode *pred) {
//Add a node to the graph
void MSchedGraph::addNode(const MachineInstr *MI,
- MSchedGraphNode *node) {
+ MSchedGraphNode *node) {
//Make sure node does not already exist
assert(GraphMap.find(MI) == GraphMap.end()
- && "New MSchedGraphNode already exists for this instruction");
+ && "New MSchedGraphNode already exists for this instruction");
GraphMap[MI] = node;
}
@@ -149,10 +149,10 @@ void MSchedGraph::deleteNode(MSchedGraphNode *node) {
//is a special case in Modulo Scheduling. We only want to deal with
//the body of the loop.
MSchedGraph::MSchedGraph(const MachineBasicBlock *bb,
- const TargetMachine &targ,
- std::map<const MachineInstr*, unsigned> &ignoreInstrs,
- DependenceAnalyzer &DA,
- std::map<MachineInstr*, Instruction*> &machineTollvm)
+ const TargetMachine &targ,
+ std::map<const MachineInstr*, unsigned> &ignoreInstrs,
+ DependenceAnalyzer &DA,
+ std::map<MachineInstr*, Instruction*> &machineTollvm)
: Target(targ) {
//Make sure BB is not null,
@@ -172,10 +172,10 @@ MSchedGraph::MSchedGraph(const MachineBasicBlock *bb,
//is a special case in Modulo Scheduling. We only want to deal with
//the body of the loop.
MSchedGraph::MSchedGraph(std::vector<const MachineBasicBlock*> &bbs,
- const TargetMachine &targ,
- std::map<const MachineInstr*, unsigned> &ignoreInstrs,
- DependenceAnalyzer &DA,
- std::map<MachineInstr*, Instruction*> &machineTollvm)
+ const TargetMachine &targ,
+ std::map<const MachineInstr*, unsigned> &ignoreInstrs,
+ DependenceAnalyzer &DA,
+ std::map<MachineInstr*, Instruction*> &machineTollvm)
: BBs(bbs), Target(targ) {
//Make sure there is at least one BB and it is not null,
@@ -191,7 +191,7 @@ MSchedGraph::MSchedGraph(std::vector<const MachineBasicBlock*> &bbs,
//Copies the graph and keeps a map from old to new nodes
MSchedGraph::MSchedGraph(const MSchedGraph &G,
- std::map<MSchedGraphNode*, MSchedGraphNode*> &newNodes)
+ std::map<MSchedGraphNode*, MSchedGraphNode*> &newNodes)
: Target(G.Target) {
BBs = G.BBs;
@@ -199,7 +199,7 @@ MSchedGraph::MSchedGraph(const MSchedGraph &G,
std::map<MSchedGraphNode*, MSchedGraphNode*> oldToNew;
//Copy all nodes
for(MSchedGraph::const_iterator N = G.GraphMap.begin(),
- NE = G.GraphMap.end(); N != NE; ++N) {
+ NE = G.GraphMap.end(); N != NE; ++N) {
MSchedGraphNode *newNode = new MSchedGraphNode(*(N->second));
oldToNew[&*(N->second)] = newNode;
@@ -272,8 +272,8 @@ int MSchedGraph::totalDelay() {
}
//Experimental code to add edges from the branch to all nodes dependent upon it.
void hasPath(MSchedGraphNode *node, std::set<MSchedGraphNode*> &visited,
- std::set<MSchedGraphNode*> &branches, MSchedGraphNode *startNode,
- std::set<std::pair<MSchedGraphNode*,MSchedGraphNode*> > &newEdges ) {
+ std::set<MSchedGraphNode*> &branches, MSchedGraphNode *startNode,
+ std::set<std::pair<MSchedGraphNode*,MSchedGraphNode*> > &newEdges ) {
visited.insert(node);
DEBUG(std::cerr << "Visiting: " << *node << "\n");
@@ -287,7 +287,7 @@ void hasPath(MSchedGraphNode *node, std::set<MSchedGraphNode*> &visited,
//only visit if we have not already
else if(!visited.count(dest)) {
if(edge->getIteDiff() == 0)
- hasPath(dest, visited, branches, startNode, newEdges);}
+ hasPath(dest, visited, branches, startNode, newEdges);}
}
@@ -302,7 +302,7 @@ void MSchedGraph::addBranchEdges() {
I != E; ++I) {
if(I->second->isBranch())
if(I->second->hasPredecessors())
- branches.insert(I->second);
+ branches.insert(I->second);
}
//See if there is a path first instruction to the branches, if so, add an
@@ -318,8 +318,8 @@ void MSchedGraph::addBranchEdges() {
unsigned min = GraphMap.size();
if(newEdges.size() == 1) {
((newEdges.begin())->first)->addOutEdge(((newEdges.begin())->second),
- MSchedGraphEdge::BranchDep,
- MSchedGraphEdge::NonDataDep, 1);
+ MSchedGraphEdge::BranchDep,
+ MSchedGraphEdge::NonDataDep, 1);
}
else {
@@ -331,13 +331,13 @@ void MSchedGraph::addBranchEdges() {
DEBUG(std::cerr << "Branch Edge from: " << *(I->first) << " to " << *(I->second) << "\n");
// if(I->second->getIndex() <= min) {
- start = I->first;
- end = I->second;
- //min = I->second->getIndex();
- //}
- start->addOutEdge(end,
- MSchedGraphEdge::BranchDep,
- MSchedGraphEdge::NonDataDep, 1);
+ start = I->first;
+ end = I->second;
+ //min = I->second->getIndex();
+ //}
+ start->addOutEdge(end,
+ MSchedGraphEdge::BranchDep,
+ MSchedGraphEdge::NonDataDep, 1);
}
}
}
@@ -345,8 +345,8 @@ void MSchedGraph::addBranchEdges() {
//Add edges between the nodes
void MSchedGraph::buildNodesAndEdges(std::map<const MachineInstr*, unsigned> &ignoreInstrs,
- DependenceAnalyzer &DA,
- std::map<MachineInstr*, Instruction*> &machineTollvm) {
+ DependenceAnalyzer &DA,
+ std::map<MachineInstr*, Instruction*> &machineTollvm) {
//Get Machine target information for calculating latency
@@ -361,18 +361,18 @@ void MSchedGraph::buildNodesAndEdges(std::map<const MachineInstr*, unsigned> &ig
unsigned index = 0;
for(std::vector<const MachineBasicBlock*>::iterator B = BBs.begin(),
- BE = BBs.end(); B != BE; ++B) {
+ 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) {
+ MI != e; ++MI) {
//Ignore indvar instructions
if(ignoreInstrs.count(MI)) {
- ++index;
- continue;
+ ++index;
+ continue;
}
//Get each instruction of machine basic block, get the delay
@@ -386,16 +386,16 @@ void MSchedGraph::buildNodesAndEdges(std::map<const MachineInstr*, unsigned> &ig
//Check if subsequent instructions can be issued before
//the result is ready, if so use min delay.
if(MTI->hasResultInterlock(MIopCode))
- delay = MTI->minLatency(MIopCode);
+ delay = MTI->minLatency(MIopCode);
else
#endif
- //Get delay
- delay = MTI->maxLatency(opCode);
+ //Get delay
+ delay = MTI->maxLatency(opCode);
//Create new node for this machine instruction and add to the graph.
//Create only if not a nop
if(MTI->isNop(opCode))
- continue;
+ continue;
//Sparc BE does not use PHI opcode, so assert on this case
assert(opCode != TargetInstrInfo::PHI && "Did not expect PHI opcode");
@@ -404,74 +404,74 @@ void MSchedGraph::buildNodesAndEdges(std::map<const MachineInstr*, unsigned> &ig
//We want to flag the branch node to treat it special
if(MTI->isBranch(opCode))
- isBranch = true;
+ isBranch = true;
//Node is created and added to the graph automatically
MSchedGraphNode *node = new MSchedGraphNode(MI, this, index, delay,
- isBranch);
+ isBranch);
DEBUG(std::cerr << "Created Node: " << *node << "\n");
//Check OpCode to keep track of memory operations to add memory
//dependencies later.
if(MTI->isLoad(opCode) || MTI->isStore(opCode))
- memInstructions.push_back(node);
+ memInstructions.push_back(node);
//Loop over all operands, and put them into the register number to
//graph node map for determining dependencies
//If an operands is a use/def, we have an anti dependence to itself
for(unsigned i=0; i < MI->getNumOperands(); ++i) {
- //Get Operand
- const MachineOperand &mOp = MI->getOperand(i);
-
- //Check if it has an allocated register
- if(mOp.hasAllocatedReg()) {
- int regNum = mOp.getReg();
-
- if(regNum != SparcV9::g0) {
- //Put into our map
- regNumtoNodeMap[regNum].push_back(std::make_pair(i, node));
- }
- continue;
- }
-
-
- //Add virtual registers dependencies
- //Check if any exist in the value map already and create dependencies
- //between them.
- if(mOp.getType() == MachineOperand::MO_VirtualRegister
- || mOp.getType() == MachineOperand::MO_CCRegister) {
-
- //Make sure virtual register value is not null
- assert((mOp.getVRegValue() != NULL) && "Null value is defined");
-
- //Check if this is a read operation in a phi node, if so DO NOT PROCESS
- if(mOp.isUse() && (opCode == TargetInstrInfo::PHI)) {
- DEBUG(std::cerr << "Read Operation in a PHI node\n");
- continue;
- }
-
- if (const Value* srcI = mOp.getVRegValue()) {
-
- //Find value in the map
- std::map<const Value*, std::vector<OpIndexNodePair> >::iterator V
- = valuetoNodeMap.find(srcI);
-
- //If there is something in the map already, add edges from
- //those instructions