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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

C Language1.10. Functions1.10.1. Calling ConventionParameter passingA lot of execution time of an application is spent transferring parameters between functions. The fastestparameter transport is via registers. There<strong>for</strong>e, function parameters are first passed via registers. If nomore registers are available <strong>for</strong> a parameter, the compiler pushes parameters on the stack.Registers available <strong>for</strong> parameter passing are r0, r1, r2 and r3.Parameter type_Bool, char, short, int, long, float, 32–bitpointer, 32–bit structlong long, double, 64–bit structRegisters used <strong>for</strong> parametersR0, R1, R2, R3R0R1, R1R2, R2R3The parameters are processed from left to right. The first not used and fitting register is used. Registersare searched <strong>for</strong> in the order listed above.When a parameter is > 64 bit, or all registers are used, parameterpassing continues on the stack.The stack grows from higher towards lower addresses.The first parameteris pushed at the lowest stack address. The alignment on the stack depends on the data type as listed inSection 1.1, Data Types.Examples:void func1( int a, char * b, char c ); /* R0 R1 R2 */void func2( long long d, char e ); /* R0R1 R2 */void func4( double f, long long g, char h );/* R0R1 R2R3 stack */Function return valuesThe C compiler uses registers to store C function return values, depending on the function return types.Return type_Bool, char, short, int, long, float, 32–bitpointer, 32–bit structlong long, double, 64–bit structRegisterR0R0R1Objects larger than 64 bits are returned via the stack.1.10.2. Inlining Functions: inlineWith the C compiler option --optimize=+inline, the C compiler automatically inlines small functions inorder to reduce execution time (smart inlining). The compiler inserts the function body at the place thefunction is called. The C compiler decides which functions will be inlined. You can overrule this behaviorwith the two keywords inline (ISO-C) and __noinline.23

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

Saved successfully!

Ooh no, something went wrong!