Liwei Yang
2014-Sep-14 03:49 UTC
[LLVMdev] How to translate library functions into LLVM IR bitcode?
Hello, I run into a situation where I need to provide the library functions, such as sqrt() from <math.h> and rand() from <stdlib.h>, in the format of LLVM IR bitcode files. Then I can try to link the bitcode of my program against these library bitcode files to formulate a holistic bitcode file. However, these library functions are only available in object format. And the source files of them I found have many references to other library files. So, is there any way to translate the library source files into bitcode files, so that all the information that the library functions need is included and can provide the implementation of these functions to the calling program after linking? Thanks for any suggestions:) -- Best Regards Liwei -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140914/88a7d64c/attachment.html>
Yabin Hu
2014-Sep-15 03:30 UTC
[LLVMdev] How to translate library functions into LLVM IR bitcode?
Hi Liwei, You may at first look into whether there is a llvm intrinsic for the function you want to call. In case there is not, I would suggest you wrapped the original function in your own project and call the wrapped one instead. And at last you may dynamically load the original library and link to it at runtime (using dlopen). Regards, Yabin 2014-09-14 11:49 GMT+08:00 Liwei Yang <yangliwei.uestc at gmail.com>:> Hello, > > I run into a situation where I need to provide the library functions, such > as sqrt() from <math.h> and rand() from <stdlib.h>, in the format of LLVM > IR bitcode files. Then I can try to link the bitcode of my program against > these library bitcode files to formulate a holistic bitcode file. > > However, these library functions are only available in object format. And > the source files of them I found have many references to other library > files. > > So, is there any way to translate the library source files into bitcode > files, so that all the information that the library functions need is > included and can provide the implementation of these functions to the > calling program after linking? > > Thanks for any suggestions:) > > -- > Best Regards > Liwei > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140915/79b66e84/attachment.html>
Liwei Yang
2014-Sep-15 06:31 UTC
[LLVMdev] How to translate library functions into LLVM IR bitcode?
Thanks for your reply, Yabin. Actually I'm trying to come up with a way to translate any source code into bitcode format. So some of them are not necessarily LLVM intrinsics. Also it seems like that dynamically loading the library by dlopen() is for loading object files, not .bc files. So it might not be useful for library in .bc files. Anyway, I've found a way to solve this by manually compiling each of the source file into a .bc file. If there's any automated way to infer about all the subroutines that one function needs, clang them into .bc file and link them into a stand-alone .bc library, that will be more than appreciated:-) On Mon, Sep 15, 2014 at 11:30 AM, Yabin Hu <yabin.hwu at gmail.com> wrote:> Hi Liwei, > > You may at first look into whether there is a llvm intrinsic for the > function you want to call. In case there is not, I would suggest you > wrapped the original function in your own project and call the wrapped one > instead. And at last you may dynamically load the original library and link > to it at runtime (using dlopen). > > Regards, > Yabin > > 2014-09-14 11:49 GMT+08:00 Liwei Yang <yangliwei.uestc at gmail.com>: > >> Hello, >> >> I run into a situation where I need to provide the library functions, >> such as sqrt() from <math.h> and rand() from <stdlib.h>, in the format of >> LLVM IR bitcode files. Then I can try to link the bitcode of my program >> against these library bitcode files to formulate a holistic bitcode file. >> >> However, these library functions are only available in object format. And >> the source files of them I found have many references to other library >> files. >> >> So, is there any way to translate the library source files into bitcode >> files, so that all the information that the library functions need is >> included and can provide the implementation of these functions to the >> calling program after linking? >> >> Thanks for any suggestions:) >> >> -- >> Best Regards >> Liwei >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> >-- Best Regards Liwei -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140915/2be45925/attachment.html>
Seemingly Similar Threads
- [LLVMdev] How to translate library functions into LLVM IR bitcode?
- [LLVMdev] How to translate library functions into LLVM IR bitcode?
- [LLVMdev] How to translate library functions into LLVM IR bitcode?
- [LLVMdev] How to translate library functions into LLVM IR bitcode?
- [LLVMdev] NVPTX: why ret instruction is not translated to exit in kernel function?