Skip to content
Snippets Groups Projects
Commit 72e39580 authored by Chris Lattner's avatar Chris Lattner
Browse files

add a Constant::getAllOnesValue helper function, which works on integers

AND vectors.

llvm-svn: 37586
parent 1edec381
No related branches found
No related tags found
No related merge requests found
...@@ -48,6 +48,11 @@ public: ...@@ -48,6 +48,11 @@ public:
/// ///
static Constant *getNullValue(const Type *Ty); 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 /// isNullValue - Return true if this is the value that would be returned by
/// getNullValue. /// getNullValue.
virtual bool isNullValue() const = 0; virtual bool isNullValue() const = 0;
......
...@@ -122,6 +122,11 @@ Constant *Constant::getNullValue(const Type *Ty) { ...@@ -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 // Static constructor to create an integral constant with all bits set
ConstantInt *ConstantInt::getAllOnesValue(const Type *Ty) { ConstantInt *ConstantInt::getAllOnesValue(const Type *Ty) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment