[LLVMdev] lli in interpreter mode and external native libraries
Chris Lattner
sabre at nondot.org
Wed Oct 25 20:20:07 PDT 2006
On Wed, 25 Oct 2006, Sarah Thompson wrote:
> Is there any way to support calling external libraries from interpreted
> code (*not* JITted code) within lli?
Sure.
> I am looking at the external functions implementation, and it seems just
> to wrap back onto its own library, looking up lli_X_... prefixed
> functions. It would (for obvious reasons) be incredibly useful not to be
> restricted to the (tiny) set of supplied functions.
There are three ways to do this:
1. Ugly: teach the interpreter about every function you care about, in
ExternalFunctions.cpp.
2. Less Ugly: refactor the interpreter to think about things in terms of
their prototype instead of their name. All external functions of the
same prototype use the same calling sequence. Add code for each
prototype you care about.
3. Best: Find a "foreign function interface" library, and use that to
interface to native code.
> PS: I'm attempting to extend the interpreter to implement threads
> (mostly working), and will shortly attempt to rip out its state handling
> in order to build an explicit state model checker. So far, it looks like
> LLVM will do very nicely, and though supporting native code external
> functions isn't essential for my purposes, it would be extremely useful.
Cool!
-Chris
--
http://nondot.org/sabre/
http://llvm.org/
More information about the llvm-dev
mailing list