diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2018-05-29 18:06:50 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2018-05-29 18:06:50 +0000 |
commit | 64c6ab445e9a59e7f97cf4cbf342db070979a6f5 (patch) | |
tree | d214288f1150b48c3d86918b082b3ea48df846f1 | |
parent | ceafc55e5a1a4796e48d0d09b589c0e77aa28944 (diff) | |
download | bcm5719-llvm-64c6ab445e9a59e7f97cf4cbf342db070979a6f5.tar.gz bcm5719-llvm-64c6ab445e9a59e7f97cf4cbf342db070979a6f5.zip |
IRBuilder: Add overload for intrinsics without args
llvm-svn: 333443
-rw-r--r-- | llvm/include/llvm/IR/IRBuilder.h | 5 | ||||
-rw-r--r-- | llvm/lib/IR/IRBuilder.cpp | 8 | ||||
-rw-r--r-- | llvm/unittests/IR/IRBuilderTest.cpp | 4 |
3 files changed, 17 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h index ce1ecde46ad..f9bb3a983be 100644 --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -632,6 +632,11 @@ public: Value *LHS, Value *RHS, const Twine &Name = ""); + /// Create a call to intrinsic \p ID with no operands. + CallInst *CreateIntrinsic(Intrinsic::ID ID, + Instruction *FMFSource = nullptr, + const Twine &Name = ""); + /// Create a call to intrinsic \p ID with 1 or more operands assuming the /// intrinsic and all operands have the same type. If \p FMFSource is /// provided, copy fast-math-flags from that instruction to the intrinsic. diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp index 71bdc35d4c1..f80be2d1b72 100644 --- a/llvm/lib/IR/IRBuilder.cpp +++ b/llvm/lib/IR/IRBuilder.cpp @@ -669,6 +669,14 @@ CallInst *IRBuilderBase::CreateBinaryIntrinsic(Intrinsic::ID ID, } CallInst *IRBuilderBase::CreateIntrinsic(Intrinsic::ID ID, + Instruction *FMFSource, + const Twine &Name) { + Module *M = BB->getModule(); + Function *Fn = Intrinsic::getDeclaration(M, ID); + return createCallHelper(Fn, {}, this, Name); +} + +CallInst *IRBuilderBase::CreateIntrinsic(Intrinsic::ID ID, ArrayRef<Value *> Args, Instruction *FMFSource, const Twine &Name) { diff --git a/llvm/unittests/IR/IRBuilderTest.cpp b/llvm/unittests/IR/IRBuilderTest.cpp index 6a3d121552d..3e032751692 100644 --- a/llvm/unittests/IR/IRBuilderTest.cpp +++ b/llvm/unittests/IR/IRBuilderTest.cpp @@ -63,6 +63,10 @@ TEST_F(IRBuilderTest, Intrinsics) { Call = Builder.CreateMaxNum(V, V); II = cast<IntrinsicInst>(Call); EXPECT_EQ(II->getIntrinsicID(), Intrinsic::maxnum); + + Call = Builder.CreateIntrinsic(Intrinsic::readcyclecounter); + II = cast<IntrinsicInst>(Call); + EXPECT_EQ(II->getIntrinsicID(), Intrinsic::readcyclecounter); } TEST_F(IRBuilderTest, Lifetime) { |