Book contents
- Frontmatter
- Contents
- Preface
- Part I Fundamentals of Compilation
- 1 Introduction
- 2 Lexical Analysis
- 3 Parsing
- 4 Abstract Syntax
- 5 Semantic Analysis
- 6 Activation Records
- 7 Translation to Intermediate Code
- 8 Basic Blocks and Traces
- 9 Instruction Selection
- 10 Liveness Analysis
- 11 Register Allocation
- 12 Putting It All Together
- Part II Advanced Topics
- Appendix: Tiger Language Reference Manual
- Bibliography
- Index
12 - Putting It All Together
Published online by Cambridge University Press: 05 June 2012
- Frontmatter
- Contents
- Preface
- Part I Fundamentals of Compilation
- 1 Introduction
- 2 Lexical Analysis
- 3 Parsing
- 4 Abstract Syntax
- 5 Semantic Analysis
- 6 Activation Records
- 7 Translation to Intermediate Code
- 8 Basic Blocks and Traces
- 9 Instruction Selection
- 10 Liveness Analysis
- 11 Register Allocation
- 12 Putting It All Together
- Part II Advanced Topics
- Appendix: Tiger Language Reference Manual
- Bibliography
- Index
Summary
de-bug: to eliminate errors in or malfunctions of
Webster's DictionaryChapters 2–11 have described the fundamental components of a good compiler: a front end, which does lexical analysis, parsing, construction of abstract syntax, type-checking, and translation to intermediate code; and a back end, which does instruction selection, dataflow analysis, and register allocation.
What lessons have we learned? I hope that the reader has learned about the algorithms used in different components of a compiler and the interfaces used to connect the components. But the author has also learned quite a bit from the exercise.
My goal was to describe a good compiler that is, to use Einstein's phrase, “as simple as possible – but no simpler.” I will now discuss the thorny issues that arose in designing Tiger and its compiler.
Nested functions. Tiger has nested functions, requiring some mechanism (such as static links) for implementing access to nonlocal variables. But many programming languages in widespread use −C, C++, Java – do not have nested functions or static links. The Tiger compiler would become simpler without nested functions, for then variables would not escape, and the FindEscape phase would be unnecessary. But there are two reasons for explaining how to compile nonlocal variables. First, there are programming languages where nested functions are extremely useful – these are the functional languages described in Chapter 15.
- Type
- Chapter
- Information
- Modern Compiler Implementation in ML , pp. 258 - 264Publisher: Cambridge University PressPrint publication year: 1997