-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIRRTL] Inliner: Support for ops with regions. #7398
[FIRRTL] Inliner: Support for ops with regions. #7398
Conversation
e7ce11d
to
5d819f4
Compare
There's some follow-up commits too, but may be useful to look through this before the the "format" commit, most of the changes are here: f6e254b . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Some nits/comments throughout.
TypeSwitch<Operation *, LogicalResult>(&sourceWithRegions) | ||
.Case<LayerBlockOp, WhenOp, MatchOp>([&](auto op) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love TypeSwitch
. However, this can avoid one level of nesting with an isa
given that this is only two cases: (1) layer block/when/match and (2) error.
firrtl.matchingconnect %c_i, %i : !firrtl.uint<8> | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rejection of layerblock inlining is fine for now. 👍 There are some situations where it could be legal or could be fixed up like you've suggested before.
firrtl.matchingconnect %c_cond, %cond : !firrtl.uint<1> | ||
firrtl.ref.define %o, %c_p : !firrtl.probe<uint<8>, @I::@J> | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are a tad large. It may be better to factor this into narrower tests of features. E.g., just inlining into a layerblock of a trivial module. There are also a lot of operations which could be pruned, e.g., invalid connections.
inlineInstances/flattenInstances: * Walk entire body, not only top-level operations. Fixes missing instances and allows inlining them when conservatively legal. * Reject inlining instances under when/match. inlineInto/flattenInto: Walk entire body using new `inliningWalk` method that drives the per-operations handling but also handles cloning "structure" operations that have regions (when/match/layer) and managing what should be cloned where. This allows inlining modules that contain these operations. Inliner now may produce errors, thread throughout. This allows the inliner to run earlier in the pipeline, particularly before LowerLayers.
5d819f4
to
a645ea6
Compare
Does a bit more redundant work than needed in the tight loop re:cloning individual (regionless) operations, but avoids some tricky flow re:break and re-checking termination condition.
inlineInstances/flattenInstances:
Fixes missing instances and allows inlining them
when conservatively legal.
inlineInto/flattenInto:
Walk entire body using new
inliningWalk
methodthat drives the per-operations handling but also
handles cloning "structure" operations that have
regions (when/match/layer) and managing what
should be cloned where.
This allows inlining modules that contain these
operations.
Inliner now may produce errors, thread throughout.
This allows the inliner to run earlier in the pipeline,
particularly before LowerLayers.