11.07.2015 Views

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ICCV8 <strong>for</strong> AVR – C Compiler <strong>for</strong> Atmel AVROptimizationsImageCraft <strong>compiler</strong>s are derived from <strong>the</strong> LCC <strong>compiler</strong> (see Acknowledgments). Assuch, <strong>the</strong> portable front end of <strong>the</strong> LCC <strong>compiler</strong>s per<strong>for</strong>m <strong>the</strong> following optimizations: Algebraic Simplifications <strong>and</strong> Constant Folding.The <strong>compiler</strong> may replace expensive algebraic expressions with simplerexpressions (e.g., adding by 0, dividing by 1, etc.). The <strong>compiler</strong> also evaluatesconstant expressions <strong>and</strong> “folds” <strong>the</strong>m (e.g., 1+1 becomes 2). The <strong>compiler</strong> alsoper<strong>for</strong>ms <strong>the</strong>se optimizations on floating-point constants <strong>and</strong> <strong>the</strong> results may beslightly different if <strong>the</strong> floating-point constants are not “folded.” This is because <strong>the</strong>precision <strong>and</strong> range of <strong>the</strong> floating-point operations of <strong>the</strong> host CPU (e.g., Intelprocessors) differ from <strong>the</strong> target CPU. In most cases, any minor differences willnot be an issue. Basic Block Common Subexpression Elimination.Expressions that are reused within a basic block (i.e., a sequence of straight linecode without jumps) may be cached in a <strong>compiler</strong>-created temporary <strong>and</strong> notrecomputed. Switch Optimizations.The <strong>compiler</strong> analyzes <strong>the</strong> switch values <strong>and</strong> generates code using a combinationof binary searches <strong>and</strong> jump tables. The jump tables are effective <strong>for</strong> denselypacked switch values <strong>and</strong> <strong>the</strong> binary searches locate <strong>the</strong> right jump table quickly.In <strong>the</strong> case where <strong>the</strong> values are widely spread or few in numbers, a simple if<strong>the</strong>n-elsesearch is per<strong>for</strong>med.The <strong>compiler</strong> code generator (<strong>the</strong> “backend”) uses a technique called bottom-up treerewriting with dynamic programming to generate assembly code, meaning that <strong>the</strong>generated code is locally (i.e., per expression) optimal. In addition, <strong>the</strong> backend mayper<strong>for</strong>m <strong>the</strong> following optimizations. Note that <strong>the</strong>se are ImageCraft enhancements<strong>and</strong> not part of <strong>the</strong> st<strong>and</strong>ard LCC distribution. Peephole Optimizations.While locally optimal, <strong>the</strong> generated code may still have redundant fragmentsresulting from different C statements. Peephole optimizations eliminate some of<strong>the</strong>se redundancies. Register Allocation.For targets with multiple machine registers (e.g., AVR, MSP430, <strong>and</strong> ARM), <strong>for</strong>each function, <strong>the</strong> <strong>compiler</strong> per<strong>for</strong>ms register allocation <strong>and</strong> tries to pack as manylocal variables as possible into <strong>the</strong> machine registers <strong>and</strong> <strong>the</strong>reby increase23

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!