7.7.2 Optimizations

Using the EDS/PSV address space qualifiers may be expensive. If your application footprint does not need to access these variables often, then it may be more efficient to use the const-in-data memory model and manually place the less often accessed data into a Flash space (using the named address attributes and qualifiers). This can reduce the overhead by allowing the compiler to not force the EDS access to return to a single page. This model does not preclude the use of an automatically managed PSV space; using space(auto_psv) allows the programmer to nominate which const variables go into this area.

By default the compiler will arrange to assert the const-in-code page at the start of an interrupt service routine. If an ISR does not need to access const data, then specifying __attribute__((no_auto_psv)) will let the compiler know that the ISR, or any function it calls, does not use any auto PSV data.

The compiler also has an optimization setting that attempts to reduce the number of page swaps; not as a cache, but modifications of the DSR/DSW/PSV Page SFR register. This is a separate switch, -moptimize-page-setting, which can be applied at any optimization level. Like many optimizations, it generally reduces the number page setting operations which may reduce code-size and improve application performance.