本文整理汇总了C++中PBB::getPrevStmt方法的典型用法代码示例。如果您正苦于以下问题:C++ PBB::getPrevStmt方法的具体用法?C++ PBB::getPrevStmt怎么用?C++ PBB::getPrevStmt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PBB
的用法示例。
在下文中一共展示了PBB::getPrevStmt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renameBlockVars
//.........这里部分代码省略.........
// modifications. This is necessary because we do several passes of this algorithm to sort out the
// memory expressions
Stacks[a->clone()].push(S);
// Replace definition of a with definition of a_i in S (we don't do this)
}
// FIXME: MVE: do we need this awful hack?
if (a->getOper() == opLocal) {
Exp *a1 = S->getProc()->expFromSymbol(((Const*)a->getSubExp1())->getStr());
assert(a1);
a = a1;
// Stacks already has a definition for a (as just the bare local)
if (suitable) {
Stacks[a->clone()].push(S);
}
}
}
// Special processing for define-alls (presently, only childless calls).
// But note that only everythings at the current memory level are defined!
if (S->isCall() && ((CallStatement*)S)->isChildless() && !Boomerang::get()->assumeABI) {
// S is a childless call (and we're not assuming ABI compliance)
Stacks[defineAll]; // Ensure that there is an entry for defineAll
std::map<Exp*, std::stack<Statement*>, lessExpStar>::iterator dd;
for (dd = Stacks.begin(); dd != Stacks.end(); ++dd) {
// if (dd->first->isMemDepth(memDepth))
dd->second.push(S); // Add a definition for all vars
}
}
}
// For each successor Y of block n
std::vector<PBB>& outEdges = bb->getOutEdges();
unsigned numSucc = outEdges.size();
for (unsigned succ = 0; succ < numSucc; succ++) {
PBB Ybb = outEdges[succ];
// Suppose n is the jth predecessor of Y
int j = Ybb->whichPred(bb);
// For each phi-function in Y
Statement* S;
for (S = Ybb->getFirstStmt(rit, sit); S; S = Ybb->getNextStmt(rit, sit)) {
PhiAssign* pa = dynamic_cast<PhiAssign*>(S);
// if S is not a phi function, then quit the loop (no more phi's)
// Wrong: do not quit the loop: there's an optimisation that turns a PhiAssign into an ordinary Assign.
// So continue, not break.
if (!pa) continue;
// Suppose the jth operand of the phi is a
// For now, just get the LHS
Exp* a = pa->getLeft();
// Only consider variables that can be renamed
if (!canRename(a, proc)) continue;
Statement* def;
if (STACKS_EMPTY(a))
def = NULL; // No reaching definition
else
def = Stacks[a].top();
// "Replace jth operand with a_i"
pa->putAt(j, def, a);
}
}
// For each child X of n
// Note: linear search!
unsigned numBB = proc->getCFG()->getNumBBs();
for (unsigned X=0; X < numBB; X++) {
if (idom[X] == n)
renameBlockVars(proc, X);
}
// For each statement S in block n
// NOTE: Because of the need to pop childless calls from the Stacks, it is important in my algorithm to process the
// statments in the BB *backwards*. (It is not important in Appel's algorithm, since he always pushes a definition
// for every variable defined on the Stacks).
BasicBlock::rtlrit rrit; StatementList::reverse_iterator srit;
for (S = bb->getLastStmt(rrit, srit); S; S = bb->getPrevStmt(rrit, srit)) {
// For each definition of some variable a in S
LocationSet defs;
S->getDefinitions(defs);
LocationSet::iterator dd;
for (dd = defs.begin(); dd != defs.end(); dd++) {
if (canRename(*dd, proc)) {
// if ((*dd)->getMemDepth() == memDepth)
std::map<Exp*, std::stack<Statement*>, lessExpStar>::iterator ss = Stacks.find(*dd);
if (ss == Stacks.end()) {
std::cerr << "Tried to pop " << *dd << " from Stacks; does not exist\n";
assert(0);
}
ss->second.pop();
}
}
// Pop all defs due to childless calls
if (S->isCall() && ((CallStatement*)S)->isChildless()) {
std::map<Exp*, std::stack<Statement*>, lessExpStar>::iterator sss;
for (sss = Stacks.begin(); sss != Stacks.end(); ++sss) {
if (!sss->second.empty() && sss->second.top() == S) {
sss->second.pop();
}
}
}
}
return changed;
}