<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
- <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
- <TITLE>SDCC Compiler User Guide: Library routines.</TITLE>
+ <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.7">
+ <TITLE>SDCC Compiler User Guide: Pragmas</TITLE>
<LINK HREF="SDCCUdoc-20.html" REL=next>
<LINK HREF="SDCCUdoc-18.html" REL=previous>
<LINK HREF="SDCCUdoc.html#toc19" REL=contents>
<A HREF="SDCCUdoc-18.html">Previous</A>
<A HREF="SDCCUdoc.html#toc19">Contents</A>
<HR>
-<H2><A NAME="Library"></A> <A NAME="s19">19. Library routines.</A> </H2>
+<H2><A NAME="Pragmaa"></A> <A NAME="s19">19. Pragmas</A> </H2>
-<P>The following library routines are provided for your convenience.
-<P><B>stdio.h </B>- Contains the following functions printf & sprintf these routines
-are developed by Martijn van Balen <balen@natlab.research.philips.com>.
+<P>SDCC supports the following #pragma directives. This directives are
+applicable only at a function level.
<P>
+<UL>
+<LI><B>SAVE</B>
+<A NAME="pragma save"></A> - this will save all the current options .</LI>
+<LI><B>RESTORE </B>
+<A NAME="pragma restore"></A> - will restore the saved options from the last save. Note that
+SAVES & RESTOREs cannot be nested. SDCC uses the same buffer to save the
+options each time a SAVE is called.</LI>
+<LI><B>NOGCSE</B>
+<A NAME="pragma nogcse"></A> - will stop global subexpression elimination.</LI>
+<LI><B>NOINDUCTION</B>
+<A NAME="pragma noinduction"></A> - will stop loop induction optimizations .</LI>
+<LI><B>NOJTBOUND</B>
+<A NAME="pragma nojtbound"></A> - will not generate code for boundary value checking , when switch
+statements are turned into jump-tables.</LI>
+<LI><B>NOOVERLAY </B>
+<A NAME="pragma nooverlay"></A> - the compiler will not overlay the parameters and local variables
+of a function.</LI>
+<LI><B>NOLOOPREVERSE</B>
+<A NAME="pragma noloopreverse"></A> - Will not do loop reversal optimization</LI>
+<LI><B>EXCLUDE NONE | {acc[,b[,dpl[,dph]]]</B>
+<A NAME="pragma exclude"></A>
+- 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"</LI>
+<LI><B>CALLEE-SAVES function1[,function2[,function3...]]</B>
+<A NAME="pragma callee-saves"></A> -
+The compiler by default uses a caller saves convention for register saving
+across function calls, however this can cause unneccessary register pushing
+& popping when calling small functions from larger functions. This option
+can be used to switch the register saving convention for the function names
+specified. The compiler will not save registers when calling these functions,
+extra code will be generated 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 future
+the compiler (with interprocedural analysis) will be able to determine the
+appropriate scheme to use for each function call. If --callee-saves
+<A HREF="SDCCUdoc-4.html#--callee-saves"></A> command
+line option is used, the function names specified in #pragma CALLEE-SAVES
+is appended to the list of functions specified inthe command line.</LI>
+</UL>
+<P>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.
<P>
<PRE>
-%[flags][width][b|B|l|L]type flags: - left justify output in specified field width
-
- + prefix output with +/- sign if output is signed
- type
- space prefix output with a blank if it's a signed
- positive value
- width: specifies minimum number of characters
- outputted for numbers
- or strings.
-
- - For numbers, spaces are added on the left when needed.
-
- If width starts with a zero character, zeroes and used
-
- instead of spaces.
- - For strings, spaces are are
- added on the left or right (when
- flag '-' is used)
- when needed.
-
- b/B: byte argument
- (used by d, u, o, x, X)
- l/L: long argument (used by d,
- u, o, x, X)
- type: d decimal number
- u
- unsigned decimal number
- o unsigned octal number
-
- x unsigned hexadecimal number (0-9, a-f)
- X
- unsigned hexadecimal number (0-9, A-F)
- c character
-
- s string (generic pointer)
- p
- generic pointer (I:data/idata, C:code, X:xdata, P:paged)
-
- f float (still to be implemented)
-
-</PRE>
-<P>Also contains a very simple version of printf (<B>printf_small</B>). This simplified
-version of printf supports only the following formats.
-<P>
-<PRE>
-format output type argument-type <bf>
-%d decimal
- int
-%ld decimal long
-%hd decimal short/char
-
-%x hexadecimal int
-%lx hexadecimal long
-
-%hx hexadecimal short/char
-%o octal int
-
-%lo octal long
-%ho octal short/char
-
-%c character char/short
-%s character _generic
- pointer
- <p><tt>The routine is <tt><bf>very stack intesive , --stack-after-data parameter should
- be used when using this routine, the routine also takes about 1K of code space
- .It also expects an external function named putchar(char ) to be present (this
- can be changed). When using the %s format the string / pointer should
- be cast to a generic pointer. eg.
+eg#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 */
</PRE>
+<P>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.
<HR>
<A HREF="SDCCUdoc-20.html">Next</A>
<A HREF="SDCCUdoc-18.html">Previous</A>