[LLVMdev] Using LLVM to generate x86 dynamically in memory

Shasank Chavan shanko_chavano at hotmail.com
Wed Feb 3 01:08:41 PST 2010


Thanks Reid.  What you wrote makes a lot of sense.  The more I learn about the LLVM, the more I'll be able to determine how easy it would be to translate our IR into it.  If it proves too difficult, I'll do what you suggested.  Thanks again everyone for your responses...

 

- Shasank
 
> From: rnk at mit.edu
> Date: Tue, 2 Feb 2010 22:11:50 -0500
> Subject: Re: [LLVMdev] Using LLVM to generate x86 dynamically in memory
> To: shanko_chavano at hotmail.com
> CC: grosbach at apple.com; llvmdev at cs.uiuc.edu
> 
> On Tue, Feb 2, 2010 at 7:39 PM, Shasank Chavan
> <shanko_chavano at hotmail.com> wrote:
> > Hi Jim.  Thanks for your speedy response.  I'm not entirely sure if a JIT is
> > what I'm looking for.  I'm basically looking for a dll with an interface
> > that takes a C program as input and compiles and optimizes it to native x86
> > instructions in an in-memory buffer.  I don't want the dll the execute it,
> > and I don't particularly want to translate our expressions into LLVM bitcode
> > (although I can if the rest of the pieces are there).  Also, I briefly read
> > up on lli.  This looks like a separate process will have to be spawned to
> > invoke the JIT to execute programs in LLVM bytecode.  This will definitely
> > incur an overhead penalty that we wouldn't want to pay.  Thanks in advance
> > for your response.
> 
> Compiling code to native code in an in-memory buffer is really all a JIT is.
> 
> If you're attached to writing the definitions of each opcode in C,
> here's an old idea in JIT compilation. For every opcode in your
> bytecode, write a corresponding C function that takes relevant
> parameters and implements the opcode. Mark each action as
> __attribute__((always_inline)) Compile this C file with clang to a
> .bc. Load that module from disk at runtime into the JIT. For each
> bytecode string you want to execute, translate it from bytecode to
> LLVM IR (with IRBuilder) that simply calls the opcode action
> functions. The run an inlining optimization pass to inline all the
> actions, and ask the JIT for a pointer to the function. Then you can
> call it like a C function pointer.
> 
> lli is just a driver. It's source code is an example of how you would
> use LLVM to embed a JIT into your program.
> 
> Reid
 		 	   		  
_________________________________________________________________
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
http://clk.atdmt.com/GBL/go/201469229/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100203/2d07de61/attachment.html>


More information about the llvm-dev mailing list