[FIRRTL] Elide domains of zero-width ports in LowerDomains
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 524
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 46
Description
Consider the following example, directly adapted from an existing lower-domains.mlir test:
firrtl.circuit "Foo" {
firrtl.domain @ClockDomain
firrtl.module private @ZeroWidthPort(
in %A: !firrtl.domain of @ClockDomain,
in %a: !firrtl.uint<0> domains [%A]
) {
}
firrtl.module @Foo() {}
}
Currently, this will lower the ZeroWidthPort module to the following. This keeps the domain information, but it is intentionally empty because LowerToHW will strip zero-width ports.
firrtl.module private @ZeroWidthPort(
in %A: !firrtl.class<@ClockDomain()>,
out %A_out: !firrtl.class<@ClockDomain_out(
in domainInfo_in: !firrtl.class<@ClockDomain()>,
out domainInfo_out: !firrtl.class<@ClockDomain()>,
in associations_in: !firrtl.list<path>,
out associations_out: !firrtl.list<path>
)>,
in %a: !firrtl.uint<0>
) {
%A_object = firrtl.object @ClockDomain_out(in domainInfo_in: !firrtl.class<@ClockDomain()>, out domainInfo_out: !firrtl.class<@ClockDomain()>, in associations_in: !firrtl.list<path>, out associations_out: !firrtl.list<path>)
%0 = firrtl.object.subfield %A_object[domainInfo_in] : !firrtl.class<@ClockDomain_out(in domainInfo_in: !firrtl.class<@ClockDomain()>, out domainInfo_out: !firrtl.class<@ClockDomain()>, in associations_in: !firrtl.list<path>, out associations_out: !firrtl.list<path>)>
firrtl.propassign %0, %A : !firrtl.class<@ClockDomain()>
%1 = firrtl.object.subfield %A_object[associations_in] : !firrtl.class<@ClockDomain_out(in domainInfo_in: !firrtl.class<@ClockDomain()>, out domainInfo_out: !firrtl.class<@ClockDomain()>, in associations_in: !firrtl.list<path>, out associations_out: !firrtl.list<path>)>
%2 = firrtl.list.create : !firrtl.list<path>
firrtl.propassign %1, %2 : !firrtl.list<path>
firrtl.propassign %A_out, %A_object : !firrtl.class<@ClockDomain_out(in domainInfo_in: !firrtl.class<@ClockDomain()>, out domainInfo_out: !firrtl.class<@ClockDomain()>, in associations_in: !firrtl.list<path>, out associations_out: !firrtl.list<path>)>
}
I've observed a handful of situations where there are private modules with lots of this going on, e.g., O(10) unused, inferred domains show up because there are lots of zero-width ports.
It would be better if truly unused domains could be stripped when they have no association information. This may motivate breaking the zero-width removal part of LowerToHW out to a pass that runs earlier in the FIRRTL to HW conversion pipeline.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the existing lower-domains.mlir test and trace the LowerDomains and LowerToHW passes that handle the zero-width port example. Determine where unused domains with no association information are retained, then verify that they are elided without removing domains that carry associations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100