diff options
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/firrtl/transforms/ConstantPropagation.scala | 16 | ||||
| -rw-r--r-- | src/main/scala/firrtl/transforms/DeadCodeElimination.scala | 15 |
2 files changed, 14 insertions, 17 deletions
diff --git a/src/main/scala/firrtl/transforms/ConstantPropagation.scala b/src/main/scala/firrtl/transforms/ConstantPropagation.scala index dc9b2bbe..10e99beb 100644 --- a/src/main/scala/firrtl/transforms/ConstantPropagation.scala +++ b/src/main/scala/firrtl/transforms/ConstantPropagation.scala @@ -100,7 +100,7 @@ object ConstantPropagation { } -class ConstantPropagation extends Transform with DependencyAPIMigration with ResolvedAnnotationPaths { +class ConstantPropagation extends Transform with DependencyAPIMigration { import ConstantPropagation._ override def prerequisites = @@ -124,8 +124,6 @@ class ConstantPropagation extends Transform with DependencyAPIMigration with Res case _ => false } - override val annotationClasses: Traversable[Class[_]] = Seq(classOf[DontTouchAnnotation]) - sealed trait SimplifyBinaryOp { def matchingArgsValue(e: DoPrim, arg: Expression): Expression def apply(e: DoPrim): Expression = { @@ -841,13 +839,15 @@ class ConstantPropagation extends Transform with DependencyAPIMigration with Res } def execute(state: CircuitState): CircuitState = { - val dontTouchRTs = state.annotations.flatMap { - case anno: HasDontTouches => anno.dontTouches + val dontTouches: Seq[(OfModule, String)] = state.annotations.flatMap { + case anno: HasDontTouches => + anno.dontTouches + // We treat all ReferenceTargets as if they were local because of limitations of + // EliminateTargetPaths + .map(rt => OfModule(rt.encapsulatingModule) -> rt.ref) case o => Nil } - val dontTouches: Seq[(OfModule, String)] = dontTouchRTs.map { - case Target(_, Some(m), Seq(Ref(c))) => m.OfModule -> c - } + // Map from module name to component names val dontTouchMap: Map[OfModule, Set[String]] = dontTouches.groupBy(_._1).mapValues(_.map(_._2).toSet).toMap diff --git a/src/main/scala/firrtl/transforms/DeadCodeElimination.scala b/src/main/scala/firrtl/transforms/DeadCodeElimination.scala index fb1bd1f6..c9b42f8e 100644 --- a/src/main/scala/firrtl/transforms/DeadCodeElimination.scala +++ b/src/main/scala/firrtl/transforms/DeadCodeElimination.scala @@ -28,11 +28,7 @@ import collection.mutable * circumstances of their instantiation in their parent module, they will still not be removed. To * remove such modules, use the [[NoDedupAnnotation]] to prevent deduplication. */ -class DeadCodeElimination - extends Transform - with ResolvedAnnotationPaths - with RegisteredTransform - with DependencyAPIMigration { +class DeadCodeElimination extends Transform with RegisteredTransform with DependencyAPIMigration { override def prerequisites = firrtl.stage.Forms.LowForm ++ Seq( @@ -368,12 +364,13 @@ class DeadCodeElimination state.copy(circuit = newCircuit, renames = Some(renames)) } - override val annotationClasses: Traversable[Class[_]] = - Seq(classOf[DontTouchAnnotation], classOf[OptimizableExtModuleAnnotation]) - def execute(state: CircuitState): CircuitState = { val dontTouches: Seq[LogicNode] = state.annotations.flatMap { - case anno: HasDontTouches => anno.dontTouches.filter(_.isLocal).map(LogicNode(_)) + case anno: HasDontTouches => + anno.dontTouches + // We treat all ReferenceTargets as if they were local because of limitations of + // EliminateTargetPaths + .map(rt => LogicNode(rt.encapsulatingModule, rt.ref)) case o => Nil } val doTouchExtMods: Seq[String] = state.annotations.collect { |
