本文整理汇总了C++中Exp::AsBound方法的典型用法代码示例。如果您正苦于以下问题:C++ Exp::AsBound方法的具体用法?C++ Exp::AsBound怎么用?C++ Exp::AsBound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exp
的用法示例。
在下文中一共展示了Exp::AsBound方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MatchEquality
Exp* MatchEquality(Exp *base, const BaseCompare &equality)
{
Exp *source = equality.source;
Exp *target = equality.target;
// check for the source and base being the same value.
if (source == base)
return target;
// check for the source and base begin different bounds on the same lvalue.
if (source->IsBound() && base->IsBound()) {
ExpBound *nsource = source->AsBound();
ExpBound *nbase = base->AsBound();
if (nsource->GetTarget() != nbase->GetTarget())
return NULL;
if (nsource->GetBoundKind() != nbase->GetBoundKind())
return NULL;
size_t base_width = nbase->GetStrideType()->Width();
size_t source_width = nsource->GetStrideType()->Width();
if (source_width == base_width)
return target;
// only handling upper bounds where the base's width is an even multiple
// of the source's width. this is to handle cases where there is an
// equality due to calling a primitive allocation function.
if (nbase->GetBoundKind() != BND_Upper)
return NULL;
if (source_width == 0)
return NULL;
if (base_width < source_width)
return NULL;
size_t factor = base_width / source_width;
if (source_width * factor != base_width)
return NULL;
// construct a new equality and recurse on it. the base's bound
// can be compared with (target / factor).
Exp *factor_exp = Exp::MakeInt(factor);
return Exp::MakeBinop(B_Div, target, factor_exp);
}
return NULL;
}