| Foreword |
|
vii | (14) |
|
|
|
|
|
| Preface |
|
xxi | |
|
1 Introduction to Advanced Topics |
|
|
1 | (18) |
|
1.1 Review of Compiler Structure |
|
|
1 | (2) |
|
1.2 Advanced Issues in Elementary Topics |
|
|
3 | (3) |
|
1.3 The Importance of Code Optimization |
|
|
6 | (1) |
|
1.4 Structure of Optimizing Compilers |
|
|
7 | (4) |
|
1.5 Placement of Optimizations in Aggressive Optimizing Compilers |
|
|
11 | (3) |
|
1.6 Reading Flow Among the Chapters |
|
|
14 | (2) |
|
1.7 Related Topics Not Covered in This Text |
|
|
16 | (1) |
|
1.8 Target Machines Used in Examples |
|
|
16 | (1) |
|
1.9 Number Notations and Data Sizes |
|
|
16 | (1) |
|
|
|
17 | (1) |
|
|
|
18 | (1) |
|
|
|
18 | (1) |
|
2 Informal Compiler Algorithm Notation (ICAN) |
|
|
19 | (24) |
|
2.1 Extended Backus-Naur Form Syntax Notation |
|
|
19 | (1) |
|
|
|
20 | (3) |
|
2.3 A Quick Overview of ICAN |
|
|
23 | (2) |
|
|
|
25 | (1) |
|
|
|
25 | (1) |
|
|
|
26 | (1) |
|
2.7 Data Types and Expressions |
|
|
27 | (9) |
|
|
|
36 | (5) |
|
|
|
41 | (1) |
|
|
|
41 | (1) |
|
|
|
41 | (2) |
|
|
|
43 | (24) |
|
3.1 Storage Classes, Visibility, and Lifetimes |
|
|
43 | (2) |
|
3.2 Symbol Attributes and Symbol-Table Entries |
|
|
45 | (2) |
|
3.3 Local Symbol-Table Management |
|
|
47 | (2) |
|
3.4 Global Symbol-Table Structure |
|
|
49 | (5) |
|
3.5 Storage Binding and Symbolic Registers |
|
|
54 | (5) |
|
3.6 Approaches to Generating Loads and Stores |
|
|
59 | (4) |
|
|
|
63 | (1) |
|
|
|
64 | (1) |
|
|
|
64 | (3) |
|
4 Intermediate Representations |
|
|
67 | (38) |
|
4.1 Issues in Designing an Intermediate Language |
|
|
67 | (2) |
|
4.2 High-Level Intermediate Languages |
|
|
69 | (2) |
|
4.3 Medium-Level Intermediate Languages |
|
|
71 | (1) |
|
4.4 Low-Level Intermediate Languages |
|
|
71 | (1) |
|
4.5 Multi-Level Intermediate Languages |
|
|
72 | (1) |
|
4.6 Our Intermediate Languages: MIR, HIR, and LIR |
|
|
73 | (8) |
|
4.7 Representing MIR, HIR, and LIR in ICAN |
|
|
81 | (11) |
|
4.8 ICAN Naming of Data Structures and Routines that Manipulate Intermediate Code |
|
|
92 | (4) |
|
4.9 Other Intermediate-Language Forms |
|
|
96 | (5) |
|
|
|
101 | (1) |
|
|
|
102 | (1) |
|
|
|
102 | (3) |
|
|
|
105 | (32) |
|
5.1 Data Representations and Instructions |
|
|
106 | (3) |
|
|
|
109 | (2) |
|
5.3 The Local Stack Frame |
|
|
111 | (3) |
|
|
|
114 | (2) |
|
5.5 Parameter-Passing Disciplines |
|
|
116 | (3) |
|
5.6 Procedure Prologues, Epilogues, Calls, and Returns |
|
|
119 | (8) |
|
5.7 Code Sharing and Position-Independent Code |
|
|
127 | (4) |
|
5.8 Symbolic and Polymorphic Language Support |
|
|
131 | (2) |
|
|
|
133 | (1) |
|
|
|
134 | (1) |
|
|
|
135 | (2) |
|
6 Producing Code Generators Automatically |
|
|
137 | (32) |
|
6.1 Introduction to Automatic Generation of Code Generators |
|
|
138 | (1) |
|
6.2 A Syntax-Directed Technique |
|
|
139 | (20) |
|
6.3 Introduction to Semantics-Directed Parsing |
|
|
159 | (1) |
|
6.4 Tree Pattern Matching and Dynamic Programming |
|
|
160 | (5) |
|
|
|
165 | (1) |
|
|
|
166 | (1) |
|
|
|
166 | (3) |
|
|
|
169 | (48) |
|
7.1 Approaches to Control-Flow Analysis |
|
|
172 | (5) |
|
7.2 Depth-First Search, Preorder Traversal, Postorder Traversal, and Breadth-First Search |
|
|
177 | (4) |
|
7.3 Dominators and Postdominators |
|
|
181 | (10) |
|
7.4 Loops and Strongly Connected Components |
|
|
191 | (5) |
|
|
|
196 | (1) |
|
7.6 Interval Analysis and Control Trees |
|
|
197 | (5) |
|
|
|
202 | (12) |
|
|
|
214 | (1) |
|
|
|
214 | (1) |
|
|
|
215 | (2) |
|
|
|
217 | (50) |
|
8.1 An Example: Reaching Definitions |
|
|
218 | (5) |
|
8.2 Basic Concepts: Lattices, Flow Functions, and Fixed Points |
|
|
223 | (5) |
|
8.3 Taxonomy of Data-Flow Problems and Solution Methods |
|
|
228 | (3) |
|
8.4 Iterative Data-Flow Analysis |
|
|
231 | (4) |
|
8.5 Lattices of Flow Functions |
|
|
235 | (1) |
|
8.6 Control-Tree-Based Data-Flow Analysis |
|
|
236 | (1) |
|
|
|
236 | (13) |
|
|
|
249 | (1) |
|
|
|
250 | (1) |
|
8.10 Du-Chains, Ud-Chains, and Webs |
|
|
251 | (1) |
|
8.11 Static Single-Assignment (SSA) Form |
|
|
252 | (6) |
|
8.12 Dealing with Arrays, Structures, and Pointers |
|
|
258 | (1) |
|
8.13 Automating Construction of Data-Flow Analyzers |
|
|
259 | (2) |
|
8.14 More Ambitious Analyses |
|
|
261 | (2) |
|
|
|
263 | (1) |
|
|
|
264 | (1) |
|
|
|
265 | (2) |
|
9 Dependence Analysis and Dependence Graphs |
|
|
267 | (26) |
|
|
|
267 | (2) |
|
9.2 Basic-Block Dependence DAGs |
|
|
269 | (5) |
|
|
|
274 | (5) |
|
|
|
279 | (5) |
|
9.5 Program-Dependence Graphs |
|
|
284 | (2) |
|
9.6 Dependences Between Dynamically Allocated Objects |
|
|
286 | (2) |
|
|
|
288 | (1) |
|
|
|
289 | (1) |
|
|
|
290 | (3) |
|
|
|
293 | (26) |
|
10.1 Aliases in Various Real Programming Languages |
|
|
297 | (5) |
|
|
|
302 | (5) |
|
10.3 The Alias Propagator |
|
|
307 | (7) |
|
|
|
314 | (1) |
|
|
|
315 | (1) |
|
|
|
316 | (3) |
|
11 Introduction to Optimization |
|
|
319 | (10) |
|
11.1 Global Optimizations Discussed in Chapters 12 Through 18 |
|
|
321 | (2) |
|
11.2 Flow Sensitivity and May vs. Must Information |
|
|
323 | (1) |
|
11.3 Importance of Individual Optimizations |
|
|
323 | (2) |
|
11.4 Order and Repetition of Optimizations |
|
|
325 | (3) |
|
|
|
328 | (1) |
|
|
|
328 | (1) |
|
|
|
329 | (48) |
|
12.1 Constant-Expression Evaluation (Constant Folding) |
|
|
329 | (2) |
|
12.2 Scalar Replacement of Aggregates |
|
|
331 | (2) |
|
12.3 Algebraic Simplifications and Reassociation |
|
|
333 | (10) |
|
|
|
343 | (13) |
|
|
|
356 | (6) |
|
12.6 Sparse Conditional Constant Propagation |
|
|
362 | (9) |
|
|
|
371 | (2) |
|
|
|
373 | (1) |
|
|
|
374 | (3) |
|
13 Redundancy Elimination |
|
|
377 | (48) |
|
13.1 Common-Subexpression Elimination |
|
|
378 | (19) |
|
13.2 Loop-Invariant Code Motion |
|
|
397 | (10) |
|
13.3 Partial-Redundancy Elimination |
|
|
407 | (8) |
|
13.4 Redundancy Elimination and Reassociation |
|
|
415 | (2) |
|
|
|
417 | (3) |
|
|
|
420 | (2) |
|
|
|
422 | (1) |
|
|
|
422 | (3) |
|
|
|
425 | (36) |
|
14.1 Induction-Variable Optimizations |
|
|
425 | (29) |
|
14.2 Unnecessary Bounds-Checking Elimination |
|
|
454 | (3) |
|
|
|
457 | (2) |
|
|
|
459 | (1) |
|
|
|
460 | (1) |
|
15 Procedure Optimizations |
|
|
461 | (20) |
|
15.1 Tail-Call Optimization and Tail-Recursion Elimination |
|
|
461 | (4) |
|
15.2 Procedure Integration |
|
|
465 | (5) |
|
|
|
470 | (2) |
|
15.4 Leaf-Routine Optimization and Shrink Wrapping |
|
|
472 | (4) |
|
|
|
476 | (2) |
|
|
|
478 | (1) |
|
|
|
478 | (3) |
|
|
|
481 | (50) |
|
16.1 Register Allocation and Assignment |
|
|
482 | (1) |
|
|
|
483 | (2) |
|
|
|
485 | (39) |
|
16.4 Priority-Based Graph Coloring |
|
|
524 | (1) |
|
16.5 Other Approaches to Register Allocation |
|
|
525 | (1) |
|
|
|
526 | (2) |
|
|
|
528 | (1) |
|
|
|
529 | (2) |
|
|
|
531 | (48) |
|
17.1 Instruction Scheduling |
|
|
532 | (15) |
|
17.2 Speculative Loads and Boosting |
|
|
547 | (1) |
|
17.3 Speculative Scheduling |
|
|
548 | (1) |
|
|
|
548 | (21) |
|
|
|
569 | (2) |
|
17.6 Percolation Scheduling |
|
|
571 | (2) |
|
|
|
573 | (2) |
|
|
|
575 | (1) |
|
|
|
576 | (3) |
|
18 Control-Flow and Low-Level Optimizations |
|
|
579 | (28) |
|
18.1 Unreachable-Code Elimination |
|
|
580 | (3) |
|
|
|
583 | (2) |
|
|
|
585 | (1) |
|
18.4 Loop Simplifications |
|
|
586 | (1) |
|
|
|
587 | (1) |
|
|
|
588 | (1) |
|
18.7 Branch Optimizations |
|
|
589 | (1) |
|
18.8 Tail Merging or Cross Jumping |
|
|
590 | (1) |
|
|
|
591 | (1) |
|
18.10 Dead-Code Elimination |
|
|
592 | (5) |
|
|
|
597 | (2) |
|
18.12 Machine Idioms and Instruction Combining |
|
|
599 | (3) |
|
|
|
602 | (2) |
|
|
|
604 | (1) |
|
|
|
605 | (2) |
|
19 Interprocedural Analysis and Optimization |
|
|
607 | (62) |
|
19.1 Interprocedural Control-Flow Analysis: The Call Graph |
|
|
609 | (10) |
|
19.2 Interprocedural Data-Flow Analysis |
|
|
619 | (18) |
|
19.3 Interprocedural Constant Propagation |
|
|
637 | (4) |
|
19.4 Interprocedural Alias Analysis |
|
|
641 | (15) |
|
19.5 Interprocedural Optimizations |
|
|
656 | (3) |
|
19.6 Interprocedural Register Allocation |
|
|
659 | (4) |
|
19.7 Aggregation of Global References |
|
|
663 | (1) |
|
19.8 Other Issues in Interprocedural Program Management |
|
|
663 | (1) |
|
|
|
664 | (2) |
|
|
|
666 | (1) |
|
|
|
667 | (2) |
|
20 Optimization for the Memory Hierarchy |
|
|
669 | (36) |
|
20.1 Impact of Data and Instruction Caches |
|
|
670 | (2) |
|
20.2 Instruction-Cache Optimization |
|
|
672 | (10) |
|
20.3 Scalar Replacement of Array Elements |
|
|
682 | (5) |
|
20.4 Data-Cache Optimization |
|
|
687 | (13) |
|
20.5 Scalar vs. Memory-Oriented Optimizations |
|
|
700 | (1) |
|
|
|
700 | (3) |
|
|
|
703 | (1) |
|
|
|
704 | (1) |
|
21 Case Studies of Compilers and Future Trends |
|
|
705 | (42) |
|
21.1 The Sun Compilers for SPARC |
|
|
707 | (9) |
|
21.2 The IBM XL Compilers for the POWER and PowerPC Architectures |
|
|
716 | (10) |
|
21.3 Digital Equipment's Compilers for Alpha |
|
|
726 | (8) |
|
21.4 The Intel Reference Compilers for the Intel 386 Architecture Family |
|
|
734 | (10) |
|
|
|
744 | (1) |
|
21.6 Future Trends in Compiler Design and Implementation |
|
|
745 | (1) |
|
|
|
746 | (1) |
| App. A Guide to Assembly Languages Used in This Book |
|
747 | (10) |
| A.1 Sun SPARC Versions 8 and 9 Assembly Language |
|
747 | (2) |
| A.2 IBM POWER and PowerPC Assembly Language |
|
749 | (1) |
| A.3 DEC Alpha Assembly Language |
|
750 | (2) |
| A.4 Intel 386 Architecture Assembly Language |
|
752 | (1) |
| A.5 Hewlett-Packard's PA-RISC Assembly Language |
|
753 | (4) |
| App. B Representation of Sets, Sequences, Trees, DAGs, and Functions |
|
757 | (10) |
| B.1 Representation of Sets |
|
759 | (4) |
| B.2 Representation of Sequences |
|
763 | (1) |
| B.3 Representation of Trees and DAGs |
|
763 | (1) |
| B.4 Representation of Functions |
|
764 | (1) |
| B.5 Further Reading |
|
765 | (2) |
| App. C Software Resources |
|
767 | (6) |
| C.1 Finding and Accessing Software on the Internet |
|
767 | (1) |
| C.2 Machine Simulators |
|
767 | (1) |
| C.3 Compilers |
|
768 | (1) |
| C.4 Code-Generator Generators: BURG and IBURG |
|
769 | (1) |
| C.5 Profiling Tools |
|
770 | (3) |
|
|
|
773 | (24) |
|
|
|
797 | (4) |
| Bibliography |
|
801 | (20) |
| Technical Index of Mathematical Formulas and ICAN Procedures and Major Data Structures |
|
821 | (6) |
| Subject Index |
|
827 | |