[LLVMdev] C++ to C?
daniel at zuster.org
Sat Oct 11 13:56:00 PDT 2008
I realized I missed this part of your email:
Can LLVM help, or am I completely off track?
It isn't clear to me yet. I have used LLVM for a different but similar
purpose, which effectively implements a stronger virtual machine on top of
the LLVM IR. I have been very happy with the decision to use LLVM instead
of, say, working with x86 directly.
On the other hand, if you are only interested in a teaching tool, why not
use something like SPIM for example? If your usage model is different than
SPIM then explaining it may clarify how LLVM would fit.
> M. McDonnell
> --- On *Sat, 10/11/08, Daniel Dunbar <daniel at zuster.org>* wrote:
> From: Daniel Dunbar <daniel at zuster.org>
> Subject: Re: [LLVMdev] C++ to C?
> To: michaeldmcdonnell at yahoo.com, "LLVM Developers Mailing List" <
> llvmdev at cs.uiuc.edu>
> Cc: "Duncan Sands" <baldrick at free.fr>
> Date: Saturday, October 11, 2008, 1:18 PM
> Hi Michael,
> On Sat, Oct 11, 2008 at 12:44 PM, Michael McDonnell <
> michaeldmcdonnell at yahoo.com> wrote:
>> My assumption has been that LLVM generates machine code for a virtual
>> machine, and that you supply an interpreter that will execute the code.
> The name can be somewhat confusing. LLVM is a lot of things, the web page
> gives some important areas (http://llvm.org/). In your case it sounds like
> you are mainly interested in the "virtual instruction set" aspect. In this
> case, yes, llvm-gcc does generate "machine code" (LLVM intermediate
> representation (IR)) for the virtual instruction set, which lli can
> interpret directly. Additionally, LLVM supplies a variety of tools for
> working with .bc files (serialized versions of this formation), i.e. for
> linking, archiving, etc.
>> 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.
> Using LLVM is a viable strategy for this. However, it is a question of how
> much support you are expecting. The main benefit you are getting is precise
> semantics for LLVM IR and the tool chain for working with .bc files. This
> allows you to avoid dealing with many nitty particulars of x86 (assuming
> that is your target). On the other hand, the current interpreter makes no
> pretense of running on a "virtual machine", so if this is your goal you will
> need to build those facilities yourself. Finally, using LLVM IR directly may
> pose some issues depending on what level of precision you want. Since a
> significant amount of work is done in code generation for the particular
> target, the actual x86 instructions which are generated may access memory
> "differently" than your interpretation of the LLVM IR would; generally this
> would be because the source code didn't constrain things appropriately
> (volatile) but it is something to be cognizant of.
> - Daniel
> 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
>> M. McDonnell
>> --- On *Sat, 10/11/08, Duncan Sands <baldrick at free.fr>* wrote:
>> From: Duncan Sands <baldrick at free.fr>
>> Subject: Re: [LLVMdev] C++ to C?
>> To: michaeldmcdonnell at yahoo.com
>> Cc: llvmdev at cs.uiuc.edu
>> Date: Saturday, October 11, 2008, 12:25 PM
>> Hi Michael,
>> > Thank you very much for your help. I have a few more questions if you have
>> a moment...
>> > * Are there executables available for windows?
>> I think so, but since I don't use windows I can't say for sure.
>> > * Is the source code for the interpreter available, and if so, what is/are
>> the filename(s)?
>> Sure, all source code is available: this is an open source project!
>> Do you really mean the interpreter? You seemed more interested in
>> the C backend. In any case, you can find source code here:
>> For the 2.3 release:
>> > * Is there an IDE available?
>> LLVM is not a compiler. It is used by various compilers such
>> as llvm-gcc and clang. One of those might have an IDE, but I
>> wouldn't know since I never use IDE's myself.
>> PS: Please don't send messages just to me: CC to mailing
>> list too. That way others can answer you too, and the
>> discussion is recorded in the archives where others with
>> the same questions can find it.
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev