1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

IRBuilder: Add overload for intrinsics without args

llvm-svn: 333443
This commit is contained in:
Matt Arsenault 2018-05-29 18:06:50 +00:00
parent 27a95e7d2c
commit 885ae3077d
3 changed files with 17 additions and 0 deletions

View File

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

View File

@ -668,6 +668,14 @@ CallInst *IRBuilderBase::CreateBinaryIntrinsic(Intrinsic::ID ID,
return createCallHelper(Fn, { LHS, RHS }, this, Name);
}
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,

View File

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