mirror of https://github.com/llvm/circt.git
[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:
parent
0ff71625c6
commit
41dffd36cb
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue