Specifications

CAVR-4
Part1. Using the compiler
Efficient coding for embedded applications
125
Clustering of variables
When clustering of variables is enabled, static and global variables are arranged so that
variables that are accessed in the same function are stored close to each other. This
makes it possible for the compiler to use the same base pointer for several accesses.
Note: This option has no effect at optimization levels None and Low.
Cross call
Common code sequences are extracted to local subroutines. This optimization, which is
performed at optimization level High, can reduce code size, sometimes dramatically, on
behalf of execution time and stack size. The resulting code might however be difficult
to debug. This optimization cannot be disabled using the
#pragma optimize directive.
Note: This option has no effect at optimization levels None, Low, and Medium, unless
the option
--do_cross_call is used.
To read more about related command line options, see --no_cross_call, page 189,
--do_cross_call, page 179, and --cross_call_passes, page 174.
Selecting data types and placing data in memory
For efficient treatment of data, you should consider the data types used and the most
efficient placement of the data.This section provides useful information for efficient
treatment of data:
Locating strings in ROM, RAM and flash
Using efficient data types
Memory model and memory attributes for data
Using the best pointer type
Anonymous structs and unions
Saving stack space and RAM memory.
LOCATING STRINGS IN ROM, RAM AND FLASH
With the AVR IAR C/C++ Compiler there are three possible locations for storing
strings:
In external ROM in the data memory space
In internal RAM in the data memory space
In flash in the code memory space.
To read more about this, see Initialized data, page 39.