Skip to content

IR: Refactoring and introduction of explicitly names "statement nodes"#656

Open
mlange05 wants to merge 16 commits intomainfrom
naml-ir-intrinsic-nodes
Open

IR: Refactoring and introduction of explicitly names "statement nodes"#656
mlange05 wants to merge 16 commits intomainfrom
naml-ir-intrinsic-nodes

Conversation

@mlange05
Copy link
Collaborator

@mlange05 mlange05 commented Mar 9, 2026

Note: This PR technically introduces an externally API-changing change, as it renames ir.Intrinsic -> ir.GenericStmt

This PR refactors the loki.ir.nodes source into a dedicated sub-package and introduces a new set of statement nodes that all inherit from loki.ir.nodes.GenericStmt. These replace previous ir.Intrinsic nodes (a misnomer from the early days 😉 ), which in turn allows us to refer to specific statement nodes explicitly by type (eg. ir.ImplicitStmt or ir.ContainsStmt). It is worth pointing out that I've only specialised CONTAINS, IMPLICIT, CYCLE, RETURN, GO TO, PUBLIC, PRIVATE thus far, but others could follow.

Pleas note also that the latter two now exist as dedicated node types, but I've not changed (yet) the internal mechanics of the Module that use this information.

In some more detail:

  • Moved IR utilities (including dataclass_strict to loki.tools
  • Separated loki.ir.nodes into sub-package with sources for abstract_nodes, internal_nodes and leaf_nodes
  • Renamed loki.ir.Intrinsic => loki.ir.GenericStmt
  • Added source for stmt_nodes to loki.ir.nodes and implemented ImplicitStmt, ContainsStmt, ReturnStmt, CycleStmt, GotoStmt, PrivateStmt and PublicStmt
  • Adjusted used of generic statement nodes in both code and test base
  • Consolidated some statement tests in ir.nodes.tests to capture new node types and avoid JIT
  • Some more import massaging in a test files that I had to touch anyway

@mlange05 mlange05 requested a review from reuterbal March 9, 2026 09:43
@github-actions
Copy link

github-actions bot commented Mar 9, 2026

Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/656/index.html

@mlange05 mlange05 force-pushed the naml-ir-intrinsic-nodes branch 2 times, most recently from 9f21857 to 7096f5e Compare March 9, 2026 11:05
@mlange05 mlange05 force-pushed the naml-ir-intrinsic-nodes branch 4 times, most recently from 660ab00 to cf50b27 Compare March 9, 2026 14:35
@mlange05 mlange05 force-pushed the naml-ir-intrinsic-nodes branch from cf50b27 to c705e00 Compare March 9, 2026 15:03
@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 95.72414% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.38%. Comparing base (b711b95) to head (da12fe7).

Files with missing lines Patch % Lines
loki/ir/nodes/stmt_nodes.py 90.21% 9 Missing ⚠️
loki/ir/nodes/abstract_nodes.py 92.92% 8 Missing ⚠️
loki/ir/nodes/internal_nodes.py 95.53% 8 Missing ⚠️
loki/frontend/fparser.py 95.34% 2 Missing ⚠️
loki/frontend/omni.py 91.30% 2 Missing ⚠️
loki/tests/test_sourcefile.py 93.10% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #656      +/-   ##
==========================================
- Coverage   96.39%   96.38%   -0.02%     
==========================================
  Files         266      271       +5     
  Lines       46418    46567     +149     
==========================================
+ Hits        44745    44883     +138     
- Misses       1673     1684      +11     
Flag Coverage Δ
lint_rules 96.38% <100.00%> (-0.03%) ⬇️
loki 96.38% <95.68%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mlange05 mlange05 force-pushed the naml-ir-intrinsic-nodes branch from 51a2cda to da12fe7 Compare March 9, 2026 16:52
@mlange05 mlange05 marked this pull request as ready for review March 9, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant