aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Support/ConstantRange.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-03-30 00:20:08 +0000
committerChris Lattner <sabre@nondot.org>2004-03-30 00:20:08 +0000
commitfc33d30446843009b0eadf63c0bfca35ae2baac6 (patch)
tree76fd51298c49e0d8e103617ccf12dc0c087c6e24 /include/llvm/Support/ConstantRange.h
parenteb8863db909e1a8383c849c3de23eefa0a1c23b7 (diff)
Add some new methods
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12539 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/ConstantRange.h')
-rw-r--r--include/llvm/Support/ConstantRange.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/llvm/Support/ConstantRange.h b/include/llvm/Support/ConstantRange.h
index cc3b23fd8e..30618a1692 100644
--- a/include/llvm/Support/ConstantRange.h
+++ b/include/llvm/Support/ConstantRange.h
@@ -30,6 +30,7 @@
namespace llvm {
class Constant;
class ConstantIntegral;
+class ConstantInt;
class Type;
class ConstantRange {
@@ -39,6 +40,10 @@ class ConstantRange {
///
ConstantRange(const Type *Ty, bool isFullSet = true);
+ /// Initialize a range to hold the single specified value.
+ ///
+ ConstantRange(Constant *Value);
+
/// Initialize a range of values explicitly... this will assert out if
/// Lower==Upper and Lower != Min or Max for its type, if the two constants
/// have different types, or if the constant are not integral values.
@@ -74,6 +79,10 @@ class ConstantRange {
/// for example: [100, 8)
///
bool isWrappedSet() const;
+
+ /// contains - Return true if the specified value is in the set.
+ ///
+ bool contains(ConstantInt *Val) const;
/// getSingleElement - If this set contains a single element, return it,
/// otherwise return null.
@@ -97,6 +106,10 @@ class ConstantRange {
return !operator==(CR);
}
+ /// subtract - Subtract the specified constant from the endpoints of this
+ /// constant range.
+ ConstantRange subtract(ConstantInt *CI) const;
+
/// intersect - 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
@@ -113,6 +126,18 @@ class ConstantRange {
///
ConstantRange unionWith(const ConstantRange &CR) 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.
+ ConstantRange zeroExtend(const Type *Ty) 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.
+ ConstantRange truncate(const Type *Ty) const;
+
/// print - Print out the bounds to a stream...
///
void print(std::ostream &OS) const;