always_inline

Description

The always_inline attribute indicates that a function must be inlined. This attribute is a standard feature of GCC, and a standard feature of the SDx compilers.

This attribute enables a compiler optimization to have a function inlined into the calling function. The inlined function is dissolved and no longer appears as a separate level of hierarchy in the RTL.

In some cases, inlining a function allows operations within the function to be shared and optimized more effectively with surrounding operations in the calling function. However, an inlined function can no longer be shared with other functions, so the logic may be duplicated between the inlined function and a separate instance of the function which can be more broadly shared. While this can improve performance, this will also increase the area required for implementing the RTL.

In some cases the compiler may choose to ignore the always_inline attribute and not inline a function.

By default, inlining is only performed on the next level of function hierarchy, not sub-functions.

Syntax

Place the attribute in the OpenCL source before the function definition to always have it inlined whenever the function is called.
__attribute__((always_inline))

Examples

This example adds the always_inline attribute to function foo:

__attribute__((always_inline))
  void foo ( a, b, c, d ) {
  ...
}

See Also