I'm looking for an example of how to insert a new function into a module. I have a module pass that needs to create some new functions. Tia. Reed
Grep any LLVM code for Function::Create
For example:
https://hpcforge.org/scm/viewvc.php/*checkout*/trunk/src/runtime/Wrappers.cpp?root=kernelgen
// The host call launcher prototype to be added
// to entire module.
Module* m = call->getParent()->getParent()->getParent();
Function* hostcall = m->getFunction("kernelgen_hostcall");
if (!hostcall)
hostcall = Function::Create(
TypeBuilder<void(types::i<8>*,
types::i<64>,
types::i<64>, types::i<32>*),
true>::get(context),
GlobalValue::ExternalLinkage,
"kernelgen_hostcall",
m);
2013/4/19 reed kotler <rkotler at mips.com>
> I'm looking for an example of how to insert a new function into a
module.
>
> I have a module pass that needs to create some new functions.
>
> Tia.
>
> Reed
>
>
> ______________________________**_________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>
http://lists.cs.uiuc.edu/**mailman/listinfo/llvmdev<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20130419/1b6dedd9/attachment.html>
Your query should be adequately covered by: http://llvm.org/docs/tutorial/LangImpl3.html#function-code-generation -- Sean Silva -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130418/cec08c98/attachment.html>
On 4/18/13 6:41 PM, reed kotler wrote:> I'm looking for an example of how to insert a new function into a module.You'll create a function declaration (i.e., an empty function) and then add basic blocks to it. I believe this code from SAFECode (http://llvm.org/viewvc/llvm-project/safecode/branches/release_32/lib/OptimizeChecks/InlineFastChecks.cpp?revision=168085&view=markup) may provide an example (caveat: it works with LLVM 3.2). -- John T.> > I have a module pass that needs to create some new functions. > > Tia. > > Reed > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev