Dear All, I am considering a possibility of using LLVM JIT for an algebraic modelling language. I have already done some prototyping following the Kaleidoscope tutorial and currently thinking of how to connect the jitted code to a runtime library (for this language) which I would like to code in C++. If it was *NIX I would use g++ possibly with '-rdynamic' option as suggested in the tutorial to resolve required functions at runtime. However it is not an option, I am stuck to Windows and Visual C++. One possibility that I have found is to create llvm::Function objects and use ExecutionEngine::addGlobalMapping to map them to the implementations. This works fine but is quite labour-consuming since every library function required used in jitted code needs to be mapped. Does anyone know a better way? Thanks, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090615/a82ac575/attachment.html>
Hello, Victor> found is to create llvm::Function objects and use > ExecutionEngine::addGlobalMapping to map them to the implementations. This > works fine but is quite labour-consuming since every library function > required used in jitted code needs to be mapped. Does anyone know a better > way?Theoretically you should be able to load the .dll into address space of the application, "register" it and stuff should magically work. I am not sure whether this functionality obtained much care recently, so some bugfixing might be needed. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
Victor Zverovich wrote:> I am considering a possibility of using LLVM JIT for an algebraic > modelling language. I have already done some prototyping following the > Kaleidoscope tutorial and currently thinking of how to connect the > jitted code to a runtime library (for this language) which I would like > to code in C++. If it was *NIX I would use g++ possibly with '-rdynamic' > option as suggested in the tutorial to resolve required functions at > runtime. However it is not an option, I am stuck to Windows and Visual > C++.Well, backlinking doesn't work on Windows, but you can create a dll for your runtime and use LLVM's dynamic library interface to load that dll. I'm doing it that way in my project (http://pure-lang.googlecode.com/, search for 'sys::DynamicLibrary::' in interpreter.cc) and it works fine on Windows. Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr.Graef at t-online.de, ag at muwiinfa.geschichte.uni-mainz.de WWW: http://www.musikinformatik.uni-mainz.de/ag
Albert Graef <Dr.Graef at t-online.de> writes:> Victor Zverovich wrote: >> I am considering a possibility of using LLVM JIT for an algebraic >> modelling language. I have already done some prototyping following the >> Kaleidoscope tutorial and currently thinking of how to connect the >> jitted code to a runtime library (for this language) which I would like >> to code in C++. If it was *NIX I would use g++ possibly with '-rdynamic' >> option as suggested in the tutorial to resolve required functions at >> runtime. However it is not an option, I am stuck to Windows and Visual >> C++. > > Well, backlinking doesn't work on Windows, but you can create a dll for > your runtime and use LLVM's dynamic library interface to load that dll. > I'm doing it that way in my project (http://pure-lang.googlecode.com/, > search for 'sys::DynamicLibrary::' in interpreter.cc) and it works fine > on Windows.The OP says that he wants to link to a dll coded in C++. Isn't name mangling the main problem here? -- Óscar
Albert and Anton, thanks for all the answers. I tried to load a DLL with DynamicLibrary::LoadLibraryPermanently and it works perfectly, so there is no need to use ExecutionEngine::addGlobalMapping. However Function objects still need to be constructed since they are required when creating a call, right? Victor 2009/6/15 Albert Graef <Dr.Graef at t-online.de>> Victor Zverovich wrote: > > I am considering a possibility of using LLVM JIT for an algebraic > > modelling language. I have already done some prototyping following the > > Kaleidoscope tutorial and currently thinking of how to connect the > > jitted code to a runtime library (for this language) which I would like > > to code in C++. If it was *NIX I would use g++ possibly with '-rdynamic' > > option as suggested in the tutorial to resolve required functions at > > runtime. However it is not an option, I am stuck to Windows and Visual > > C++. > > Well, backlinking doesn't work on Windows, but you can create a dll for > your runtime and use LLVM's dynamic library interface to load that dll. > I'm doing it that way in my project (http://pure-lang.googlecode.com/, > search for 'sys::DynamicLibrary::' in interpreter.cc) and it works fine > on Windows. > > Albert > > -- > Dr. Albert Gr"af > Dept. of Music-Informatics, University of Mainz, Germany > Email: Dr.Graef at t-online.de, ag at muwiinfa.geschichte.uni-mainz.de > WWW: http://www.musikinformatik.uni-mainz.de/ag > _______________________________________________ > 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/20090615/3f4dc042/attachment.html>
Maybe Matching Threads
- [LLVMdev] runtime library for jitted code
- [LLVMdev] runtime library for jitted code
- [LLVMdev] runtime library for jitted code
- [LLVMdev] Having JIT resolve extern "C" functions declared in executible
- [LLVMdev] Having JIT resolve extern "C" functions declared in executible