[Sim] Add sim.assoc_array.clear op - #10996
Conversation
|
I'm afraid I don't quite understand the purpose of this operation. We're treating associative arrays (and other dynamic containers) as immutable values in the Sim dialect. So, what would be the benefit of |
I have listed a couple reasons for the addition (mainly for lowering and the convenience it will provide for later work):
|
fabianschuiki
left a comment
There was a problem hiding this comment.
I agree with @fzi-hielscher: this feels like it's just empty with an unused operand. I think what you're going for is the ability to emit a table.clear() in Verilog. If that's the case, you might be able to just emit table.clear() when you see an assignment of sim.assoc_array.empty to an assoc array sv.reg. The conversion from sim.assoc_array.* ops to the in-place mutation that SV provides feels like a pattern similar to MLIR's Bufferization pass. Not that we need to use that pass, but it might contain a few ideas worth stealing. They probably also have a pattern of turning an empty buffer into a memset on the allocated storage 🤔
|
I agree with @fzi-hielscher and @fabianschuiki. sim.assoc_array.clear doesn't look compose well in core dialect representation. I think it's reasonable addition for SV dialect though. |
|
Thank you @fzi-hielscher @fabianschuiki @uenoku for the feedback on this. I'll abandon this PR/change. I think i'll branch off on @uenoku suggestion to have a dedicatd So something like: emits lke: |
|
We might prefer straightforward representation for SV based on SV spec ( |
Thanks, i didn't catch that indexes were optional in the spec for that. That gives us a nice two-in-one operation! |
Adds
sim.assoc_array.clear, which returns and empty associative array of the same type as its input. This work is part of ongoing work to add simulation hashtable support within CIRCT. An explicit operation is the cleaner choice here than pattern-matching a whole array store in the emitter because it gives the lowering a single anchor for the places a table gets emptied from (e.g. reset, a clear port).