Kaleidoscope: Conclusion

Written by Chris Lattner

Tutorial Conclusion

Welcome to the the final chapter of the "Implementing a language with LLVM" tutorial. In the course of this tutorial, we have grown our little Kaleidoscope language from being a useless toy, to being a semi-interesting (but probably still useless) toy. :)

It is interesting to see how far we've come, and how little code it has taken. We built the entire lexer, parser, AST, code generator, and an interactive run-loop (with a JIT!) by-hand in under 700 lines of (non-comment/non-blank) code.

Our little language supports a couple of interesting features: it supports user defined binary and unary operators, it uses JIT compilation for immediate evaluation, and it supports a few control flow constructs with SSA construction.

Part of the idea of this tutorial was to show you how easy and fun it can be to define, build, and play with languages. Building a compiler need not be a scary or mystical process! Now that you've seen some of the basics, I strongly encourage you to take the code and hack on it. For example, try adding:

Have fun - try doing something crazy and unusual. Building a language like everyone else always has is much less fun than trying something a little crazy and off the wall and seeing how it turns out. If you get stuck or want to talk about it, feel free to email the llvmdev mailing list: it has lots of people who are interested in languages and are often willing to help out.

Before we end, I want to talk about some "tips and tricks" for generating LLVM IR. These are some of the more subtle things that may not be obvious, but are very useful if you want to take advantage of LLVM's capabilities.

Tips and Tricks


Valid CSS! Valid HTML 4.01! Chris Lattner
The LLVM Compiler Infrastructure
Last modified: $Date: 2007-10-17 11:05:13 -0700 (Wed, 17 Oct 2007) $