summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Constant.h5
-rw-r--r--llvm/lib/VMCore/Constants.cpp5
2 files changed, 10 insertions, 0 deletions
diff --git a/llvm/include/llvm/Constant.h b/llvm/include/llvm/Constant.h
index bfe65a6faa1..d925fdb618e 100644
--- a/llvm/include/llvm/Constant.h
+++ b/llvm/include/llvm/Constant.h
@@ -48,6 +48,11 @@ public:
///
static Constant *getNullValue(const Type *Ty);
+ /// Static constructor to get a '-1' constant. This supports integers and
+ /// vectors.
+ ///
+ static Constant *getAllOnesValue(const Type *Ty);
+
/// isNullValue - Return true if this is the value that would be returned by
/// getNullValue.
virtual bool isNullValue() const = 0;
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