diff options
author | Owen Anderson <resistor@mac.com> | 2010-08-07 05:47:46 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2010-08-07 05:47:46 +0000 |
commit | 1a9078b86217953dc478d5df8cb35d34284523d8 (patch) | |
tree | 6e785af39c5f932192f92615f50c5fcbb8d93ec6 /llvm/lib/Support/ConstantRange.cpp | |
parent | 5caa7c58db926a9481de01971c67e9d7ca2116d4 (diff) | |
download | bcm5719-llvm-1a9078b86217953dc478d5df8cb35d34284523d8.tar.gz bcm5719-llvm-1a9078b86217953dc478d5df8cb35d34284523d8.zip |
Add an inverse() method to ConstantRange.
llvm-svn: 110504
Diffstat (limited to 'llvm/lib/Support/ConstantRange.cpp')
-rw-r--r-- | llvm/lib/Support/ConstantRange.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Support/ConstantRange.cpp b/llvm/lib/Support/ConstantRange.cpp index fb0442823c4..26a23efe031 100644 --- a/llvm/lib/Support/ConstantRange.cpp +++ b/llvm/lib/Support/ConstantRange.cpp @@ -655,6 +655,17 @@ ConstantRange::lshr(const ConstantRange &Amount) const { return ConstantRange(min, max); } +ConstantRange ConstantRange::inverse() const { + if (isFullSet()) { + return ConstantRange(APInt::getNullValue(Lower.getBitWidth()), + APInt::getNullValue(Lower.getBitWidth())); + } else if (isEmptySet()) { + return ConstantRange(APInt::getAllOnesValue(Lower.getBitWidth()), + APInt::getAllOnesValue(Lower.getBitWidth())); + } + return ConstantRange(Upper, Lower); +} + /// print - Print out the bounds to a stream... /// void ConstantRange::print(raw_ostream &OS) const { |