Skip to content

[FIRRTL][circt-reduce] Extend the FIRRTL LayerDisable reduction to strip enabled layers #10527

@seldridge

Description

@seldridge

Consider the following:

module {
  firrtl.circuit "Foo" {
    firrtl.layer @A bind attributes {output_file = #hw.output_file<"a/">, sym_visibility = "private"} {
      firrtl.layer @B bind attributes {output_file = #hw.output_file<"a/b/">} {
      }
      firrtl.layer @C bind attributes {output_file = #hw.output_file<"a/c/">} {
      }
    }
    firrtl.module @Foo() attributes {layers = [@A, @A::@B, @A::@C]} {
    }
  }
}

When run through circt-reduce, this could remove the layer enables, but it doesn't:

# circt-reduce -test /usr/bin/grep -test-arg '@Foo' reduced.1.mlir
All reduction strategies exhausted
Final size: 402 (0% reduction)
module {
  firrtl.circuit "Foo" {
    firrtl.layer @A bind attributes {output_file = #hw.output_file<"a/">, sym_visibility = "private"} {
      firrtl.layer @B bind attributes {output_file = #hw.output_file<"a/b/">} {
      }
      firrtl.layer @C bind attributes {output_file = #hw.output_file<"a/c/">} {
      }
    }
    firrtl.module @Foo() attributes {layers = [@A, @A::@B, @A::@C]} {
    }
  }
}

There already exists a LayerDisable reduction, but this doesn't apply to layer enables. Extend this (or add a new reduction) that removes this so the final output is:

module {
  firrtl.circuit "Foo" {
    firrtl.module @Foo() {
    }
  }
}

Metadata

Metadata

Assignees

Labels

FIRRTLInvolving the `firrtl` dialectReducerRelated to `circt-reduce`good first issueGood for newcomers

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions