diff options
Diffstat (limited to 'src/main/scala/firrtl/passes')
| -rw-r--r-- | src/main/scala/firrtl/passes/Checks.scala | 18 | ||||
| -rw-r--r-- | src/main/scala/firrtl/passes/ConstProp.scala | 54 | ||||
| -rw-r--r-- | src/main/scala/firrtl/passes/LowerTypes.scala | 2 | ||||
| -rw-r--r-- | src/main/scala/firrtl/passes/Passes.scala | 60 | ||||
| -rw-r--r-- | src/main/scala/firrtl/passes/Uniquify.scala | 4 |
5 files changed, 69 insertions, 69 deletions
diff --git a/src/main/scala/firrtl/passes/Checks.scala b/src/main/scala/firrtl/passes/Checks.scala index 272c96ea..1a11c0a4 100644 --- a/src/main/scala/firrtl/passes/Checks.scala +++ b/src/main/scala/firrtl/passes/Checks.scala @@ -148,7 +148,7 @@ object CheckHighForm extends Pass with LazyLogging { } def checkValidLoc(e: Expression) = { e match { - case e @ ( _: UIntValue | _: SIntValue | _: DoPrim ) => errors.append(new InvalidLOCException) + case e @ (_: UIntLiteral | _: SIntLiteral | _: DoPrim ) => errors.append(new InvalidLOCException) case _ => // Do Nothing } } @@ -189,7 +189,7 @@ object CheckHighForm extends Pass with LazyLogging { validSubexp(e.exp) e } - case e: UIntValue => + case e: UIntLiteral => if (e.value < 0) errors.append(new NegUIntException) case e => e map (validSubexp) } @@ -411,7 +411,7 @@ object CheckTypes extends Pass with LazyLogging { if (!passive(tpe(e))) errors.append(new ValidIfPassiveTypes(info)) if (!(tpe(e.cond).typeof[UIntType])) errors.append(new ValidIfCondUInt(info)) } - case (_:UIntValue|_:SIntValue) => false + case (_:UIntLiteral | _:SIntLiteral) => false } e } @@ -560,8 +560,8 @@ object CheckGenders extends Pass { case (e:WSubIndex) => get_gender(e.exp,genders) case (e:WSubAccess) => get_gender(e.exp,genders) case (e:DoPrim) => MALE - case (e:UIntValue) => MALE - case (e:SIntValue) => MALE + case (e:UIntLiteral) => MALE + case (e:SIntLiteral) => MALE case (e:Mux) => MALE case (e:ValidIf) => MALE } @@ -577,8 +577,8 @@ object CheckGenders extends Pass { case (e:DoPrim) => for (e <- e.args ) { check_gender(info,genders,MALE)(e) } case (e:Mux) => e map (check_gender(info,genders,MALE)) case (e:ValidIf) => e map (check_gender(info,genders,MALE)) - case (e:UIntValue) => false - case (e:SIntValue) => false + case (e:UIntLiteral) => false + case (e:SIntLiteral) => false } e } @@ -659,7 +659,7 @@ object CheckWidths extends Pass { } def check_width_e (info:Info)(e:Expression) : Expression = { (e map (check_width_e(info))) match { - case (e:UIntValue) => { + case (e:UIntLiteral) => { (e.width) match { case (w:IntWidth) => if (scala.math.max(1,e.value.bitLength) > w.width) { @@ -669,7 +669,7 @@ object CheckWidths extends Pass { } check_width_w(info)(e.width) } - case (e:SIntValue) => { + case (e:SIntLiteral) => { (e.width) match { case (w:IntWidth) => if (e.value.bitLength + 1 > w.width) errors.append(new WidthTooSmall(info, e.value)) diff --git a/src/main/scala/firrtl/passes/ConstProp.scala b/src/main/scala/firrtl/passes/ConstProp.scala index 11c14e56..e562f71d 100644 --- a/src/main/scala/firrtl/passes/ConstProp.scala +++ b/src/main/scala/firrtl/passes/ConstProp.scala @@ -37,20 +37,20 @@ object ConstProp extends Pass { def name = "Constant Propagation" trait FoldLogicalOp { - def fold(c1: UIntValue, c2: UIntValue): UIntValue - def simplify(e: Expression, lhs: UIntValue, rhs: Expression): Expression + def fold(c1: UIntLiteral, c2: UIntLiteral): UIntLiteral + def simplify(e: Expression, lhs: UIntLiteral, rhs: Expression): Expression def apply(e: DoPrim): Expression = (e.args(0), e.args(1)) match { - case (lhs: UIntValue, rhs: UIntValue) => fold(lhs, rhs) - case (lhs: UIntValue, rhs) => simplify(e, lhs, rhs) - case (lhs, rhs: UIntValue) => simplify(e, rhs, lhs) + case (lhs: UIntLiteral, rhs: UIntLiteral) => fold(lhs, rhs) + case (lhs: UIntLiteral, rhs) => simplify(e, lhs, rhs) + case (lhs, rhs: UIntLiteral) => simplify(e, rhs, lhs) case _ => e } } object FoldAND extends FoldLogicalOp { - def fold(c1: UIntValue, c2: UIntValue) = UIntValue(c1.value & c2.value, c1.width max c2.width) - def simplify(e: Expression, lhs: UIntValue, rhs: Expression) = lhs.width match { + def fold(c1: UIntLiteral, c2: UIntLiteral) = UIntLiteral(c1.value & c2.value, c1.width max c2.width) + def simplify(e: Expression, lhs: UIntLiteral, rhs: Expression) = lhs.width match { case IntWidth(w) if long_BANG(tpe(rhs)) == w => if (lhs.value == 0) lhs // and(x, 0) => 0 else if (lhs.value == (BigInt(1) << w.toInt) - 1) rhs // and(x, 1) => x @@ -60,8 +60,8 @@ object ConstProp extends Pass { } object FoldOR extends FoldLogicalOp { - def fold(c1: UIntValue, c2: UIntValue) = UIntValue(c1.value | c2.value, c1.width max c2.width) - def simplify(e: Expression, lhs: UIntValue, rhs: Expression) = lhs.width match { + def fold(c1: UIntLiteral, c2: UIntLiteral) = UIntLiteral(c1.value | c2.value, c1.width max c2.width) + def simplify(e: Expression, lhs: UIntLiteral, rhs: Expression) = lhs.width match { case IntWidth(w) if long_BANG(tpe(rhs)) == w => if (lhs.value == 0) rhs // or(x, 0) => x else if (lhs.value == (BigInt(1) << w.toInt) - 1) lhs // or(x, 1) => 1 @@ -71,8 +71,8 @@ object ConstProp extends Pass { } object FoldXOR extends FoldLogicalOp { - def fold(c1: UIntValue, c2: UIntValue) = UIntValue(c1.value ^ c2.value, c1.width max c2.width) - def simplify(e: Expression, lhs: UIntValue, rhs: Expression) = lhs.width match { + def fold(c1: UIntLiteral, c2: UIntLiteral) = UIntLiteral(c1.value ^ c2.value, c1.width max c2.width) + def simplify(e: Expression, lhs: UIntLiteral, rhs: Expression) = lhs.width match { case IntWidth(w) if long_BANG(tpe(rhs)) == w => if (lhs.value == 0) rhs // xor(x, 0) => x else e @@ -81,8 +81,8 @@ object ConstProp extends Pass { } object FoldEqual extends FoldLogicalOp { - def fold(c1: UIntValue, c2: UIntValue) = UIntValue(if (c1.value == c2.value) 1 else 0, IntWidth(1)) - def simplify(e: Expression, lhs: UIntValue, rhs: Expression) = lhs.width match { + def fold(c1: UIntLiteral, c2: UIntLiteral) = UIntLiteral(if (c1.value == c2.value) 1 else 0, IntWidth(1)) + def simplify(e: Expression, lhs: UIntLiteral, rhs: Expression) = lhs.width match { case IntWidth(w) if w == 1 && long_BANG(tpe(rhs)) == 1 => if (lhs.value == 1) rhs // eq(x, 1) => x else e @@ -91,8 +91,8 @@ object ConstProp extends Pass { } object FoldNotEqual extends FoldLogicalOp { - def fold(c1: UIntValue, c2: UIntValue) = UIntValue(if (c1.value != c2.value) 1 else 0, IntWidth(1)) - def simplify(e: Expression, lhs: UIntValue, rhs: Expression) = lhs.width match { + def fold(c1: UIntLiteral, c2: UIntLiteral) = UIntLiteral(if (c1.value != c2.value) 1 else 0, IntWidth(1)) + def simplify(e: Expression, lhs: UIntLiteral, rhs: Expression) = lhs.width match { case IntWidth(w) if w == 1 && long_BANG(tpe(rhs)) == w => if (lhs.value == 0) rhs // neq(x, 0) => x else e @@ -101,15 +101,15 @@ object ConstProp extends Pass { } private def foldConcat(e: DoPrim) = (e.args(0), e.args(1)) match { - case (UIntValue(xv, IntWidth(xw)), UIntValue(yv, IntWidth(yw))) => UIntValue(xv << yw.toInt | yv, IntWidth(xw + yw)) + case (UIntLiteral(xv, IntWidth(xw)), UIntLiteral(yv, IntWidth(yw))) => UIntLiteral(xv << yw.toInt | yv, IntWidth(xw + yw)) case _ => e } private def foldShiftLeft(e: DoPrim) = e.consts(0).toInt match { case 0 => e.args(0) case x => e.args(0) match { - case UIntValue(v, IntWidth(w)) => UIntValue(v << x, IntWidth(w + x)) - case SIntValue(v, IntWidth(w)) => SIntValue(v << x, IntWidth(w + x)) + case UIntLiteral(v, IntWidth(w)) => UIntLiteral(v << x, IntWidth(w + x)) + case SIntLiteral(v, IntWidth(w)) => SIntLiteral(v << x, IntWidth(w + x)) case _ => e } } @@ -118,9 +118,9 @@ object ConstProp extends Pass { case 0 => e.args(0) case x => e.args(0) match { // TODO when amount >= x.width, return a zero-width wire - case UIntValue(v, IntWidth(w)) => UIntValue(v >> x, IntWidth((w - x) max 1)) + case UIntLiteral(v, IntWidth(w)) => UIntLiteral(v >> x, IntWidth((w - x) max 1)) // take sign bit if shift amount is larger than arg width - case SIntValue(v, IntWidth(w)) => SIntValue(v >> x, IntWidth((w - x) max 1)) + case SIntLiteral(v, IntWidth(w)) => SIntLiteral(v >> x, IntWidth((w - x) max 1)) case _ => e } } @@ -208,15 +208,15 @@ object ConstProp extends Pass { case NEQUAL_OP => FoldNotEqual(e) case LESS_OP|LESS_EQ_OP|GREATER_OP|GREATER_EQ_OP => foldComparison(e) case NOT_OP => e.args(0) match { - case UIntValue(v, IntWidth(w)) => UIntValue(v ^ ((BigInt(1) << w.toInt) - 1), IntWidth(w)) + case UIntLiteral(v, IntWidth(w)) => UIntLiteral(v ^ ((BigInt(1) << w.toInt) - 1), IntWidth(w)) case _ => e } case BITS_SELECT_OP => e.args(0) match { - case UIntValue(v, _) => { + case UIntLiteral(v, _) => { val hi = e.consts(0).toInt val lo = e.consts(1).toInt require(hi >= lo) - UIntValue((v >> lo) & ((BigInt(1) << (hi - lo + 1)) - 1), widthBANG(tpe(e))) + UIntLiteral((v >> lo) & ((BigInt(1) << (hi - lo + 1)) - 1), widthBANG(tpe(e))) } case x if long_BANG(tpe(e)) == long_BANG(tpe(x)) => tpe(x) match { case t: UIntType => x @@ -230,28 +230,28 @@ object ConstProp extends Pass { private def constPropMuxCond(m: Mux) = { // Only propagate a value if its width matches the mux width def propagate(e: Expression, muxWidth: BigInt) = e match { - case UIntValue(v, _) => UIntValue(v, IntWidth(muxWidth)) + case UIntLiteral(v, _) => UIntLiteral(v, IntWidth(muxWidth)) case _ => tpe(e) match { case UIntType(IntWidth(w)) if muxWidth == w => e case _ => m } } (m.cond, m.tpe) match { - case (UIntValue(c, _), UIntType(IntWidth(w))) => propagate(if (c == 1) m.tval else m.fval, w) + case (UIntLiteral(c, _), UIntType(IntWidth(w))) => propagate(if (c == 1) m.tval else m.fval, w) case _ => m } } private def constPropMux(m: Mux): Expression = (m.tval, m.fval) match { case _ if m.tval == m.fval => m.tval - case (t: UIntValue, f: UIntValue) => + case (t: UIntLiteral, f: UIntLiteral) => if (t.value == 1 && f.value == 0 && long_BANG(m.tpe) == 1) m.cond else constPropMuxCond(m) case _ => constPropMuxCond(m) } private def constPropNodeRef(r: WRef, e: Expression) = e match { - case _: UIntValue | _: SIntValue | _: WRef => e + case _: UIntLiteral | _: SIntLiteral | _: WRef => e case _ => r } diff --git a/src/main/scala/firrtl/passes/LowerTypes.scala b/src/main/scala/firrtl/passes/LowerTypes.scala index 36919756..d905fc34 100644 --- a/src/main/scala/firrtl/passes/LowerTypes.scala +++ b/src/main/scala/firrtl/passes/LowerTypes.scala @@ -149,7 +149,7 @@ object LowerTypes extends Pass { } case e: Mux => e map (lowerTypesExp) case e: ValidIf => e map (lowerTypesExp) - case (_: UIntValue | _: SIntValue) => e + case (_: UIntLiteral | _: SIntLiteral) => e case e: DoPrim => e map (lowerTypesExp) } diff --git a/src/main/scala/firrtl/passes/Passes.scala b/src/main/scala/firrtl/passes/Passes.scala index 094166fb..ce1c7eed 100644 --- a/src/main/scala/firrtl/passes/Passes.scala +++ b/src/main/scala/firrtl/passes/Passes.scala @@ -69,10 +69,10 @@ object ToWorkingIR extends Pass { def run (c:Circuit): Circuit = { def toExp (e:Expression) : Expression = { e map (toExp) match { - case e:Ref => WRef(e.name, e.tpe, NodeKind(), UNKNOWNGENDER) - case e:SubField => WSubField(e.exp, e.name, e.tpe, UNKNOWNGENDER) - case e:SubIndex => WSubIndex(e.exp, e.value, e.tpe, UNKNOWNGENDER) - case e:SubAccess => WSubAccess(e.exp, e.index, e.tpe, UNKNOWNGENDER) + case e:Reference => WRef(e.name, e.tpe, NodeKind(), UNKNOWNGENDER) + case e:SubField => WSubField(e.expr, e.name, e.tpe, UNKNOWNGENDER) + case e:SubIndex => WSubIndex(e.expr, e.value, e.tpe, UNKNOWNGENDER) + case e:SubAccess => WSubAccess(e.expr, e.index, e.tpe, UNKNOWNGENDER) case e => e } } @@ -176,8 +176,8 @@ object InferTypes extends Pass { case e:WSubAccess => WSubAccess(e.exp,e.index,sub_type(tpe(e.exp)),e.gender) case e:DoPrim => set_primop_type(e) case e:Mux => Mux(e.cond,e.tval,e.fval,mux_type_and_widths(e.tval,e.fval)) - case e:UIntValue => e - case e:SIntValue => e + case e:UIntLiteral => e + case e:SIntLiteral => e } } def infer_types_s (s:Statement) : Statement = { @@ -822,8 +822,8 @@ object RemoveAccesses extends Pass { case (e:DoPrim) => e map (remove_e) case (e:Mux) => e map (remove_e) case (e:ValidIf) => e map (remove_e) - case (e:SIntValue) => e - case (e:UIntValue) => e + case (e:SIntLiteral) => e + case (e:UIntLiteral) => e case x => { val e = x match { case (w:WSubAccess) => WSubAccess(w.exp,remove_e(w.index),w.tpe,w.gender) @@ -900,7 +900,7 @@ object Legalize extends Pass { lazy val msb = width - 1 if (amount >= width) { e.tpe match { - case t: UIntType => UIntValue(0, IntWidth(1)) + case t: UIntType => UIntLiteral(0, IntWidth(1)) case t: SIntType => DoPrim(BITS_SELECT_OP, e.args, Seq(msb, msb), SIntType(IntWidth(1))) case t => error(s"Unsupported type ${t} for Primop Shift Right") @@ -1053,14 +1053,14 @@ object CInferTypes extends Pass { val types = LinkedHashMap[String,Type]() def infer_types_e (e:Expression) : Expression = { (e map (infer_types_e)) match { - case (e:Ref) => Ref(e.name, types.getOrElse(e.name,UnknownType)) - case (e:SubField) => SubField(e.exp,e.name,field_type(tpe(e.exp),e.name)) - case (e:SubIndex) => SubIndex(e.exp,e.value,sub_type(tpe(e.exp))) - case (e:SubAccess) => SubAccess(e.exp,e.index,sub_type(tpe(e.exp))) + case (e:Reference) => Reference(e.name, types.getOrElse(e.name,UnknownType)) + case (e:SubField) => SubField(e.expr,e.name,field_type(tpe(e.expr),e.name)) + case (e:SubIndex) => SubIndex(e.expr,e.value,sub_type(tpe(e.expr))) + case (e:SubAccess) => SubAccess(e.expr,e.index,sub_type(tpe(e.expr))) case (e:DoPrim) => set_primop_type(e) case (e:Mux) => Mux(e.cond,e.tval,e.fval,mux_type(e.tval,e.tval)) case (e:ValidIf) => ValidIf(e.cond,e.value,tpe(e.value)) - case (_:UIntValue|_:SIntValue) => e + case (_:UIntLiteral | _:SIntLiteral) => e } } def infer_types_s (s:Statement) : Statement = { @@ -1126,7 +1126,7 @@ object CInferMDir extends Pass { val mports = LinkedHashMap[String,MPortDir]() def infer_mdir_e (dir:MPortDir)(e:Expression) : Expression = { (e map (infer_mdir_e(dir))) match { - case (e:Ref) => { + case (e:Reference) => { if (mports.contains(e.name)) { val new_mport_dir = { (mports(e.name),dir) match { @@ -1253,23 +1253,23 @@ object RemoveCHIRRTL extends Pass { val tdata = s.tpe def set_poison (vec:Seq[MPort],addr:String) : Unit = { for (r <- vec ) { - stmts += IsInvalid(s.info,SubField(SubField(Ref(s.name,ut),r.name,ut),addr,taddr)) - stmts += IsInvalid(s.info,SubField(SubField(Ref(s.name,ut),r.name,ut),"clk",taddr)) + stmts += IsInvalid(s.info,SubField(SubField(Reference(s.name,ut),r.name,ut),addr,taddr)) + stmts += IsInvalid(s.info,SubField(SubField(Reference(s.name,ut),r.name,ut),"clk",taddr)) } } def set_enable (vec:Seq[MPort],en:String) : Unit = { for (r <- vec ) { - stmts += Connect(s.info,SubField(SubField(Ref(s.name,ut),r.name,ut),en,taddr),zero) + stmts += Connect(s.info,SubField(SubField(Reference(s.name,ut),r.name,ut),en,taddr),zero) }} def set_wmode (vec:Seq[MPort],wmode:String) : Unit = { for (r <- vec) { - stmts += Connect(s.info,SubField(SubField(Ref(s.name,ut),r.name,ut),wmode,taddr),zero) + stmts += Connect(s.info,SubField(SubField(Reference(s.name,ut),r.name,ut),wmode,taddr),zero) }} def set_write (vec:Seq[MPort],data:String,mask:String) : Unit = { val tmask = create_mask(s.tpe) for (r <- vec ) { - stmts += IsInvalid(s.info,SubField(SubField(Ref(s.name,ut),r.name,ut),data,tdata)) - for (x <- create_exps(SubField(SubField(Ref(s.name,ut),r.name,ut),mask,tmask)) ) { + stmts += IsInvalid(s.info,SubField(SubField(Reference(s.name,ut),r.name,ut),data,tdata)) + for (x <- create_exps(SubField(SubField(Reference(s.name,ut),r.name,ut),mask,tmask)) ) { stmts += Connect(s.info,x,zero) }}} val rds = (hash.getOrElse(s.name,EMPs())).readers @@ -1296,21 +1296,21 @@ object RemoveCHIRRTL extends Pass { val masks = ArrayBuffer[String]() s.direction match { case MReadWrite => { - repl(s.name) = DataRef(SubField(Ref(s.mem,ut),s.name,ut),"rdata","data","mask",true) + repl(s.name) = DataRef(SubField(Reference(s.mem,ut),s.name,ut),"rdata","data","mask",true) addrs += "addr" clks += "clk" ens += "en" masks += "mask" } case MWrite => { - repl(s.name) = DataRef(SubField(Ref(s.mem,ut),s.name,ut),"data","data","mask",false) + repl(s.name) = DataRef(SubField(Reference(s.mem,ut),s.name,ut),"data","data","mask",false) addrs += "addr" clks += "clk" ens += "en" masks += "mask" } case _ => { - repl(s.name) = DataRef(SubField(Ref(s.mem,ut),s.name,ut),"data","data","blah",false) + repl(s.name) = DataRef(SubField(Reference(s.mem,ut),s.name,ut),"data","data","blah",false) addrs += "addr" clks += "clk" ens += "en" @@ -1318,13 +1318,13 @@ object RemoveCHIRRTL extends Pass { } val stmts = ArrayBuffer[Statement]() for (x <- addrs ) { - stmts += Connect(s.info,SubField(SubField(Ref(s.mem,ut),s.name,ut),x,ut),s.exps(0)) + stmts += Connect(s.info,SubField(SubField(Reference(s.mem,ut),s.name,ut),x,ut),s.exps(0)) } for (x <- clks ) { - stmts += Connect(s.info,SubField(SubField(Ref(s.mem,ut),s.name,ut),x,ut),s.exps(1)) + stmts += Connect(s.info,SubField(SubField(Reference(s.mem,ut),s.name,ut),x,ut),s.exps(1)) } for (x <- ens ) { - stmts += Connect(s.info,SubField(SubField(Ref(s.mem,ut),s.name,ut),x,ut),one) + stmts += Connect(s.info,SubField(SubField(Reference(s.mem,ut),s.name,ut),x,ut),one) } Begin(stmts) } @@ -1336,7 +1336,7 @@ object RemoveCHIRRTL extends Pass { var has_readwrite_mport:Option[Expression] = None def remove_chirrtl_e (g:Gender)(e:Expression) : Expression = { (e) match { - case (e:Ref) => { + case (e:Reference) => { if (repl.contains(e.name)) { val vt = repl(e.name) g match { @@ -1350,13 +1350,13 @@ object RemoveCHIRRTL extends Pass { } } else e } - case (e:SubAccess) => SubAccess(remove_chirrtl_e(g)(e.exp),remove_chirrtl_e(MALE)(e.index),e.tpe) + case (e:SubAccess) => SubAccess(remove_chirrtl_e(g)(e.expr),remove_chirrtl_e(MALE)(e.index),e.tpe) case (e) => e map (remove_chirrtl_e(g)) } } def get_mask (e:Expression) : Expression = { (e map (get_mask)) match { - case (e:Ref) => { + case (e:Reference) => { if (repl.contains(e.name)) { val vt = repl(e.name) val t = create_mask(e.tpe) diff --git a/src/main/scala/firrtl/passes/Uniquify.scala b/src/main/scala/firrtl/passes/Uniquify.scala index 2fdc3454..3ad0c3dc 100644 --- a/src/main/scala/firrtl/passes/Uniquify.scala +++ b/src/main/scala/firrtl/passes/Uniquify.scala @@ -192,7 +192,7 @@ object Uniquify extends Pass { val (subExp, subMap) = rec(e.exp, m) val index = uniquifyNamesExp(e.index, map) (WSubAccess(subExp, index, e.tpe, e.gender), subMap) - case (_: UIntValue | _: SIntValue) => (exp, m) + case (_: UIntLiteral | _: SIntLiteral) => (exp, m) case (_: Mux | _: ValidIf | _: DoPrim) => (exp map ((e: Expression) => uniquifyNamesExp(e, map)), m) } @@ -267,7 +267,7 @@ object Uniquify extends Pass { uniquifyNamesExp(e, nameMap.toMap) case e: Mux => e map (uniquifyExp) case e: ValidIf => e map (uniquifyExp) - case (_: UIntValue | _: SIntValue) => e + case (_: UIntLiteral | _: SIntLiteral) => e case e: DoPrim => e map (uniquifyExp) } |
