<div dir="ltr">I realized I missed this part of your email:<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><table border="0" cellpadding="0" cellspacing="0">
<tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top"><div>
Can LLVM help, or am I completely off track?</div>
</td></tr></tbody></table></blockquote><div><br>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.<br>
<br>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.<br><br><a href="http://pages.cs.wisc.edu/~larus/spim.html">http://pages.cs.wisc.edu/~larus/spim.html</a><br>
<br> - Daniel<br> <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">

<div>Thanks,</div>
<div>M. McDonnell</div>
<div><br><br>--- On <b>Sat, 10/11/08, Daniel Dunbar <i><<a href="mailto:daniel@zuster.org" target="_blank">daniel@zuster.org</a>></i></b> wrote:<br></div>
<blockquote style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;">From: Daniel Dunbar <<a href="mailto:daniel@zuster.org" target="_blank">daniel@zuster.org</a>><div class="Ih2E3d"><br>
Subject: Re: [<span>LLVMdev</span>] C++ to C?<br></div>To: <a href="mailto:michaeldmcdonnell@yahoo.com" target="_blank">michaeldmcdonnell@yahoo.com</a>, "LLVM Developers Mailing List" <<a href="mailto:llvmdev@cs.uiuc.edu" target="_blank">llvmdev@cs.uiuc.edu</a>><br>
Cc: "Duncan Sands" <<a href="mailto:baldrick@free.fr" target="_blank">baldrick@free.fr</a>><br>Date: Saturday, October 11, 2008, 1:18 PM<div><div></div><div class="Wj3C7c"><br><br>
<div>
<div dir="ltr">Hi Michael,<br><br>
<div class="gmail_quote">On Sat, Oct 11, 2008 at 12:44 PM, Michael McDonnell <span dir="ltr"><<a href="mailto:michaeldmcdonnell@yahoo.com" rel="nofollow" target="_blank">michaeldmcdonnell@yahoo.com</a>></span> wrote: 
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="font-family: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top"><br></td></tr></tbody></table></blockquote>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="font-family: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">
<div></div>
<div>My assumption has been that <span>LLVM</span> generates machine code for a virtual machine, and that you supply an interpreter that will execute the code. </div>
<div></div></td></tr></tbody></table></blockquote>
<div><br>The name can be somewhat confusing. LLVM is a lot of things, the web page gives some important areas (<a href="http://llvm.org/" rel="nofollow" target="_blank">http://llvm.org/</a>). 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.<br>
 </div>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="font-family: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">
<div> </div>
<div>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, <span>DMA</span> controllers, etc.. I know that your interpreter does not, but I thought I might add these peripherals in.</div>

<div> </div></td></tr></tbody></table></blockquote>
<div><br>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.<br>
<br> -
 Daniel<br><br></div>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="font-family: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">
<div></div>
<div>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.</div>
<div> </div>
<div>Thanks,</div>
<div>M. McDonnell</div>
<div><br>--- On <b>Sat, 10/11/08, Duncan Sands <i><<a href="mailto:baldrick@free.fr" rel="nofollow" target="_blank">baldrick@free.fr</a>></i></b> wrote:<br></div>
<blockquote style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;">From: Duncan Sands <<a href="mailto:baldrick@free.fr" rel="nofollow" target="_blank">baldrick@free.fr</a>><br>Subject: Re: [<span>LLVMdev</span>] C++ to C?<br>
To: <a href="mailto:michaeldmcdonnell@yahoo.com" rel="nofollow" target="_blank">michaeldmcdonnell@yahoo.com</a><br>Cc: <a href="mailto:llvmdev@cs.uiuc.edu" rel="nofollow" target="_blank">llvmdev@cs.uiuc.edu</a><br>Date: Saturday, October 11, 2008, 12:25 PM<br>
<br><pre>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:
  <a href="http://llvm.org/releases/" rel="nofollow" target="_blank">http://llvm.org/releases/</a>
For the 2.3 release:
  <a href="http://llvm.org/releases/download.html#2.3" rel="nofollow" target="_blank">http://llvm.org/releases/download.html#2.3</a>

> * 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.

Ciao,

Duncan.

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.
</pre></blockquote></td></tr></tbody></table><br><br>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" rel="nofollow" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu/" rel="nofollow" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="nofollow" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br><br></blockquote></div><br></div></div></div></div></blockquote></td></tr>
</tbody></table><br>

      </blockquote></div><br></div>