Hi, I have a small JIT project based on MCJIT. The generated LLVM IR code uses the i256 type. Also, the jitted code has to call back the host application from time to time. E.g. it calls a function i256 @callback(i256). 1. Can the callback function be implemented on the host application side (C/C++) to match the ABI used for the call by MCJIT? Or maybe the i256 has be to be casted to any struct type on LLVM side to make that possible? 2. Should that work correctly on different host OSes? So far I used pointer arguments for both arguments and return types. But I'm afraid that using pointers blocks a lots of optimizations. - Paweł -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160414/daebb761/attachment.html>
Hi Pawel, This should be fine. MCJIT doesn't use any special calling conventions. As long as your JIT'd code has the same calling convention as the callback in the host program this *should* just work. If it doesn't please file a bug and assign it to me. :) - Lang. On Thu, Apr 14, 2016 at 4:59 AM, Paweł Bylica <llvm-dev at lists.llvm.org> wrote:> Hi, > > I have a small JIT project based on MCJIT. The generated LLVM IR code uses > the i256 type. Also, the jitted code has to call back the host application > from time to time. E.g. it calls a function i256 @callback(i256). > > 1. Can the callback function be implemented on the host application > side (C/C++) to match the ABI used for the call by MCJIT? Or maybe the i256 > has be to be casted to any struct type on LLVM side to make that possible? > 2. Should that work correctly on different host OSes? > > So far I used pointer arguments for both arguments and return types. But > I'm afraid that using pointers blocks a lots of optimizations. > > - Paweł > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160415/dac5a57e/attachment.html>
Thank you for the response. The other part of the question is how to match i256 type on the C/C++ side? On Sat, Apr 16, 2016, 01:21 Lang Hames <lhames at gmail.com> wrote:> Hi Pawel, > > This should be fine. MCJIT doesn't use any special calling conventions. As > long as your JIT'd code has the same calling convention as the callback in > the host program this *should* just work. If it doesn't please file a bug > and assign it to me. :) > > - Lang. > > On Thu, Apr 14, 2016 at 4:59 AM, Paweł Bylica <llvm-dev at lists.llvm.org> > wrote: > >> Hi, >> >> I have a small JIT project based on MCJIT. The generated LLVM IR code >> uses the i256 type. Also, the jitted code has to call back the host >> application from time to time. E.g. it calls a function i256 >> @callback(i256). >> >> 1. Can the callback function be implemented on the host application >> side (C/C++) to match the ABI used for the call by MCJIT? Or maybe the i256 >> has be to be casted to any struct type on LLVM side to make that possible? >> 2. Should that work correctly on different host OSes? >> >> So far I used pointer arguments for both arguments and return types. But >> I'm afraid that using pointers blocks a lots of optimizations. >> >> - Paweł >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160416/5ae5e0e7/attachment.html>