From 41dffd36cbbf76346db3e4c9445f338edd91ae4c Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Mon, 25 Sep 2023 18:43:40 -0400 Subject: [PATCH] [FIRRTL] Use methods for IMDCE anno deletion, NFC Switch from a static method to annotation member functions to determine of a port with annotations can be deleted by IMDCE. Signed-off-by: Schuyler Eldridge --- lib/Dialect/FIRRTL/Transforms/IMDeadCodeElim.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/Dialect/FIRRTL/Transforms/IMDeadCodeElim.cpp b/lib/Dialect/FIRRTL/Transforms/IMDeadCodeElim.cpp index 7ce8e7ff15..a7cc6cac0b 100644 --- a/lib/Dialect/FIRRTL/Transforms/IMDeadCodeElim.cpp +++ b/lib/Dialect/FIRRTL/Transforms/IMDeadCodeElim.cpp @@ -46,17 +46,6 @@ static bool isDeletableDeclaration(Operation *op) { return !hasDontTouch(op) && AnnotationSet(op).empty(); } -/// Return true if the annotation is ok to drop when the target is dead. -static bool isWeakReferencingAnnotation(Annotation anno) { - if (!anno.isClass(omirTrackerAnnoClass)) - return false; - - auto tpe = anno.getMember("type"); - return tpe && - (tpe == "OMReferenceTarget" || tpe == "OMMemberReferenceTarget" || - tpe == "OMMemberInstanceTarget"); -} - namespace { struct IMDeadCodeElimPass : public IMDeadCodeElimBase { void runOnOperation() override; @@ -402,7 +391,7 @@ void IMDeadCodeElimPass::runOnOperation() { hierPathOp = symbolTable->template lookup(hierPathSym.getAttr()); - if (isWeakReferencingAnnotation(anno)) { + if (anno.canBeDeleted()) { if (hierPathOp && portId >= 0) hierPathToElements[hierPathOp].insert(module.getArgument(portId)); return false; @@ -554,7 +543,7 @@ void IMDeadCodeElimPass::rewriteModuleBody(FModuleOp module) { auto hierPathSym = anno.getMember("circt.nonlocal"); // We only clean up non-local annotations here as local annotations will // be deleted afterwards. - if (!isWeakReferencingAnnotation(anno) || !hierPathSym) + if (!anno.canBeDeleted() || !hierPathSym) return false; auto hierPathOp = symbolTable->template lookup(hierPathSym.getAttr());