[LLVMdev] Using JIT to construct an invocation of a non-JIT function, or how do I interface to GCC exception handling
Tom Quarendon
tom at quarendon.net
Tue Aug 12 07:35:18 PDT 2008
I'm just starting to have a look at LLVM, so forgive me if this is a
simple question.
What I'd like to do is use the JIT api to construct a "program" that
calls a series of functions. In other words I'm wanting to translate a
scripting language into some executable assembler where each primitive
of my scripting language is implemented with a "normal" function. That
is, lets say I've got two primitives PUT and GET and my C++ interpretter
goes somehting like
int doPUT() {
// Do the work of PUT
}
int doGET() {
// Do the work of GET
}
int main() {
// read in the script file and construct a Module containing a Function
containing suitably ordered
// CallInst objects that invoke doPUT and doGET
}
Can I do that? I can't figure out how to looking at the APIs.
What I really want to do is figure out how GCC exception handling
structures work, and I was using LLVM as an investigative tool. I'm some
code to GCC on Linux where we "JIT" a function into memory (not using
LLVM, I've just done it by manually generating x86 instructions) where
that dynamically created function just consists of a series of function
calls to other, "normal" functions that do the work. However I'm having
trouble with getting exceptions propagated through my dynamically
created function and I'm struggling to figure out quite what exception
handling tables I need to generate and quite how I make the GCC
exception handler find them. So in other words I've got
int doPUT() {
throw IOException;
}
int doGET() {
throw IOException
}
int main() {
// magic up my function in memory containing calls to doGET and doPUT.
try {
// call my magic'd function
}
catch (IOException) {
}
}
I've found various bits of information about the structure of the
exception handling tables that GCC uses, but so far I can't see the
whole picture in terms of what I'd actually do with those tables in
terms of registering them with the exception handler. I was hoping that
I could mock up something similar using LLVM to see what it did.
Any help on this would be great thanks.
Tom Quarendon.
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
More information about the llvm-dev
mailing list