Add a new ConstantPacked::getAllOnesValue method

llvm-svn: 32856
This commit is contained in:
Chris Lattner 2007-01-04 01:49:26 +00:00
parent 2f0b276731
commit ecab54cfc0
2 changed files with 17 additions and 0 deletions

View File

@ -422,6 +422,11 @@ public:
return reinterpret_cast<const PackedType*>(Value::getType()); 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 /// isNullValue - Return true if this is the value that would be returned by
/// getNullValue. This always returns false because zero arrays are always /// getNullValue. This always returns false because zero arrays are always
/// created as ConstantAggregateZero objects. /// created as ConstantAggregateZero objects.

View 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 // ConstantXXX Classes
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//