[LLVMdev] C++ to C?

Török Edwin edwintorok at gmail.com
Sat Oct 11 13:17:22 PDT 2008


On 2008-10-11 22:44, Michael McDonnell wrote:
> Hi Duncan,
>  
> Thanks again for your reply.
>  
> Yes, I am interested in the interpreter, but perhaps I misunderstand
> what LLVM is...
>  
> My assumption has been that LLVM generates machine code for a virtual
> machine, and that you supply an interpreter that will execute the code.
>  
> I'm interested in this from an educational standpoint. What I'd like
> is a C/C++ compiler that generates machine code for a virtual software
> machine. Ideally the machine would support interrupts, timers, DMA
> controllers, etc.. I know that your interpreter does not, but I
> thought I might add these peripherals in.
>  
> If you have any suggestions I'd appreciate hearing them. I know about
> the various PC emulators like BOCHS, but they're doing a lot more than
> I need.
>  
>

The term "virtual" in LLVM doesn't refer to emulating hardware, or
providing a hypervisor. It simply refers to the intermediate instruction
format (please correct me if I am wrong).

LLVM is already capable to generate *native* machine code from C/C++ on
its own.
There is also a JIT and interpreter that run your program in the same
process.
The JIT translates to native code on the fly, and the interpreter is
like a bytecode interpreter (say compare to Lua), and not an interpreter for
instructions of a processor (say compare to a MIPS emulator/simulator).
It is not a hypervisor, and doesn't emulate peripherals and such.

Best regards,
--Edwin



More information about the llvm-dev mailing list