3 ms·
Can somebody recommend a book that covers recent techniques implemented in LLVM?
by amelius 12y ago
Can somebody recommend a book that covers recent techniques implemented in LLVM?
- ltta 12y agoMuch of the frontend is pretty much the same: parsing, semantic analysis, type checking. LLLVM mostly comes into play when generating the code. Instead of generating assembbler or opcodes directly, you call into LLVM to create data structures that represent low-level code and then a final call to gen machine code or JIT. There are several versions of the LLVM Kaleidoscope language tutorial where you build a compiler that supports numeric operations, it is often based on Pratt parsers (at least the official C++ version[1]), but there's a C version on github [2]. In my opinion, you could get pretty far by reading the "Compiler design in C" or "Modern compiler implementation in C" up to the point of optimization and then applying the code generation from kaleidoscope tutorials. LLVM takes care of many optimizations. [1] http://llvm.org/docs/tutorial/LangImpl1.html http://llvm.org/docs/tutorial/LangImpl1.html [2] https://github.com/benbjohnson/llvm-c-kaleidoscope https://github.com/benbjohnson/llvm-c-kaleidoscope
- nickik 12y agoThe good intro to compilers is Engineering a Compiler. It focuse more on optimization then most intro books, and its all SSA. If you want to go all in on SSA optimization, there is a book called Static Single Assignment Book and its written by a hole list of compiler writers. Its not finished but there is still a lot of information. You can find it here: http://ssabook.gforge.inria.fr/latest/book.pdf http://ssabook.gforge.inria.fr/latest/book.pdf Or you can go with the classic, Advanced Compiler Design & Implementation. See here, http://www.amazon.com/Advanced-Compiler-Design-Implementation-Muchnick/dp/1558603204 http://www.amazon.com/Advanced-Compiler-Design-Implementatio... All of them will teach you a lot about LLVM.
- ltta 12y agoSpeaking of SSA and optimizations, I just remembered that Andy Wingo (core contributor to Guile scheme) has a treasure trove of great articles, e.g. a fun intro to SSA [1] or CPS as used in Guile [2]. His blog is totally worth just browsing around. [1] http://wingolog.org/archives/2011/07/12/static-single-assignment-for-functional-programmers http://wingolog.org/archives/2011/07/12/static-single-assign... [2] http://wingolog.org/archives/2014/01/12/a-continuation-passing-style-intermediate-language-for-guile http://wingolog.org/archives/2014/01/12/a-continuation-passi...
- nickik 12y agoYes. His posts are a great. He is working on a VM and I do to so I follow his work closly.
- drivers99 12y agoInteresting that on page 6 of this book, it talks about the same idea as LLVM (as I understand it): "There are advantages and disadvantages to an intermediate-language approach to compiler writing[...] Intermediate languages give you flexibility as well. A single lexical-analyzer/parser front end can be used to generate code for several different machines by providing different back ends that translate a common intermediate language to a machine-specific assembly language. Conversely, you can write several front ends that parse several different high-level languages, but which all output the same intermediate language. This way, compilers for several languages can share a single optimizer and back end."