Wrapping Up Copyright 2003 Keith D Cooper Kennedy
- Slides: 12
Wrapping Up Copyright 2003, Keith D. Cooper, Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission to make copies of these materials for their personal use. The Last Lecture
High-level View Source code Compiler Machine code Errors Definitions • Compiler consumes code & produces code • Interpreter consumes executable & produces results The Last Lecture
High-level View Source Code Front End IR Middle IR Back End Machine code • Front end consumes source code & produces IRErrors ® Determines code shape for rest of compiler • Middle reads & writes IR Analyzes & transforms IR to “improve” it ® Myriad techniques at several distinct scopes ® • Back end consumes optimizes IR & produces target code ® Maps code to target ISA & handles resource issues The Last Lecture
Front End Source Code d e v l o s S lem b o r P Front End IR Middle IR Back End Machine code Scanner Errors • Applies DFA technology to classify words • Use RE-based tools to generate fast scanners Parser • Takes stream of classified words & computes structure • Many techniques (TDRD, LL(1), LR(1) + others) Context-sensitive Analysis • Type-checking & IR generation (AGs & Ad-hoc SDT) • Problems are harder & tools not as well developed The Last Lecture
Middle (Optimizer) Source Code Front End IR Middle IR Back End • Typically structured as a series of passes Machine code Errors Allows for separation of concerns ® Simplifies development & debugging ® • Rewrites IR to improve running time, code space, … • We studied redundancy elimination ® Other optimizations include code motion, dead-code elimination, constant propagation, strength reduction, … (see Ch 10) The Last Lecture Most compilers need better optimization …
Back End Source Code Front End IR Middle IR Back End Three Problems • Instruction Selection ® Machine code Errors Mapping optimized IR to target machine’s ISA • Instruction Scheduling ® Reordering operations to hide latencies & speed execution • Register Allocation ® Mapping name space of optimized IR to target’s register set The Last Lecture
Back End Source Code Front End IR Middle IR Back End Instruction Selection • This is a pattern-matching problem Machine code Errors We looked at tree pattern matching, peephole optimization ® Other ideas: string matching, ad-hoc matching, parsing, … ® • Criterion is “local optimality” Map immediate context to ISA in an efficient way ® Leave “global optimality” to optimizer ® • My algorithm of choice: peephole matching The Last Lecture
Back End Source Code Front End IR Middle IR Back End Instruction Scheduling • Fixed set of operations, can vary the order Machine code Errors Must preserve inter-operation dependences ® May change demand for registers ® • List scheduling is dominant paradigm ® Applied to blocks, extended blocks, regions in code • My algorithm of choice: Schielke’s RBF algorithm on EBBs The Last Lecture
Back End Source Code Front End IR Middle IR Back End Machine code Errors Register Allocation • Handle disconnect between optimizer’s assumption of unlimited registers and chip’s limited set Insert loads and stores to reconcile the two models ® Minimize the slowdown ® (spills) • Global allocation via graph coloring is the dominant paradigm Build interference graph and color it ® Many minor variations, but one strong theme ® The Last Lecture
Perspective Source Code Front End IR Middle IR Back End Machine code Errors Different concerns in each phase • Front end worries about shaping code for optimization ® Expose facts that can be improved & tailored • Middle worries about global issues that affect speed, space ® Redundancy, constants, code motion, locality, . . . • Back end worries about using the target’s resources ® Address modes, functional units, registers, issue slots, … The Last Lecture These concerns “bleed” from one phase to another
Perspective Source Code Front End IR Middle IR Back End Different complexities in each phase • Front end is mostly linear time ® Machine code Errors DFAs, parsers take time proportional to size of input stream • Middle is low-order polynomial time ® Analysis & optimization are O(n) to O(n 2 ), in general • Back end solves hard problems with approximations Heuristics that typically take O(n) to (n 2) ® Underlying problems are seriously hard ® The Last Lecture
Perspective Source Code Front End IR Middle IR Remaining work • Front end is solved ® Machine code Errors No more theses on parsing, I hope • Middle has some room for work ® Back End (not a wide open frontier) New machines, new languages present new problems • Back end has room for work Complications from new machines ® Longer latencies, wider processors ® The Last Lecture
- Copyrightfrance
- Copyright 2003
- Copyright 2003
- 2008 pearson education inc
- Neck wrapping for low-pressure hydrocephalus
- What is the purpose of taping and wrapping?
- Tissue paper hot air balloon
- Surface area (with a wrapping task)
- Which is the physical container or wrapping for a product
- How to wrap wrist with ace bandage
- Surface area formula
- Chapter 10 worksheet wrapping and taping techniques
- Warping and morphing