diff options
| author | Albert Magyar | 2020-03-24 19:29:06 -0700 |
|---|---|---|
| committer | Albert Magyar | 2020-03-30 12:09:07 -0700 |
| commit | b2ec0c378b99556503aaf6d1d7324d3e3d7c8b73 (patch) | |
| tree | bdf8f3878fa7d9388df1c90e6293dd466eafa65f /src | |
| parent | d879a36237bb8bb67bd9eb5e417ac630ebaadd7f (diff) | |
Avoid generating illegal part-selects in InlineCasts
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/firrtl/transforms/InlineCasts.scala | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/main/scala/firrtl/transforms/InlineCasts.scala b/src/main/scala/firrtl/transforms/InlineCasts.scala index 2ebee225..59520228 100644 --- a/src/main/scala/firrtl/transforms/InlineCasts.scala +++ b/src/main/scala/firrtl/transforms/InlineCasts.scala @@ -5,9 +5,10 @@ package transforms import firrtl.ir._ import firrtl.Mappers._ +import firrtl.PrimOps.Pad import firrtl.options.{Dependency, PreservesAll} -import firrtl.Utils.{isCast, NodeMap} +import firrtl.Utils.{isCast, isBitExtract, NodeMap} object InlineCastsTransform { @@ -27,16 +28,18 @@ object InlineCastsTransform { * @param expr the Expression being transformed * @return Returns expr with [[WRef]]s replaced by values found in replace */ - def onExpr(replace: NodeMap)(expr: Expression): Expression = { - expr.map(onExpr(replace)) match { + def onExpr(replace: NodeMap)(expr: Expression): Expression = expr match { + // Anything that may generate a part-select should not be inlined! + case DoPrim(op, _, _, _) if (isBitExtract(op) || op == Pad) => expr + case e => e.map(onExpr(replace)) match { case e @ WRef(name, _,_,_) => replace.get(name) - .filter(isSimpleCast(castSeen=false)) - .getOrElse(e) + .filter(isSimpleCast(castSeen=false)) + .getOrElse(e) case e @ DoPrim(op, Seq(WRef(name, _,_,_)), _,_) if isCast(op) => replace.get(name) - .map(value => e.copy(args = Seq(value))) - .getOrElse(e) + .map(value => e.copy(args = Seq(value))) + .getOrElse(e) case other => other // Not a candidate } } |
