本文整理汇总了C++中SymbolicVal类的典型用法代码示例。如果您正苦于以下问题:C++ SymbolicVal类的具体用法?C++ SymbolicVal怎么用?C++ SymbolicVal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SymbolicVal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: impl_access_array_length
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);
}
示例2: Min
SymbolicVal Min( const SymbolicVal &v1, const SymbolicVal &v2,
MapObject<SymbolicVal, SymbolicBound>* f)
{ if (v1.IsNIL())
return v2;
if (v2.IsNIL())
return v1;
switch (CompareVal(v1,v2,f)) {
case REL_NONE:
case REL_UNKNOWN:
case REL_NE:
{
SelectApplicator minOp(-1);
return ApplyBinOP(minOp,v1,v2);
}
case REL_EQ:
case REL_LT:
case REL_LE:
return v1;
case REL_GT:
case REL_GE:
return v2;
default:
assert(0);
}
}
示例3: CodeGen
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());
}
}
示例4: CompareVal
CompareRel CompareVal(const SymbolicVal &v1, const SymbolicVal &v2,
MapObject<SymbolicVal,SymbolicBound>* f)
{
if ( v1.IsNIL() && v2.IsNIL()) return REL_UNKNOWN;
if (DebugCompareVal())
std::cerr << "comparing " << v1.toString() << " with " << v2.toString() << " under " << f << std::endl;
comparetime = 0;
return CompareValHelp(v1,v2,f);
}
示例5: CompareValHelp
CompareRel CompareValHelp(const SymbolicVal &v1, const SymbolicVal &v2,
MapObject<SymbolicVal,SymbolicBound>* f)
{
CompareRel r = REL_UNKNOWN;
if (++comparetime < COMPARE_MAX)
r = ValCompare(f)(v1,v2);
if (DebugCompareVal())
std::cerr << v1.toString() << RelToString(r) << v2.toString() << " under " << f << std::endl;
return r;
}
示例6: operator
virtual SymbolicVal operator()( const SymbolicVal& v)
{
SymbolicVal r;
if (valmap != 0)
r = (*valmap)(v);
if (r.IsNIL()) {
v.Visit(this);
}
return r;
}
示例7: Default1
void Default1( const SymbolicVal &v1, const SymbolicVal &v2)
{
if (v1.IsSame(v2))
result = REL_EQ;
else if (v1.IsNIL() || v2.IsNIL())
result = REL_UNKNOWN;
else if (v1 == v2)
result = REL_EQ;
else
result = REL_UNKNOWN;
}
示例8: VisitFunction
void VisitFunction( const SymbolicFunction &v)
{
if (target.GetValType() == VAL_FUNCTION && cur == target)
result = true;
else {
for (SymbolicFunction::const_iterator p = v.args_begin();
p != v.args_end(); ++p) {
SymbolicVal tmp = *p;
cur = tmp;
cur.Visit(this);
if ( result)
break;
}
}
}
示例9: VisitExpr
void VisitExpr( const SymbolicExpr &v)
{
if (target.GetValType() == VAL_EXPR && cur == target)
result = true;
else {
for (SymbolicExpr::OpdIterator iter = v.GetOpdIterator();
!iter.ReachEnd(); iter.Advance()) {
SymbolicVal tmp = v.Term2Val(iter.Current());
cur = tmp;
cur.Visit(this);
if (result)
break;
}
}
}
示例10: operator
bool operator ()( const SymbolicVal &v, const SymbolicVal& _target)
{
target = _target;
cur = v;
result = false;
v.Visit(this);
return result;
}
示例11: operator
bool operator()(const SymbolicVal& v, SymbolicVal* i, SymbolicVal* f)
{
inp = i;
frp = f;
if (inp != 0) *inp = 0;
if (frp != 0) *frp = 0;
hasfrac = false;
v.Visit(this);
return hasfrac;
}
示例12: GetArrayBound
bool ArrayInterface ::
GetArrayBound( AstInterface& _fa, const AstNodePtr& array,
int dim, int &lb, int &ub)
{
CPPAstInterface& fa = static_cast<CPPAstInterface&>(_fa);
SymbolicFunctionDeclarationGroup len;
if (!is_array_exp( fa, array, 0, &len))
assert(false);
std::vector<SymbolicVal> pars;
pars.push_back( SymbolicConst(dim));
SymbolicVal rval;
if (!len.get_val( pars, rval))
return false;
if (!rval.isConstInt(ub))
return false;
lb = 0;
return true;
}
示例13: SplitEquation
bool SplitEquation( CoeffVec& cur,
const SymbolicVal& cut, const BoundVec& bounds,
BoundOp& boundop, CoeffVec& split)
{
int dim = cur.size()-1;
SymbolicVal leftval = cur[dim]; // obtain the last coefficient, which is right side terms without using loop index variable
if (leftval != 0) {
CompareRel r1 = CompareVal(leftval,-cut, &boundop);
CompareRel r2 = CompareVal(leftval,cut, &boundop);
bool lt = ((r1 & REL_GT) && (r2 & REL_LT)) || ((r1 & REL_LT) && (r2 & REL_GT));
if (!lt) { // relation of r1 and r2 must be reversed pair, or error
if (DebugDep())
std::cerr << "unable to split because " << leftval.toString() << " ? " << cut.toString() << std::endl;
return false;
}
}
bool succ = false;
split.clear();
int j =0;
for (; j < dim; ++j) {
SymbolicVal left = cur[j] / cut;
if (HasFraction(left))
split.push_back(0);
else {
split.push_back(left);
succ = true;
}
}
split.push_back(0); // right-hand side value
if (succ) {
SymbolicVal left = 0;
for (j = 0; j < dim; ++j) {
if (split[j]== 0)
switch (CompareVal(cur[j],0,&boundop)) {
case REL_LE:
left = left + cur[j] * bounds[j].lb; break;
case REL_GE:
left = left + cur[j] * bounds[j].ub; break;
default: break;
}
}
if (j == dim && (left == 0 || (CompareVal(left,cut) & REL_LT))) {
for (j = 0; j < dim; ++j) {
if (split[j] != 0)
cur[j] = 0; // clear some coefficency values
}
return true;
}
else if (DebugDep()) {
if (j == dim)
std::cerr << "unable to decide left " << left.toString() << " ? " << cut.toString() << std::endl;
else
std::cerr << "unable to decide cur[" << j << "] ? 0\n";
}
}
split.clear();
return false;
}
示例14: ApplyBlocking
LoopTreeNode* LoopBlocking::
ApplyBlocking( const CompSliceDepGraphNode::FullNestInfo& nestInfo,
LoopTreeDepComp& comp, DependenceHoisting &op, LoopTreeNode *&top)
{
const CompSliceNest& slices = *nestInfo.GetNest();
if (DebugLoop()) {
std::cerr << "\n Blocking slices: " << slices.toString() << "\n";
}
LoopTreeNode *head = 0;
AstInterface& fa = LoopTransformInterface::getAstInterface();
for (int j = FirstIndex(); j >= 0; j = NextIndex(j)) {
top = op.Transform( comp, slices[j], top);
SymbolicVal b = BlockSize(j);
if (DebugLoop()) {
std::cerr << "\n after slice " << j << " : \n";
//top->DumpTree();
comp.DumpTree();
comp.DumpDep();
std::cerr << "\n blocking size for this loop is " << b.toString() << "\n";
}
if (!(b == 1)) {
LoopTreeNode *n = LoopTreeBlockLoop()( top, SymbolicVar(fa.NewVar(fa.GetType("int")), AST_NULL), b);
if (DebugLoop()) {
std::cerr << "\n after tiling loop with size " << b.toString() << " : \n";
//top->DumpTree();
comp.DumpTree();
comp.DumpDep();
}
if (head == 0)
head = n;
else {
while (n->FirstChild() != head)
LoopTreeSwapNodePos()( n->Parent(), n);
}
}
}
return head;
}
示例15: 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);
}
}