Skip to content

Commit

Permalink
[HW] InnerSymbolTable: only check top-level ops for portlists
Browse files Browse the repository at this point in the history
This changes the inner symbol table to only check top-level operations
for portlists.  Trying to dyn_cast every single operation to PortList is
expensive, and is not a cost we have to pay when only module operations
have port lists.
  • Loading branch information
youngar committed Nov 2, 2024
1 parent 1fd4c9e commit 1dc931d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/Dialect/HW/InnerSymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ LogicalResult InnerSymbolTable::walkSymbols(Operation *op,
return success();
};

// Check for ports
if (auto mod = dyn_cast<PortList>(op)) {
for (auto [i, port] : llvm::enumerate(mod.getPortList())) {
if (auto symAttr = port.getSym())
if (failed(walkSyms(symAttr, InnerSymTarget(i, mod))))
return failure();
}
}

// Walk the operation and add InnerSymbolTarget's to the table.
return success(
!op->walk<mlir::WalkOrder::PreOrder>([&](Operation *curOp) -> WalkResult {
Expand All @@ -86,14 +95,6 @@ LogicalResult InnerSymbolTable::walkSymbols(Operation *op,
if (failed(walkSyms(symAttr, InnerSymTarget(symOp))))
return WalkResult::interrupt();

// Check for ports
if (auto mod = dyn_cast<PortList>(curOp)) {
for (auto [i, port] : llvm::enumerate(mod.getPortList())) {
if (auto symAttr = port.getSym())
if (failed(walkSyms(symAttr, InnerSymTarget(i, curOp))))
return WalkResult::interrupt();
}
}
return WalkResult::advance();
}).wasInterrupted());
}
Expand Down

0 comments on commit 1dc931d

Please sign in to comment.