13.07.2015 Views

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>TASKING</strong> <strong>VX</strong>-<strong>toolset</strong> <strong>for</strong> <strong>ARM</strong> <strong>User</strong> <strong>Guide</strong>You must define inline functions in the same source module as in which you call the function, becausethe compiler only inlines a function in the module that contains the function definition. When you need tocall the inline function from several source modules, you must include the definition of the inline functionin each module (<strong>for</strong> example using a header file).With the __noinline keyword, you prevent a function from being inlined:__noinline unsigned int abs(int val){unsigned int abs_val = val;if (val < 0) abs_val = -val;return abs_val;}Using pragmas: inline, noinline, smartinlineInstead of the inline qualifier, you can also use #pragma inline and #pragma noinline to inlinea function body:#pragma inlineunsigned int abs(int val){unsigned int abs_val = val;if (val < 0) abs_val = -val;return abs_val;}#pragma noinlinevoid main( void ){int i;i = abs(-1);}If a function has an inline/__noinline function qualifier, then this qualifier will overrule the currentpragma setting.With the #pragma noinline / #pragma smartinline you can temporarily disable the default behaviorthat the C compiler automatically inlines small functions when you turn on the C compiler option--optimize=+inline.With the C compiler options --inline-max-incr and --inline-max-size you have more control over theautomatic function inlining process of the compiler.Combining inline with __asm to create intrinsic functionsWith the keyword __asm it is possible to use assembly instructions in the body of an inline function.Because the compiler inserts the (assembly) body at the place the function is called, you can create yourown intrinsic function. See Section 1.10.4.1, Writing Your Own Intrinsic Function.24

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!