-
Notifications
You must be signed in to change notification settings - Fork 299
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
[SV][Prepare] Improve a namehint propagation and spilling logic #4261
Conversation
7e0e830
to
b5844c2
Compare
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'm not sure about the change to PrepareForEmission, but the update in the wire canonicalizer looks great. I think this is always going to be an improvement, but I do wonder what about if the existing expression already had a namehint. I guess the name of the wire is a "stronger" hint, so I think what you have here looks good.
@@ -615,8 +615,7 @@ bool EmittedExpressionStateManager::shouldSpillWireBasedOnState(Operation &op) { | |||
// If the operation is only used by an assignment, the op is already spilled | |||
// to a wire. | |||
if (op.hasOneUse() && | |||
isa<hw::OutputOp, sv::AssignOp, sv::BPAssignOp, sv::PAssignOp>( |
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.
Why was sv::PAssignOp
removed here? Is this maybe an unrelated change that snuck in? I wouldn't think this is required for this change.
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 is unrelated to the PR but it's necessary for name propagation improvement. I'll split a PR.
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.
It doesn't have to be a separate PR if it's related, I'm just curious why it is necessary here, since we are only updating the canonicalizer or wires.
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.
The condition was intended to avoid spilling same expressions twice by skipping expressions that have single use of assignments. Therefore an expression used by procedural assignments was not spilled to a wire. For example,
%0 = comb.add {sv.namehint = "good_name"}
sv.always .. {
sv.passign %reg, %0 : ..
}
In this case %0
was inlined to the assignment, but we want to create a wire for it.
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 see, so I think this makes sense then. In general, I guess it's all about tradeoffs, so trading off some inlining for better names sounds good to me.
Right, currently a name on a wire overwrites expressions's namehint. The intention is that the name on the wire is generally better than a namehint. I agree we might want to introduce a notion of priority of names. |
This implements a name hint propagation to a wire op canonicalization.
will be converted into
This also improves wire spilling logic by allowing expressions used only procedural assignments.