From 6426b4afe6ef57797340b235c774baec05862869 Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 12 Feb 2020 16:19:54 -0500 Subject: Record self-renames in RenameMap, distinct renames Change the behavior of RenameMap.completeTarget so that self-renames do not silently *not* happen. Previously, requests to self-rename would be ignored unless they were packaged in a sequences of renames that included a self-rename. Change renames to be recorded distinctly so that multiple requests to rename to the same thing will now deduplicate. Previously, these renames would be recorded multiple times. This change was required because allowing self-renames exposed a bug in InferWidthsAnnosSpec due to multiple renames. These changes benefit the situation where you rightly want to do a self-rename. Namely, when doing module duplication (with the EliminateTargetPaths transform). Signed-off-by: Schuyler Eldridge Do not record the same rename multiple times Signed-off-by: Schuyler Eldridge --- src/main/scala/firrtl/RenameMap.scala | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/main/scala/firrtl/RenameMap.scala b/src/main/scala/firrtl/RenameMap.scala index 03f01991..ffb7acc2 100644 --- a/src/main/scala/firrtl/RenameMap.scala +++ b/src/main/scala/firrtl/RenameMap.scala @@ -484,19 +484,15 @@ final class RenameMap private (val underlying: mutable.HashMap[CompleteTarget, S * @param tos */ private def completeRename(from: CompleteTarget, tos: Seq[CompleteTarget]): Unit = { - (from, tos) match { - case (x, Seq(y)) if x == y => - case _ => - tos.foreach{recordSensitivity(from, _)} - val existing = underlying.getOrElse(from, Vector.empty) - val updated = existing ++ tos - underlying(from) = updated - getCache.clear() - traverseTokensCache.clear() - traverseHierarchyCache.clear() - traverseLeftCache.clear() - traverseRightCache.clear() - } + tos.foreach{recordSensitivity(from, _)} + val existing = underlying.getOrElse(from, Vector.empty) + val updated = (existing ++ tos).distinct + underlying(from) = updated + getCache.clear() + traverseTokensCache.clear() + traverseHierarchyCache.clear() + traverseLeftCache.clear() + traverseRightCache.clear() } /* DEPRECATED ACCESSOR/SETTOR METHODS WITH [[firrtl.ir.Named Named]] */ -- cgit v1.2.3