mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-04 18:06:49 +00:00
compiled with the new SchedGraphCommon
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6545 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b84388937c
commit
099b064a46
@ -50,12 +50,12 @@ struct ValueToDefVecMap:public hash_map<const Instruction*,RefVec> {
|
|||||||
|
|
||||||
// class Modulo SchedGraphNode
|
// class Modulo SchedGraphNode
|
||||||
|
|
||||||
ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned int _nodeId,
|
ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned int in_nodeId,
|
||||||
const BasicBlock * _bb,
|
const BasicBlock * in_bb,
|
||||||
const Instruction * _inst,
|
const Instruction * in_inst,
|
||||||
int indexInBB,
|
int indexInBB,
|
||||||
const TargetMachine & target)
|
const TargetMachine & target)
|
||||||
:SchedGraphNodeCommon(_nodeId, _bb, indexInBB), inst(_inst)
|
:SchedGraphNodeCommon(in_nodeId, indexInBB), inst(in_inst)
|
||||||
{
|
{
|
||||||
if (inst) {
|
if (inst) {
|
||||||
//FIXME: find the latency
|
//FIXME: find the latency
|
||||||
@ -298,8 +298,7 @@ bool ModuloSchedGraph::isLoop() {
|
|||||||
//only if the last instruction in the basicblock is branch instruction and
|
//only if the last instruction in the basicblock is branch instruction and
|
||||||
//there is at least an option to branch itself
|
//there is at least an option to branch itself
|
||||||
|
|
||||||
assert(bbVec.size() == 1 && "only 1 basicblock in a graph");
|
assert(this->bb&& "the basicblock is not empty");
|
||||||
const BasicBlock *bb = bbVec[0];
|
|
||||||
const Instruction *inst = &(bb->back());
|
const Instruction *inst = &(bb->back());
|
||||||
if (BranchInst::classof(inst))
|
if (BranchInst::classof(inst))
|
||||||
for (unsigned i = 0; i < ((BranchInst *) inst)->getNumSuccessors();
|
for (unsigned i = 0; i < ((BranchInst *) inst)->getNumSuccessors();
|
||||||
@ -308,7 +307,7 @@ bool ModuloSchedGraph::isLoop() {
|
|||||||
if (sb == bb)
|
if (sb == bb)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -674,7 +673,6 @@ void ModuloSchedGraph::orderNodes() {
|
|||||||
oNodes.clear();
|
oNodes.clear();
|
||||||
|
|
||||||
std::vector < ModuloSchedGraphNode * >set;
|
std::vector < ModuloSchedGraphNode * >set;
|
||||||
const BasicBlock *bb = bbVec[0];
|
|
||||||
unsigned numNodes = bb->size();
|
unsigned numNodes = bb->size();
|
||||||
|
|
||||||
// first order all the sets
|
// first order all the sets
|
||||||
@ -873,9 +871,8 @@ void ModuloSchedGraph::orderNodes() {
|
|||||||
|
|
||||||
void ModuloSchedGraph::buildGraph(const TargetMachine & target)
|
void ModuloSchedGraph::buildGraph(const TargetMachine & target)
|
||||||
{
|
{
|
||||||
const BasicBlock *bb = bbVec[0];
|
|
||||||
|
|
||||||
assert(bbVec.size() == 1 && "only handling a single basic block here");
|
assert(this->bb && "The basicBlock is NULL?");
|
||||||
|
|
||||||
// Use this data structure to note all machine operands that compute
|
// Use this data structure to note all machine operands that compute
|
||||||
// ordinary LLVM values. These must be computed defs (i.e., instructions).
|
// ordinary LLVM values. These must be computed defs (i.e., instructions).
|
||||||
@ -1277,10 +1274,9 @@ void ModuloSchedGraph::dump(const BasicBlock * bb, std::ostream & os)
|
|||||||
void ModuloSchedGraph::dump() const
|
void ModuloSchedGraph::dump() const
|
||||||
{
|
{
|
||||||
DEBUG(std::cerr << " ModuloSchedGraph for basic Blocks:");
|
DEBUG(std::cerr << " ModuloSchedGraph for basic Blocks:");
|
||||||
for (unsigned i = 0, N = bbVec.size(); i < N; i++) {
|
|
||||||
DEBUG(std::cerr << (bbVec[i]->hasName()? bbVec[i]->getName() : "block")
|
DEBUG(std::cerr << (bb->hasName()? bb->getName() : "block")
|
||||||
<< " (" << bbVec[i] << ")" << ((i == N - 1) ? "" : ", "));
|
<< " (" << bb << ")" << "");
|
||||||
}
|
|
||||||
|
|
||||||
DEBUG(std::cerr << "\n\n Actual Root nodes : ");
|
DEBUG(std::cerr << "\n\n Actual Root nodes : ");
|
||||||
for (unsigned i = 0, N = graphRoot->outEdges.size(); i < N; i++)
|
for (unsigned i = 0, N = graphRoot->outEdges.size(); i < N; i++)
|
||||||
@ -1290,7 +1286,7 @@ void ModuloSchedGraph::dump() const
|
|||||||
DEBUG(std::cerr << "\n Graph Nodes:\n");
|
DEBUG(std::cerr << "\n Graph Nodes:\n");
|
||||||
//for (const_iterator I=begin(); I != end(); ++I)
|
//for (const_iterator I=begin(); I != end(); ++I)
|
||||||
//DEBUG(std::cerr << "\n" << *I->second;
|
//DEBUG(std::cerr << "\n" << *I->second;
|
||||||
unsigned numNodes = bbVec[0]->size();
|
unsigned numNodes = bb->size();
|
||||||
for (unsigned i = 2; i < numNodes + 2; i++) {
|
for (unsigned i = 2; i < numNodes + 2; i++) {
|
||||||
ModuloSchedGraphNode *node = getNode(i);
|
ModuloSchedGraphNode *node = getNode(i);
|
||||||
DEBUG(std::cerr << "\n" << *node);
|
DEBUG(std::cerr << "\n" << *node);
|
||||||
@ -1301,7 +1297,7 @@ void ModuloSchedGraph::dump() const
|
|||||||
|
|
||||||
void ModuloSchedGraph::dumpNodeProperty() const
|
void ModuloSchedGraph::dumpNodeProperty() const
|
||||||
{
|
{
|
||||||
const BasicBlock *bb = bbVec[0];
|
|
||||||
unsigned numNodes = bb->size();
|
unsigned numNodes = bb->size();
|
||||||
for (unsigned i = 2; i < numNodes + 2; i++) {
|
for (unsigned i = 2; i < numNodes + 2; i++) {
|
||||||
ModuloSchedGraphNode *node = getNode(i);
|
ModuloSchedGraphNode *node = getNode(i);
|
||||||
@ -1317,8 +1313,11 @@ void ModuloSchedGraph::dumpNodeProperty() const
|
|||||||
void ModuloSchedGraphSet::buildGraphsForMethod(const Function *F,
|
void ModuloSchedGraphSet::buildGraphsForMethod(const Function *F,
|
||||||
const TargetMachine &target)
|
const TargetMachine &target)
|
||||||
{
|
{
|
||||||
for (Function::const_iterator BI = F->begin(); BI != F->end(); ++BI)
|
for (Function::const_iterator BI = F->begin(); BI != F->end(); ++BI){
|
||||||
addGraph(new ModuloSchedGraph(BI, target));
|
const BasicBlock* local_bb;
|
||||||
|
local_bb=BI;
|
||||||
|
addGraph(new ModuloSchedGraph((BasicBlock*)local_bb, target));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream &os,
|
std::ostream& operator<<(std::ostream &os,
|
||||||
|
@ -56,6 +56,7 @@ public:
|
|||||||
const unsigned getInstOpcode() const {
|
const unsigned getInstOpcode() const {
|
||||||
return inst->getOpcode();
|
return inst->getOpcode();
|
||||||
}
|
}
|
||||||
|
|
||||||
//return whether the node is NULL
|
//return whether the node is NULL
|
||||||
bool isNullNode() const {
|
bool isNullNode() const {
|
||||||
return (inst == NULL);
|
return (inst == NULL);
|
||||||
@ -138,6 +139,9 @@ class ModuloSchedGraph :
|
|||||||
protected hash_map<const Instruction*,ModuloSchedGraphNode*> {
|
protected hash_map<const Instruction*,ModuloSchedGraphNode*> {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
BasicBlock* bb;
|
||||||
|
|
||||||
//iteration Interval
|
//iteration Interval
|
||||||
int MII;
|
int MII;
|
||||||
|
|
||||||
@ -153,14 +157,14 @@ private:
|
|||||||
typedef std::vector<ModuloSchedGraphNode*> NodeVec;
|
typedef std::vector<ModuloSchedGraphNode*> NodeVec;
|
||||||
|
|
||||||
//the function to compute properties
|
//the function to compute properties
|
||||||
void computeNodeASAP(const BasicBlock *bb);
|
void computeNodeASAP(const BasicBlock * in_bb);
|
||||||
void computeNodeALAP(const BasicBlock *bb);
|
void computeNodeALAP(const BasicBlock * in_bb);
|
||||||
void computeNodeMov(const BasicBlock *bb);
|
void computeNodeMov(const BasicBlock * in_bb);
|
||||||
void computeNodeDepth(const BasicBlock *bb);
|
void computeNodeDepth(const BasicBlock * in_bb);
|
||||||
void computeNodeHeight(const BasicBlock *bb);
|
void computeNodeHeight(const BasicBlock * in_bb);
|
||||||
|
|
||||||
//the function to compute node property
|
//the function to compute node property
|
||||||
void computeNodeProperty(const BasicBlock *bb);
|
void computeNodeProperty(const BasicBlock * in_bb);
|
||||||
|
|
||||||
//the function to sort nodes
|
//the function to sort nodes
|
||||||
void orderNodes();
|
void orderNodes();
|
||||||
@ -220,6 +224,13 @@ public:
|
|||||||
const TargetMachine & getTarget() {
|
const TargetMachine & getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get the basic block
|
||||||
|
BasicBlock* getBasicBlock() const {
|
||||||
|
return bb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//get the iteration interval
|
//get the iteration interval
|
||||||
const int getMII() {
|
const int getMII() {
|
||||||
return MII;
|
return MII;
|
||||||
@ -265,8 +276,9 @@ private:
|
|||||||
friend class ModuloSchedGraphSet; //give access to ctor
|
friend class ModuloSchedGraphSet; //give access to ctor
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ModuloSchedGraph(const BasicBlock *bb, const TargetMachine &_target)
|
ModuloSchedGraph(BasicBlock * in_bb,
|
||||||
:SchedGraphCommon(bb), target(_target)
|
const TargetMachine & in_target)
|
||||||
|
:SchedGraphCommon(), bb(in_bb),target(in_target)
|
||||||
{
|
{
|
||||||
buildGraph(target);
|
buildGraph(target);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
graph(_graph), target(graph.getTarget()), oNodes(graph.getONodes())
|
graph(_graph), target(graph.getTarget()), oNodes(graph.getONodes())
|
||||||
{
|
{
|
||||||
II = graph.getMII();
|
II = graph.getMII();
|
||||||
bb = (BasicBlock *) graph.getBasicBlocks()[0];
|
bb = graph.getBasicBlock();
|
||||||
instrScheduling();
|
instrScheduling();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,12 +50,12 @@ struct ValueToDefVecMap:public hash_map<const Instruction*,RefVec> {
|
|||||||
|
|
||||||
// class Modulo SchedGraphNode
|
// class Modulo SchedGraphNode
|
||||||
|
|
||||||
ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned int _nodeId,
|
ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned int in_nodeId,
|
||||||
const BasicBlock * _bb,
|
const BasicBlock * in_bb,
|
||||||
const Instruction * _inst,
|
const Instruction * in_inst,
|
||||||
int indexInBB,
|
int indexInBB,
|
||||||
const TargetMachine & target)
|
const TargetMachine & target)
|
||||||
:SchedGraphNodeCommon(_nodeId, _bb, indexInBB), inst(_inst)
|
:SchedGraphNodeCommon(in_nodeId, indexInBB), inst(in_inst)
|
||||||
{
|
{
|
||||||
if (inst) {
|
if (inst) {
|
||||||
//FIXME: find the latency
|
//FIXME: find the latency
|
||||||
@ -298,8 +298,7 @@ bool ModuloSchedGraph::isLoop() {
|
|||||||
//only if the last instruction in the basicblock is branch instruction and
|
//only if the last instruction in the basicblock is branch instruction and
|
||||||
//there is at least an option to branch itself
|
//there is at least an option to branch itself
|
||||||
|
|
||||||
assert(bbVec.size() == 1 && "only 1 basicblock in a graph");
|
assert(this->bb&& "the basicblock is not empty");
|
||||||
const BasicBlock *bb = bbVec[0];
|
|
||||||
const Instruction *inst = &(bb->back());
|
const Instruction *inst = &(bb->back());
|
||||||
if (BranchInst::classof(inst))
|
if (BranchInst::classof(inst))
|
||||||
for (unsigned i = 0; i < ((BranchInst *) inst)->getNumSuccessors();
|
for (unsigned i = 0; i < ((BranchInst *) inst)->getNumSuccessors();
|
||||||
@ -308,7 +307,7 @@ bool ModuloSchedGraph::isLoop() {
|
|||||||
if (sb == bb)
|
if (sb == bb)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -674,7 +673,6 @@ void ModuloSchedGraph::orderNodes() {
|
|||||||
oNodes.clear();
|
oNodes.clear();
|
||||||
|
|
||||||
std::vector < ModuloSchedGraphNode * >set;
|
std::vector < ModuloSchedGraphNode * >set;
|
||||||
const BasicBlock *bb = bbVec[0];
|
|
||||||
unsigned numNodes = bb->size();
|
unsigned numNodes = bb->size();
|
||||||
|
|
||||||
// first order all the sets
|
// first order all the sets
|
||||||
@ -873,9 +871,8 @@ void ModuloSchedGraph::orderNodes() {
|
|||||||
|
|
||||||
void ModuloSchedGraph::buildGraph(const TargetMachine & target)
|
void ModuloSchedGraph::buildGraph(const TargetMachine & target)
|
||||||
{
|
{
|
||||||
const BasicBlock *bb = bbVec[0];
|
|
||||||
|
|
||||||
assert(bbVec.size() == 1 && "only handling a single basic block here");
|
assert(this->bb && "The basicBlock is NULL?");
|
||||||
|
|
||||||
// Use this data structure to note all machine operands that compute
|
// Use this data structure to note all machine operands that compute
|
||||||
// ordinary LLVM values. These must be computed defs (i.e., instructions).
|
// ordinary LLVM values. These must be computed defs (i.e., instructions).
|
||||||
@ -1277,10 +1274,9 @@ void ModuloSchedGraph::dump(const BasicBlock * bb, std::ostream & os)
|
|||||||
void ModuloSchedGraph::dump() const
|
void ModuloSchedGraph::dump() const
|
||||||
{
|
{
|
||||||
DEBUG(std::cerr << " ModuloSchedGraph for basic Blocks:");
|
DEBUG(std::cerr << " ModuloSchedGraph for basic Blocks:");
|
||||||
for (unsigned i = 0, N = bbVec.size(); i < N; i++) {
|
|
||||||
DEBUG(std::cerr << (bbVec[i]->hasName()? bbVec[i]->getName() : "block")
|
DEBUG(std::cerr << (bb->hasName()? bb->getName() : "block")
|
||||||
<< " (" << bbVec[i] << ")" << ((i == N - 1) ? "" : ", "));
|
<< " (" << bb << ")" << "");
|
||||||
}
|
|
||||||
|
|
||||||
DEBUG(std::cerr << "\n\n Actual Root nodes : ");
|
DEBUG(std::cerr << "\n\n Actual Root nodes : ");
|
||||||
for (unsigned i = 0, N = graphRoot->outEdges.size(); i < N; i++)
|
for (unsigned i = 0, N = graphRoot->outEdges.size(); i < N; i++)
|
||||||
@ -1290,7 +1286,7 @@ void ModuloSchedGraph::dump() const
|
|||||||
DEBUG(std::cerr << "\n Graph Nodes:\n");
|
DEBUG(std::cerr << "\n Graph Nodes:\n");
|
||||||
//for (const_iterator I=begin(); I != end(); ++I)
|
//for (const_iterator I=begin(); I != end(); ++I)
|
||||||
//DEBUG(std::cerr << "\n" << *I->second;
|
//DEBUG(std::cerr << "\n" << *I->second;
|
||||||
unsigned numNodes = bbVec[0]->size();
|
unsigned numNodes = bb->size();
|
||||||
for (unsigned i = 2; i < numNodes + 2; i++) {
|
for (unsigned i = 2; i < numNodes + 2; i++) {
|
||||||
ModuloSchedGraphNode *node = getNode(i);
|
ModuloSchedGraphNode *node = getNode(i);
|
||||||
DEBUG(std::cerr << "\n" << *node);
|
DEBUG(std::cerr << "\n" << *node);
|
||||||
@ -1301,7 +1297,7 @@ void ModuloSchedGraph::dump() const
|
|||||||
|
|
||||||
void ModuloSchedGraph::dumpNodeProperty() const
|
void ModuloSchedGraph::dumpNodeProperty() const
|
||||||
{
|
{
|
||||||
const BasicBlock *bb = bbVec[0];
|
|
||||||
unsigned numNodes = bb->size();
|
unsigned numNodes = bb->size();
|
||||||
for (unsigned i = 2; i < numNodes + 2; i++) {
|
for (unsigned i = 2; i < numNodes + 2; i++) {
|
||||||
ModuloSchedGraphNode *node = getNode(i);
|
ModuloSchedGraphNode *node = getNode(i);
|
||||||
@ -1317,8 +1313,11 @@ void ModuloSchedGraph::dumpNodeProperty() const
|
|||||||
void ModuloSchedGraphSet::buildGraphsForMethod(const Function *F,
|
void ModuloSchedGraphSet::buildGraphsForMethod(const Function *F,
|
||||||
const TargetMachine &target)
|
const TargetMachine &target)
|
||||||
{
|
{
|
||||||
for (Function::const_iterator BI = F->begin(); BI != F->end(); ++BI)
|
for (Function::const_iterator BI = F->begin(); BI != F->end(); ++BI){
|
||||||
addGraph(new ModuloSchedGraph(BI, target));
|
const BasicBlock* local_bb;
|
||||||
|
local_bb=BI;
|
||||||
|
addGraph(new ModuloSchedGraph((BasicBlock*)local_bb, target));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream &os,
|
std::ostream& operator<<(std::ostream &os,
|
||||||
|
@ -56,6 +56,7 @@ public:
|
|||||||
const unsigned getInstOpcode() const {
|
const unsigned getInstOpcode() const {
|
||||||
return inst->getOpcode();
|
return inst->getOpcode();
|
||||||
}
|
}
|
||||||
|
|
||||||
//return whether the node is NULL
|
//return whether the node is NULL
|
||||||
bool isNullNode() const {
|
bool isNullNode() const {
|
||||||
return (inst == NULL);
|
return (inst == NULL);
|
||||||
@ -138,6 +139,9 @@ class ModuloSchedGraph :
|
|||||||
protected hash_map<const Instruction*,ModuloSchedGraphNode*> {
|
protected hash_map<const Instruction*,ModuloSchedGraphNode*> {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
BasicBlock* bb;
|
||||||
|
|
||||||
//iteration Interval
|
//iteration Interval
|
||||||
int MII;
|
int MII;
|
||||||
|
|
||||||
@ -153,14 +157,14 @@ private:
|
|||||||
typedef std::vector<ModuloSchedGraphNode*> NodeVec;
|
typedef std::vector<ModuloSchedGraphNode*> NodeVec;
|
||||||
|
|
||||||
//the function to compute properties
|
//the function to compute properties
|
||||||
void computeNodeASAP(const BasicBlock *bb);
|
void computeNodeASAP(const BasicBlock * in_bb);
|
||||||
void computeNodeALAP(const BasicBlock *bb);
|
void computeNodeALAP(const BasicBlock * in_bb);
|
||||||
void computeNodeMov(const BasicBlock *bb);
|
void computeNodeMov(const BasicBlock * in_bb);
|
||||||
void computeNodeDepth(const BasicBlock *bb);
|
void computeNodeDepth(const BasicBlock * in_bb);
|
||||||
void computeNodeHeight(const BasicBlock *bb);
|
void computeNodeHeight(const BasicBlock * in_bb);
|
||||||
|
|
||||||
//the function to compute node property
|
//the function to compute node property
|
||||||
void computeNodeProperty(const BasicBlock *bb);
|
void computeNodeProperty(const BasicBlock * in_bb);
|
||||||
|
|
||||||
//the function to sort nodes
|
//the function to sort nodes
|
||||||
void orderNodes();
|
void orderNodes();
|
||||||
@ -220,6 +224,13 @@ public:
|
|||||||
const TargetMachine & getTarget() {
|
const TargetMachine & getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get the basic block
|
||||||
|
BasicBlock* getBasicBlock() const {
|
||||||
|
return bb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//get the iteration interval
|
//get the iteration interval
|
||||||
const int getMII() {
|
const int getMII() {
|
||||||
return MII;
|
return MII;
|
||||||
@ -265,8 +276,9 @@ private:
|
|||||||
friend class ModuloSchedGraphSet; //give access to ctor
|
friend class ModuloSchedGraphSet; //give access to ctor
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ModuloSchedGraph(const BasicBlock *bb, const TargetMachine &_target)
|
ModuloSchedGraph(BasicBlock * in_bb,
|
||||||
:SchedGraphCommon(bb), target(_target)
|
const TargetMachine & in_target)
|
||||||
|
:SchedGraphCommon(), bb(in_bb),target(in_target)
|
||||||
{
|
{
|
||||||
buildGraph(target);
|
buildGraph(target);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
graph(_graph), target(graph.getTarget()), oNodes(graph.getONodes())
|
graph(_graph), target(graph.getTarget()), oNodes(graph.getONodes())
|
||||||
{
|
{
|
||||||
II = graph.getMII();
|
II = graph.getMII();
|
||||||
bb = (BasicBlock *) graph.getBasicBlocks()[0];
|
bb = graph.getBasicBlock();
|
||||||
instrScheduling();
|
instrScheduling();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user