diff options
| author | Jack Koenig | 2020-05-12 22:10:35 -0700 |
|---|---|---|
| committer | Jack Koenig | 2020-05-13 17:56:21 -0700 |
| commit | a15f65c8eeb032899928dcd19332225d2d7d0f16 (patch) | |
| tree | 2a7d7cfb2088a87f574400233570b42d2bed6544 /src | |
| parent | d6e3cd00aa1ec6faa898b50474b1f4c5deae0f79 (diff) | |
Use HashMap instead of LinkedHashMap in InferTypes
Do the same in CInferTypes
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/firrtl/passes/InferTypes.scala | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/main/scala/firrtl/passes/InferTypes.scala b/src/main/scala/firrtl/passes/InferTypes.scala index 78213f49..8910999e 100644 --- a/src/main/scala/firrtl/passes/InferTypes.scala +++ b/src/main/scala/firrtl/passes/InferTypes.scala @@ -12,8 +12,11 @@ object InferTypes extends Pass with PreservesAll[Transform] { override def prerequisites = Dependency(ResolveKinds) +: firrtl.stage.Forms.WorkingIR + @deprecated("This should never have been public", "1.3.2") type TypeMap = collection.mutable.LinkedHashMap[String, Type] + private type TypeLookup = collection.mutable.HashMap[String, Type] + def run(c: Circuit): Circuit = { val namespace = Namespace() val mtypes = (c.modules map (m => m.name -> module_type(m))).toMap @@ -36,7 +39,7 @@ object InferTypes extends Pass with PreservesAll[Transform] { } } - def infer_types_e(types: TypeMap)(e: Expression): Expression = + def infer_types_e(types: TypeLookup)(e: Expression): Expression = e map infer_types_e(types) match { case e: WRef => e copy (tpe = types(e.name)) case e: WSubField => e copy (tpe = field_type(e.expr.tpe, e.name)) @@ -48,7 +51,7 @@ object InferTypes extends Pass with PreservesAll[Transform] { case e @ (_: UIntLiteral | _: SIntLiteral) => e } - def infer_types_s(types: TypeMap)(s: Statement): Statement = s match { + def infer_types_s(types: TypeLookup)(s: Statement): Statement = s match { case sx: WDefInstance => val t = mtypes(sx.module) types(sx.name) = t @@ -73,14 +76,14 @@ object InferTypes extends Pass with PreservesAll[Transform] { case sx => sx map infer_types_s(types) map infer_types_e(types) } - def infer_types_p(types: TypeMap)(p: Port): Port = { + def infer_types_p(types: TypeLookup)(p: Port): Port = { val t = remove_unknowns(p.tpe) types(p.name) = t p copy (tpe = t) } def infer_types(m: DefModule): DefModule = { - val types = new TypeMap + val types = new TypeLookup m map infer_types_p(types) map infer_types_s(types) } @@ -92,12 +95,15 @@ object CInferTypes extends Pass with PreservesAll[Transform] { override def prerequisites = firrtl.stage.Forms.ChirrtlForm + @deprecated("This should never have been public", "1.3.2") type TypeMap = collection.mutable.LinkedHashMap[String, Type] + private type TypeLookup = collection.mutable.HashMap[String, Type] + def run(c: Circuit): Circuit = { val mtypes = (c.modules map (m => m.name -> module_type(m))).toMap - def infer_types_e(types: TypeMap)(e: Expression) : Expression = + def infer_types_e(types: TypeLookup)(e: Expression) : Expression = e map infer_types_e(types) match { case (e: Reference) => e copy (tpe = types.getOrElse(e.name, UnknownType)) case (e: SubField) => e copy (tpe = field_type(e.expr.tpe, e.name)) @@ -109,7 +115,7 @@ object CInferTypes extends Pass with PreservesAll[Transform] { case e @ (_: UIntLiteral | _: SIntLiteral) => e } - def infer_types_s(types: TypeMap)(s: Statement): Statement = s match { + def infer_types_s(types: TypeLookup)(s: Statement): Statement = s match { case sx: DefRegister => types(sx.name) = sx.tpe sx map infer_types_e(types) @@ -136,13 +142,13 @@ object CInferTypes extends Pass with PreservesAll[Transform] { case sx => sx map infer_types_s(types) map infer_types_e(types) } - def infer_types_p(types: TypeMap)(p: Port): Port = { + def infer_types_p(types: TypeLookup)(p: Port): Port = { types(p.name) = p.tpe p } def infer_types(m: DefModule): DefModule = { - val types = new TypeMap + val types = new TypeLookup m map infer_types_p(types) map infer_types_s(types) } |
