//===-- ConstantRange.cpp - ConstantRange implementation ------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
//
// Represent a range of possible values that may occur when the program is run
// for an integral value. This keeps track of a lower and upper bound for the
#include "llvm/Instruction.h"
#include "llvm/ConstantHandling.h"
+namespace llvm {
+
/// Initialize a full (the default) or empty set for the specified type.
///
ConstantRange::ConstantRange(const Type *Ty, bool Full) {
Upper = C;
return;
case Instruction::SetGT:
- Upper = ConstantIntegral::getMaxValue(C->getType());
Lower = Next(C);
+ Upper = ConstantIntegral::getMinValue(C->getType()); // Min = Next(Max)
return;
case Instruction::SetLE:
Lower = ConstantIntegral::getMinValue(C->getType());
Upper = Next(C);
return;
case Instruction::SetGE:
- Upper = ConstantIntegral::getMaxValue(C->getType());
Lower = C;
+ Upper = ConstantIntegral::getMinValue(C->getType()); // Min = Next(Max)
return;
}
}
// Simply subtract the bounds...
Constant *Result = *(Constant*)Upper - *(Constant*)Lower;
assert(Result && "Subtraction of constant integers not implemented?");
- if (getType()->isSigned())
- return (uint64_t)cast<ConstantSInt>(Result)->getValue();
- else
- return cast<ConstantUInt>(Result)->getValue();
+ return cast<ConstantInt>(Result)->getRawValue();
}
void ConstantRange::dump() const {
print(std::cerr);
}
+
+} // End llvm namespace