loki.transform.transform_inline
Collection of utility routines to perform code-level force-inlining.
Functions
|
Replace instances of variables with known constant values by Literals. |
|
Replaces InlineCall expression to elemental functions with the called functions body. |
|
Inline all member subroutines contained in an individual |
|
Inline an individual member |
Classes
|
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