[LLVMdev] accessing a bitcode library exported from C++ using the JIT

Samuel Crow samuraileumas at yahoo.com
Mon Aug 31 17:57:56 PDT 2009


----- Original Message ----
> From: Eli Friedman <eli.friedman at gmail.com>
> To: Samuel Crow <samuraileumas at yahoo.com>
> Cc: LLVM Developers Mailing List <llvmdev at cs.uiuc.edu>
> Sent: Monday, August 31, 2009 7:36:10 PM
> Subject: Re: [LLVMdev] accessing a bitcode library exported from C++ using the  JIT
> 
> On Tue, Sep 1, 2009 at 4:53 AM, Samuel Crowwrote:
> > We're using the LLVM Value * class functions to box and unbox values and 
> functions for our stack.  The stack needs to be able to take indexing without 
> changing the stack pointer so we're using a std::vector for that.  The 
> std::string section would be a lot easier to replace than the two I just 
> mentioned since we store the length separately.
> 
> If you really want to stick with std::string and std::vector, I'd
> suggest just writing some wrappers for the relevant functions.  For
> example:
> 
> extern "C" char* String_cstr(std::string*);
> extern "C" void Stack_pushback(std::vector*, void* value);
> 
> You can even compile these to bitcode with llvm-g++ and inline them
> into your other IR.
> 
> I don't think compiling libstdc++ to bitcode actually helps you here;
> you can call the relevant functions in libstdc++ whether or not
> they're bitcode.
> 
> -Eli

Hi Eli,

That's exactly what we are trying to do.  All of the parameters are passed in as text and parsed using StringStreams into their relavent types in the Value stack.  You can view the current code at http://mattathias.cvs.sourceforge.net/viewvc/mattathias/mattathias/modules/front_ends/Amos/BasicLib.cpp?view=markup and the BasicLib.h included in it only has a bunch of LLVM includes and an irrelevant previous attempt at code abstraction and a C struct to return the length-terminated string in.  I think my mistake is that I'm using Value * as a return code in one place instead of a void *.  I think that's causing the name mangling to kick in.  I'll see what I can do to fix it.

Thanks for talking me through the problem,

--Sam



      



More information about the llvm-dev mailing list