本文整理汇总了C++中AstInterface::RemoveStmt方法的典型用法代码示例。如果您正苦于以下问题:C++ AstInterface::RemoveStmt方法的具体用法?C++ AstInterface::RemoveStmt怎么用?C++ AstInterface::RemoveStmt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstInterface
的用法示例。
在下文中一共展示了AstInterface::RemoveStmt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
bool LoopUnrolling::operator() ( AstInterface& fa, const AstNodePtr& s, AstNodePtr& r)
{
bool isLoop = false;
if (enclosingloop == s || (enclosingloop == AST_NULL && (isLoop = fa.IsLoop(s)))) {
for (enclosingloop = fa.GetParent(s);
enclosingloop != AST_NULL && !fa.IsLoop(enclosingloop);
enclosingloop = fa.GetParent(enclosingloop));
if (!isLoop)
return false;
}
AstNodePtr body;
SymbolicVal stepval, ubval, lbval;
SymbolicVar ivar;
if (!SymbolicValGenerator::IsFortranLoop(fa, s, &ivar, &lbval, &ubval, &stepval, &body))
return false;
if (opt & POET_TUNING) {
AutoTuningInterface* tune = LoopTransformInterface::getAutoTuningInterface();
if (tune == 0) {
std::cerr << "ERROR: AutoTuning Interface not defined!\n";
assert(0);
}
tune->UnrollLoop(fa,s, unrollsize);
}
else {
AstNodePtr r = s;
SymbolicVal nstepval = stepval * unrollsize;
SymbolicVal nubval = ubval;
bool hasleft = true, negativeStep = (stepval < 0);
std::vector<AstNodePtr> bodylist;
AstNodePtr leftbody, lefthead;
int stepnum=0, loopnum = 0;
SymbolicVal loopval = ubval - lbval + 1;
if (stepval.isConstInt(stepnum) && loopval.isConstInt(loopnum)
&& !(loopnum % stepnum)) {
hasleft = false;
}
else {
nubval = ubval - SymbolicVal(unrollsize - 1);
if (opt & COND_LEFTOVER) {
leftbody = fa.CreateBlock();
lefthead = leftbody;
}
else {
leftbody = fa.CopyAstTree(body);
lefthead = fa.CreateLoop( ivar.CodeGen(fa),
AstNodePtr(),
ubval.CodeGen(fa),
stepval.CodeGen(fa), leftbody,
negativeStep);
}
}
fa.RemoveStmt(body);
AstNodePtr s1 = fa.CreateLoop(ivar.CodeGen(fa), lbval.CodeGen(fa),
nubval.CodeGen(fa),
nstepval.CodeGen(fa), body,
negativeStep);
fa.ReplaceAst( s,s1);
r = s1;
AstNodePtr origbody = fa.CopyAstTree(body);
std::string nvarname = "";
SymbolicVal nvar;
if (opt & USE_NEWVAR) {
nvarname = fa.NewVar(fa.GetType("int"),"",true,body, ivar.CodeGen(fa));
nvar = SymbolicVar(nvarname,body);
}
bodylist.push_back(body);
for (int i = 1; i < unrollsize; ++i) {
AstNodePtr bodycopy = fa.CopyAstTree(origbody);
if (opt & USE_NEWVAR) {
AstNodePtr nvarassign =
fa.CreateAssignment(nvar.CodeGen(fa), (nvar+1).CodeGen(fa));
fa.BlockAppendStmt( body, nvarassign);
AstTreeReplaceVar repl(ivar, nvar);
repl( fa, bodycopy);
}
else {
AstTreeReplaceVar repl(ivar, ivar+i);
repl( fa, bodycopy);
}
fa.BlockAppendStmt( body, bodycopy);
bodylist.push_back(bodycopy);
if (hasleft && (opt & COND_LEFTOVER)) {
AstNodePtr cond =
fa.CreateBinaryOP( AstInterface::BOP_LE, ivar.CodeGen(fa), (ubval-(i-1)).CodeGen(fa));
AstNodePtr body1 = fa.CopyAstTree(bodylist[i-1]);
AstNodePtr ifstmt = fa.CreateIf( cond, body1);
fa.BlockAppendStmt( leftbody, ifstmt);
leftbody = body1;
}
}
if (hasleft) {
fa.InsertStmt( r, lefthead, false, true);
}
r = s;
return true;
//.........这里部分代码省略.........