-
Notifications
You must be signed in to change notification settings - Fork 382
[FIRRTL] Add InferDomains pass #8877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
e1ae48d
to
a17ada0
Compare
df67311
to
7e543de
Compare
a17ada0
to
f0512f4
Compare
Add a pass that does domain inference and checking. This is used to verify the legality of a FIRRTL circuit with respect to its domains. E.g., this pass is intended to be used for checking for illegal clock domain crossings. Signed-off-by: Schuyler Eldridge <[email protected]>
f0512f4
to
a12e326
Compare
std::unique_ptr<mlir::Pass> clonePass() const override { | ||
return std::make_unique<InferDomainsPass>(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to define clonePass?
// domains | ||
if (!op->getOperands().empty()) { | ||
Value firstOperand = op->getOperand(0); | ||
for (auto operand : op->getOperands()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop a first operand.
if (hasErrors) { | ||
signalPassFailure(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (hasErrors) { | |
signalPassFailure(); | |
} | |
if (hasErrors) | |
signalPassFailure(); |
// pointer comparison is only stable within a run of MLIR and should not be | ||
// relied upon for determinism outside of a run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't non-deterministic still visible outside soon after we attached ? I think you can sort by properlyDominate
// Set the merged domain sequence on the new representative | ||
if (!mergedDomains.empty()) { | ||
Value newRep = equivalenceClasses.getLeaderValue(rep1); | ||
concreteDomains[newRep] = mergedDomains; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this has a lifetime issue. mergedDomains
points to a reference to concreteDomains but concreteDomains[newRep] could grow capacity and invalidate the mergedDomains
. You might want to change the type concreateDomains
to DenseMap<Value, std::uninque_ptr<SmallVector<..>>>
.
if (isa<DomainType>(port.type)) { | ||
newDomainInfo.push_back(port.domains | ||
? port.domains | ||
: ArrayAttr::get(module.getContext(), {})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Please hoist empty array out of loop.
Add a pass that does domain inference and checking. This is used to verify the legality of a FIRRTL circuit with respect to its domains. E.g., this pass is intended to be used for checking for illegal clock domain crossings.