From 39d76a02785f4391b67abd3b7d7720d287736312 Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Tue, 21 Apr 2020 22:41:23 -0400 Subject: Mixin DependencyAPIMigration to all Transforms This mixes in the new DependencyAPIMigration trait into all Transforms and Passes. This enables in-tree transforms/passes to build without deprecation warnings associated with the deprecated CircuitForm. As a consequence of this, every Transform now has UnknownForm as both its inputForm and outputForm. This PR modifies legacy Compiler and testing infrastructure to schedule transforms NOT using mergeTransforms/getLoweringTransforms (which rely on inputForm and outputForm not being UnknownForm), but instead using the Dependency API. Signed-off-by: Schuyler Eldridge --- .../scala/firrtl/transforms/GroupComponents.scala | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src/main/scala/firrtl/transforms/GroupComponents.scala') diff --git a/src/main/scala/firrtl/transforms/GroupComponents.scala b/src/main/scala/firrtl/transforms/GroupComponents.scala index 9e3d639d..083ddbb7 100644 --- a/src/main/scala/firrtl/transforms/GroupComponents.scala +++ b/src/main/scala/firrtl/transforms/GroupComponents.scala @@ -6,6 +6,7 @@ import firrtl.ir._ import firrtl.annotations.{Annotation, ComponentName} import firrtl.passes.{InferTypes, LowerTypes, ResolveKinds} import firrtl.graph.MutableDiGraph +import firrtl.stage.Forms import scala.collection.mutable @@ -44,11 +45,17 @@ case class GroupAnnotation(components: Seq[ComponentName], newModule: String, ne /** * Splits a module into multiple modules by grouping its components via [[GroupAnnotation]]'s */ -class GroupComponents extends firrtl.Transform { +class GroupComponents extends Transform with DependencyAPIMigration { type MSet[T] = mutable.Set[T] - def inputForm: CircuitForm = MidForm - def outputForm: CircuitForm = MidForm + override def prerequisites = Forms.MidForm + override def optionalPrerequisites = Seq.empty + override def dependents = Forms.MidEmitters + + override def invalidates(a: Transform): Boolean = a match { + case InferTypes | ResolveKinds => true + case _ => false + } override def execute(state: CircuitState): CircuitState = { val groups = state.annotations.collect {case g: GroupAnnotation => g} @@ -60,10 +67,7 @@ class GroupComponents extends firrtl.Transform { groupModule(m, module2group(m.name).filter(_.components.nonEmpty), mnamespace) case other => Seq(other) } - val cs = state.copy(circuit = state.circuit.copy(modules = newModules)) - /* @todo move ResolveKinds and InferTypes out */ - val csx = ResolveKinds.execute(InferTypes.execute(cs)) - csx + state.copy(circuit = state.circuit.copy(modules = newModules)) } def groupModule(m: Module, groups: Seq[GroupAnnotation], mnamespace: Namespace): Seq[Module] = { @@ -350,13 +354,11 @@ class GroupComponents extends firrtl.Transform { * Splits a module into multiple modules by grouping its components via [[GroupAnnotation]]'s * Tries to deduplicate the resulting circuit */ -class GroupAndDedup extends Transform { - def inputForm: CircuitForm = MidForm - def outputForm: CircuitForm = MidForm +class GroupAndDedup extends GroupComponents { - override def execute(state: CircuitState): CircuitState = { - val cs = new GroupComponents().execute(state) - val csx = new DedupModules().execute(cs) - csx + override def invalidates(a: Transform): Boolean = a match { + case _: DedupModules => true + case _ => super.invalidates(a) } + } -- cgit v1.2.3