diff options
author | Chris Lattner <sabre@nondot.org> | 2007-01-04 01:49:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-01-04 01:49:26 +0000 |
commit | 58513aa1c22a08118734ac799d935ea2910db35a (patch) | |
tree | a0ce8a953a13776ed1165e5270a34badaa0041c6 | |
parent | 8688428b0510e5e7dab43379b3d53c9b40dc182d (diff) | |
download | external_llvm-58513aa1c22a08118734ac799d935ea2910db35a.zip external_llvm-58513aa1c22a08118734ac799d935ea2910db35a.tar.gz external_llvm-58513aa1c22a08118734ac799d935ea2910db35a.tar.bz2 |
Add a new ConstantPacked::getAllOnesValue method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32856 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Constants.h | 5 | ||||
-rw-r--r-- | lib/VMCore/Constants.cpp | 12 |
2 files changed, 17 insertions, 0 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index a6050f4..e7552e3 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -422,6 +422,11 @@ public: return reinterpret_cast<const PackedType*>(Value::getType()); } + /// @returns the value for an packed integer constant of the given type that + /// has all its bits set to true. + /// @brief Get the all ones value + static ConstantPacked *getAllOnesValue(const PackedType *Ty); + /// isNullValue - Return true if this is the value that would be returned by /// getNullValue. This always returns false because zero arrays are always /// created as ConstantAggregateZero objects. diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 56219e2..dfdb1f7 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -146,6 +146,18 @@ ConstantIntegral *ConstantIntegral::getAllOnesValue(const Type *Ty) { } } +/// @returns the value for an packed integer constant of the given type that +/// has all its bits set to true. +/// @brief Get the all ones value +ConstantPacked *ConstantPacked::getAllOnesValue(const PackedType *Ty) { + std::vector<Constant*> Elts; + Elts.resize(Ty->getNumElements(), + ConstantIntegral::getAllOnesValue(Ty->getElementType())); + assert(Elts[0] && "Not a packed integer type!"); + return cast<ConstantPacked>(ConstantPacked::get(Elts)); +} + + //===----------------------------------------------------------------------===// // ConstantXXX Classes //===----------------------------------------------------------------------===// |