Download presentation
Presentation is loading. Please wait.
Published byPhyllis Franklin Modified over 9 years ago
1
Compiler Construction Dr. Naveed Ejaz Lecture 4
2
2 The Back End Register Allocation: Have each value in a register when it is used. Instruction selection IR machine code errors Register allocation Instruction scheduling IR
3
3 The Back End Register Allocation: Manage a limited set of resources – register file. Instruction selection IR machine code errors Register allocation Instruction scheduling IR
4
4 The Back End Register Allocation: Can change instruction choices and insert LOADs and STOREs. Instruction selection IR machine code errors Register allocation Instruction scheduling IR
5
5 The Back End Register Allocation: Optimal register allocation is NP-Complete. Instruction selection IR machine code errors Register allocation Instruction scheduling IR
6
6 The Back End Instruction Scheduling: Avoid hardware stalls and interlocks. Instruction selection IR machine code errors Register allocation Instruction scheduling IR
7
7 The Back End Instruction Scheduling: Use all functional units productively. Instruction selection IR machine code errors Register allocation Instruction scheduling IR
8
8 The Back End Instruction Scheduling: Optimal scheduling is NP-Complete in nearly all cases. Instruction selection IR machine code errors Register allocation Instruction scheduling IR
9
9 Three-pass Compiler Intermediate stage for code improvement or optimization Front End Source code machine code errors Middle End Back End IR
10
10 Three-pass Compiler Analyzes IR and rewrites (or transforms) IR Front End Source code machine code errors Middle End Back End IR
11
11 Three-pass Compiler Primary goal is to reduce running time of the compiled code Front End Source code machine code errors Middle End Back End IR
12
12 Three-pass Compiler May also improve space usage, power consumption,... Front End Source code machine code errors Middle End Back End IR
13
13 Three-pass Compiler Must preserve “meaning” of the code. Measured by values of named variables Front End Source code machine code errors Middle End Back End IR
14
14 OptimizerOptimizer Modern optimizers are structured as a series of passes Opt 1 IR errors Opt 2 Opt n IR Opt 3 IR
15
15 OptimizerOptimizer Typical transformations Discover & propagate some constant value Opt 1 IR errors Opt 2 Opt n IR Opt 3 IR
16
16 OptimizerOptimizer Typical transformations Move a computation to a less frequently executed place Opt 1 IR errors Opt 2 Opt n IR Opt 3 IR
17
17 OptimizerOptimizer Typical transformations Specialize some computation based on context Opt 1 IR errors Opt 2 Opt n IR Opt 3 IR
18
18 OptimizerOptimizer Typical transformations Discover a redundant computation & remove it Opt 1 IR errors Opt 2 Opt n IR Opt 3 IR
19
19 OptimizerOptimizer Typical transformations Remove useless or unreachable code Opt 1 IR errors Opt 2 Opt n IR Opt 3 IR
20
20 OptimizerOptimizer Typical transformations Encode an idiom in some particularly efficient form Opt 1 IR errors Opt 2 Opt n IR Opt 3 IR
21
21 Related to Compilers Interpreters (direct execution) Assemblers Preprocessors Text formatters (non- WYSIWYG) Analysis tools
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.