[Sim] Implement the lowering logic from sim.proc.print to the SV dialect#10172
Conversation
d2a978d to
5358f98
Compare
fzi-hielscher
left a comment
There was a problem hiding this comment.
It is generally not recommended to traverse def-use-chains within the dialect conversion framework, so an OpConversionPattern is not ideal for lowering the print operations. We should perform the lowering of sim.proc.print before doing the dialect conversion. I would suggest to:
- Find and convert the print operations
- Run Region DCE on the bodies of the affected
hw.triggeredops to remove the dangling formatting ops. - Run the dialect conversion
62e153a to
ee209ff
Compare
19f96ea to
4e6adb2
Compare
672d519 to
3911e4b
Compare
fabianschuiki
left a comment
There was a problem hiding this comment.
Really amazing effort @nanjo712 🥳, thanks for pushing this forward! One thing I noticed: you had this neatly tucked into the SimToSV conversion earlier, which feels like the right spot to convert a sim.proc.print op to sv.fwrite. Would it make sense to go back to that? That would eventually allow us to have SimTransforms not link against the SV dialect anymore -- all the patterns that touch both Sim and SV would live in the SimToSV conversion. WDYT?
91262c9 to
e314a09
Compare
That sounds reasonable. I must have misunderstood some of the previous reviews, sorry. |
e314a09 to
d0dae92
Compare
Yeah.. I now remember the problem with the SV procedural region trait : #7314 🫤 |
|
It would be great to have a unified trait for that! I wonder whether this could live somewhere in CIRCTSupport or so, since it seems to be mostly orthogonal to the actual dialects. WDYT @fzi-hielscher? |
|
Having a common trait would be great 🙏 I encountered this a few times in the past and it was really annoying to avoid. |
82c4417 to
dbf232d
Compare
Thanks for following up on this with #10180 and #10195. Given that, I plan to wait for #10195 to land before continuing this PR. Once that happens, I'll update the checking logic here to follow that design instead of preserving the current ad hoc restrictions. |
dbf232d to
7ac0123
Compare
uenoku
left a comment
There was a problem hiding this comment.
Could you split get_file lowering? I think it's better to get plain format string done first.
e57cf9e to
f18f480
Compare
This sounds reasonable. I have reduced the current PR to only handle the range without specified output streams. We can focus on this issue first. |
fzi-hielscher
left a comment
There was a problem hiding this comment.
Thanks for pursuing this, @nanjo712 👍
4b2f3ad to
1c83edc
Compare
fzi-hielscher
left a comment
There was a problem hiding this comment.
Thanks. The conversion LGTM. Could you change the sv.* ops in the test to HW and SCF ops, so they align with how the pass will be used in practice?
1c83edc to
7fc794c
Compare
That's resonable. Done. |
…ect. AI-assisted-by: OpenAI ChatGPT
7fc794c to
712394b
Compare
fzi-hielscher
left a comment
There was a problem hiding this comment.
Cool. 🥳 Thanks again for putting in the work.
Just one small thing and a request for the future: If you are making incremental changes due to review comments, please add commits to the PR instead of force-pushing the single commit. The commits get squashed before merging, and it helps me (and others) a lot to track which parts have changed and need re-review.
|
Thank you for your detailed review!
I understand. I wasn't very familiar with the squash mechanism before, sorry for any inconvenience it may have caused. |
24cde9e to
610adc7
Compare
610adc7 to
328cf80
Compare
This PR lowers
sim.proc.printto SystemVerilogsv.fwrite.It only handles the procedural form of print operations. Non-procedural
sim.printis expected to be converted first, for example by--sim-proceduralize.Split from #10146 .
AI-assisted-by: OpenAI ChatGPT