loki.transform.transform_inline

Collection of utility routines to perform code-level force-inlining.

Functions

inline_constant_parameters(routine[, ...])

Replace instances of variables with known constant values by Literals.

inline_elemental_functions(routine)

Replaces InlineCall expression to elemental functions with the called functions body.

inline_member_procedures(routine)

Inline all member subroutines contained in an individual Subroutine.

inline_member_routine(routine, member)

Inline an individual member Subroutine at source level.

Classes

InlineSubstitutionMapper([invalidate_source])

An expression mapper that defines symbolic substitution for inlining.

inline_constant_parameters(routine, external_only=True)

Replace instances of variables with known constant values by Literals.

Parameters:

external_only – Do not replace variables declared in the local scope

Note, the .type.initial property is used to derive the replacement value, which means for symbols imported from external modules, the parent Module needs to be supplied in the definitions to the constructor when creating :param routine:.

Variables that are replaced are also removed from their corresponding import statements, with empty import statements being removed alltogether.

inline_elemental_functions(routine)

Replaces InlineCall expression to elemental functions with the called functions body. This will attempt to resolve the elemental function into a single expression and perform a direct replacement at expression level.

Note, that InlineCall.function.type is used to determine if a function cal be inlined. For functions imported via module use statements. This implies that the module needs to be provided in the definitions argument to the original Subroutine constructor.

inline_member_procedures(routine)

Inline all member subroutines contained in an individual Subroutine.

Please note that member functions are not yet supported!

Parameters:

routine (Subroutine) – The subroutine in which to inline all member routines