diff options
| author | Jack Koenig | 2021-05-04 13:18:51 -0700 |
|---|---|---|
| committer | GitHub | 2021-05-04 13:18:51 -0700 |
| commit | 6db311b39b2330637e5bf47f308e68292eca1381 (patch) | |
| tree | 71e973127d36de379b16c94ad18442e2ff78ed83 /src/main | |
| parent | 7f70aefee953c39c13189824aff559de8580e481 (diff) | |
Make MustDeduplicateAnnotation deletable (#2215)
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/firrtl/transforms/MustDedup.scala | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/main/scala/firrtl/transforms/MustDedup.scala b/src/main/scala/firrtl/transforms/MustDedup.scala index 3e7629cd..0d2dd569 100644 --- a/src/main/scala/firrtl/transforms/MustDedup.scala +++ b/src/main/scala/firrtl/transforms/MustDedup.scala @@ -14,18 +14,21 @@ import firrtl.graph.DiGraph import java.io.{File, FileWriter} /** Marks modules as "must deduplicate" */ -case class MustDeduplicateAnnotation(modules: Seq[IsModule]) extends MultiTargetAnnotation { - def targets: Seq[Seq[IsModule]] = modules.map(Seq(_)) - - def duplicate(n: Seq[Seq[Target]]): MustDeduplicateAnnotation = { - val newModules = n.map { - case Seq(mod: IsModule) => mod - case _ => - val msg = "Something went wrong! This anno should only rename to single IsModules! " + - s"Got: $modules -> $n" - throw new Exception(msg) +case class MustDeduplicateAnnotation(modules: Seq[IsModule]) extends Annotation { + + def update(renames: RenameMap): Seq[MustDeduplicateAnnotation] = { + val newModules: Seq[IsModule] = modules.flatMap { m => + renames.get(m) match { + case None => Seq(m) + case Some(Seq()) => Seq() + case Some(Seq(one: IsModule)) => Seq(one) + case Some(many) => + val msg = "Something went wrong! This anno's targets should only rename to IsModules! " + + s"Got: ${m.serialize} -> ${many.map(_.serialize).mkString(", ")}" + throw new Exception(msg) + } } - MustDeduplicateAnnotation(newModules) + if (newModules.isEmpty) Seq() else Seq(this.copy(newModules)) } } |
