aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/transforms/ConstantPropagation.scala
diff options
context:
space:
mode:
authorJack Koenig2020-09-14 19:43:01 -0700
committerGitHub2020-09-15 02:43:01 +0000
commit0c646459b52394e8a388143cee324b8af3dc7c09 (patch)
tree2a346a8669a48ae8ddba72488686f5cc70e98383 /src/main/scala/firrtl/transforms/ConstantPropagation.scala
parent5f410f0e4774121932d644f31fde83b9b8ed78be (diff)
Don't use ResolvedAnnotationPaths in ConstProp nor DCE (#1896)
Both use EliminateTargetPaths to duplicate modules based on annotations. Currently, EliminateTargetPaths API is a little too limited so it duplicates more than it should which effectively breaks Dedup whenever DontTouchAnnotations are present. Also, make ConstProp and DCE treat all HasDontTouches as local annotations even if they are instance annotations. This is more conservative but it is generally better to preserve deduplication than to maximally optimize every instance. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main/scala/firrtl/transforms/ConstantPropagation.scala')
-rw-r--r--src/main/scala/firrtl/transforms/ConstantPropagation.scala16
1 files changed, 8 insertions, 8 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