07.04.2013 Views

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Using the <strong>Compiler</strong> on the Comm<strong>and</strong> Line<br />

TABLE 3-8: GENERAL OPTIMIZATION OPTIONS (CONTINUED)<br />

Option Definition<br />

-O2 Optimize even more. The compiler per<strong>for</strong>ms nearly all<br />

supported optimizations that do not involve a space-speed<br />

trade-off. -O2 turns on all optional optimizations except <strong>for</strong><br />

loop unrolling (-funroll-loops), function inlining<br />

(-finline-functions), <strong>and</strong> strict aliasing optimizations<br />

(-fstrict-aliasing). It also turns on <strong>for</strong>ce copy of<br />

memory oper<strong>and</strong>s (-f<strong>for</strong>ce-mem) <strong>and</strong> Frame Pointer elimination<br />

(-fomit-frame-pointer). As compared to -O, this<br />

option increases both compilation time <strong>and</strong> the per<strong>for</strong>mance of<br />

the generated code.<br />

-O3 Optimize yet more. -O3 turns on all optimizations specified by<br />

-O2 <strong>and</strong> also turns on the inline-functions option.<br />

-Os Optimize <strong>for</strong> size. -Os enables all -O2 optimizations that do<br />

not typically increase code size. It also per<strong>for</strong>ms further<br />

optimizations designed to reduce code size.<br />

The following options control specific optimizations. The -O2 option turns on all of<br />

these optimizations except -funroll-loops, -funroll-all-loops <strong>and</strong><br />

-fstrict-aliasing.<br />

You can use the following flags in the rare cases when “fine-tuning” of optimizations to<br />

be per<strong>for</strong>med is desired.<br />

TABLE 3-9: SPECIFIC OPTIMIZATION OPTIONS<br />

Option Definition<br />

-falign-functions<br />

-falign-functions=n<br />

-falign-labels<br />

-falign-labels=n<br />

-falign-loops<br />

-falign-loops=n<br />

Align the start of functions to the next power-of-two greater<br />

than n, skipping up to n bytes. For instance,<br />

-falign-functions=32 aligns functions to the next<br />

32-byte boundary, but -falign-functions=24 would align<br />

to the next 32-byte boundary only if this can be done by<br />

skipping 23 bytes or less.<br />

-fno-align-functions <strong>and</strong> -falign-functions=1 are<br />

equivalent <strong>and</strong> mean that functions will not be aligned.<br />

The assembler only supports this flag when n is a power of<br />

two; so n is rounded up. If n is not specified, use a<br />

machine-dependent default.<br />

Align all branch targets to a power-of-two boundary, skipping<br />

up to n bytes like -falign-functions. This option can<br />

easily make code slower, because it must insert dummy<br />

operations <strong>for</strong> when the branch target is reached in the usual<br />

flow of the code.<br />

If -falign-loops or -falign-jumps are applicable <strong>and</strong><br />

are greater than this value, then their values are used instead.<br />

If n is not specified, use a machine-dependent default which is<br />

very likely to be 1, meaning no alignment.<br />

Align loops to a power-of-two boundary, skipping up to n bytes<br />

like -falign-functions. The hope is that the loop will be<br />

executed many times, which will make up <strong>for</strong> any execution of<br />

the dummy operations.<br />

If n is not specified, use a machine-dependent default.<br />

-fcaller-saves Enable values to be allocated in registers that will be<br />

clobbered by function calls, by emitting extra instructions to<br />

save <strong>and</strong> restore the registers around such calls. Such<br />

allocation is done only when it seems to result in better code<br />

than would otherwise be produced.<br />

© 2008 <strong>Microchip</strong> Technology Inc. DS51284H-page 47

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

Saved successfully!

Ooh no, something went wrong!