go to single .html
[fw/sdcc] / doc / SDCCUdoc-19.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML>
3 <HEAD>
4  <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.7">
5  <TITLE>SDCC Compiler User Guide: Pragmas</TITLE>
6  <LINK HREF="SDCCUdoc-20.html" REL=next>
7  <LINK HREF="SDCCUdoc-18.html" REL=previous>
8  <LINK HREF="SDCCUdoc.html#toc19" REL=contents>
9 </HEAD>
10 <BODY>
11 <A HREF="SDCCUdoc-20.html">Next</A>
12 <A HREF="SDCCUdoc-18.html">Previous</A>
13 <A HREF="SDCCUdoc.html#toc19">Contents</A>
14 <HR>
15 <H2><A NAME="Pragmaa"></A> <A NAME="s19">19. Pragmas</A> </H2>
16
17 <P>SDCC supports the following #pragma directives. This directives are
18 applicable only at a function level.
19 <P>
20 <UL>
21 <LI><B>SAVE</B>
22 <A NAME="pragma save"></A>  - this will save all the current options .</LI>
23 <LI><B>RESTORE </B>
24 <A NAME="pragma restore"></A> - will restore the saved options from the last save. Note that
25 SAVES &amp; RESTOREs cannot be nested. SDCC uses the same buffer to save the
26 options each time a SAVE is called.</LI>
27 <LI><B>NOGCSE</B>
28 <A NAME="pragma nogcse"></A>  - will stop global subexpression elimination.</LI>
29 <LI><B>NOINDUCTION</B> 
30 <A NAME="pragma noinduction"></A> - will stop loop induction optimizations .</LI>
31 <LI><B>NOJTBOUND</B> 
32 <A NAME="pragma nojtbound"></A> - will not generate code for boundary value checking , when switch
33 statements are turned into jump-tables.</LI>
34 <LI><B>NOOVERLAY </B>
35 <A NAME="pragma nooverlay"></A> - the compiler will not overlay the parameters and local variables
36 of a function.</LI>
37 <LI><B>NOLOOPREVERSE</B> 
38 <A NAME="pragma noloopreverse"></A> - Will not do loop reversal optimization</LI>
39 <LI><B>EXCLUDE NONE | {acc[,b[,dpl[,dph]]]</B>
40 <A NAME="pragma exclude"></A> 
41 - The exclude pragma disables generation of pair of push/pop instruction in
42 ISR function (using interrupt keyword). The directive should be placed immediately
43 before the ISR function definition and it affects ALL ISR functions following
44 it. To enable the normal register saving for ISR functions use "#pragma
45 EXCLUDE none"</LI>
46 <LI><B>CALLEE-SAVES function1[,function2[,function3...]]</B>
47 <A NAME="pragma callee-saves"></A>  -
48 The compiler by default uses a caller saves convention for register saving
49 across function calls, however this can cause unneccessary register pushing
50 &amp; popping when calling small functions from larger functions. This option
51 can be used to switch the register saving convention for the function names
52 specified. The compiler will not save registers when calling these functions,
53 extra code will be generated at the entry &amp; exit for these functions to
54 save &amp; restore the registers used by these functions, this can SUBSTANTIALLY
55 reduce code &amp; improve run time performance of the generated code. In future
56 the compiler (with interprocedural analysis) will be able to determine the
57 appropriate scheme to use for each function call. If --callee-saves
58 <A HREF="SDCCUdoc-4.html#--callee-saves"></A> command
59 line option is used, the function names specified in #pragma CALLEE-SAVES
60 is appended to the list of functions specified inthe command line.</LI>
61 </UL>
62 <P>The pragma's are intended to be used to turn-off certain optimizations
63 which might cause the compiler to generate extra stack / data space to store
64 compiler generated temporary variables. This usually happens in large functions.
65 Pragma directives should be used as shown in the following example, they are
66 used to control options &amp; optimizations for a given function; pragmas should
67 be placed before and/or after a function, placing pragma's inside a function
68 body could have unpredictable results.
69 <P>
70 <PRE>
71 eg#pragma SAVE   /* save the current settings */ 
72 #pragma NOGCSE
73  /* turnoff global subexpression elimination */ 
74 #pragma NOINDUCTION /*
75  turn off induction optimizations */ 
76 int foo () 
77
78     ... 
79     /* large
80  code */ 
81     ... 
82
83 #pragma RESTORE /* turn the optimizations back
84  on */
85  
86 </PRE>
87 <P>The compiler will generate a warning message when extra space is allocated.
88 It is strongly recommended that the SAVE and RESTORE pragma's be used when
89 changing options for a function.
90 <HR>
91 <A HREF="SDCCUdoc-20.html">Next</A>
92 <A HREF="SDCCUdoc-18.html">Previous</A>
93 <A HREF="SDCCUdoc.html#toc19">Contents</A>
94 </BODY>
95 </HTML>