diff options
| author | Jack | 2015-10-15 14:16:06 -0700 |
|---|---|---|
| committer | Jack | 2015-10-15 14:16:06 -0700 |
| commit | 80c055ce93c9d5988c6158c4a91c01633f8ebf22 (patch) | |
| tree | 0e356d563db0d4701da41a201dcae3ff7cbf8e2f /src/main/scala/firrtl/Visitor.scala | |
| parent | 7a7936c8fbddbffc1c4775fafeb5106ba1002dd4 (diff) | |
Reorganized Primops (renamed from PrimOps), added maps and functions to convert object <=> string, added eqv and neqv
Diffstat (limited to 'src/main/scala/firrtl/Visitor.scala')
| -rw-r--r-- | src/main/scala/firrtl/Visitor.scala | 43 |
1 files changed, 3 insertions, 40 deletions
diff --git a/src/main/scala/firrtl/Visitor.scala b/src/main/scala/firrtl/Visitor.scala index 8bbed2e3..7d54ca1a 100644 --- a/src/main/scala/firrtl/Visitor.scala +++ b/src/main/scala/firrtl/Visitor.scala @@ -14,6 +14,7 @@ import org.antlr.v4.runtime.tree.ErrorNode import org.antlr.v4.runtime.tree.TerminalNode import scala.collection.JavaConversions._ import antlr._ +import Primops._ class Visitor(val fullFilename: String) extends FIRRTLBaseVisitor[AST] { @@ -149,48 +150,10 @@ class Visitor(val fullFilename: String) extends FIRRTLBaseVisitor[AST] case "." => new Subfield(visitExp(ctx.exp(0)), ctx.id.getText, UnknownType) case "[" => new Index(visitExp(ctx.exp(0)), string2BigInt(ctx.IntLit(0).getText), UnknownType) case "(" => - DoPrimOp(visitPrimop(ctx.primop), ctx.exp.map(visitExp), + DoPrimop(visitPrimop(ctx.primop), ctx.exp.map(visitExp), ctx.IntLit.map(x => string2BigInt(x.getText)), UnknownType) } } - // TODO can I create this and have the opposite? create map and invert it? - private def visitPrimop[AST](ctx: FIRRTLParser.PrimopContext): PrimOp = - ctx.getText match { - case "add" => Add - case "sub" => Sub - case "addw" => Addw - case "subw" => Subw - case "mul" => Mul - case "div" => Div - case "mod" => Mod - case "quo" => Quo - case "rem" => Rem - case "lt" => Lt - case "leq" => Leq - case "gt" => Gt - case "geq" => Geq - case "eq" => Eq - case "neq" => Neq - case "mux" => Mux - case "pad" => Pad - case "asUInt" => AsUInt - case "asSInt" => AsSInt - case "shl" => Shl - case "shr" => Shr - case "dshl" => Dshl - case "dshr" => Dshr - case "cvt" => Cvt - case "neg" => Neg - case "not" => Not - case "and" => And - case "or" => Or - case "xor" => Xor - case "andr" => Andr - case "orr" => Orr - case "xorr" => Xorr - case "cat" => Cat - case "bit" => Bit - case "bits" => Bits - } + private def visitPrimop[AST](ctx: FIRRTLParser.PrimopContext): Primop = fromString(ctx.getText) } |
