Skip to content

[SV][HW][Sim] Rework (Non)ProceduralOp traits#10195

Merged
fzi-hielscher merged 4 commits intollvm:mainfrom
fzi-hielscher:nonprocreg
Apr 14, 2026
Merged

[SV][HW][Sim] Rework (Non)ProceduralOp traits#10195
fzi-hielscher merged 4 commits intollvm:mainfrom
fzi-hielscher:nonprocreg

Conversation

@fzi-hielscher
Copy link
Copy Markdown
Contributor

@fzi-hielscher fzi-hielscher commented Apr 13, 2026

Follow up #10180

This moves the ProcecduralOp and NonProceduralOp traits of the SV dialect to the CIRCT support library, adds them to operations of the HW and Sim dialects, and makes several changes to improve interaction with upstream dialects. The traits only affect operation verification. Compilation results should remain unchanged.

Previously, operations carrying the ProceduralOp trait were only permitted in regions where the immediate parent carried the ProceduralRegion trait. This made it impossible to use these operations in non-SV dialect regions, such as scf.if or func.func. To enable this, this PR makes three notable changes to the way these traits work:

  • Switch from a positive to a negative check. I.e.: A procedural operation must not be in a non-procedural region.
  • Add the NonProceduralRegion trait to mark these regions.
  • Let the verifier of the (Non)ProceduralOp trait look through parent operations which carry neither the ProceduralRegion nor the NonProceduralRegion trait, so these traits apply transitively.


LogicalResult verifyNotInProceduralRegion(Operation *op) {
auto *parent = op;
while ((parent = parent->getParentOp())) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change in behavior regarding the transitivity of unknown operations makes sense to me 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'm a bit concerned about the potential performance impact added by recursing over the parent ops. But I hope if we consistently apply the ProceduralRegion/NonProceduralRegion trait to the operations that we control, it shouldn't be noticeable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree this is negligible for our dialects in tree. It's possible for some users to create deeply nested scf.if etc but I think that's their responsibility not to do that.

@fzi-hielscher fzi-hielscher changed the title [Draft] Rework (Non)ProceduralOp traits [SV][HW][Sim] Rework (Non)ProceduralOp traits Apr 14, 2026
@fzi-hielscher fzi-hielscher marked this pull request as ready for review April 14, 2026 19:15
Copy link
Copy Markdown
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for going through all the existing code and fixing things up 💯 👍

@fzi-hielscher fzi-hielscher merged commit e0f3233 into llvm:main Apr 14, 2026
6 checks passed
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.

3 participants