Lec15Compiler

Lec15Compiler - Lecture 15 Code Generation and Optimization...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 471 15-Comp-1 Outline Compiler passes Code generation options Optimizations Functions calls Lecture 15 Code Generation and Optimization
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 471 15-Comp-2 Compiler Optimization Compiler supports several optimization options Performance Size Often these choices are mutually exclusive The smallest program may not necessarily be the fastest!
Background image of page 2
ECE 471 15-Comp-3 Compiler Optimization Compiler has three passes cp6812 – the parser Handles preprocessor directives Performs some constant substitutions cg6812 – the code generator Converts the pre-processed C into assembly cg6812 – the assembly language optimizer Performs optimization based on selected options And an assembler… ca6812 – the assembler Converts the assembly language output to a relocatable object module.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 471 15-Comp-4 Parser Options Some parser options include: -f Default single precision float -nw Do not widen arguments In addition, you can tell the parser to: Reverse bitfield order Require prototypes Align on even boundary
Background image of page 4
ECE 471 15-Comp-5 Code Generator Options Some available code generator options include: -no Don’t optimize – default is optimize -ck Enable stack overflow checking -i Inline machine library calls for long integer handling Resultant code is bigger, but faster
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 471 15-Comp-6 Assembly Language Optimizer Uses peephole optimization Redundant load and store operations are removed Eliminates unreachable code Options -c Keep original lines as comments -v Print efficiency statistics
Background image of page 6
ECE 471 15-Comp-7 Compiling Normally we compile using the cx6812 command To access the individual compiler passes we can run the programs separately cp6812 –o temp.cx1 file.c cg6812 –o temp.cx2 temp.cx1 co6812 –o temp.cx3 temp.cx2 ca6812 –o file.o temp.cx3 Normally, we would just run: cx6812 file.c To turn off optimizations, use the –no switch cx6812 –no file.c
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 471 15-Comp-8 Generated Code Memory Management .text Program code (ROM) .const Constant and literal data (ROM) .data All static initialized data (RAM) .bss All non-initialized data (RAM) .bsct Initialized data in zero page memory
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 28

Lec15Compiler - Lecture 15 Code Generation and Optimization...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online