Skip to content

Commit

Permalink
Speed up ExpandWhens for very large designs (#1666)
Browse files Browse the repository at this point in the history
Use WrappedExpression instead of MemoizedHash. The benefit of memoizing
the hash pales in comparison to the cost of hashing deeply nested Types
in the AST.

Co-authored-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
  • Loading branch information
jackkoenig and seldridge authored Jun 9, 2020
1 parent 14099e1 commit bffc340
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/scala/firrtl/passes/ExpandWhens.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ object ExpandWhens extends Pass {
}

/** Maps an expression to a declared node name. Used to memoize predicates */
@deprecated("This will be removed in FIRRTL 1.4.0", "FIRRTL 1.3.2")
type NodeMap = mutable.HashMap[MemoizedHash[Expression], String]

private type NodeLookup = mutable.HashMap[WrappedExpression, String]

/** Maps a reference to whatever connects to it. Used to resolve last connect semantics */
type Netlist = mutable.LinkedHashMap[WrappedExpression, Expression]

Expand Down Expand Up @@ -88,10 +91,10 @@ object ExpandWhens extends Pass {
val simlist = new Simlist

// Memoizes if an expression contains any WVoids inserted in this pass
val memoizedVoid = new mutable.HashSet[MemoizedHash[Expression]] += WVoid
val memoizedVoid = new mutable.HashSet[WrappedExpression] += WVoid

// Memoizes the node that holds a particular expression, if any
val nodes = new NodeMap
val nodes = new NodeLookup

// Seq of attaches in order
lazy val attaches = mutable.ArrayBuffer.empty[Attach]
Expand Down

0 comments on commit bffc340

Please # to comment.