4 ms·
Besides devoting too many pages to parsing, I think compiler practitioners have low opinion of the book because it isn't useful for them. For example, the secon
by sanxiyn 3y ago
Besides devoting too many pages to parsing, I think compiler practitioners have low opinion of the book because it isn't useful for them. For example, the second edition claims to be updated to modern optimization techniques, and in a sense that's true, but it is useless because the book isn't using SSA. For practitioners, SSA is not optional these days, and everything about optimization in the book needs to be updated to SSA to be useful.
But you are probably not a compiler practitioner. Then I agree it is a good book to learn about compilers.
- incompleteCode 3y agoDo you recommend a book that’s more up-to-date?
- jobhdez 3y agoYou can try this book if you want something that came out this year https://github.com/IUCompilerCourse/Essentials-of-Compilation https://github.com/IUCompilerCourse/Essentials-of-Compilatio.... Go to the releases to either get the racket version or python version. But I mean cmu uses the dragon book second edition for a graduate level compiler optimization class.
- pjmlp 3y agoTiger books include SSA, GC (tracing and RC), OOP, FP,.... https://www.cs.princeton.edu/~appel/modern/ https://www.cs.princeton.edu/~appel/modern/
- jobhdez 3y agoBut the dragon book introduces three address code. SSA is a variant of three address code. Take a look here http://www.cs.columbia.edu/~aho/cs4115/Lectures/15-03-25.html#:~:text=Static%20single%2Dassignment%20(SSA),two%20different%20control%2Dflow%20paths http://www.cs.columbia.edu/~aho/cs4115/Lectures/15-03-25.htm....
- sanxiyn 3y agoWell yes, but you can't use the algorithm in the dragon book to generate three address code to generate SSA, because SSA has additional constraints. The dragon book really dropped the ball here, there is no excuse why it doesn't include any algorithm for SSA construction.
- deleted 3y ago[deleted]
- k_g_b_ 3y ago3AC/TAC is something fundamentally different than SSA. Sure, both somehow superficially constrain how you write variable assignment statements - if your intermediate representation contains such things and is a list of instructions. 3AC means that your "instructions" have <=3 operands, SSA means each "syntactic" variable is assigned at most once, that is: they are not a variable anymore. In fact, SSA transformation makes an imperative program referentially transparent (excluding any loads/stores from/to memory) and thus makes it a pure functional program (excluding memory). You can see a program in SSA form simply as a functional program where each basic block is a (nested) function and each PHI is a parameter of the function. SSA as a list of instructions/statements as in 3AC is a red herring and doesn't have any relation to why it's used in compilers/for static analysis. SSA is not a variant of 3AC, also because SSA transformation of 3AC requires the same algorithms as SSA transformation of any other common imperative IR does. In fact SSA makes no constraints on the number of operands in an instruction/operation what so ever.
- jobhdez 3y agoThree address code: ``` p = a + b q = p-c p = q * d ``` Ssa: ``` p1 = a+ b q1= p1 - c p2 = q1 * d ``` Given the above examples how is it not straightforward to use ssa instead of three address code using what the dragon book teaches? What is wrong with the above examples? In fact section 6.2.4 in the dragon book it says: “Two distinctive aspects distinguish SSA from three-address code. The first is that all assignments in SSA are to variables with distinct names; hence the term static single-assigment.” The second one is that ssa uses a function to combine two definitions
- lmarcos 3y agoThe dragon book is a theoretical book. It's like any other (good) OS book out there: good source of information to know the foundations. After reading it, go out and read something more practical (which you probably won't have issues learning it since you now know the foundations)