Chris Lattner
2007-Nov-05 07:14 UTC
[LLVMdev] 'Implementing a language with LLVM' tutorial
Hi All, LLVM has long needed a tutorial for people who are interested in using it to implement their favorite language and to demonstrate how to use the JIT. To help solve this, I've put together a little tutorial that runs through the implementation and extension of a toy language here: http://llvm.org/docs/tutorial/ At this point, the tutorial is feature complete, but might still need some final editing. Before I try to get other sites to link to it, I thought it would be good to get some more eyeballs on it and get some thoughts and feedback from you. Anyone have thoughts or feedback? :) -Chris
> Hi All, > > LLVM has long needed a tutorial for people who are interested in using > it to implement their favorite language and to demonstrate how to use > the JIT. To help solve this, I've put together a little tutorial that > runs through the implementation and extension of a toy language here: > > http://llvm.org/docs/tutorial/ > > At this point, the tutorial is feature complete, but might still need > some final editing. Before I try to get other sites to link to it, I > thought it would be good to get some more eyeballs on it and get some > thoughts and feedback from you. > > Anyone have thoughts or feedback? :)Nice job. The only bit that is not immediately clear is the 'Proto' variable, but is clear when looking through the code at the end of the page. Could do with a link to the LLVMBuilder class reference material. Thanks, Aaron
On 11/5/07, Chris Lattner <clattner at apple.com> wrote:> Hi All,Hi,> > http://llvm.org/docs/tutorial/Very interesting tutorial, reading it now :)> Anyone have thoughts or feedback? :)There's a typo in http://llvm.org/docs/tutorial/LangImpl5.html "the Phi node expects to have an extry" s/extry/entry/ Best regards, Edwin
On 11/5/07, Chris Lattner <clattner at apple.com> wrote:> http://llvm.org/docs/tutorial/> Anyone have thoughts or feedback? :)Found some typos in LangImpl2.html: /// identifierexpr /// ::= identifer /// ::= identifer '(' expression* ')' HTH, Kevin André
Basile STARYNKEVITCH
2007-Nov-05 15:06 UTC
[LLVMdev] 'Implementing a language with LLVM' tutorial
Chris Lattner wrote:> Hi All, > > LLVM has long needed a tutorial for people who are interested in using > it to implement their favorite language and to demonstrate how to use > the JIT. To help solve this, I've put together a little tutorial that > runs through the implementation and extension of a toy language here: > > http://llvm.org/docs/tutorial/A big thanks for it. I had just a glance on it (some I may be wrong) but I would find nice an exact explanation of llvm/examples/HowToUseJIT/ in particular it seems that the exact way of calling the just JIT-ed code is skipped in this tutorial. Maybe I missed some link. Again, a big thanks to Chris ! -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mines, sont seulement les miennes} ***
Vikram S. Adve
2007-Nov-05 16:47 UTC
[LLVMdev] 'Implementing a language with LLVM' tutorial
Nice work, Chris! This is a much needed tutorial. Some comments: -- It would be helpful to add some navigation links at the top and bottom of the pages. -- Not clear why PrototypeAST::Codegen returns a Function* instead of a Value* like the other CodeGen methods? -- It can be convenient to use Visitor methods on the AST classes for code generation, instead of hard-coding the CodeGen methods into the AST classes. Many languages will need other traversals besides the CodeGen operations, e.g., for type checking, class layout, etc. -- In the optimization section, how much code size reduction have you seen in practice by doing constant folding in the LLVMFoldingBuilder (instead of just letting the later optimization pass take care of it)? -- One of the harder parts is generating type declarations correctly for recursively connected types (e.g., for classes). Without extending Kaleidoscope, it would be be helpful to add a link to the Programmers Manual section on recursive type construction. --Vikram http://www.cs.uiuc.edu/~vadve http://llvm.org/ On Nov 5, 2007, at 1:14 AM, Chris Lattner wrote:> Hi All, > > LLVM has long needed a tutorial for people who are interested in using > it to implement their favorite language and to demonstrate how to use > the JIT. To help solve this, I've put together a little tutorial that > runs through the implementation and extension of a toy language here: > > http://llvm.org/docs/tutorial/ > > At this point, the tutorial is feature complete, but might still need > some final editing. Before I try to get other sites to link to it, I > thought it would be good to get some more eyeballs on it and get some > thoughts and feedback from you. > > Anyone have thoughts or feedback? :) > > -Chris > _______________________________________________ > 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/20071105/9cfd2004/attachment.html>
Ralph Corderoy
2007-Nov-05 17:45 UTC
[LLVMdev] 'Implementing a language with LLVM' tutorial
Hi Chris, edwintorok at gmail.com wrote:> On 11/5/07, Chris Lattner <clattner at apple.com> wrote: > > http://llvm.org/docs/tutorial/ > > There's a typo in http://llvm.org/docs/tutorial/LangImpl5.html > "the Phi node expects to have an extry" s/extry/entry/And elsewhere it has "an function" as the output of a.out despite the source saying "a function". Cheers, Ralph.
Chris Lattner
2007-Nov-05 18:08 UTC
[LLVMdev] 'Implementing a language with LLVM' tutorial
On Mon, 5 Nov 2007, [ISO-8859-1] T�r�k Edvin wrote:>> Anyone have thoughts or feedback? :) > > There's a typo in http://llvm.org/docs/tutorial/LangImpl5.html > "the Phi node expects to have an extry" s/extry/entry/Fixed, thanks! On Mon, 5 Nov 2007, HyperQuantum wrote:> Found some typos in LangImpl2.html: > /// identifierexpr > /// ::= identifer > /// ::= identifer '(' expression* ')'Fixed, thanks! On Mon, 5 Nov 2007, Basile STARYNKEVITCH wrote:> A big thanks for it. I had just a glance on it (some I may be wrong) > but I would find nice an exact explanation of > llvm/examples/HowToUseJIT/ in particular it seems that the exact way of > calling the just JIT-ed code is skipped in this tutorial. Maybe I missed > some link.I think that is is covered here (it's only 3 lines of code, so it's easy to miss ;-): http://llvm.org/docs/tutorial/LangImpl4.html#jit Please let me know if it is unclear. On Mon, 5 Nov 2007, Ralph Corderoy wrote:> And elsewhere it has "an function" as the output of a.out despite the > source saying "a function".Fixed, thanks! -Chris -- http://nondot.org/sabre/ http://llvm.org/
Chris Lattner
2007-Nov-05 18:14 UTC
[LLVMdev] 'Implementing a language with LLVM' tutorial
On Mon, 5 Nov 2007, Aaron Gray wrote:>> Anyone have thoughts or feedback? :) > > Nice job. The only bit that is not immediately clear is the 'Proto' > variable, but is clear when looking through the code at the end of the page.Where in the tutorial? What would you suggest that I say?> Could do with a link to the LLVMBuilder class reference material.I added a link to the doxygen info, thanks! -Chris -- http://nondot.org/sabre/ http://llvm.org/
Chris Lattner
2007-Nov-05 19:42 UTC
[LLVMdev] 'Implementing a language with LLVM' tutorial
On Mon, 5 Nov 2007, Vikram S. Adve wrote:> -- It would be helpful to add some navigation links at the top and bottom of > the pages.I added a TOC to each chapter, thanks.> -- Not clear why PrototypeAST::Codegen returns a Function* instead of a > Value* like the other CodeGen methods?I clarified this in the text. The short version is that PrototypeAST doesn't correspond to an expression value.> -- It can be convenient to use Visitor methods on the AST classes for code > generation, instead of hard-coding the CodeGen methods into the AST classes. > Many languages will need other traversals besides the CodeGen operations, > e.g., for type checking, class layout, etc.Yep, the tutorial also leaks memory, uses global variables, and commits a number of other sins against good software engineering practice. However, I added a mention of the possibility of using a visitor to the text.> -- In the optimization section, how much code size reduction have you seen in > practice by doing constant folding in the LLVMFoldingBuilder (instead of just > letting the later optimization pass take care of it)?Depends on the language. For C, it can be significant. In any case, there is no reason not to use the folding builder, so it doesn't hurt anything.> -- One of the harder parts is generating type declarations correctly for > recursively connected types (e.g., for classes). Without extending > Kaleidoscope, it would be be helpful to add a link to the Programmers Manual > section on recursive type construction.I added a link to chapter 8, thanks for the feedback! -Chris> > On Nov 5, 2007, at 1:14 AM, Chris Lattner wrote: > >> Hi All, >> >> LLVM has long needed a tutorial for people who are interested in using >> it to implement their favorite language and to demonstrate how to use >> the JIT. To help solve this, I've put together a little tutorial that >> runs through the implementation and extension of a toy language here: >> >> http://llvm.org/docs/tutorial/ >> >> At this point, the tutorial is feature complete, but might still need >> some final editing. Before I try to get other sites to link to it, I >> thought it would be good to get some more eyeballs on it and get some >> thoughts and feedback from you. >> >> Anyone have thoughts or feedback? :) >> >> -Chris >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > >-Chris -- http://nondot.org/sabre/ http://llvm.org/
Hi Chris, I edited "The basic language, with its lexer" somewhat and I am attaching a .html file. This is simply spelling/grammar editing and not content. It includes a few small changes to things like - ending a sentence with a noun and starting the next sentence with the same noun, clarifying some statements, not using "and" too many times in a sentence...little things like that. A simple diff should show the changes. Please let me know if this format (ie. html file) is acceptable for your use. I don't think I changed anything too drastically, but please let me know if I took too many liberties. You may also tell me not to be so picky, if you like ;) Thanks, K.Wilson P.S. Good work. This is a well written and much needed tutorial. On Sun, 2007-11-04 at 23:14 -0800, Chris Lattner wrote:> Hi All, > > LLVM has long needed a tutorial for people who are interested in using > it to implement their favorite language and to demonstrate how to use > the JIT. To help solve this, I've put together a little tutorial that > runs through the implementation and extension of a toy language here: > > http://llvm.org/docs/tutorial/ > > At this point, the tutorial is feature complete, but might still need > some final editing. Before I try to get other sites to link to it, I > thought it would be good to get some more eyeballs on it and get some > thoughts and feedback from you. > > Anyone have thoughts or feedback? :) > > -Chris > _______________________________________________ > 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/20071105/5a195a0c/attachment.html>
Chris Lattner
2007-Nov-05 20:27 UTC
[LLVMdev] 'Implementing a language with LLVM' tutorial
On Mon, 5 Nov 2007, Kelly Wilson wrote:> I edited "The basic language, with its lexer" somewhat and I am > attaching a .html file. This is simply spelling/grammar editing and not > content.Thanks, I merged them in!> A simple diff should show the changes. Please let me know if this format > (ie. html file) is acceptable for your use. I don't think I changed > anything too drastically, but please let me know if I took too many > liberties. You may also tell me not to be so picky, if you like ;)All the changes you made look great, I appreciate it. If you are interested in making future changes, please send me a diff of the change you make. This makes it easier for me, because I don't know which version of the file you started from, making it harder to pull the difference out on my end. Thanks again! -Chris -- http://nondot.org/sabre/ http://llvm.org/
Hey Chris: Here are the diffs for the next few chapters of the tutorial that I have edited. Please note that there is one recurring fix (straight-forward is changed to straightforward). Once again, these are simple changes, not including any real content changes. Thanks, K.Wilson On Sun, 2007-11-04 at 23:14 -0800, Chris Lattner wrote:> Hi All, > > LLVM has long needed a tutorial for people who are interested in using > it to implement their favorite language and to demonstrate how to use > the JIT. To help solve this, I've put together a little tutorial that > runs through the implementation and extension of a toy language here: > > http://llvm.org/docs/tutorial/ > > At this point, the tutorial is feature complete, but might still need > some final editing. Before I try to get other sites to link to it, I > thought it would be good to get some more eyeballs on it and get some > thoughts and feedback from you. > > Anyone have thoughts or feedback? :) > > -Chris > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- A non-text attachment was scrubbed... Name: LangImpl3.diff Type: text/x-patch Size: 11183 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20071111/c78e604d/attachment.bin> -------------- next part -------------- A non-text attachment was scrubbed... Name: LangImpl4.diff Type: text/x-patch Size: 8585 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20071111/c78e604d/attachment-0001.bin> -------------- next part -------------- A non-text attachment was scrubbed... Name: LangImpl5.diff Type: text/x-patch Size: 10988 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20071111/c78e604d/attachment-0002.bin>
Chris Lattner
2007-Nov-13 07:07 UTC
[LLVMdev] 'Implementing a language with LLVM' tutorial
On Nov 11, 2007, at 2:41 PM, Kelly Wilson wrote:> Hey Chris: > > Here are the diffs for the next few chapters of the tutorial that I > have > edited.Nice! You are an excellent editor, I'm impressed. I committed these without any changes here: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071112/055566.html Thank you for the help with this.> Please note that there is one recurring fix (straight-forward is > changed to straightforward).Noted, I'll try to teach my fingers :) -Chris
Reasonably Related Threads
- [LLVMdev] 'Implementing a language with LLVM' tutorial
- [LLVMdev] 'Implementing a language with LLVM' tutorial
- [LLVMdev] 'Implementing a language with LLVM' tutorial
- [LLVMdev] 'Implementing a language with LLVM' tutorial
- [LLVMdev] 'Implementing a language with LLVM' tutorial