#include "llvm/ADT/APInt.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Operator.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <optional>
usingnamespacellvm;
ConstantRange::ConstantRange(uint32_t BitWidth, bool Full)
: … { … }
ConstantRange::ConstantRange(APInt V)
: … { … }
ConstantRange::ConstantRange(APInt L, APInt U)
: … { … }
ConstantRange ConstantRange::fromKnownBits(const KnownBits &Known,
bool IsSigned) { … }
KnownBits ConstantRange::toKnownBits() const { … }
ConstantRange ConstantRange::makeAllowedICmpRegion(CmpInst::Predicate Pred,
const ConstantRange &CR) { … }
ConstantRange ConstantRange::makeSatisfyingICmpRegion(CmpInst::Predicate Pred,
const ConstantRange &CR) { … }
ConstantRange ConstantRange::makeExactICmpRegion(CmpInst::Predicate Pred,
const APInt &C) { … }
bool ConstantRange::areInsensitiveToSignednessOfICmpPredicate(
const ConstantRange &CR1, const ConstantRange &CR2) { … }
bool ConstantRange::areInsensitiveToSignednessOfInvertedICmpPredicate(
const ConstantRange &CR1, const ConstantRange &CR2) { … }
CmpInst::Predicate ConstantRange::getEquivalentPredWithFlippedSignedness(
CmpInst::Predicate Pred, const ConstantRange &CR1,
const ConstantRange &CR2) { … }
void ConstantRange::getEquivalentICmp(CmpInst::Predicate &Pred,
APInt &RHS, APInt &Offset) const { … }
bool ConstantRange::getEquivalentICmp(CmpInst::Predicate &Pred,
APInt &RHS) const { … }
bool ConstantRange::icmp(CmpInst::Predicate Pred,
const ConstantRange &Other) const { … }
static ConstantRange makeExactMulNUWRegion(const APInt &V) { … }
static ConstantRange makeExactMulNSWRegion(const APInt &V) { … }
ConstantRange
ConstantRange::makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp,
const ConstantRange &Other,
unsigned NoWrapKind) { … }
ConstantRange ConstantRange::makeExactNoWrapRegion(Instruction::BinaryOps BinOp,
const APInt &Other,
unsigned NoWrapKind) { … }
ConstantRange ConstantRange::makeMaskNotEqualRange(const APInt &Mask,
const APInt &C) { … }
bool ConstantRange::isFullSet() const { … }
bool ConstantRange::isEmptySet() const { … }
bool ConstantRange::isWrappedSet() const { … }
bool ConstantRange::isUpperWrapped() const { … }
bool ConstantRange::isSignWrappedSet() const { … }
bool ConstantRange::isUpperSignWrapped() const { … }
bool
ConstantRange::isSizeStrictlySmallerThan(const ConstantRange &Other) const { … }
bool
ConstantRange::isSizeLargerThan(uint64_t MaxSize) const { … }
bool ConstantRange::isAllNegative() const { … }
bool ConstantRange::isAllNonNegative() const { … }
bool ConstantRange::isAllPositive() const { … }
APInt ConstantRange::getUnsignedMax() const { … }
APInt ConstantRange::getUnsignedMin() const { … }
APInt ConstantRange::getSignedMax() const { … }
APInt ConstantRange::getSignedMin() const { … }
bool ConstantRange::contains(const APInt &V) const { … }
bool ConstantRange::contains(const ConstantRange &Other) const { … }
unsigned ConstantRange::getActiveBits() const { … }
unsigned ConstantRange::getMinSignedBits() const { … }
ConstantRange ConstantRange::subtract(const APInt &Val) const { … }
ConstantRange ConstantRange::difference(const ConstantRange &CR) const { … }
static ConstantRange getPreferredRange(
const ConstantRange &CR1, const ConstantRange &CR2,
ConstantRange::PreferredRangeType Type) { … }
ConstantRange ConstantRange::intersectWith(const ConstantRange &CR,
PreferredRangeType Type) const { … }
ConstantRange ConstantRange::unionWith(const ConstantRange &CR,
PreferredRangeType Type) const { … }
std::optional<ConstantRange>
ConstantRange::exactIntersectWith(const ConstantRange &CR) const { … }
std::optional<ConstantRange>
ConstantRange::exactUnionWith(const ConstantRange &CR) const { … }
ConstantRange ConstantRange::castOp(Instruction::CastOps CastOp,
uint32_t ResultBitWidth) const { … }
ConstantRange ConstantRange::zeroExtend(uint32_t DstTySize) const { … }
ConstantRange ConstantRange::signExtend(uint32_t DstTySize) const { … }
ConstantRange ConstantRange::truncate(uint32_t DstTySize) const { … }
ConstantRange ConstantRange::zextOrTrunc(uint32_t DstTySize) const { … }
ConstantRange ConstantRange::sextOrTrunc(uint32_t DstTySize) const { … }
ConstantRange ConstantRange::binaryOp(Instruction::BinaryOps BinOp,
const ConstantRange &Other) const { … }
ConstantRange ConstantRange::overflowingBinaryOp(Instruction::BinaryOps BinOp,
const ConstantRange &Other,
unsigned NoWrapKind) const { … }
bool ConstantRange::isIntrinsicSupported(Intrinsic::ID IntrinsicID) { … }
ConstantRange ConstantRange::intrinsic(Intrinsic::ID IntrinsicID,
ArrayRef<ConstantRange> Ops) { … }
ConstantRange
ConstantRange::add(const ConstantRange &Other) const { … }
ConstantRange ConstantRange::addWithNoWrap(const ConstantRange &Other,
unsigned NoWrapKind,
PreferredRangeType RangeType) const { … }
ConstantRange
ConstantRange::sub(const ConstantRange &Other) const { … }
ConstantRange ConstantRange::subWithNoWrap(const ConstantRange &Other,
unsigned NoWrapKind,
PreferredRangeType RangeType) const { … }
ConstantRange
ConstantRange::multiply(const ConstantRange &Other) const { … }
ConstantRange
ConstantRange::multiplyWithNoWrap(const ConstantRange &Other,
unsigned NoWrapKind,
PreferredRangeType RangeType) const { … }
ConstantRange ConstantRange::smul_fast(const ConstantRange &Other) const { … }
ConstantRange
ConstantRange::smax(const ConstantRange &Other) const { … }
ConstantRange
ConstantRange::umax(const ConstantRange &Other) const { … }
ConstantRange
ConstantRange::smin(const ConstantRange &Other) const { … }
ConstantRange
ConstantRange::umin(const ConstantRange &Other) const { … }
ConstantRange
ConstantRange::udiv(const ConstantRange &RHS) const { … }
ConstantRange ConstantRange::sdiv(const ConstantRange &RHS) const { … }
ConstantRange ConstantRange::urem(const ConstantRange &RHS) const { … }
ConstantRange ConstantRange::srem(const ConstantRange &RHS) const { … }
ConstantRange ConstantRange::binaryNot() const { … }
ConstantRange ConstantRange::binaryAnd(const ConstantRange &Other) const { … }
ConstantRange ConstantRange::binaryOr(const ConstantRange &Other) const { … }
ConstantRange ConstantRange::binaryXor(const ConstantRange &Other) const { … }
ConstantRange
ConstantRange::shl(const ConstantRange &Other) const { … }
static ConstantRange computeShlNUW(const ConstantRange &LHS,
const ConstantRange &RHS) { … }
static ConstantRange computeShlNSWWithNNegLHS(const APInt &LHSMin,
const APInt &LHSMax,
unsigned RHSMin,
unsigned RHSMax) { … }
static ConstantRange computeShlNSWWithNegLHS(const APInt &LHSMin,
const APInt &LHSMax,
unsigned RHSMin, unsigned RHSMax) { … }
static ConstantRange computeShlNSW(const ConstantRange &LHS,
const ConstantRange &RHS) { … }
ConstantRange ConstantRange::shlWithNoWrap(const ConstantRange &Other,
unsigned NoWrapKind,
PreferredRangeType RangeType) const { … }
ConstantRange
ConstantRange::lshr(const ConstantRange &Other) const { … }
ConstantRange
ConstantRange::ashr(const ConstantRange &Other) const { … }
ConstantRange ConstantRange::uadd_sat(const ConstantRange &Other) const { … }
ConstantRange ConstantRange::sadd_sat(const ConstantRange &Other) const { … }
ConstantRange ConstantRange::usub_sat(const ConstantRange &Other) const { … }
ConstantRange ConstantRange::ssub_sat(const ConstantRange &Other) const { … }
ConstantRange ConstantRange::umul_sat(const ConstantRange &Other) const { … }
ConstantRange ConstantRange::smul_sat(const ConstantRange &Other) const { … }
ConstantRange ConstantRange::ushl_sat(const ConstantRange &Other) const { … }
ConstantRange ConstantRange::sshl_sat(const ConstantRange &Other) const { … }
ConstantRange ConstantRange::inverse() const { … }
ConstantRange ConstantRange::abs(bool IntMinIsPoison) const { … }
ConstantRange ConstantRange::ctlz(bool ZeroIsPoison) const { … }
static ConstantRange getUnsignedCountTrailingZerosRange(const APInt &Lower,
const APInt &Upper) { … }
ConstantRange ConstantRange::cttz(bool ZeroIsPoison) const { … }
static ConstantRange getUnsignedPopCountRange(const APInt &Lower,
const APInt &Upper) { … }
ConstantRange ConstantRange::ctpop() const { … }
ConstantRange::OverflowResult ConstantRange::unsignedAddMayOverflow(
const ConstantRange &Other) const { … }
ConstantRange::OverflowResult ConstantRange::signedAddMayOverflow(
const ConstantRange &Other) const { … }
ConstantRange::OverflowResult ConstantRange::unsignedSubMayOverflow(
const ConstantRange &Other) const { … }
ConstantRange::OverflowResult ConstantRange::signedSubMayOverflow(
const ConstantRange &Other) const { … }
ConstantRange::OverflowResult ConstantRange::unsignedMulMayOverflow(
const ConstantRange &Other) const { … }
void ConstantRange::print(raw_ostream &OS) const { … }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void ConstantRange::dump() const {
print(dbgs());
}
#endif
ConstantRange llvm::getConstantRangeFromMetadata(const MDNode &Ranges) { … }