-Constant *Constant::getAllOnesValue(const Type *Ty) {
- if (const IntegerType* ITy = dyn_cast<IntegerType>(Ty))
- return ConstantInt::get(APInt::getAllOnesValue(ITy->getBitWidth()));
- return ConstantVector::getAllOnesValue(cast<VectorType>(Ty));
-}
-
-// Static constructor to create an integral constant with all bits set
-ConstantInt *ConstantInt::getAllOnesValue(const Type *Ty) {
- if (const IntegerType* ITy = dyn_cast<IntegerType>(Ty))
- return ConstantInt::get(APInt::getAllOnesValue(ITy->getBitWidth()));
- return 0;
-}
-
-/// @returns the value for a vector integer constant of the given type that
-/// has all its bits set to true.
-/// @brief Get the all ones value
-ConstantVector *ConstantVector::getAllOnesValue(const VectorType *Ty) {
- std::vector<Constant*> Elts;
- Elts.resize(Ty->getNumElements(),
- ConstantInt::getAllOnesValue(Ty->getElementType()));
- assert(Elts[0] && "Not a vector integer type!");
- return cast<ConstantVector>(ConstantVector::get(Elts));
-}
-
-