本文整理汇总了C++中ConstantRange::getSingleElement方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstantRange::getSingleElement方法的具体用法?C++ ConstantRange::getSingleElement怎么用?C++ ConstantRange::getSingleElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstantRange
的用法示例。
在下文中一共展示了ConstantRange::getSingleElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConstantRange
ConstantRange
ConstantRange::makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp,
const ConstantRange &Other,
unsigned NoWrapKind) {
typedef OverflowingBinaryOperator OBO;
// Computes the intersection of CR0 and CR1. It is different from
// intersectWith in that the ConstantRange returned will only contain elements
// in both CR0 and CR1 (i.e. SubsetIntersect(X, Y) is a *subset*, proper or
// not, of both X and Y).
auto SubsetIntersect =
[](const ConstantRange &CR0, const ConstantRange &CR1) {
return CR0.inverse().unionWith(CR1.inverse()).inverse();
};
assert(BinOp >= Instruction::BinaryOpsBegin &&
BinOp < Instruction::BinaryOpsEnd && "Binary operators only!");
assert((NoWrapKind == OBO::NoSignedWrap ||
NoWrapKind == OBO::NoUnsignedWrap ||
NoWrapKind == (OBO::NoUnsignedWrap | OBO::NoSignedWrap)) &&
"NoWrapKind invalid!");
unsigned BitWidth = Other.getBitWidth();
if (BinOp != Instruction::Add)
// Conservative answer: empty set
return ConstantRange(BitWidth, false);
if (auto *C = Other.getSingleElement())
if (C->isMinValue())
// Full set: nothing signed / unsigned wraps when added to 0.
return ConstantRange(BitWidth);
ConstantRange Result(BitWidth);
if (NoWrapKind & OBO::NoUnsignedWrap)
Result =
SubsetIntersect(Result, ConstantRange(APInt::getNullValue(BitWidth),
-Other.getUnsignedMax()));
if (NoWrapKind & OBO::NoSignedWrap) {
APInt SignedMin = Other.getSignedMin();
APInt SignedMax = Other.getSignedMax();
if (SignedMax.isStrictlyPositive())
Result = SubsetIntersect(
Result,
ConstantRange(APInt::getSignedMinValue(BitWidth),
APInt::getSignedMinValue(BitWidth) - SignedMax));
if (SignedMin.isNegative())
Result = SubsetIntersect(
Result, ConstantRange(APInt::getSignedMinValue(BitWidth) - SignedMin,
APInt::getSignedMinValue(BitWidth)));
}
return Result;
}
示例2: get
Constant *LazyValueInfo::getConstant(Value *V, BasicBlock *BB) {
LVILatticeVal Result = getCache(PImpl).getValueInBlock(V, BB);
if (Result.isConstant())
return Result.getConstant();
if (Result.isConstantRange()) {
ConstantRange CR = Result.getConstantRange();
if (const APInt *SingleVal = CR.getSingleElement())
return ConstantInt::get(V->getContext(), *SingleVal);
}
return 0;
}
示例3: get
Constant *LazyValueInfo::getConstant(Value *V, BasicBlock *BB,
Instruction *CxtI) {
LVILatticeVal Result =
getCache(PImpl, AC, DL, DT).getValueInBlock(V, BB, CxtI);
if (Result.isConstant())
return Result.getConstant();
if (Result.isConstantRange()) {
ConstantRange CR = Result.getConstantRange();
if (const APInt *SingleVal = CR.getSingleElement())
return ConstantInt::get(V->getContext(), *SingleVal);
}
return nullptr;
}
示例4: get
/// Determine whether the specified value is known to be a
/// constant on the specified edge. Return null if not.
Constant *LazyValueInfo::getConstantOnEdge(Value *V, BasicBlock *FromBB,
BasicBlock *ToBB,
Instruction *CxtI) {
const DataLayout &DL = FromBB->getModule()->getDataLayout();
LVILatticeVal Result =
getCache(PImpl, AC, &DL, DT).getValueOnEdge(V, FromBB, ToBB, CxtI);
if (Result.isConstant())
return Result.getConstant();
if (Result.isConstantRange()) {
ConstantRange CR = Result.getConstantRange();
if (const APInt *SingleVal = CR.getSingleElement())
return ConstantInt::get(V->getContext(), *SingleVal);
}
return nullptr;
}