CS 404 Introduction To Compiler Design: Lecture 12 + 13 Ahmed Ezzat
CS 404 Introduction To Compiler Design: Lecture 12 + 13 Ahmed Ezzat
Lecture 12 + 13
Ahmed Ezzat
Code optimizations
Runtime environment
Target code generation
Assemblers, linkers, loaders, debuggers,
profilers
Programmar
– Use better algorithms (n vs n^2)
– Move computation out of loops
– Remove redundant computations
Intermediate representation (machine
independent)
Target code (machine dependent)
A list of instructions
Once the block is entered, each instruction is
executed exactly once
Only the first statement can be reached from
outside the block (no jumping in)
Execution continues from first instruction to
last in the block (no jumping out)
Reduction in strength
– Some operations are faster than others
Multiplications -> additions
Multiply or divided by 2 -> shift left or right
– Be careful with correctness
Overflow behavior preserved
Other side-effect of operations (e.g., interrupts)
Returned value
Actual parameters
Optional control link: to parent procedure
Optional access link: non-local data held elsewhere
Saved machine status: registers, program counters
Local data: variables declared local to a function
Temporary data: used by target code