[HW] Align instance_like_impl verification with `getReferencedModule` (#6155)

Previously, `instance_like_impl::verifyReferencedModule` and `instance_like_impl::getReferencedModule` had different semantics for where the referenced module is located;

`getReferencedModule` uses the nearest `ModuleOp` as the target symbol table, whereas `verifyReferencedModule` uses the nearest symbol table. As a result, `verifyReferencedModule` fails if the `hw.instance` op is nested within another symbol table operation.

e.g. the following would fail:
```mlir
module {
  hw.module.extern @Foo()
  ibis.container @C { // could be any SymbolTable-defining op. Use builtin.module for simplicity.
    %this = ibis.this @C
      hw.instance "foo" @Foo() -> ()
  }
}
```
This commit is contained in:
Morten Borup Petersen 2023-09-21 09:46:58 +02:00 committed by GitHub
parent f52624565c
commit b2c56896bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -28,7 +28,7 @@ instance_like_impl::getReferencedModule(const HWSymbolCache *cache,
LogicalResult instance_like_impl::verifyReferencedModule(
Operation *instanceOp, SymbolTableCollection &symbolTable,
mlir::FlatSymbolRefAttr moduleName, Operation *&module) {
module = symbolTable.lookupNearestSymbolFrom(instanceOp, moduleName);
module = getReferencedModule(nullptr, instanceOp, moduleName);
if (module == nullptr)
return instanceOp->emitError("Cannot find module definition '")
<< moduleName.getValue() << "'";