本文整理汇总了C++中Prog::finishDecode方法的典型用法代码示例。如果您正苦于以下问题:C++ Prog::finishDecode方法的具体用法?C++ Prog::finishDecode怎么用?C++ Prog::finishDecode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Prog
的用法示例。
在下文中一共展示了Prog::finishDecode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testRenameVars
/*==============================================================================
* FUNCTION: CfgTest::testRenameVars
* OVERVIEW: Test the renaming of variables
*============================================================================*/
void CfgTest::testRenameVars ()
{
BinaryFileFactory bff;
BinaryFile* pBF = bff.Load(FRONTIER_PENTIUM);
CPPUNIT_ASSERT(pBF != 0);
Prog* prog = new Prog;
FrontEnd* pFE = new PentiumFrontEnd(pBF, prog, &bff);
Type::clearNamedTypes();
prog->setFrontEnd(pFE);
pFE->decode(prog);
UserProc* pProc = (UserProc*) prog->getProc(0);
Cfg* cfg = pProc->getCFG();
DataFlow* df = pProc->getDataFlow();
// Simplify expressions (e.g. m[ebp + -8] -> m[ebp - 8]
prog->finishDecode();
df->dominators(cfg);
df->placePhiFunctions(pProc);
pProc->numberStatements(); // After placing phi functions!
df->renameBlockVars(pProc, 0, 1); // Block 0, mem depth 1
// MIKE: something missing here?
delete pFE;
}
示例2: Binary
/*==============================================================================
* FUNCTION: CfgTest::testPlacePhi2
* OVERVIEW: Test a case where a phi function is not needed
*============================================================================*/
void CfgTest::testPlacePhi2 ()
{
BinaryFileFactory bff;
BinaryFile* pBF = bff.Load(IFTHEN_PENTIUM);
CPPUNIT_ASSERT(pBF != 0);
Prog* prog = new Prog;
FrontEnd* pFE = new PentiumFrontEnd(pBF, prog, &bff);
Type::clearNamedTypes();
prog->setFrontEnd(pFE);
pFE->decode(prog);
UserProc* pProc = (UserProc*) prog->getProc(0);
Cfg* cfg = pProc->getCFG();
DataFlow* df = pProc->getDataFlow();
// Simplify expressions (e.g. m[ebp + -8] -> m[ebp - 8]
prog->finishDecode();
df->dominators(cfg);
df->placePhiFunctions(pProc);
// In this program, x is allocated at [ebp-4], a at [ebp-8], and
// b at [ebp-12]
// We check that A_phi[ m[ebp-8] ] is 4, and that
// A_phi A_phi[ m[ebp-8] ] is null
// (block 4 comes out with n=4)
std::string expected = "4 ";
std::ostringstream actual;
// m[r29 - 8]
Exp* e = new Unary(opMemOf,
new Binary(opMinus,
Location::regOf(29),
new Const(8)));
std::set<int>& s = df->getA_phi(e);
std::set<int>::iterator pp;
for (pp = s.begin(); pp != s.end(); pp++)
actual << *pp << " ";
CPPUNIT_ASSERT_EQUAL(expected, actual.str());
delete e;
expected = "";
std::ostringstream actual2;
// m[r29 - 12]
e = new Unary(opMemOf,
new Binary(opMinus,
Location::regOf(29),
new Const(12)));
std::set<int>& s2 = df->getA_phi(e);
for (pp = s2.begin(); pp != s2.end(); pp++)
actual2 << *pp << " ";
CPPUNIT_ASSERT_EQUAL(expected, actual2.str());
delete e;
delete pFE;
}
示例3: testPlacePhi
/*==============================================================================
* FUNCTION: CfgTest::testPlacePhi
* OVERVIEW: Test the placing of phi functions
*============================================================================*/
void CfgTest::testPlacePhi ()
{
BinaryFileFactory bff;
BinaryFile* pBF = bff.Load(FRONTIER_PENTIUM);
CPPUNIT_ASSERT(pBF != 0);
Prog* prog = new Prog;
FrontEnd* pFE = new PentiumFrontEnd(pBF, prog, &bff);
Type::clearNamedTypes();
prog->setFrontEnd(pFE);
pFE->decode(prog);
UserProc* pProc = (UserProc*) prog->getProc(0);
Cfg* cfg = pProc->getCFG();
// Simplify expressions (e.g. m[ebp + -8] -> m[ebp - 8]
prog->finishDecode();
DataFlow* df = pProc->getDataFlow();
df->dominators(cfg);
df->placePhiFunctions(pProc);
// m[r29 - 8] (x for this program)
Exp* e = new Unary(opMemOf,
new Binary(opMinus,
Location::regOf(29),
new Const(4)));
// A_phi[x] should be the set {7 8 10 15 20 21} (all the join points)
std::ostringstream ost;
std::set<int>::iterator ii;
std::set<int>& A_phi = df->getA_phi(e);
for (ii = A_phi.begin(); ii != A_phi.end(); ++ii)
ost << *ii << " ";
std::string expected("7 8 10 15 20 21 ");
CPPUNIT_ASSERT_EQUAL(expected, ost.str());
delete pFE;
}