diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2021-01-05 10:56:13 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2021-01-05 11:01:10 +0000 |
commit | 313d982df65a7a8f1da2da5f0e03e6b6e301ce3c (patch) | |
tree | 05613e32258e19add6b5c2a80b28cccb445a2434 /llvm/lib/IR/Constants.cpp | |
parent | eba6deab22b576004a209b3f42ccc5e58f7603bf (diff) | |
download | llvm-313d982df65a7a8f1da2da5f0e03e6b6e301ce3c.zip llvm-313d982df65a7a8f1da2da5f0e03e6b6e301ce3c.tar.gz llvm-313d982df65a7a8f1da2da5f0e03e6b6e301ce3c.tar.bz2 |
[IR] Add ConstantInt::getBool helpers to wrap getTrue/getFalse.
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 82a5f9d..a38302d 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -815,6 +815,10 @@ ConstantInt *ConstantInt::getFalse(LLVMContext &Context) { return pImpl->TheFalseVal; } +ConstantInt *ConstantInt::getBool(LLVMContext &Context, bool V) { + return V ? getTrue(Context) : getFalse(Context); +} + Constant *ConstantInt::getTrue(Type *Ty) { assert(Ty->isIntOrIntVectorTy(1) && "Type not i1 or vector of i1."); ConstantInt *TrueC = ConstantInt::getTrue(Ty->getContext()); @@ -831,6 +835,10 @@ Constant *ConstantInt::getFalse(Type *Ty) { return FalseC; } +Constant *ConstantInt::getBool(Type *Ty, bool V) { + return V ? getTrue(Ty) : getFalse(Ty); +} + // Get a ConstantInt from an APInt. ConstantInt *ConstantInt::get(LLVMContext &Context, const APInt &V) { // get an existing value or the insertion position |