diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-06-15 06:10:53 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-06-15 06:10:53 +0000 |
| commit | 72e3958003ee84839797b9219e91d6a4648d78c5 (patch) | |
| tree | a5797e8ac652fc2b06dce0c38ed1398e60792534 /llvm/lib | |
| parent | 1edec381a53b0ec454dc2b66516f80179a927f2d (diff) | |
| download | bcm5719-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.cpp | 5 |
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) { |

