|
| 1 | +============== |
1 | 2 | Compiler Books
|
2 | 3 | ==============
|
3 | 4 |
|
4 | 5 | I own a bunch of compiler books that I have purchased over the years.
|
| 6 | + |
| 7 | +Dragon Books |
| 8 | +============ |
| 9 | +I have 3 editions of these. |
| 10 | + |
| 11 | +* Principles of Compiler Design. Aho & Ullman, 1977. |
| 12 | +* Compilers: Principles, Techniques and Tools. Aho, Sethi, Ullman, 1986. |
| 13 | +* Compilers: Principles, Techniques and Tools, 2nd Ed. Aho, Lam, Sethi, Ullman, 2006. |
| 14 | + |
| 15 | +These books are criticised today because of the excessive focus on lexical analysis and parsing techniques. |
| 16 | +While this is true, they do cover various aspects of a compiler backend such as intermediate representations and |
| 17 | +optimization techniques including peephole optimization, data flow analysis, register allocation etc. |
| 18 | +I found the description of the lattice in a data flow analysis quite accessible. |
| 19 | + |
| 20 | +The 2nd edition adopts a more mathematical presentation style, whereas the earlier editions present |
| 21 | +algorithms using pseudo code. I think the 1986 edition is the best. |
| 22 | + |
| 23 | +For a different take on 2nd edition see `Review of the second addition of the "Dragon Book" <https://gcc.gnu.org/wiki/Review_of_the_second_addition_of_the_Dragon_Book.>`_. |
| 24 | + |
| 25 | +Engineering a Compiler, 2nd Ed. Cooper & Torczon. 2012. |
| 26 | +======================================================= |
| 27 | +This is a more modern version of the Dragon book. It is less focused on the lexical analysis / parsing |
| 28 | +phases, and covers the later phases of a compiler in more detail. Exposition is similar to the Dragon book, i.e. mostly describes |
| 29 | +techniques conceptually, with some high level algorithm descriptions, but like the Dragon book, does not |
| 30 | +go into detailed descriptions of algorithms. |
| 31 | + |
| 32 | +Both this and the Dragon books describe ahead of time compilers and cover topics that are suited for procedural languages |
| 33 | +such as C or traditional Pascal or Fortran. They cover both front-end and back-end techniques; however, on the front-end |
| 34 | +side, interesting topics such as Object Orientation, Closures, Generics, |
| 35 | +or Semantic analysis of more complex languages such as Java are not covered. |
| 36 | + |
| 37 | +Modern Compiler Implementation in C. Appel. 1998. (Tiger book) |
| 38 | +============================================================== |
| 39 | +This book takes a hands on tutorial like approach to describing how to implement both the front-end and back-end |
| 40 | +of a compiler, using a toy language called Tiger as an example. Algorithms are described in pseudo code. |
| 41 | +If I had to choose between the Dragon book, Engineering a compiler, and this book, I would pick this one. |
| 42 | + |
| 43 | +This book covers functional languages, closures, as well as Object Oriented languages such as Java. Type inference is |
| 44 | +covered too. |
| 45 | + |
| 46 | +Crafting a Compiler. Fischer, LeBlanc, Cytron. 2010. |
| 47 | +==================================================== |
| 48 | +The last couple of chapters are the most interesting - these focus on code generation and program optimization. |
| 49 | + |
| 50 | +The 2nd edition of the book (with Cytron as co author) has a description of Static Single assignment that is |
| 51 | +perhaps the most complete in all the books I cover here. The 1st edition describes data flow analysis in more |
| 52 | +detail. |
| 53 | + |
| 54 | +Apart from the final two chapters, the rest of the book is about parsing and semantic analysis. |
| 55 | + |
| 56 | +Building an Optimizing Compiler. Bob Morgan. 1998. |
| 57 | +================================================== |
| 58 | +I have the kindle edition which is very poor and hard to read. I wish I had a paper copy. |
| 59 | + |
| 60 | +This book is almost completely about the backend of the compiler. |
| 61 | + |
| 62 | +Advanced Compiler Design & Implementation. Muchnick. 1997. |
| 63 | +========================================================== |
| 64 | +I have the kindle edition, which is very poor and hard to read. |
| 65 | + |
| 66 | +This book is also mostly about the backend of a compiler, focusing on optimization. |
| 67 | + |
| 68 | +My impression is that this book describes many algorithms in detail. But when I tried to implement one of the |
| 69 | +simpler algorithms (18.1 Unreachable Code Elimination) I found that the description left out a |
| 70 | +part (No_Path) of the algorithm. |
| 71 | + |
| 72 | +This book describes the idea of multiple levels of intermediate representation, HIR, MIR and LIR. |
| 73 | +I guess this has influenced many compiler implementations. |
| 74 | + |
| 75 | +Its coverage of SSA is rudimentary - I guess it was written when SSA was still very new. |
| 76 | + |
| 77 | +This book has a reputation of containing many errors, although I assume the latest printings have the errors |
| 78 | +fixed. |
| 79 | + |
| 80 | +Despite its faults, it is a must have book if you want to learn about compiler construction. |
| 81 | + |
| 82 | +Retargetable C Compiler, A: Design and Implementation. Hanson & Fraser. 1995. |
| 83 | +============================================================================= |
| 84 | +Describes a production C compiler. Detailed dsecription of the actual compiler code. |
| 85 | + |
| 86 | +Weak on theoretical aspects, and limited by features of the compiler being described. |
| 87 | + |
| 88 | +Program Flow Analysis: Theory and Applications. Editors Muchnick, Jones. 1981. |
| 89 | +============================================================================== |
| 90 | +Collection of essays on program analysis, by various authors. This is pre-SSA, hence a bit |
| 91 | +dated. |
| 92 | + |
| 93 | +Other Book Reviews |
| 94 | +================== |
| 95 | +* `List of compiler books <https://gcc.gnu.org/wiki/ListOfCompilerBooks>`_ |
0 commit comments