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/a280e63d/attachment.html>
Hi Daniel, Thanks for your help. You mentioned that "the current interpreter makes no pretense of running on a "virtual machine"", but isn't the interpreter itself a virtual machine? I'm not looking to emulate any particular processor - just interested in a tool that will help teach how a processor works. Can LLVM help, or am I completely off track? 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/1eb9fc50/attachment.html>
What I meant with this comment is that lli doesn't add any abstractions to the machine. For example, lli allows calling out to native functions which happen to be linked in to the executable. Additionally, decisions like the size of various types have already been hardened in the LLVM IR by whatever front end generated the code. I don't find the term "virtual machine" to be very precise; but I would be hesitant to say the interpreter is (implements?) one. - Daniel On Sat, Oct 11, 2008 at 1:28 PM, Michael McDonnell < michaeldmcdonnell at yahoo.com> wrote:> Hi Daniel, > > Thanks for your help. > > You mentioned that "the current interpreter makes no pretense of running on > a "virtual machine"", but isn't the interpreter itself a virtual machine? > I'm not looking to emulate any particular processor - just interested in a > tool that will help teach how a processor works. > > Can LLVM help, or am I completely off track? > > 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/04404305/attachment.html>
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>
I think LLVM is capable of what you're asking, but it isn't really a goal of the project, and thus might require you to put in a fair amount of work yourself to get there. LLVM is targeted much more at the compiler side of things...it makes a great educational tool in that domain, but the virtual instruction set is tailored more to the needs of compiler front-ends, optimizers, and code generators than to being a realistic model of a processor architecture. Have you taken a look at Knuth's MMIX? ( http://www-cs-faculty.stanford.edu/~uno/mmix.html ) It seems like that might be a closer match to what you are looking for. Last I looked, the core MMIX software included an assembler, but not a compiler...but I believe there is an MMIX backend for gcc available. Also, although it isn't a virtual machine, the MIPS architecture is relatively simple and regular, and thus has been commonly used educationally as an introduction to machine architecture and code generation. On Sat, Oct 11, 2008 at 1:28 PM, Michael McDonnell <michaeldmcdonnell at yahoo.com> wrote:> Hi Daniel, > > Thanks for your help. > > You mentioned that "the current interpreter makes no pretense of running on > a "virtual machine"", but isn't the interpreter itself a virtual machine? > I'm not looking to emulate any particular processor - just interested in a > tool that will help teach how a processor works. > > Can LLVM help, or am I completely off track? > > 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 >> > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >
On Sat, Oct 11, 2008 at 10:28 PM, Michael McDonnell <michaeldmcdonnell at yahoo.com> wrote:> Hi Daniel, > > Thanks for your help. > > You mentioned that "the current interpreter makes no pretense of running on > a "virtual machine"", but isn't the interpreter itself a virtual machine? > I'm not looking to emulate any particular processor - just interested in a > tool that will help teach how a processor works. > > Can LLVM help, or am I completely off track? > > Thanks, > M. McDonnell >I think LLVM is way overkill for what you need (which I assume to be some sort of introductory course in computer architecture), "The Elements of Computing Systems" [1] and the accompanying software [2] would probably be great teaching material instead, I haven't really used them but I've watched a short video lecture about it [3], and it looks quite well done [1] http://www1.idc.ac.il/tecs/ [2] http://www1.idc.ac.il/tecs/software.html [3] http://video.google.com/videoplay?docid=7654043762021156507