11.07.2015 Views

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

SHOW MORE
SHOW LESS
  • No tags were found...

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

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

Controlling compiler optimizationsThe following example shows incorrect usage:int delta @ "NOINIT"; /* Error, neither *//* "__no_init" nor "const" */Examples of placing functions in named segmentsvoid f(void) @ "FUNCTIONS";void g(void) @ "FUNCTIONS"{}#pragma location="FUNCTIONS"void h(void);To override the default segment allocation, you can explicitly specify a memory attributeother than the default:__data20 void f(void) @ "FUNCTIONS";Controlling compiler optimizationsThe compiler performs many transformations on your application in order to generatethe best possible code. Examples of such transformations are storing values in registersinstead of memory, removing superfluous code, reordering computations in a moreefficient order, and replacing arithmetic operations by cheaper operations.The linker should also be considered an integral part of the compilation system, becausethere are some optimizations that are performed by the linker. For instance, all unusedfunctions and variables are removed and not included in the final output.SCOPE FOR PERFORMED OPTIMIZATIONSYou can decide whether optimizations should be performed on your whole applicationor on individual files. By default, the same types of optimizations are used for an entireproject, but you should consider using different optimization settings for individual files.For example, put code that must execute very quickly into a separate file and compile itfor minimal execution time, and the rest of the code for minimal code size. This will givea small program, which is still fast enough where it matters.In addition, you can exclude individual functions from the performed optimizations. The#pragma optimize directive allows you to either lower the optimization level, orspecify another type of optimization to be performed. Refer to optimize, page 208, forinformation about the pragma directive.120<strong>MSP430</strong> <strong>IAR</strong> C/<strong>C++</strong> <strong>Compiler</strong>Reference Guide

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

Saved successfully!

Ooh no, something went wrong!