-
Notifications
You must be signed in to change notification settings - Fork 383
[MooreToCore] Support slicing of nested arrays #9073
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
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.
Thanks a lot for finding and fixing this!
| if (auto resArrTy = dyn_cast<hw::ArrayType>(resultType)) { | ||
| if (auto resArrTy = dyn_cast<hw::ArrayType>(resultType); | ||
| resArrTy && arrayNestingLevel(resArrTy) == arrayNestingLevel(arrTy)) { |
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 remember @jpienaar fixing a similar issue for ExtractRefOp a few weeks ago:
Do you think we could use a similar way of checking for slicing vs. element access, by checking whether the arrType.getElementType() != resultType? That would avoid having to reason about nesting levels of arrays, and would turn this into a quick pointer equality check.
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.
That seems way better. I updated the code. Initially, I wasn't sure if there may be edge-cases I hadn't thought about. All tests pass though.
9261708 to
a4de7d6
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.
Really neat! π₯³ Thanks a lot. Will land this as soon as CI has run through.
Added a testcase that is the result of parsing the following sv code: ```sv module bug ( input logic [1:0][1:0][1:0] wr_addr, output logic [1:0] out ); assign out = wr_addr[0][0][1:0]; endmodule ``` The current MooreToCore pass translates the sv ode incorrectly to ``` hw.module @bug(in %wr_addr : !hw.array<2xarray<2xi2>>, out out : i2) { %false = hw.constant false %0 = builtin.unrealized_conversion_cast %wr_addr : !hw.array<2xarray<2xi2>> to !hw.array<2xi2> %1 = hw.array_get %0[%false] : !hw.array<2xi2>, i1 hw.output %1 : i2 } ``` Adding a check if operand and result array have the same level of nesting in the ExtractOpConversion fixes the bug.
a4de7d6 to
c5da9e1
Compare
|
Thanks! I rebased to head to resolve the conflict and pushed my branch again |
Added a testcase that is the result of parsing the following sv code:
The current MooreToCore pass translates the sv ode incorrectly to
Adding a check if operand and result array have the same level of nesting in the ExtractOpConversion fixes the bug.