Skip to content

Conversation

seldridge
Copy link
Member

This is an experimental approach to add domains to FIRRTL. This approach
sees what it looks like to put domain information into the MLIR type
system.

This gets very funky, very quickly because this is doing many things which
are very against the ethos of MLIR:

  1. Some types have symbol storage.
  2. Some types have inner symbol storage.

(2) is specifically working around the fact that MLIR provides no built-in
way to associate a value to a type. (There are good reasons for this!)

This will be contrasted with a future approach that does an association of
domain information on a per-operation basis.

This is broken up into the following logical commits:

  • [FIRRTL] Add firrtl.domain
  • [FIRRTL] Add firrtl.domain type
  • [FIRRTL] Add domain information to types
  • [FIRRTL] Canonicalize domains on scalar types

Add a new `firrtl.domain` op which defines the existence of a kind of
domain.  E.g., this can be used to declare abstract notions of a clock or
reset domain.

Signed-off-by: Schuyler Eldridge <[email protected]>
Add a dedicate type for representing a value of a declared domain.  This
is working towards being able to represent user-defined domains in FIRRTL
and eventually in Chisel.

Signed-off-by: Schuyler Eldridge <[email protected]>
Add domain information to some FIRRTL types: UInt, SInt, and Analog.  The
MLIR representation of FIRRTL Dialect now supports all of the following:

``` mlir
!firrtl.uint<1>
!firrtl.uint<1, []>
!firrtl.uint<1, [@A]>
!firrtl.uint<1, [@A, @b]>
```

Note: this should be extended in the future to be on all base types or on
all types.  When doing this extension, we will need to figure out how to
handle bundles where there are redundant encodings for types (which is a
huge red flag if allowed).

Signed-off-by: Schuyler Eldridge <[email protected]>
For scalar types which currently support domains (UInt, SInt, and Analog),
canonicalize their domains in their backing storage.  Specifically, sort
and unique the domains.  This means that domains will be stored
alphabetically and no duplicates will be allowed.

This is done to enable trivial pointer comparisons between types and not
require deep introspection to know if two types are the same.  This does
not, yet solve the problem of canonicalization involving aggregates whose
leaves may contain domains.

Aside: this will not run into the same problems that the mythological "flip
type canonicalization" effort ran into.  There are no operations which
care about the order of domains.  We are free to rearrange them as we want.

Signed-off-by: Schuyler Eldridge <[email protected]>
@seldridge
Copy link
Member Author

Closed in favor or #8843.

@seldridge seldridge closed this Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant