Next: 3.20 Defines Created by
Up: 3 Using SDCC
Previous: 3.18 DS390 Memory Models
  Contents
  Index
3.19 Pragmas
SDCC supports the following #pragma directives.
- SAVE - this will save all current options to
the SAVE/RESTORE stack. See RESTORE.
- RESTORE - will restore saved options from
the last save. SAVEs & RESTOREs can be nested. SDCC uses a SAVE/RESTORE
stack: SAVE pushes current options to the stack, RESTORE pulls current
options from the stack. See SAVE.
- NOGCSE - will stop global common subexpression
elimination.
- NOINDUCTION - will stop loop induction
optimizations.
- NOJTBOUND - will not generate code for
boundary value checking, when switch statements are turned into jump-tables
(dangerous).
- NOOVERLAY - the compiler will not overlay
the parameters and local variables of a function.
- LESS_PEDANTIC - the compiler will
not warn you anymore for obvious mistakes, you'r on your own now ;-(
- NOLOOPREVERSE - Will not do loop reversal
optimization
- EXCLUDE NONE | {acc[,b[,dpl[,dph]]]
- The exclude pragma disables generation of pair of push/pop
instruction in ISR function (using interrupt keyword).
The directive should be placed immediately before the ISR function
definition and it affects ALL ISR functions following it. To enable
the normal register saving for ISR functions use #pragma EXCLUDE none.
- NOIV - Do not generate interrupt vector table
entries for all ISR functions defined after the pragma. This is useful
in cases where the interrupt vector table must be defined manually,
or when there is a secondary, manually defined interrupt vector table
(e.g. for the autovector feature of the Cypress EZ-USB FX2).
- CALLEE-SAVES
function1[,function2[,function3...]] - The compiler by default
uses a caller saves convention for register saving across function
calls, however this can cause unnecessary register pushing & popping
when calling small functions from larger functions. This option can
be used to switch off the register saving convention for the function
names specified. The compiler will not save registers when calling
these functions, extra code need to be manually inserted at the entry
& exit for these functions to save & restore the registers used
by these functions, this can SUBSTANTIALLY reduce code & improve
run time performance of the generated code. In the future the compiler
(with inter procedural analysis) may be able to determine the appropriate
scheme to use for each function call. If --callee-saves command
line option is used, the function names specified in #pragma CALLEE-SAVES
is appended to the list of functions specified in the command line.
The pragma's are intended to be used to turn-off certain optimizations
which might cause the compiler to generate extra stack / data space
to store compiler generated temporary variables. This usually happens
in large functions. Pragma directives should be used as shown in the
following example, they are used to control options & optimizations
for a given function; pragmas should be placed before and/or after
a function, placing pragma's inside a function body could have unpredictable
results.
#pragma SAVE /* save
the current settings */
#pragma NOGCSE /* turnoff
global subexpression elimination */
#pragma NOINDUCTION /* turn
off induction optimizations */
int foo ()
{
...
/* large code */
...
}
#pragma RESTORE /* turn the optimizations
back on */
The compiler will generate a warning message when extra space is allocated.
It is strongly recommended that the SAVE and RESTORE pragma's be used
when changing options for a function.
Next: 3.20 Defines Created by
Up: 3 Using SDCC
Previous: 3.18 DS390 Memory Models
  Contents
  Index
Bernhard Held
2003-08-29