[FIRRTL] Remove "weak" annotated in IMCP

Change FIRRTL's inter-module constant propagation (IMCP) pass to remove
things which have constants driven through them and have "weak"
annotations.  These annotations are currently limited to Object Model (OM)
annotations of specific types.

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

View File

@ -57,7 +57,7 @@ static bool isDeletableWireOrRegOrNode(Operation *op) {
return true;
// Otherwise, don't delete if has anything keeping it around or unknown.
return AnnotationSet(op).empty() && !hasDontTouch(op) &&
return AnnotationSet(op).canBeDeleted() && !hasDontTouch(op) &&
hasDroppableName(op) && !cast<Forceable>(op).isForceable();
}

View File

@ -880,3 +880,73 @@ firrtl.circuit "RefSubOpPropagate" {
// CHECK-NEXT: }
}
}
// -----
// OMIR annotation should not block removal.
// - See: https://github.com/llvm/circt/issues/6199
//
// CHECK-LABEL: firrtl.circuit "OMIRRemoval"
firrtl.circuit "OMIRRemoval" {
firrtl.module @OMIRRemoval(
out %a: !firrtl.uint<1>,
out %b: !firrtl.uint<2>,
out %c: !firrtl.uint<3>,
out %d: !firrtl.uint<4>
) {
%c1_ui1 = firrtl.constant 1 : !firrtl.uint<1>
%c3_ui2 = firrtl.constant 3 : !firrtl.uint<2>
%c7_ui3 = firrtl.constant 7 : !firrtl.uint<3>
%c15_ui4 = firrtl.constant 15 : !firrtl.uint<4>
// CHECK-NOT: %tmp_0
%tmp_0 = firrtl.node %c1_ui1 {
annotations = [
{
class = "freechips.rocketchip.objectmodel.OMIRTracker",
id = 0 : i64,
type = "OMReferenceTarget"
}
]} : !firrtl.uint<1>
firrtl.strictconnect %a, %tmp_0 : !firrtl.uint<1>
// CHECK-NOT: %tmp_1
%tmp_1 = firrtl.node %c3_ui2 {
annotations = [
{
class = "freechips.rocketchip.objectmodel.OMIRTracker",
id = 1 : i64,
type = "OMMemberReferenceTarget"
}
]} : !firrtl.uint<2>
firrtl.strictconnect %b, %tmp_1 : !firrtl.uint<2>
// CHECK-NOT: %tmp_2
%tmp_2 = firrtl.node %c7_ui3 {
annotations = [
{
class = "freechips.rocketchip.objectmodel.OMIRTracker",
id = 3 : i64,
type = "OMMemberInstanceTarget"
}
]} : !firrtl.uint<3>
firrtl.strictconnect %c, %tmp_2 : !firrtl.uint<3>
// Adding one additional annotation will block removal.
//
// CHECK: %tmp_3
%tmp_3 = firrtl.node %c15_ui4 {
annotations = [
{
class = "freechips.rocketchip.objectmodel.OMIRTracker",
id = 4 : i64,
type = "OMReferenceTarget"
},
{
class = "circt.test"
}
]} : !firrtl.uint<4>
// CHECK-NEXT: firrtl.strictconnect %d, %c15_ui4
firrtl.strictconnect %d, %tmp_3 : !firrtl.uint<4>
}
}