[FIRRTL] Remove "weak" annotated ports

Modify FIRRTL's RemoveUnusedPorts pass to remove ports that have only
"weak" annotations.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
This commit is contained in:
Schuyler Eldridge 2023-09-25 22:32:03 -04:00
parent 43e143c8ac
commit cc940668e1
No known key found for this signature in database
GPG Key ID: 50C5E9936AAD536D
2 changed files with 57 additions and 1 deletions

View File

@ -68,7 +68,8 @@ void RemoveUnusedPortsPass::removeUnusedModulePorts(
// If the port is don't touch or has unprocessed annotations, we cannot
// remove the port. Maybe we can allow annotations though.
if ((hasDontTouch(arg) || !port.annotations.empty()) && !ignoreDontTouch)
if ((hasDontTouch(arg) || !port.annotations.canBeDeleted()) &&
!ignoreDontTouch)
continue;
// TODO: Handle inout ports.

View File

@ -180,3 +180,58 @@ firrtl.circuit "UnusedOutput" {
firrtl.strictconnect %b, %singleDriver_b : !firrtl.uint<1>
}
}
// -----
// OMIR annotations should not block removal.
// - See: https://github.com/llvm/circt/issues/6199
//
// CHECK-LABEL: firrtl.circuit "OMIRRemoval"
firrtl.circuit "OMIRRemoval" {
// CHECK-NOT: %a
// CHECK-NOT: %b
// CHECK-NOT: %c
// CHECK: %d
firrtl.module private @Foo(
out %a: !firrtl.uint<1> [
{
class = "freechips.rocketchip.objectmodel.OMIRTracker",
id = 0 : i64,
type = "OMReferenceTarget"
}
],
out %b: !firrtl.uint<2> [
{
class = "freechips.rocketchip.objectmodel.OMIRTracker",
id = 1 : i64,
type = "OMMemberReferenceTarget"
}
],
in %c: !firrtl.uint<3> [
{
class = "freechips.rocketchip.objectmodel.OMIRTracker",
id = 3 : i64,
type = "OMMemberInstanceTarget"
}
],
in %d: !firrtl.uint<4> [
{
class = "freechips.rocketchip.objectmodel.OMIRTracker",
id = 4 : i64,
type = "OMMemberInstanceTarget"
},
// Adding one additional annotation will block removal.
{
class = "circt.test"
}
]
) {}
firrtl.module @OMIRRemoval() {
%foo_a, %foo_b, %foo_c, %foo_d = firrtl.instance foo @Foo(
out a: !firrtl.uint<1>,
out b: !firrtl.uint<2>,
in c: !firrtl.uint<3>,
in d: !firrtl.uint<4>
)
}
}