Add a new ConstantPacked::getAllOnesValue method
authorChris Lattner <sabre@nondot.org>
Thu, 4 Jan 2007 01:49:26 +0000 (01:49 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 4 Jan 2007 01:49:26 +0000 (01:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32856 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Constants.h
lib/VMCore/Constants.cpp

index a6050f44a637afcd78040ff18ec4fbebddc4c0bb..e7552e33e088d1b480cef3ff5cef64bbfb2e593e 100644 (file)
@@ -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.
index 56219e27567a591527e7979946337dfb8392b50c..dfdb1f72dcdf6eb0f1d3c97d0123c5ecf9f146b0 100644 (file)
@@ -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
 //===----------------------------------------------------------------------===//