inserting a target specific builtin in llvm pass

Hi,

I'm writing a pass which needs to insert an intrinsic in for my target, but
I'm not sure how to create the call. I've tried defining a function, with
the target intrinsic as its name, and then creating a new CallInst to call
it. But how am I supposed to declare this function as an intrinsic?

Thanks,

Sam

Hi Sam,

I'm writing a pass which needs to insert an intrinsic in for my target, but
I'm not sure how to create the call. I've tried defining a function, with
the target intrinsic as its name, and then creating a new CallInst to call
it. But how am I supposed to declare this function as an intrinsic?

you don't have to do anything special for intrinsics, you can just declare them
like any other function declaration.

Ciao, Duncan.

You can do like this:
Function *MyFunc = Intrinsic::getDeclaration(M, Intrinsic::my_instrinc);
CallInst::Create(Myfunc, Args, "", InsertBefore);