aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Support/IRBuilder.h
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-04-13 01:38:57 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-04-13 01:38:57 +0000
commitee09d2781de2f5a47bbb991a5a525c67557ac5cd (patch)
tree2fdb9a741ef029fb35c4d562d5ffc417f2f9816d /include/llvm/Support/IRBuilder.h
parent43ac721e3b35341e7cf59d5982ad702ca8d27433 (diff)
downloadexternal_llvm-ee09d2781de2f5a47bbb991a5a525c67557ac5cd.zip
external_llvm-ee09d2781de2f5a47bbb991a5a525c67557ac5cd.tar.gz
external_llvm-ee09d2781de2f5a47bbb991a5a525c67557ac5cd.tar.bz2
IRBuilder: Add Create{Shl,LShr,And,Or,Xor} methods from uin64_t and APInt constants.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101110 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/IRBuilder.h')
-rw-r--r--include/llvm/Support/IRBuilder.h61
1 files changed, 59 insertions, 2 deletions
diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h
index 660c9f8..1fd965d 100644
--- a/include/llvm/Support/IRBuilder.h
+++ b/include/llvm/Support/IRBuilder.h
@@ -432,12 +432,19 @@ public:
return Folder.CreateFRem(LC, RC);
return Insert(BinaryOperator::CreateFRem(LHS, RHS), Name);
}
+
Value *CreateShl(Value *LHS, Value *RHS, const Twine &Name = "") {
if (Constant *LC = dyn_cast<Constant>(LHS))
if (Constant *RC = dyn_cast<Constant>(RHS))
return Folder.CreateShl(LC, RC);
return Insert(BinaryOperator::CreateShl(LHS, RHS), Name);
}
+ Value *CreateShl(Value *LHS, const APInt &RHS, const Twine &Name = "") {
+ Constant *RHSC = ConstantInt::get(LHS->getType(), RHS);
+ if (Constant *LC = dyn_cast<Constant>(LHS))
+ return Folder.CreateShl(LC, RHSC);
+ return Insert(BinaryOperator::CreateShl(LHS, RHSC), Name);
+ }
Value *CreateShl(Value *LHS, uint64_t RHS, const Twine &Name = "") {
Constant *RHSC = ConstantInt::get(LHS->getType(), RHS);
if (Constant *LC = dyn_cast<Constant>(LHS))
@@ -451,23 +458,35 @@ public:
return Folder.CreateLShr(LC, RC);
return Insert(BinaryOperator::CreateLShr(LHS, RHS), Name);
}
+ Value *CreateLShr(Value *LHS, const APInt &RHS, const Twine &Name = "") {
+ Constant *RHSC = ConstantInt::get(LHS->getType(), RHS);
+ if (Constant *LC = dyn_cast<Constant>(LHS))
+ return Folder.CreateLShr(LC, RHSC);
+ return Insert(BinaryOperator::CreateLShr(LHS, RHSC), Name);
+ }
Value *CreateLShr(Value *LHS, uint64_t RHS, const Twine &Name = "") {
Constant *RHSC = ConstantInt::get(LHS->getType(), RHS);
if (Constant *LC = dyn_cast<Constant>(LHS))
return Folder.CreateLShr(LC, RHSC);
return Insert(BinaryOperator::CreateLShr(LHS, RHSC), Name);
}
-
+
Value *CreateAShr(Value *LHS, Value *RHS, const Twine &Name = "") {
if (Constant *LC = dyn_cast<Constant>(LHS))
if (Constant *RC = dyn_cast<Constant>(RHS))
return Folder.CreateAShr(LC, RC);
return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name);
}
+ Value *CreateAShr(Value *LHS, const APInt &RHS, const Twine &Name = "") {
+ Constant *RHSC = ConstantInt::get(LHS->getType(), RHS);
+ if (Constant *LC = dyn_cast<Constant>(LHS))
+ return Folder.CreateAShr(LC, RHSC);
+ return Insert(BinaryOperator::CreateAShr(LHS, RHSC), Name);
+ }
Value *CreateAShr(Value *LHS, uint64_t RHS, const Twine &Name = "") {
Constant *RHSC = ConstantInt::get(LHS->getType(), RHS);
if (Constant *LC = dyn_cast<Constant>(LHS))
- return Folder.CreateSShr(LC, RHSC);
+ return Folder.CreateAShr(LC, RHSC);
return Insert(BinaryOperator::CreateAShr(LHS, RHSC), Name);
}
@@ -480,6 +499,19 @@ public:
}
return Insert(BinaryOperator::CreateAnd(LHS, RHS), Name);
}
+ Value *CreateAnd(Value *LHS, const APInt &RHS, const Twine &Name = "") {
+ Constant *RHSC = ConstantInt::get(LHS->getType(), RHS);
+ if (Constant *LC = dyn_cast<Constant>(LHS))
+ return Folder.CreateAnd(LC, RHSC);
+ return Insert(BinaryOperator::CreateAnd(LHS, RHSC), Name);
+ }
+ Value *CreateAnd(Value *LHS, uint64_t RHS, const Twine &Name = "") {
+ Constant *RHSC = ConstantInt::get(LHS->getType(), RHS);
+ if (Constant *LC = dyn_cast<Constant>(LHS))
+ return Folder.CreateAnd(LC, RHSC);
+ return Insert(BinaryOperator::CreateAnd(LHS, RHSC), Name);
+ }
+
Value *CreateOr(Value *LHS, Value *RHS, const Twine &Name = "") {
if (Constant *RC = dyn_cast<Constant>(RHS)) {
if (RC->isNullValue())
@@ -489,12 +521,37 @@ public:
}
return Insert(BinaryOperator::CreateOr(LHS, RHS), Name);
}
+ Value *CreateOr(Value *LHS, const APInt &RHS, const Twine &Name = "") {
+ Constant *RHSC = ConstantInt::get(LHS->getType(), RHS);
+ if (Constant *LC = dyn_cast<Constant>(LHS))
+ return Folder.CreateOr(LC, RHSC);
+ return Insert(BinaryOperator::CreateOr(LHS, RHSC), Name);
+ }
+ Value *CreateOr(Value *LHS, uint64_t RHS, const Twine &Name = "") {
+ Constant *RHSC = ConstantInt::get(LHS->getType(), RHS);
+ if (Constant *LC = dyn_cast<Constant>(LHS))
+ return Folder.CreateOr(LC, RHSC);
+ return Insert(BinaryOperator::CreateOr(LHS, RHSC), Name);
+ }
+
Value *CreateXor(Value *LHS, Value *RHS, const Twine &Name = "") {
if (Constant *LC = dyn_cast<Constant>(LHS))
if (Constant *RC = dyn_cast<Constant>(RHS))
return Folder.CreateXor(LC, RC);
return Insert(BinaryOperator::CreateXor(LHS, RHS), Name);
}
+ Value *CreateXor(Value *LHS, const APInt &RHS, const Twine &Name = "") {
+ Constant *RHSC = ConstantInt::get(LHS->getType(), RHS);
+ if (Constant *LC = dyn_cast<Constant>(LHS))
+ return Folder.CreateXor(LC, RHSC);
+ return Insert(BinaryOperator::CreateXor(LHS, RHSC), Name);
+ }
+ Value *CreateXor(Value *LHS, uint64_t RHS, const Twine &Name = "") {
+ Constant *RHSC = ConstantInt::get(LHS->getType(), RHS);
+ if (Constant *LC = dyn_cast<Constant>(LHS))
+ return Folder.CreateXor(LC, RHSC);
+ return Insert(BinaryOperator::CreateXor(LHS, RHSC), Name);
+ }
Value *CreateBinOp(Instruction::BinaryOps Opc,
Value *LHS, Value *RHS, const Twine &Name = "") {