Presentation is loading. Please wait.

Presentation is loading. Please wait.

Compiler Construction

Similar presentations


Presentation on theme: "Compiler Construction"— Presentation transcript:

1 Compiler Construction
CS 606 Sohail Aslam Lecture 4 compiler: intro

2 The Back End Register Allocation:
IR Instruction selection IR Register allocation IR Instruction scheduling machine code errors Register Allocation: Have each value in a register when it is used.

3 The Back End Register Allocation:
IR Instruction selection IR Register allocation IR Instruction scheduling machine code errors Register Allocation: Manage a limited set of resources – register file.

4 The Back End Register Allocation:
IR Instruction selection IR Register allocation IR Instruction scheduling machine code errors Register Allocation: Can change instruction choices and insert LOADs and STOREs.

5 The Back End Register Allocation:
IR Instruction selection IR Register allocation IR Instruction scheduling machine code errors Register Allocation: Optimal register allocation is NP-Complete.

6 The Back End Instruction Scheduling:
IR Instruction selection IR Register allocation IR Instruction scheduling machine code errors Instruction Scheduling: Avoid hardware stalls and interlocks.

7 The Back End Instruction Scheduling:
IR Instruction selection IR Register allocation IR Instruction scheduling machine code errors Instruction Scheduling: Use all functional units productively.

8 The Back End Instruction Scheduling:
IR Instruction selection IR Register allocation IR Instruction scheduling machine code errors Instruction Scheduling: Optimal scheduling is NP-Complete in nearly all cases.

9 Three-pass Compiler IR IR Front End Source code Middle End Back End machine code errors Intermediate stage for code improvement or optimization

10 Three-pass Compiler Analyzes IR and rewrites (or transforms) IR IR IR
Front End Source code Middle End Back End machine code errors Analyzes IR and rewrites (or transforms) IR

11 Three-pass Compiler IR IR Front End Source code Middle End Back End machine code errors Primary goal is to reduce running time of the compiled code

12 Three-pass Compiler IR IR Front End Source code Middle End Back End machine code errors May also improve space usage, power consumption, ...

13 Three-pass Compiler Must preserve “meaning” of the code.
IR IR Front End Source code Middle End Back End machine code errors Must preserve “meaning” of the code. Measured by values of named variables

14 Optimizer Modern optimizers are structured as a series of passes Opt 1
IR errors Opt 2 n 3 Modern optimizers are structured as a series of passes

15 Optimizer Typical transformations
IR errors Opt 2 n 3 Typical transformations Discover & propagate some constant value

16 Optimizer Typical transformations
IR errors Opt 2 n 3 Typical transformations Move a computation to a less frequently executed place

17 Optimizer Typical transformations
IR errors Opt 2 n 3 Typical transformations Specialize some computation based on context

18 Optimizer Typical transformations
IR errors Opt 2 n 3 Typical transformations Discover a redundant computation & remove it

19 Optimizer Typical transformations Remove useless or unreachable code
IR errors Opt 2 n 3 Typical transformations Remove useless or unreachable code

20 Optimizer Typical transformations
IR errors Opt 2 n 3 Typical transformations Encode an idiom in some particularly efficient form

21 Role of Run-time System
Memory management Allocate/deallocate Garbage collection Run-time type checking Error/exception processing Interface to OS – I/O Support for parallelism Parallel threads Communication and synchronization

22 Related to Compilers Interpreters (direct execution) Assemblers
Preprocessors Text formatters (non-WYSIWYG) Analysis tools


Download ppt "Compiler Construction"

Similar presentations


Ads by Google