Next: 3.19 Defines Created by
Up: 3. Using SDCC
Previous: 3.17.2 DS390 Memory Model
Contents
Index
3.18 Pragmas
SDCC supports the following #pragma directives:
- save - this will save all current options to
the save/restore stack. See #pragma 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 #pragma save.
- 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.
- exclude none | {acc[,b[,dpl[,dph]]]
- The exclude pragma disables the generation of pairs of push/pop
instructions in Interrupt Service
Routines. 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.
See also the related keyword _naked.
- less_pedantic - the compiler will
not warn you anymore for obvious mistakes, you'r on your own now ;-(
- disable_warning <nnnn> - the compiler
will not warn you anymore about warning number <nnnn>.
- nogcse - will stop global common subexpression
elimination.
- noinduction - will stop loop induction
optimizations.
- noinvariant - will not do loop invariant
optimizations. For more details see Loop Invariants in section8.1.4.
- 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). More elegantly this can be achieved by obmitting the optional
interrupt number after the interrupt keyword, see section 3.8 about
interrupts.
- nojtbound - will not generate code for
boundary value checking, when switch statements are turned into jump-tables
(dangerous). For more details see section 8.1.7.
- noloopreverse - Will not do loop reversal
optimization
- nooverlay - the compiler will not overlay
the parameters and local variables of a function.
- stackauto- See option --stack-auto
and section 3.6 Parameters and
Local Variables.
- opt_code_speed - The compiler
will optimize code generation towards fast code, possibly at the expense
of code size.
- opt_code_size - The compiler will
optimize code generation towards compact code, possibly at the expense
of code speed.
- opt_code_balanced - The compiler
will attempt to generate code that is both compact and fast, as long
as meeting one goal is not a detriment to the other (this is the default).
- std_sdcc89 - Generally follow the C89
standard, but allow SDCC features that conflict with the standard
(default).
- std_c89 - Follow the C89 standard and disable
SDCC features that conflict with the standard.
- std_sdcc99 - Generally follow the C99
standard, but allow SDCC features that conflict with the standard
(incomplete support).
- std_c99 - Follow the C99 standard and disable
SDCC features that conflict with the standard (incomplete support).
- codeseg <name>- Use this name (max. 8 characters)
for the code segment.
- constseg <name>- Use this name (max. 8 characters)
for the const segment.
SDCPP supports the following #pragma directives:
- preproc_asm (+ | -) - switch _asm
_endasm block preprocessing on / off. Default is on.
The pragma's are intended to be used to turn-on or 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.19 Defines Created by
Up: 3. Using SDCC
Previous: 3.17.2 DS390 Memory Model
Contents
Index
Erik Petrich
2006-05-02