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. http://pages.cs.wisc.edu/~larus/spim.html - Daniel> Thanks, > 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 >> need. >> >> Thanks, >> 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: >> http://llvm.org/releases/ >> For the 2.3 release: >> http://llvm.org/releases/download.html#2.3 >> >> > * 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. >> >> >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081011/5a6e9d88/attachment.html>
Daniel, Thanks for the reference to SPIM. It looks interesting, but appears to be an assembler that can also execute the code (it does not execute binary files). In addition, I'm probably asking for too much. Ideally, I'm looking for something like MS Visual Studio with that executes on a virtual software machine, whose source code is freely available. Thanks, 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 Cc: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu> Date: Saturday, October 11, 2008, 1:56 PM 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. http://pages.cs.wisc.edu/~larus/spim.html - Daniel Thanks, 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 need. Thanks, 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 havea 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/arethe 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: http://llvm.org/releases/ For the 2.3 release: http://llvm.org/releases/download.html#2.3> * 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. _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081011/af62411d/attachment.html>
just my quick comment (not really much of a poster here): but, have you looked into the Java VM?... just from what all I have read, this is probably closer to what you might be asking for. more so, there are some compilers that allow compiling from C to java bytecode, but I have not looked much into them (I personally have doubts as to how effectively C can be mapped to the JVM, but this is a different issue). there are also IDE's like Eclipse and similar... there is also GCJ (GNU compiler for Java), which has some interesting features, some of which may be useful. MS's .NET stuff might also be worth looking into, where here we have C++/CLI and similar, which compiles to MSIL/CIL, which is a bytecode format (granted though, it is typically JIT-compiled though, as the bytecode is not particularly well suited to efficient interpretation). likewise, all of this stuff is supported in Visual Studio. a lot more free code is available for the JVM than .NET though (actually, between them, I like the JVM better, although I will admit that technically there are things .NET does a little better IMO...). ok, granted, I don't really use Java or .NET personally... (I have my own reasons for preferring to stick with targeting the native architecture... and personally don't really care for IDE's either...). ----- Original Message ----- From: Michael McDonnell To: Daniel Dunbar Cc: LLVM Developers Mailing List Sent: Sunday, October 12, 2008 7:21 AM Subject: Re: [LLVMdev] C++ to C? Daniel, Thanks for the reference to SPIM. It looks interesting, but appears to be an assembler that can also execute the code (it does not execute binary files). In addition, I'm probably asking for too much. Ideally, I'm looking for something like MS Visual Studio with that executes on a virtual software machine, whose source code is freely available. Thanks, M. McDonnell -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081012/53138a13/attachment.html>