diff options
| author | albertchen-sifive | 2018-07-20 14:36:30 -0700 |
|---|---|---|
| committer | Adam Izraelevitz | 2018-07-20 14:36:30 -0700 |
| commit | 7dff927840a30893facae957595a8e88ea62509a (patch) | |
| tree | 08210d9b2936fc4606ae8a0fe1c9f12a8c7c673e /src/main/scala/firrtl/passes/Passes.scala | |
| parent | 897dad039a12a49b3c4ae833fbf0d02087b26ed5 (diff) | |
Constant prop add (#849)
* add FoldADD to const prop, add yosys miter tests
* add option for verilog compiler without optimizations
* rename FoldLogicalOp to FoldCommutativeOp
* add GetNamespace and RenameModules, GetNamespace stores namespace as a ModuleNamespaceAnnotation
* add constant propagation for Tail DoPrims
* add scaladocs for MinimumLowFirrtlOptimization and yosysExpectFalure/Success, add constant propagation for Head DoPrim
* add legalize pass to MinimumLowFirrtlOptimizations, use constPropBitExtract in legalize pass
Diffstat (limited to 'src/main/scala/firrtl/passes/Passes.scala')
| -rw-r--r-- | src/main/scala/firrtl/passes/Passes.scala | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/main/scala/firrtl/passes/Passes.scala b/src/main/scala/firrtl/passes/Passes.scala index 9bbde5f6..5e5aa26a 100644 --- a/src/main/scala/firrtl/passes/Passes.scala +++ b/src/main/scala/firrtl/passes/Passes.scala @@ -3,12 +3,12 @@ package firrtl.passes import com.typesafe.scalalogging.LazyLogging - import firrtl._ import firrtl.ir._ import firrtl.Utils._ import firrtl.Mappers._ import firrtl.PrimOps._ +import firrtl.transforms.ConstantPropagation import scala.collection.mutable @@ -198,14 +198,9 @@ object Legalize extends Pass { e } } - private def legalizeBits(expr: DoPrim): Expression = { - lazy val (hi, low) = (expr.consts.head, expr.consts(1)) - lazy val mask = (BigInt(1) << (hi - low + 1).toInt) - 1 - lazy val width = IntWidth(hi - low + 1) + private def legalizeBitExtract(expr: DoPrim): Expression = { expr.args.head match { - case UIntLiteral(value, _) => UIntLiteral((value >> low.toInt) & mask, width) - case SIntLiteral(value, _) => SIntLiteral((value >> low.toInt) & mask, width) - //case FixedLiteral + case _: UIntLiteral | _: SIntLiteral => ConstantPropagation.constPropBitExtract(expr) case _ => expr } } @@ -236,7 +231,7 @@ object Legalize extends Pass { case prim: DoPrim => prim.op match { case Shr => legalizeShiftRight(prim) case Pad => legalizePad(prim) - case Bits => legalizeBits(prim) + case Bits | Head | Tail => legalizeBitExtract(prim) case _ => prim } case e => e // respect pre-order traversal |
