loki icon indicating copy to clipboard operation
loki copied to clipboard

Transformations: Re-organise `inline` and `extract` sub-packages

Open mlange05 opened this issue 5 months ago • 2 comments

This change creates two new separate transformation sub-packages loki.transformations.inline and loki.transformations.extract that are conceptual complements. For the inline sub-package, this allows us to separate the different types of inlining (constants, small functions and full procedures), and the associated tests. For "extract", this change brings together the two disparate current implementations (formerly extract_contained and region_to_call), and provides the counter-passes to the respective inlining operations as extract_internals and extract_marked. I've also added a wrapper ExtractTransformation class that provides both functionalities for batch processing.

Please note that, other than a minor bug-fix, I've left the implementations untouched. Further consolidation and additional features are planned, but I wanted to get the diff-heavy stuff out of the way first.

In some more detail:

  • Created separate loki.transformations.inline sub-package with constants/functions/mapper/procedures modules. Importantly, I also split the test accordingly and localised it!
  • Renamed extract_contained to extract_internals for consistency and created new loki.transformations.extract sub-package.
  • Renamed region_to_call to extract_marked and moved to loki.transformations.extract.
  • Added a new ExtractTransformation as batch-processing entry point. Importantly, this works on Module and Sourcefile objects only, as that defines where the newly created procedures go. Also added tests for this
  • A small bug-fix for extract_internals and a few linter-compliance fixes for the transformation standalone tests. (Turns out pylint does not recurse into test directories, as there is no automatic package import 😉 )

mlange05 avatar Sep 13 '24 07:09 mlange05