Skip to content

Commit

Permalink
[FIRRTL][SFCCompat] Fix behavior w/fullasyncreset on non-port.
Browse files Browse the repository at this point in the history
They are not limited to appearing on module ports.
Compute presence of full-async-reset accordingly,
and be sure to remove those annotations as well.
  • Loading branch information
dtzSiFive committed May 3, 2024
1 parent ccf5778 commit bef99bf
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/Dialect/FIRRTL/Transforms/SFCCompat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,22 @@ void SFCCompatPass::runOnOperation() {
bool madeModifications = false;
SmallVector<InvalidValueOp> invalidOps;

bool fullAsyncResetExists = false;
AnnotationSet::removePortAnnotations(
auto fullAsyncResetAttr =
StringAttr::get(&getContext(), fullAsyncResetAnnoClass);
auto isFullAsyncResetAnno = [fullAsyncResetAttr](Annotation anno) {
return anno.getClassAttr() == fullAsyncResetAttr;
};
bool fullAsyncResetExists = AnnotationSet::removePortAnnotations(
getOperation(), [&](unsigned argNum, Annotation anno) {
if (!anno.isClass(fullAsyncResetAnnoClass))
return false;
return fullAsyncResetExists = true;
return isFullAsyncResetAnno(anno);
});
if (!fullAsyncResetExists) {
getOperation()->walk([&](Operation *op) {
fullAsyncResetExists |=
AnnotationSet::removeAnnotations(op, isFullAsyncResetAnno);
});
}
madeModifications |= fullAsyncResetExists;

auto result = getOperation()->walk([&](Operation *op) {
// Populate invalidOps for later handling.
Expand Down

0 comments on commit bef99bf

Please sign in to comment.