本文整理汇总了C++中SymbolicVal::CodeGen方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolicVal::CodeGen方法的具体用法?C++ SymbolicVal::CodeGen怎么用?C++ SymbolicVal::CodeGen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolicVal
的用法示例。
在下文中一共展示了SymbolicVal::CodeGen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
AstNodePtr SymbolicFunction :: CodeGen( AstInterface &_fa) const
{
AstInterface::AstNodeList l;
for (const_iterator i = args.begin(); i != args.end(); ++i) {
SymbolicVal cur = *i;
AstNodePtr curast = cur.CodeGen(_fa);
l.push_back(curast);
}
if (t == AstInterface::OP_NONE) {
return _fa.CreateFunctionCall( op, l);
}
else if (t == AstInterface::OP_ARRAY_ACCESS) {
AstNodePtr arr = l.front();
l.pop_front();
return _fa.CreateArrayAccess(arr, l);
}
else if (t == AstInterface::OP_ASSIGN && l.size() == 2) {
return _fa.CreateAssignment(l.front(), l.back());
}
else if (l.size() == 2)
return _fa.CreateBinaryOP( t, l.front(), l.back());
else {
assert(l.size() == 1);
return _fa.CreateUnaryOP( t, l.front());
}
}
示例2: assert
AstNodePtr ArrayInterface::
impl_access_array_length( CPPAstInterface& fa, const AstNodePtr& array,
int dim, int plus)
{
SymbolicVal rval;
ArrayOptDescriptor desc;
if (get_array_opt(fa, array, desc))
{
if (!desc.get_length(dim, rval))
assert(false);
}
else
{
ArrayDefineDescriptor desc1;
if (!ArrayAnnotation::get_inst()->known_array( fa, array, &desc1))
return AST_NULL;
if (! desc1.get_length(dim, rval))
assert(false);
}
ReplaceVal(rval, SymbolicVar("this",AST_NULL), SymbolicAstWrap(array));
if (plus != 0)
rval = rval + plus;
return rval.CodeGen(fa);
}
示例3: GetDefaultBlockSize
static SymbolicVal GetDefaultBlockSize(const CompSlice* slice)
{
AstInterface& fa = LoopTransformInterface::getAstInterface();
LoopTransformOptions* opt = LoopTransformOptions::GetInstance();
if (!opt->DoDynamicTuning()) {
return opt->GetDefaultBlockSize();
}
else {
int dt = opt->GetDynamicTuningIndex();
AstInterface::AstNodeList l;
l.push_back(fa.CreateConstInt(dt));
CompSlice::ConstLoopIterator iter = slice->GetConstLoopIterator();
LoopTreeNode *loop = iter.Current();
SymbolicBound b = loop->GetLoopInfo()->GetBound();
SymbolicVal size = b.ub - b.lb + 1;
l.push_back(fa.CreateConstInt(1));
l.push_back(size.CodeGen(fa));
AstNodePtr init = fa.CreateFunctionCall("getTuningValue", l);
return SymbolicVar(fa.NewVar(fa.GetType("int"), "",true,AST_NULL, init),AST_NULL);
}
}
示例4: 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;
//.........这里部分代码省略.........