circt
circt copied to clipboard
[HandshakeToDC] Add pack/unpack lowering patterns
Adds lowering patterns for handshake.pack/unpack to DC. For the actual (data-side) tuple operations, hw.structs are used. This is purely for pragmatic reasons; Firstly, hw.struct is for all intents and purposes a generic struct type. Secondly, we don't want data-only operations to leak into DC.
This is entirely for lowering handshake.func args to a tuple? If so, why not use a struct with field names matching the arg names?
@teqdruid what struct type? hw.struct? If so, you know my opinion about that :)
hw.struct is the struct type in CIRCT and both Handshake and DC are in CIRCT. It's the practical choice. And it's not tied to hardware in any particular semantic -- just the name. We wouldn't have it there if there was a struct type upstream we could use!
I think keeping the argument names around is more important than dialect name purity. And I know you share my aversion to duplicating stuff in each dialect.
Plus, there's an argument to be made that there's nothing in the hw or comb dialects that are specifically tied to hardware.
Plus, there's an argument to be made that there's nothing in the hw or comb dialects that are specifically tied to hardware.
... except for - for the former - the dialect name itself 🙂.
You have a good point, hw.struct is - if we ignore the dialect prefix - an overall more well suited type for this than tuple.
Side note: There was some discussion at EuroLLVM about introducing a general dialect to model struct types in MLIR. There are multiple places where this would be helpful, i.e., Flang, LLVM dialect, CIR, and CIRCT. I'm not sure what the status of this is, but it might make sense to try and raise this properly on discourse.
@teqdruid updated the PR s.t. this is now strictly a HandshakeToDC PR, which uses hw.struct.