loki.transformations.inline
Transformations sub-package that provides various forms of source-level code inlining.
The various inline mechanisms are provided as standalone utility methods,
or via the InlineTransformation
class for for batch processing.
Classes
|
|
- class InlineTransformation(inline_constants=False, inline_elementals=True, inline_stmt_funcs=False, inline_internals=False, inline_marked=True, remove_dead_code=True, allowed_aliases=None, adjust_imports=True, external_only=True, resolve_sequence_association=False)
Bases:
Transformation
Transformation
class to apply several types of source inlining when batch-processing large source trees via theScheduler
.- Parameters:
inline_constants (bool) – Replace instances of variables with known constant values by
Literal
(seeinline_constant_parameters
); default: False.inline_elementals (bool) – Replaces
InlineCall
expression to elemental functions with the called function’s body (seeinline_elemental_functions
); default: True.inline_stmt_funcs (bool) – Replaces
InlineCall
expression to statement functions with the corresponding rhs of the statement function if the statement function declaration is available; default: False.inline_internals (bool) – Inline internal procedure (see
inline_internal_procedures
); default: False.inline_marked (bool) – Inline
Subroutine
objects marked by pragma annotations (seeinline_marked_subroutines
); default: True.remove_dead_code (bool) – Perform dead code elimination, where unreachable branches are trimmed from the code (see
dead_code_elimination
); default: Trueallowed_aliases (tuple or list of str or
Expression
, optional) – List of variables that will not be renamed in the parent scope during internal and pragma-driven inlining.adjust_imports (bool) – Adjust imports by removing the symbol of the inlined routine or adding imports needed by the imported routine (optional, default: True)
external_only (bool, optional) – Do not replace variables declared in the local scope when inlining constants (default: True)
resolve_sequence_association (bool) – Resolve sequence association for routines that contain calls to inline (default: False)
- reverse_traversal = True
- creates_items = False
- transform_subroutine(routine, **kwargs)
Defines the transformation to apply to
Subroutine
items.For transformations that modify
Subroutine
objects, this method should be implemented. It gets called via the dispatch methodapply()
.- Parameters:
routine (
Subroutine
) – The subroutine to be transformed.**kwargs (optional) – Keyword arguments for the transformation.
Modules