aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support/ConstantRange.cpp
diff options
context:
space:
mode:
authorZhou Sheng <zhousheng00@gmail.com>2007-01-11 12:24:14 +0000
committerZhou Sheng <zhousheng00@gmail.com>2007-01-11 12:24:14 +0000
commit6b6b6ef1677fa71b1072c2911b4c1f9524a558c9 (patch)
tree480ecf010ac5facd1bc29ab57441253691bb42d6 /lib/Support/ConstantRange.cpp
parent057809ac1c78c3456e8f1481330fa2bcd2b85029 (diff)
downloadexternal_llvm-6b6b6ef1677fa71b1072c2911b4c1f9524a558c9.zip
external_llvm-6b6b6ef1677fa71b1072c2911b4c1f9524a558c9.tar.gz
external_llvm-6b6b6ef1677fa71b1072c2911b4c1f9524a558c9.tar.bz2
For PR1043:
Merge ConstantIntegral and ConstantBool into ConstantInt. Remove ConstantIntegral and ConstantBool from LLVM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33073 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/ConstantRange.cpp')
-rw-r--r--lib/Support/ConstantRange.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp
index a8ffa58..1d49e22 100644
--- a/lib/Support/ConstantRange.cpp
+++ b/lib/Support/ConstantRange.cpp
@@ -30,9 +30,9 @@
#include <ostream>
using namespace llvm;
-static ConstantIntegral *getMaxValue(const Type *Ty, bool isSigned = false) {
+static ConstantInt *getMaxValue(const Type *Ty, bool isSigned = false) {
if (Ty == Type::BoolTy)
- return ConstantBool::getTrue();
+ return ConstantInt::getTrue();
if (Ty->isInteger()) {
if (isSigned) {
// Calculate 011111111111111...
@@ -47,9 +47,9 @@ static ConstantIntegral *getMaxValue(const Type *Ty, bool isSigned = false) {
}
// Static constructor to create the minimum constant for an integral type...
-static ConstantIntegral *getMinValue(const Type *Ty, bool isSigned = false) {
+static ConstantInt *getMinValue(const Type *Ty, bool isSigned = false) {
if (Ty == Type::BoolTy)
- return ConstantBool::getFalse();
+ return ConstantInt::getFalse();
if (Ty->isInteger()) {
if (isSigned) {
// Calculate 1111111111000000000000
@@ -62,37 +62,37 @@ static ConstantIntegral *getMinValue(const Type *Ty, bool isSigned = false) {
}
return 0;
}
-static ConstantIntegral *Next(ConstantIntegral *CI) {
- if (ConstantBool *CB = dyn_cast<ConstantBool>(CI))
- return ConstantBool::get(!CB->getValue());
+static ConstantInt *Next(ConstantInt *CI) {
+ if (CI->getType() == Type::BoolTy)
+ return ConstantInt::get(!CI->getBoolValue());
Constant *Result = ConstantExpr::getAdd(CI,
ConstantInt::get(CI->getType(), 1));
- return cast<ConstantIntegral>(Result);
+ return cast<ConstantInt>(Result);
}
-static bool LT(ConstantIntegral *A, ConstantIntegral *B, bool isSigned) {
+static bool LT(ConstantInt *A, ConstantInt *B, bool isSigned) {
Constant *C = ConstantExpr::getICmp(
(isSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT), A, B);
- assert(isa<ConstantBool>(C) && "Constant folding of integrals not impl??");
- return cast<ConstantBool>(C)->getValue();
+ assert(isa<ConstantInt>(C) && "Constant folding of integrals not impl??");
+ return cast<ConstantInt>(C)->getBoolValue();
}
-static bool LTE(ConstantIntegral *A, ConstantIntegral *B, bool isSigned) {
+static bool LTE(ConstantInt *A, ConstantInt *B, bool isSigned) {
Constant *C = ConstantExpr::getICmp(
(isSigned ? ICmpInst::ICMP_SLE : ICmpInst::ICMP_ULE), A, B);
- assert(isa<ConstantBool>(C) && "Constant folding of integrals not impl??");
- return cast<ConstantBool>(C)->getValue();
+ assert(isa<ConstantInt>(C) && "Constant folding of integrals not impl??");
+ return cast<ConstantInt>(C)->getBoolValue();
}
-static bool GT(ConstantIntegral *A, ConstantIntegral *B, bool isSigned) {
+static bool GT(ConstantInt *A, ConstantInt *B, bool isSigned) {
return LT(B, A, isSigned); }
-static ConstantIntegral *Min(ConstantIntegral *A, ConstantIntegral *B,
+static ConstantInt *Min(ConstantInt *A, ConstantInt *B,
bool isSigned) {
return LT(A, B, isSigned) ? A : B;
}
-static ConstantIntegral *Max(ConstantIntegral *A, ConstantIntegral *B,
+static ConstantInt *Max(ConstantInt *A, ConstantInt *B,
bool isSigned) {
return GT(A, B, isSigned) ? A : B;
}
@@ -111,14 +111,14 @@ ConstantRange::ConstantRange(const Type *Ty, bool Full) {
/// Initialize a range to hold the single specified value.
///
ConstantRange::ConstantRange(Constant *V)
- : Lower(cast<ConstantIntegral>(V)), Upper(Next(cast<ConstantIntegral>(V))) { }
+ : Lower(cast<ConstantInt>(V)), Upper(Next(cast<ConstantInt>(V))) { }
/// Initialize a range of values explicitly... this will assert out if
/// Lower==Upper and Lower != Min or Max for its type (or if the two constants
/// have different types)
///
ConstantRange::ConstantRange(Constant *L, Constant *U)
- : Lower(cast<ConstantIntegral>(L)), Upper(cast<ConstantIntegral>(U)) {
+ : Lower(cast<ConstantInt>(L)), Upper(cast<ConstantInt>(U)) {
assert(Lower->getType() == Upper->getType() &&
"Incompatible types for ConstantRange!");
@@ -130,7 +130,7 @@ ConstantRange::ConstantRange(Constant *L, Constant *U)
/// Initialize a set of values that all satisfy the condition with C.
///
-ConstantRange::ConstantRange(unsigned short ICmpOpcode, ConstantIntegral *C) {
+ConstantRange::ConstantRange(unsigned short ICmpOpcode, ConstantInt *C) {
switch (ICmpOpcode) {
default: assert(0 && "Invalid ICmp opcode to ConstantRange ctor!");
case ICmpInst::ICMP_EQ: Lower = C; Upper = Next(C); return;
@@ -195,7 +195,7 @@ bool ConstantRange::isWrappedSet(bool isSigned) const {
/// getSingleElement - If this set contains a single element, return it,
/// otherwise return null.
-ConstantIntegral *ConstantRange::getSingleElement() const {
+ConstantInt *ConstantRange::getSingleElement() const {
if (Upper == Next(Lower)) // Is it a single element range?
return Lower;
return 0;
@@ -292,8 +292,8 @@ ConstantRange ConstantRange::intersectWith(const ConstantRange &CR,
if (!isWrappedSet(isSigned)) {
if (!CR.isWrappedSet(isSigned)) {
- ConstantIntegral *L = Max(Lower, CR.Lower, isSigned);
- ConstantIntegral *U = Min(Upper, CR.Upper, isSigned);
+ ConstantInt *L = Max(Lower, CR.Lower, isSigned);
+ ConstantInt *U = Min(Upper, CR.Upper, isSigned);
if (LT(L, U, isSigned)) // If range isn't empty...
return ConstantRange(L, U);
@@ -306,8 +306,8 @@ ConstantRange ConstantRange::intersectWith(const ConstantRange &CR,
return intersect1Wrapped(*this, CR, isSigned);
else {
// Both ranges are wrapped...
- ConstantIntegral *L = Max(Lower, CR.Lower, isSigned);
- ConstantIntegral *U = Min(Upper, CR.Upper, isSigned);
+ ConstantInt *L = Max(Lower, CR.Lower, isSigned);
+ ConstantInt *U = Min(Upper, CR.Upper, isSigned);
return ConstantRange(L, U);
}
}