[HWAggregateToComb] Mux of unions
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 524
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 46
Description
Consider the following `minimal.mlir` (compiled from SV):
```
module {
hw.module @demo(in %a : !hw.union, in %b : !hw.union, in %c : i1, out d : !hw.union) {
%0 = comb.mux %c, %a, %b : !hw.union
hw.output %0 : !hw.union
}
}
```
`circt-opt minimal.mlir --aggregate-to-comb` fails with
```
minimal.mlir:3:10: error: failed to legalize operation 'comb.mux' that was explicitly marked illegal: %0 = "comb.mux"(%arg2, %arg0, %arg1) : (i1, !hw.union, !hw.union) -> !hw.union
%0 = comb.mux %c, %a, %b : !hw.union
```
Muxes of `hw.struct` work fine.
If this is a bug/unimplemented feature then I'm happy to try to implement the fix myself, though some guidance on where to start would be great! If it's not a bug, advice on what I should be doing differently would be great also!
Thanks!
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the minimal.mlir reproducer and run circt-opt --aggregate-to-comb to confirm the failure. Trace the aggregate-to-comb handling of comb.mux, comparing the supported hw.struct case with the failing hw.union case. Done means the command successfully legalizes the union mux and the reproducer continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 66/100