1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

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

AND vectors.

llvm-svn: 37586
This commit is contained in:
Chris Lattner 2007-06-15 06:10:53 +00:00
parent c2985cea59
commit 145fdc7e2a
2 changed files with 10 additions and 0 deletions

View File

@ -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;

View File

@ -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) {