summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-06-15 06:10:53 +0000
committerChris Lattner <sabre@nondot.org>2007-06-15 06:10:53 +0000
commit72e3958003ee84839797b9219e91d6a4648d78c5 (patch)
treea5797e8ac652fc2b06dce0c38ed1398e60792534 /llvm/lib
parent1edec381a53b0ec454dc2b66516f80179a927f2d (diff)
downloadbcm5719-llvm-72e3958003ee84839797b9219e91d6a4648d78c5.tar.gz
bcm5719-llvm-72e3958003ee84839797b9219e91d6a4648d78c5.zip
add a Constant::getAllOnesValue helper function, which works on integers
AND vectors. llvm-svn: 37586
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/Constants.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index 55e1539b5c1..e171011159c 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/lib/VMCore/Constants.cpp
@@ -122,6 +122,11 @@ Constant *Constant::getNullValue(const Type *Ty) {
}
}
+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) {
OpenPOWER on IntegriCloud