本文整理汇总了C++中ConstantRange::isEmptySet方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstantRange::isEmptySet方法的具体用法?C++ ConstantRange::isEmptySet怎么用?C++ ConstantRange::isEmptySet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstantRange
的用法示例。
在下文中一共展示了ConstantRange::isEmptySet方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConstantRange
ConstantRange
ConstantRange::lshr(const ConstantRange &Other) const {
if (isEmptySet() || Other.isEmptySet())
return ConstantRange(getBitWidth(), /*isFullSet=*/false);
APInt max = getUnsignedMax().lshr(Other.getUnsignedMin());
APInt min = getUnsignedMin().lshr(Other.getUnsignedMax());
if (min == max + 1)
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
return ConstantRange(min, max + 1);
}
示例2: ConstantRange
ConstantRange
ConstantRange::umin(const ConstantRange &Other) const {
// X umin Y is: range(umin(X_umin, Y_umin),
// umin(X_umax, Y_umax))
if (isEmptySet() || Other.isEmptySet())
return ConstantRange(getBitWidth(), /*isFullSet=*/false);
APInt NewL = APIntOps::umin(getUnsignedMin(), Other.getUnsignedMin());
APInt NewU = APIntOps::umin(getUnsignedMax(), Other.getUnsignedMax()) + 1;
if (NewU == NewL)
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
return ConstantRange(std::move(NewL), std::move(NewU));
}
示例3: ConstantRange
ConstantRange
ConstantRange::smax(const ConstantRange &Other) const {
// X smax Y is: range(smax(X_smin, Y_smin),
// smax(X_smax, Y_smax))
if (isEmptySet() || Other.isEmptySet())
return ConstantRange(getBitWidth(), /*isFullSet=*/false);
APInt NewL = APIntOps::smax(getSignedMin(), Other.getSignedMin());
APInt NewU = APIntOps::smax(getSignedMax(), Other.getSignedMax()) + 1;
if (NewU == NewL)
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
return ConstantRange(NewL, NewU);
}
示例4: ConstantRange
ConstantRange
ConstantRange::shl(const ConstantRange &Other) const {
if (isEmptySet() || Other.isEmptySet())
return ConstantRange(getBitWidth(), /*isFullSet=*/false);
APInt min = getUnsignedMin().shl(Other.getUnsignedMin());
APInt max = getUnsignedMax().shl(Other.getUnsignedMax());
// there's no overflow!
APInt Zeros(getBitWidth(), getUnsignedMax().countLeadingZeros());
if (Zeros.ugt(Other.getUnsignedMax()))
return ConstantRange(min, max + 1);
// FIXME: implement the other tricky cases
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
}
示例5: ConstantRange
ConstantRange
ConstantRange::multiply(const ConstantRange &Other) const {
if (isEmptySet() || Other.isEmptySet())
return ConstantRange(getBitWidth(), /*isFullSet=*/false);
if (isFullSet() || Other.isFullSet())
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
APInt this_min = getUnsignedMin().zext(getBitWidth() * 2);
APInt this_max = getUnsignedMax().zext(getBitWidth() * 2);
APInt Other_min = Other.getUnsignedMin().zext(getBitWidth() * 2);
APInt Other_max = Other.getUnsignedMax().zext(getBitWidth() * 2);
ConstantRange Result_zext = ConstantRange(this_min * Other_min,
this_max * Other_max + 1);
return Result_zext.truncate(getBitWidth());
}
示例6: contains
/// contains - Return true if the argument is a subset of this range.
/// Two equal sets contain each other. The empty set contained by all other
/// sets.
///
bool ConstantRange::contains(const ConstantRange &Other) const {
if (isFullSet() || Other.isEmptySet()) return true;
if (isEmptySet() || Other.isFullSet()) return false;
if (!isWrappedSet()) {
if (Other.isWrappedSet())
return false;
return Lower.ule(Other.getLower()) && Other.getUpper().ule(Upper);
}
if (!Other.isWrappedSet())
return Other.getUpper().ule(Upper) ||
Lower.ule(Other.getLower());
return Other.getUpper().ule(Upper) && Lower.ule(Other.getLower());
}
示例7: ConstantRange
ConstantRange
ConstantRange::sub(const ConstantRange &Other) const {
if (isEmptySet() || Other.isEmptySet())
return ConstantRange(getBitWidth(), /*isFullSet=*/false);
if (isFullSet() || Other.isFullSet())
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
APInt NewLower = getLower() - Other.getUpper() + 1;
APInt NewUpper = getUpper() - Other.getLower();
if (NewLower == NewUpper)
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
ConstantRange X = ConstantRange(std::move(NewLower), std::move(NewUpper));
if (X.isSizeStrictlySmallerThan(*this) ||
X.isSizeStrictlySmallerThan(Other))
// We've wrapped, therefore, full set.
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
return X;
}
示例8: binaryAnd
MyConstantRange binaryAnd(const ConstantRange &Other) const {
if (isEmptySet() || Other.isEmptySet())
return MyConstantRange(getBitWidth(), /*isFullSet=*/false);
if (!isWrappedSet() && !Other.isWrappedSet() && !isFullSet() && !Other.isFullSet()) {
unsigned width1 = ((getUpper() - 1) ^ getLower()).logBase2() + 1;
unsigned width2 = ((Other.getUpper() - 1) ^ Other.getLower()).logBase2() + 1;
APInt res1 = getLower().lshr(width1) << width1;
APInt res2 = Other.getLower().lshr(width2) << width2;
APInt res_high1 = getLower();
APInt res_high2 = Other.getLower();
res_high1.setLowBits(width1);
res_high2.setLowBits(width2);
if ((res1 & res2).isNullValue() && (res_high1 & res_high2).isAllOnesValue()) {
return MyConstantRange(getBitWidth(), /*isFullSet=*/true);
}
return MyConstantRange(res1 & res2, (res_high1 & res_high2) + 1);
}
APInt umin = APIntOps::umin(Other.getUnsignedMax(), getUnsignedMax());
if (umin.isAllOnesValue())
return MyConstantRange(getBitWidth(), /*isFullSet=*/true);
return MyConstantRange(APInt::getNullValue(getBitWidth()), std::move(umin) + 1);
}
示例9: unionWith
/// unionWith - Return the range that results from the union of this range with
/// another range. The resultant range is guaranteed to include the elements of
/// both sets, but may contain more. For example, [3, 9) union [12,15) is
/// [3, 15), which includes 9, 10, and 11, which were not included in either
/// set before.
///
ConstantRange ConstantRange::unionWith(const ConstantRange &CR) const {
assert(getBitWidth() == CR.getBitWidth() &&
"ConstantRange types don't agree!");
if ( isFullSet() || CR.isEmptySet()) return *this;
if (CR.isFullSet() || isEmptySet()) return CR;
if (!isWrappedSet() && CR.isWrappedSet()) return CR.unionWith(*this);
APInt L = Lower, U = Upper;
if (!isWrappedSet() && !CR.isWrappedSet()) {
if (CR.Lower.ult(L))
L = CR.Lower;
if (CR.Upper.ugt(U))
U = CR.Upper;
}
if (isWrappedSet() && !CR.isWrappedSet()) {
if ((CR.Lower.ult(Upper) && CR.Upper.ult(Upper)) ||
(CR.Lower.ugt(Lower) && CR.Upper.ugt(Lower))) {
return *this;
}
if (CR.Lower.ule(Upper) && Lower.ule(CR.Upper)) {
return ConstantRange(getBitWidth());
}
if (CR.Lower.ule(Upper) && CR.Upper.ule(Lower)) {
APInt d1 = CR.Upper - Upper, d2 = Lower - CR.Upper;
if (d1.ult(d2)) {
U = CR.Upper;
} else {
L = CR.Upper;
}
}
if (Upper.ult(CR.Lower) && CR.Upper.ult(Lower)) {
APInt d1 = CR.Lower - Upper, d2 = Lower - CR.Upper;
if (d1.ult(d2)) {
U = CR.Lower + 1;
} else {
L = CR.Upper - 1;
}
}
if (Upper.ult(CR.Lower) && Lower.ult(CR.Upper)) {
APInt d1 = CR.Lower - Upper, d2 = Lower - CR.Lower;
if (d1.ult(d2)) {
U = CR.Lower + 1;
} else {
L = CR.Lower;
}
}
}
if (isWrappedSet() && CR.isWrappedSet()) {
if (Lower.ult(CR.Upper) || CR.Lower.ult(Upper))
return ConstantRange(getBitWidth());
if (CR.Upper.ugt(U)) {
U = CR.Upper;
}
if (CR.Lower.ult(L)) {
L = CR.Lower;
}
if (L == U) return ConstantRange(getBitWidth());
}
return ConstantRange(L, U);
}
示例10: makeAllowedICmpRegion
ConstantRange ConstantRange::makeAllowedICmpRegion(CmpInst::Predicate Pred,
const ConstantRange &CR) {
if (CR.isEmptySet())
return CR;
uint32_t W = CR.getBitWidth();
switch (Pred) {
default:
llvm_unreachable("Invalid ICmp predicate to makeAllowedICmpRegion()");
case CmpInst::ICMP_EQ:
return CR;
case CmpInst::ICMP_NE:
if (CR.isSingleElement())
return ConstantRange(CR.getUpper(), CR.getLower());
return ConstantRange(W);
case CmpInst::ICMP_ULT: {
APInt UMax(CR.getUnsignedMax());
if (UMax.isMinValue())
return ConstantRange(W, /* empty */ false);
return ConstantRange(APInt::getMinValue(W), UMax);
}
case CmpInst::ICMP_SLT: {
APInt SMax(CR.getSignedMax());
if (SMax.isMinSignedValue())
return ConstantRange(W, /* empty */ false);
return ConstantRange(APInt::getSignedMinValue(W), SMax);
}
case CmpInst::ICMP_ULE: {
APInt UMax(CR.getUnsignedMax());
if (UMax.isMaxValue())
return ConstantRange(W);
return ConstantRange(APInt::getMinValue(W), UMax + 1);
}
case CmpInst::ICMP_SLE: {
APInt SMax(CR.getSignedMax());
if (SMax.isMaxSignedValue())
return ConstantRange(W);
return ConstantRange(APInt::getSignedMinValue(W), SMax + 1);
}
case CmpInst::ICMP_UGT: {
APInt UMin(CR.getUnsignedMin());
if (UMin.isMaxValue())
return ConstantRange(W, /* empty */ false);
return ConstantRange(UMin + 1, APInt::getNullValue(W));
}
case CmpInst::ICMP_SGT: {
APInt SMin(CR.getSignedMin());
if (SMin.isMaxSignedValue())
return ConstantRange(W, /* empty */ false);
return ConstantRange(SMin + 1, APInt::getSignedMinValue(W));
}
case CmpInst::ICMP_UGE: {
APInt UMin(CR.getUnsignedMin());
if (UMin.isMinValue())
return ConstantRange(W);
return ConstantRange(UMin, APInt::getNullValue(W));
}
case CmpInst::ICMP_SGE: {
APInt SMin(CR.getSignedMin());
if (SMin.isMinSignedValue())
return ConstantRange(W);
return ConstantRange(SMin, APInt::getSignedMinValue(W));
}
}
}
示例11: unionWith
/// unionWith - Return the range that results from the union of this range with
/// another range. The resultant range is guaranteed to include the elements of
/// both sets, but may contain more. For example, [3, 9) union [12,15) is
/// [3, 15), which includes 9, 10, and 11, which were not included in either
/// set before.
///
ConstantRange ConstantRange::unionWith(const ConstantRange &CR) const {
assert(getBitWidth() == CR.getBitWidth() &&
"ConstantRange types don't agree!");
if ( isFullSet() || CR.isEmptySet()) return *this;
if (CR.isFullSet() || isEmptySet()) return CR;
if (!isWrappedSet() && CR.isWrappedSet()) return CR.unionWith(*this);
if (!isWrappedSet() && !CR.isWrappedSet()) {
if (CR.Upper.ult(Lower) || Upper.ult(CR.Lower)) {
// If the two ranges are disjoint, find the smaller gap and bridge it.
APInt d1 = CR.Lower - Upper, d2 = Lower - CR.Upper;
if (d1.ult(d2))
return ConstantRange(Lower, CR.Upper);
return ConstantRange(CR.Lower, Upper);
}
APInt L = Lower, U = Upper;
if (CR.Lower.ult(L))
L = CR.Lower;
if ((CR.Upper - 1).ugt(U - 1))
U = CR.Upper;
if (L == 0 && U == 0)
return ConstantRange(getBitWidth());
return ConstantRange(L, U);
}
if (!CR.isWrappedSet()) {
// ------U L----- and ------U L----- : this
// L--U L--U : CR
if (CR.Upper.ule(Upper) || CR.Lower.uge(Lower))
return *this;
// ------U L----- : this
// L---------U : CR
if (CR.Lower.ule(Upper) && Lower.ule(CR.Upper))
return ConstantRange(getBitWidth());
// ----U L---- : this
// L---U : CR
// <d1> <d2>
if (Upper.ule(CR.Lower) && CR.Upper.ule(Lower)) {
APInt d1 = CR.Lower - Upper, d2 = Lower - CR.Upper;
if (d1.ult(d2))
return ConstantRange(Lower, CR.Upper);
return ConstantRange(CR.Lower, Upper);
}
// ----U L----- : this
// L----U : CR
if (Upper.ult(CR.Lower) && Lower.ult(CR.Upper))
return ConstantRange(CR.Lower, Upper);
// ------U L---- : this
// L-----U : CR
assert(CR.Lower.ult(Upper) && CR.Upper.ult(Lower) &&
"ConstantRange::unionWith missed a case with one range wrapped");
return ConstantRange(Lower, CR.Upper);
}
// ------U L---- and ------U L---- : this
// -U L----------- and ------------U L : CR
if (CR.Lower.ule(Upper) || Lower.ule(CR.Upper))
return ConstantRange(getBitWidth());
APInt L = Lower, U = Upper;
if (CR.Upper.ugt(U))
U = CR.Upper;
if (CR.Lower.ult(L))
L = CR.Lower;
return ConstantRange(L, U);
}
示例12: intersectWith
/// intersectWith - Return the range that results from the intersection of this
/// range with another range. The resultant range is guaranteed to include all
/// elements contained in both input ranges, and to have the smallest possible
/// set size that does so. Because there may be two intersections with the
/// same set size, A.intersectWith(B) might not be equal to B.intersectWith(A).
ConstantRange ConstantRange::intersectWith(const ConstantRange &CR) const {
assert(getBitWidth() == CR.getBitWidth() &&
"ConstantRange types don't agree!");
// Handle common cases.
if ( isEmptySet() || CR.isFullSet()) return *this;
if (CR.isEmptySet() || isFullSet()) return CR;
if (!isWrappedSet() && CR.isWrappedSet())
return CR.intersectWith(*this);
if (!isWrappedSet() && !CR.isWrappedSet()) {
if (Lower.ult(CR.Lower)) {
if (Upper.ule(CR.Lower))
return ConstantRange(getBitWidth(), false);
if (Upper.ult(CR.Upper))
return ConstantRange(CR.Lower, Upper);
return CR;
}
if (Upper.ult(CR.Upper))
return *this;
if (Lower.ult(CR.Upper))
return ConstantRange(Lower, CR.Upper);
return ConstantRange(getBitWidth(), false);
}
if (isWrappedSet() && !CR.isWrappedSet()) {
if (CR.Lower.ult(Upper)) {
if (CR.Upper.ult(Upper))
return CR;
if (CR.Upper.ule(Lower))
return ConstantRange(CR.Lower, Upper);
if (getSetSize().ult(CR.getSetSize()))
return *this;
return CR;
}
if (CR.Lower.ult(Lower)) {
if (CR.Upper.ule(Lower))
return ConstantRange(getBitWidth(), false);
return ConstantRange(Lower, CR.Upper);
}
return CR;
}
if (CR.Upper.ult(Upper)) {
if (CR.Lower.ult(Upper)) {
if (getSetSize().ult(CR.getSetSize()))
return *this;
return CR;
}
if (CR.Lower.ult(Lower))
return ConstantRange(Lower, CR.Upper);
return CR;
}
if (CR.Upper.ule(Lower)) {
if (CR.Lower.ult(Lower))
return *this;
return ConstantRange(CR.Lower, Upper);
}
if (getSetSize().ult(CR.getSetSize()))
return *this;
return CR;
}