mirror of https://github.com/llvm/circt.git
[MSFT] Removing unused 'getInstance' calls
This was used to refer to dynamic instances, but this was replaced by the DynamicInstanceOp paradigm.
This commit is contained in:
parent
7fe80b6ac7
commit
1722fde995
|
@ -25,14 +25,7 @@
|
|||
|
||||
namespace circt {
|
||||
namespace msft {
|
||||
class InstanceOp;
|
||||
class MSFTModuleOp;
|
||||
|
||||
void registerMSFTPasses();
|
||||
|
||||
/// Find the instance in the instance hierarchy as specified by the instance
|
||||
/// names in 'path'.
|
||||
InstanceOp getInstance(MSFTModuleOp root, SymbolRefAttr path);
|
||||
} // namespace msft
|
||||
} // namespace circt
|
||||
|
||||
|
|
|
@ -61,14 +61,6 @@ with ir.Context() as ctx, ir.Location.unknown():
|
|||
print(path)
|
||||
# CHECK-NEXT: [#hw.innerNameRef<@top::@inst1>, #hw.innerNameRef<@MyWidget::@ext1>]
|
||||
|
||||
resolved_inst = msft.get_instance(top.operation,
|
||||
ir.Attribute.parse("@inst1::@ext1"))
|
||||
assert (resolved_inst == ext_inst.operation)
|
||||
|
||||
not_found_inst = msft.get_instance(top.operation,
|
||||
ir.Attribute.parse("@inst_none::@ext1"))
|
||||
assert (not_found_inst is None)
|
||||
|
||||
# CHECK: msft.module @MyWidget {} ()
|
||||
# CHECK: msft.output
|
||||
# CHECK: msft.module @msft_mod {WIDTH = 8 : i32} ()
|
||||
|
|
|
@ -121,8 +121,6 @@ void circt::python::populateDialectMSFTSubmodule(py::module &m) {
|
|||
|
||||
m.doc() = "MSFT dialect Python native extension";
|
||||
|
||||
m.def("get_instance", circtMSFTGetInstance, py::arg("root"), py::arg("path"));
|
||||
|
||||
py::enum_<PrimitiveType>(m, "PrimitiveType")
|
||||
.value("M20K", PrimitiveType::M20K)
|
||||
.value("DSP", PrimitiveType::DSP)
|
||||
|
|
|
@ -181,9 +181,3 @@ MlirAttribute circtMSFTPhysicalBoundsAttrGet(MlirContext cContext,
|
|||
auto *context = unwrap(cContext);
|
||||
return wrap(PhysicalBoundsAttr::get(context, xMin, xMax, yMin, yMax));
|
||||
}
|
||||
|
||||
MlirOperation circtMSFTGetInstance(MlirOperation cRoot, MlirAttribute cPath) {
|
||||
auto root = cast<circt::msft::MSFTModuleOp>(unwrap(cRoot));
|
||||
auto path = unwrap(cPath).cast<SymbolRefAttr>();
|
||||
return wrap(getInstance(root, path));
|
||||
}
|
||||
|
|
|
@ -45,42 +45,5 @@ Operation *MSFTDialect::materializeConstant(OpBuilder &builder, Attribute value,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
static msft::InstanceOp getInstance(MSFTModuleOp root,
|
||||
ArrayRef<StringRef> path) {
|
||||
assert(!path.empty());
|
||||
|
||||
// Unfortunately, instance names are not symbols and modules are not symbol
|
||||
// tables, so we have to do a full walk.
|
||||
StringRef searchName = path[0];
|
||||
msft::InstanceOp match = nullptr;
|
||||
root.walk([&](msft::InstanceOp inst) {
|
||||
if (inst.instanceName() != searchName)
|
||||
return WalkResult::advance();
|
||||
match = inst;
|
||||
return WalkResult::interrupt();
|
||||
});
|
||||
if (!match)
|
||||
return nullptr;
|
||||
if (path.size() == 1)
|
||||
return match;
|
||||
|
||||
// We're not the leaf, so recurse.
|
||||
auto subPath = path.slice(1);
|
||||
Operation *submoduleOp = match.getReferencedModule();
|
||||
auto submodule = dyn_cast<msft::MSFTModuleOp>(submoduleOp);
|
||||
if (!submodule)
|
||||
return nullptr;
|
||||
return getInstance(submodule, subPath);
|
||||
}
|
||||
|
||||
msft::InstanceOp circt::msft::getInstance(MSFTModuleOp root,
|
||||
SymbolRefAttr pathAttr) {
|
||||
SmallVector<StringRef, 16> path;
|
||||
path.push_back(pathAttr.getRootReference().getValue());
|
||||
for (auto sym : pathAttr.getNestedReferences())
|
||||
path.push_back(sym.getValue());
|
||||
return ::getInstance(root, path);
|
||||
}
|
||||
|
||||
#include "circt/Dialect/MSFT/MSFTDialect.cpp.inc"
|
||||
#include "circt/Dialect/MSFT/MSFTEnums.cpp.inc"
|
||||
|
|
Loading…
Reference in New Issue