[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 <schuyler.eldridge@sifive.com>
This commit is contained in:
Schuyler Eldridge 2023-09-25 18:43:40 -04:00
parent 0ff71625c6
commit 41dffd36cb
No known key found for this signature in database
GPG Key ID: 50C5E9936AAD536D
1 changed files with 2 additions and 13 deletions

View File

@ -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<StringAttr>("type");
return tpe &&
(tpe == "OMReferenceTarget" || tpe == "OMMemberReferenceTarget" ||
tpe == "OMMemberInstanceTarget");
}
namespace {
struct IMDeadCodeElimPass : public IMDeadCodeElimBase<IMDeadCodeElimPass> {
void runOnOperation() override;
@ -402,7 +391,7 @@ void IMDeadCodeElimPass::runOnOperation() {
hierPathOp =
symbolTable->template lookup<hw::HierPathOp>(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<FlatSymbolRefAttr>("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<hw::HierPathOp>(hierPathSym.getAttr());