LLVM API Documentation

llvm::ConstantRange Class Reference

#include <ConstantRange.h>

Collaboration diagram for llvm::ConstantRange:
[legend]

List of all members.

Public Member Functions

 ConstantRange (uint32_t BitWidth, bool isFullSet=true)
 ConstantRange (const APInt &Value)
 ConstantRange (const APInt &Lower, const APInt &Upper)
 Initialize a range of values explicitly. This will assert out if Lower==Upper and Lower != Min or Max value for its type. It will also assert out if the two APInt's are not the same bit width.
const APInt & getLower () const
const APInt & getUpper () const
uint32_t getBitWidth () const
bool isFullSet () const
bool isEmptySet () const
bool isWrappedSet () const
bool contains (const APInt &Val) const
const APInt * getSingleElement () const
bool isSingleElement () const
APInt getSetSize () const
APInt getUnsignedMax () const
APInt getUnsignedMin () const
APInt getSignedMax () const
APInt getSignedMin () const
bool operator== (const ConstantRange &CR) const
bool operator!= (const ConstantRange &CR) const
ConstantRange subtract (const APInt &CI) const
ConstantRange intersectWith (const ConstantRange &CR) const
ConstantRange maximalIntersectWith (const ConstantRange &CR) const
ConstantRange unionWith (const ConstantRange &CR) const
ConstantRange zeroExtend (uint32_t BitWidth) const
ConstantRange signExtend (uint32_t BitWidth) const
ConstantRange truncate (uint32_t BitWidth) const
void print (raw_ostream &OS) const
void dump () const


Detailed Description

Definition at line 38 of file ConstantRange.h.


Constructor & Destructor Documentation

ConstantRange::ConstantRange ( uint32_t  BitWidth,
bool  Full = true 
) [explicit]

Initialize a full (the default) or empty set for the specified bit width.

Initialize a full (the default) or empty set for the specified type.

Definition at line 30 of file ConstantRange.cpp.

References llvm::APInt::getMaxValue(), and llvm::APInt::getMinValue().

Referenced by intersectWith(), maximalIntersectWith(), signExtend(), subtract(), truncate(), unionWith(), and zeroExtend().

ConstantRange::ConstantRange ( const APInt &  V  ) 

Initialize a range to hold the single specified value.

Definition at line 40 of file ConstantRange.cpp.

ConstantRange::ConstantRange ( const APInt &  Lower,
const APInt &  Upper 
)

Initialize a range of values explicitly. This will assert out if Lower==Upper and Lower != Min or Max value for its type. It will also assert out if the two APInt's are not the same bit width.

Definition at line 42 of file ConstantRange.cpp.

References llvm::APInt::getBitWidth(), llvm::APInt::isMaxValue(), and llvm::APInt::isMinValue().


Member Function Documentation

const APInt& llvm::ConstantRange::getLower (  )  const [inline]

getLower - Return the lower value for this range...

Definition at line 58 of file ConstantRange.h.

Referenced by llvm::SCEVAddRecExpr::getNumIterationsInRange(), getSignedMax(), getSignedMin(), and getUnsignedMin().

const APInt& llvm::ConstantRange::getUpper (  )  const [inline]

getUpper - Return the upper value for this range...

Definition at line 62 of file ConstantRange.h.

Referenced by llvm::SCEVAddRecExpr::getNumIterationsInRange(), getSignedMax(), getSignedMin(), getUnsignedMax(), and getUnsignedMin().

uint32_t llvm::ConstantRange::getBitWidth (  )  const [inline]

bool ConstantRange::isFullSet (  )  const

isFullSet - Return true if this set contains all of the elements possible for this data-type

isFullSet - Return true if this set contains all of the elements possible for this data-type

Definition at line 52 of file ConstantRange.cpp.

References llvm::APInt::isMaxValue().

Referenced by contains(), llvm::SCEVAddRecExpr::getNumIterationsInRange(), getUnsignedMax(), getUnsignedMin(), intersectWith(), maximalIntersectWith(), llvm::LoopVR::narrow(), signExtend(), truncate(), unionWith(), and zeroExtend().

bool ConstantRange::isEmptySet (  )  const

isEmptySet - Return true if this set contains no members.

Definition at line 58 of file ConstantRange.cpp.

References llvm::APInt::isMinValue().

Referenced by getSetSize(), intersectWith(), maximalIntersectWith(), and unionWith().

bool ConstantRange::isWrappedSet (  )  const

isWrappedSet - Return true if this set wraps around the top of the range, for example: [100, 8)

isWrappedSet - Return true if this set wraps around the top of the range, for example: [100, 8)

Definition at line 65 of file ConstantRange.cpp.

References llvm::APInt::ugt().

Referenced by contains(), getSignedMax(), getSignedMin(), getUnsignedMax(), getUnsignedMin(), intersectWith(), maximalIntersectWith(), and unionWith().

bool ConstantRange::contains ( const APInt &  V  )  const

contains - Return true if the specified value is in the set.

Definition at line 150 of file ConstantRange.cpp.

References isFullSet(), isWrappedSet(), llvm::APInt::ule(), and llvm::APInt::ult().

Referenced by llvm::SCEVAddRecExpr::getNumIterationsInRange().

const APInt* llvm::ConstantRange::getSingleElement (  )  const [inline]

getSingleElement - If this set contains a single element, return it, otherwise return null.

Definition at line 89 of file ConstantRange.h.

Referenced by isSingleElement().

bool llvm::ConstantRange::isSingleElement (  )  const [inline]

isSingleElement - Return true if this set contains exactly one member.

Definition at line 97 of file ConstantRange.h.

References getSingleElement().

APInt ConstantRange::getSetSize (  )  const

getSetSize - Return the number of elements in this set.

Definition at line 71 of file ConstantRange.cpp.

References getBitWidth(), and isEmptySet().

Referenced by maximalIntersectWith(), and truncate().

APInt ConstantRange::getUnsignedMax (  )  const

getUnsignedMax - Return the largest unsigned value contained in the ConstantRange.

getUnsignedMax - Return the largest unsigned value contained in the ConstantRange.

Definition at line 87 of file ConstantRange.cpp.

References getBitWidth(), llvm::APInt::getMaxValue(), getUpper(), isFullSet(), and isWrappedSet().

APInt ConstantRange::getUnsignedMin (  )  const

getUnsignedMin - Return the smallest unsigned value contained in the ConstantRange.

getUnsignedMin - Return the smallest unsigned value contained in the ConstantRange.

Definition at line 97 of file ConstantRange.cpp.

References getBitWidth(), getLower(), llvm::APInt::getMinValue(), getUpper(), isFullSet(), and isWrappedSet().

APInt ConstantRange::getSignedMax (  )  const

getSignedMax - Return the largest signed value contained in the ConstantRange.

getSignedMax - Return the largest signed value contained in the ConstantRange.

Definition at line 107 of file ConstantRange.cpp.

References getBitWidth(), getLower(), llvm::APInt::getSignedMaxValue(), getUpper(), and isWrappedSet().

APInt ConstantRange::getSignedMin (  )  const

getSignedMin - Return the smallest signed value contained in the ConstantRange.

getSignedMin - Return the smallest signed value contained in the ConstantRange.

Definition at line 129 of file ConstantRange.cpp.

References getBitWidth(), getLower(), llvm::APInt::getSignedMinValue(), getUpper(), and isWrappedSet().

bool llvm::ConstantRange::operator== ( const ConstantRange &  CR  )  const [inline]

operator== - Return true if this range is equal to another range.

Definition at line 125 of file ConstantRange.h.

References Lower, and Upper.

Referenced by operator!=().

bool llvm::ConstantRange::operator!= ( const ConstantRange &  CR  )  const [inline]

Definition at line 128 of file ConstantRange.h.

References operator==().

ConstantRange ConstantRange::subtract ( const APInt &  Val  )  const

subtract - Subtract the specified constant from the endpoints of this constant range.

subtract - Subtract the specified constant from the endpoints of this constant range.

Definition at line 162 of file ConstantRange.cpp.

References ConstantRange(), getBitWidth(), and llvm::APInt::getBitWidth().

Referenced by llvm::SCEVAddRecExpr::getNumIterationsInRange().

ConstantRange ConstantRange::intersectWith ( const ConstantRange &  CR  )  const

intersectWith - Return the range that results from the intersection of this range with another range. The resultant range is pruned as much as possible, but there may be cases where elements are included that are in one of the sets but not the other. For example: [100, 8) intersect [3, 120) yields [3, 120)

intersectWith - Return the range that results from the intersection of this range with another range.

Definition at line 213 of file ConstantRange.cpp.

References ConstantRange(), getBitWidth(), isEmptySet(), isFullSet(), isWrappedSet(), L, Lower, llvm::APInt::ult(), llvm::APIntOps::umax(), llvm::APIntOps::umin(), and Upper.

ConstantRange ConstantRange::maximalIntersectWith ( const ConstantRange &  CR  )  const

maximalIntersectWith - 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.maximalIntersectWith(B) might not be equal to B.maximalIntersectWith(A).

maximalIntersectWith - 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.maximalIntersectWith(B) might not be equal to B.maximalIntersect(A).

Definition at line 254 of file ConstantRange.cpp.

References ConstantRange(), getBitWidth(), getSetSize(), isEmptySet(), isFullSet(), isWrappedSet(), Lower, maximalIntersectWith(), llvm::APInt::ule(), llvm::APInt::ult(), and Upper.

Referenced by maximalIntersectWith().

ConstantRange ConstantRange::unionWith ( const ConstantRange &  CR  )  const

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.

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.

Definition at line 337 of file ConstantRange.cpp.

References ConstantRange(), getBitWidth(), if(), isEmptySet(), isFullSet(), isWrappedSet(), L, Lower, llvm::APInt::ugt(), llvm::APInt::ule(), llvm::APInt::ult(), unionWith(), and Upper.

Referenced by unionWith().

ConstantRange ConstantRange::zeroExtend ( uint32_t  DstTySize  )  const

zeroExtend - Return a new range in the specified integer type, which must be strictly larger than the current type. The returned range will correspond to the possible range of values if the source range had been zero extended to BitWidth.

zeroExtend - Return a new range in the specified integer type, which must be strictly larger than the current type. The returned range will correspond to the possible range of values as if the source range had been zero extended.

Definition at line 417 of file ConstantRange.cpp.

References ConstantRange(), getBitWidth(), isFullSet(), L, llvm::APIntOps::shl(), and llvm::APInt::zext().

ConstantRange ConstantRange::signExtend ( uint32_t  DstTySize  )  const

signExtend - Return a new range in the specified integer type, which must be strictly larger than the current type. The returned range will correspond to the possible range of values if the source range had been sign extended to BitWidth.

signExtend - Return a new range in the specified integer type, which must be strictly larger than the current type. The returned range will correspond to the possible range of values as if the source range had been sign extended.

Definition at line 433 of file ConstantRange.cpp.

References ConstantRange(), getBitWidth(), llvm::APInt::getHighBitsSet(), llvm::APInt::getLowBitsSet(), isFullSet(), L, and llvm::APInt::sext().

ConstantRange ConstantRange::truncate ( uint32_t  DstTySize  )  const

truncate - Return a new range in the specified integer type, which must be strictly smaller than the current type. The returned range will correspond to the possible range of values if the source range had been truncated to the specified type.

truncate - Return a new range in the specified integer type, which must be strictly smaller than the current type. The returned range will correspond to the possible range of values as if the source range had been truncated to the specified type.

Definition at line 450 of file ConstantRange.cpp.

References ConstantRange(), getBitWidth(), llvm::APInt::getLowBitsSet(), getSetSize(), isFullSet(), L, and llvm::APInt::trunc().

void ConstantRange::print ( raw_ostream &  OS  )  const

print - Print out the bounds to a stream...

Definition at line 464 of file ConstantRange.cpp.

Referenced by dump(), and llvm::operator<<().

void ConstantRange::dump (  )  const

dump - Allow printing from a debugger easily...

Definition at line 470 of file ConstantRange.cpp.

References llvm::errs(), and print().


The documentation for this class was generated from the following files: