9 #include "../PassDetails.h"
15 using namespace circt;
19 struct ESIAppIDHierPass :
public ESIAppIDHierBase<ESIAppIDHierPass> {
20 void runOnOperation()
override;
24 DenseMap<AppIDPathAttr, Block *> nodeBlock;
29 Block *getBlock(AppIDPathAttr path, ArrayRef<Operation *> opStack) {
30 Block *&block = nodeBlock[path];
35 if (path.getPath().empty()) {
36 auto rootOp = OpBuilder::atBlockEnd(getOperation().getBody())
39 block = &rootOp.getChildren().emplaceBlock();
41 Block *parentBlock = getBlock(path.getParent(), opStack.drop_back());
42 Operation *op = opStack.back();
43 if (
auto inst = dyn_cast<hw::InstanceOp>(op)) {
45 auto node = OpBuilder::atBlockEnd(parentBlock)
47 path.getPath().back(),
48 inst.getModuleNameAttr());
49 block = &node.getChildren().emplaceBlock();
59 void ESIAppIDHierPass::runOnOperation() {
60 auto mod = getOperation();
61 AppIDIndex index(mod);
63 return signalPassFailure();
66 LogicalResult rc = index.walk(
67 top, [&](AppIDPathAttr appidPath, ArrayRef<Operation *> opStack) {
68 assert(appidPath.getPath().size() == opStack.size() &&
69 "path and opStack must be the same size.");
70 auto *block = getBlock(appidPath, opStack);
71 auto *op = opStack.back();
72 if (isa<IsManifestData>(op))
73 OpBuilder::atBlockEnd(block).clone(*op);
76 return signalPassFailure();
80 return std::make_unique<ESIAppIDHierPass>();
assert(baseType &&"element must be base type")
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
std::unique_ptr< OperationPass< ModuleOp > > createESIAppIDHierPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.