-
Notifications
You must be signed in to change notification settings - Fork 347
[LLHD] Add support for llhd.sig.array_get
projections to Mem2Reg
#8509
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
Conversation
llhd.halt | ||
} | ||
} | ||
|
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.
Maybe add tests for the following scenarios:
- Projected signal value is passed via block argument within a process (make sure it doesn't crash)
- Multiple projection ops refer to the same part of the original signal (make sure multiple drives to these different projections that refer to the same part update to the correct value)
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.
Ooops good idea, that's definitely missing from the tests. Let me add that.
// as any of their users. | ||
if (isa<SigArrayGetOp>(user)) { | ||
for (auto *projectionUser : user->getUsers()) { | ||
if (projectionUser->getBlock() != user->getBlock()) |
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.
Isn't that too restrictive for many practical cases due to CSE of projection ops? (not blocking)
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.
Yes that's a good point 👍. We should be able to relax this by only requiring that the projection op dominates its users. That would also allow projections in dominating predecessor blocks and in the module to be covered, but still allow us to not reason about signals references through block arguments (that'll be a mighty headache).
1d733ad
to
a59ef60
Compare
Extend the Mem2Reg pass to support drives to `llhd.sig.array_get` projections into a promotable signal. This requires a few changes: - When checking whether a signal is promotable, we have to recursively check its users and look through `llhd.sig.array_get` ops to see if all uses are safe for promotion. - The lattice used to propagate needed and reaching definitions has to track the projection being driven separately from the underlying root slot being driven. - A new set of helpers to unpack and pack stacks of projections help probes and drives take a promotable slot and its value, descend into subfields as indicated by a set of projection ops ("unpack"), and then optionally mutate the value of a subfield and zip the updated value back up to the promotable slot ("pack"). - During backward and forward propagation across the lattice, drives to projections have to create the need for a definition of the slot to be available because they have to take the slot's current value in order to mutate the projected field. - The functions that resolve definitions have to unpack a slot's value according to the projections between the probe and the slot. In case of a drive they also have to mutate the projected field value after unpacking and then pack everything back op in order to create a new reaching definition for the entire slot to be forwarded to readers. This commit also drops `slotOrder` in favor of a `promotable` set of values. The actual order of slots was never used.
a59ef60
to
f8bba03
Compare
Extend the Mem2Reg pass to support drives to
llhd.sig.array_get
projections into a promotable signal. This requires a few changes:When checking whether a signal is promotable, we have to recursively check its users and look through
llhd.sig.array_get
ops to see if all uses are safe for promotion.The lattice used to propagate needed and reaching definitions has to track the projection being driven separately from the underlying root slot being driven.
A new set of helpers to unpack and pack stacks of projections help probes and drives take a promotable slot and its value, descend into subfields as indicated by a set of projection ops ("unpack"), and then optionally mutate the value of a subfield and zip the updated value back up to the promotable slot ("pack").
During backward and forward propagation across the lattice, drives to projections have to create the need for a definition of the slot to be available because they have to take the slot's current value in order to mutate the projected field.
The functions that resolve definitions have to unpack a slot's value according to the projections between the probe and the slot. In case of a drive they also have to mutate the projected field value after unpacking and then pack everything back op in order to create a new reaching definition for the entire slot to be forwarded to readers.
This commit also drops
slotOrder
in favor of apromotable
set of values. The actual order of slots was never used.