improved CFG functions style
This commit is contained in:
@@ -50,27 +50,28 @@ BBlock::BasicBlock(const BBlock& copyFrom)
|
||||
prev = copyFrom.prev;
|
||||
}
|
||||
|
||||
void BBlock::addInstruction(IR_Block* item)
|
||||
void BBlock::addInstruction(IR_Block* item, bool pushFront)
|
||||
{
|
||||
instructions.push_back(item);
|
||||
if (pushFront)
|
||||
instructions.insert(instructions.begin(), item);
|
||||
else
|
||||
instructions.push_back(item);
|
||||
item->setBasicBlock(this);
|
||||
}
|
||||
|
||||
void BBlock::addInstructionInFront(IR_Block* item)
|
||||
void BBlock::addInstructionBefore(IR_Block* item, Instruction* before)
|
||||
{
|
||||
instructions.insert(instructions.begin(), item);
|
||||
item->setBasicBlock(this);
|
||||
}
|
||||
checkNull(before, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
checkNull(item, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
void BBlock::addInstructionBeforeInstruction(IR_Block* item, Instruction* instruction)
|
||||
{
|
||||
for (auto it = instructions.begin(); it != instructions.end(); ++it) {
|
||||
if ((*it)->getInstruction() == instruction) {
|
||||
if ((*it)->getInstruction() == before) {
|
||||
instructions.insert(it, item);
|
||||
item->setBasicBlock(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
|
||||
int BBlock::removePrev(BBlock* removed)
|
||||
@@ -529,7 +530,7 @@ static int buildReachingDefs(const vector<BBlock*>& CFG, const FuncInfo* currF,
|
||||
return iter;
|
||||
}
|
||||
|
||||
//Kosaraju<EFBFBD>Sharir algorithm
|
||||
//Kosaraju-Sharir algorithm
|
||||
static vector<int> getStronglyConnectedComps(vector<vector<int>>& g) {
|
||||
// 1. For each vertex u of the graph, mark u as unvisited. Let l be empty.
|
||||
auto size = g.size();
|
||||
|
||||
Reference in New Issue
Block a user