|
|||||||||||
|
Technical Support On-Line Manuals CARM User's Guide |
CARM User's GuideDiscontinued __inline: Function in-liningThe CARM Compiler supports function inlining (using the __inline function attribute) and cross-module function inlining (using the extern keyword). <[>extern<]> __inline <[> type <]> funcname (<[> args <]>) Where
Function inlining replaces a call to a function with the body of the function. This speeds up program execution by eliminating the call/return code, the code required to pass parameters, and the code required for return values. In addition, the compiler optimizes expanded inline functions with the rest of the code. Cross-module function inlining replaces calls to inline functions defined in other source files. Use the extern keyword as shown above to declare cross-module inline functions. All function inlining is actually performed by linker (not by the compiler) after function parameters are calculated. Refer to the INLINE directive in the LARM Linker User's Manual for more information. Note
The CARM Compiler may reduce the size of the code generated when you use inline functions if some of the inline function arguments are constant expressions.
__inline void PortOut (
unsigned int io,
unsigned int pos,
int state)
{
switch (io)
{
case 0:
if (state == 0) IOCLR0 |= pos;
else IOSET0 |= pos;
break;
case 1:
if (state == 0) IOCLR1 |= pos;
else IOSET1 |= pos;
break;
}
}
In such cases, the compiler only inserts the relevant function code. For instance, PortOut (1, 0x40, 1); generates IOSET1 |= 0x40; Other code in the PortOut function is eliminated since the io and state parameters are constant. Some restrictions apply to the __inline attribute. As such, function inlining is disabled for:
Note
| ||||||||||
|
|||||||||||