Lec15Compiler - Lecture 15 Code Generation and Optimization...

Info icon This 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
Image of page 1

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

View Full Document Right 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!
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.
Image of page 3

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

View Full Document Right 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
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
Image of page 5

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

View Full Document Right 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
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
Image of page 7

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

View Full Document Right Arrow Icon
ECE 471 15-Comp-8 Generated Code Memory Management .text Program code (ROM) .const
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern