circt icon indicating copy to clipboard operation
circt copied to clipboard

[HandshakeToDC] Add pack/unpack lowering patterns

Open mortbopet opened this issue 1 year ago • 6 comments

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.

mortbopet avatar Apr 22 '24 09:04 mortbopet

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 avatar Apr 22 '24 21:04 teqdruid

@teqdruid what struct type? hw.struct? If so, you know my opinion about that :)

mortbopet avatar Apr 23 '24 08:04 mortbopet

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.

teqdruid avatar Apr 23 '24 08:04 teqdruid

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.

mortbopet avatar Apr 25 '24 14:04 mortbopet

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.

Dinistro avatar Apr 26 '24 07:04 Dinistro

@teqdruid updated the PR s.t. this is now strictly a HandshakeToDC PR, which uses hw.struct.

mortbopet avatar Apr 26 '24 12:04 mortbopet