Commit Graph

10108 Commits

Author SHA1 Message Date
Chris Lattner fbcbf00383 [EmitVerilog] Implement head/tail primitives, and refactor bit
selection code.  Also fix a firrtl spec issue - tail can't have
its amount equal to its input width.
2020-04-23 17:00:19 -07:00
Chris Lattner d3b02ce074 [EmitVerilog] Implement support for mux primitive. 2020-04-23 16:38:10 -07:00
Chris Lattner 093ed22313 [EmitVerilog] Implement support for cvt() primitive.
Improve/consolidate handling of noop casts and verilog concats.
2020-04-23 16:19:16 -07:00
Chris Lattner 9aa3d8a227 [EmitVerilog] Implement dshl/dshr/cat primitives. 2020-04-23 14:58:07 -07:00
Chris Lattner 1a7f3ed8b3 [EmitVerilog] Fix a precedence bug handling differing operators
with equal precedence level.
2020-04-23 13:27:22 -07:00
Chris Lattner 2ae6a24b18 [EmitVerilog] Implement proper sign propagation and $signed() cast
insertion.  This implement support for the As[SU]Int casts, and fixes
a parser bug where eq got turned into the wrong MLIR node.
2020-04-23 12:55:15 -07:00
Chris Lattner 8d2931c637 [VerilogEmit] Switch the expr emitter to use a single pass design
based on inserting into a SmallVector.  This is a lot simpler, probably
faster (not that it matters), and easier to extend.
2020-04-22 17:43:17 -07:00
Chris Lattner 4c0bd51ae9 [emitverilog] refactor the parenthesization logic into emitSubExpr, NFC. 2020-04-22 15:29:41 -07:00
Chris Lattner a9045c0ff4 [EmitVerilog] Implement the bits/shl/shr primitives. 2020-04-22 15:12:08 -07:00
Chris Lattner 4b210ac41a [EmitVerilog] Tidy up printing of input-only port lists. 2020-04-22 14:00:17 -07:00
Chris Lattner df65777c64 [EmitVerilog] add support for instances referring to parameterized extmodules. 2020-04-22 13:52:35 -07:00
Chris Lattner 4abf063c7a [VerilogEmitter] Implement support for instances.
This doesn't handle parameters yet.
2020-04-22 13:20:39 -07:00
Chris Lattner 80a67e70f8 [FIRParser] Correctly persist extmodule defname and parameters in
the IR.
2020-04-22 11:24:24 -07:00
Chris Lattner 126b62a5cc Give the FIR parser an options struct to configure it. Change firtool
to default to ignoring @info locations for now.  I don't need firtool to
report errors pointing at Scala files right now, I need it pointing to
the .fir files.  The default can be switched back as things mature.
2020-04-22 09:44:36 -07:00
Chris Lattner c3f7b133bb [EmitVerilog] Ignore extmodules when emitting verilog. 2020-04-22 09:37:10 -07:00
Chris Lattner 56bd282978 [EmitVerilog] emit wire declarations for intermediate values
used by expressions and node declarations.  Also add a newline
between ports and wire decls and the body for clarity.
2020-04-21 22:55:25 -07:00
Chris Lattner 2289c5ca39 Drop some defaulted attribute lists, NFC. 2020-04-21 22:11:16 -07:00
Chris Lattner 0f98ce99de Introduce a new 'firtool' command with a simplified user interface. 2020-04-21 14:38:09 -07:00
Chris Lattner 69518665e0 Introduce an 'asPassive' operand to convert input values to passive
values, fixing a bug in the FIR parser when handling when conditions.

Also update some stale paths that should have been updated in a previous
patch... *shakes fist at non-hermitic ninja builds*
2020-04-20 21:05:21 -07:00
Chris Lattner 386699b142 Implement some basic casts that turn into no syntax. 2020-04-20 18:24:31 -07:00
Chris Lattner b206a59955 Implement a simple classification scheme in ExprVisitor, allowing better factoring of
code. NFC.
2020-04-20 15:28:09 -07:00
Chris Lattner cb5933029b Move syntax info into the prepass over the expression. NFC. 2020-04-20 15:19:36 -07:00
Chris Lattner 4c572ad611 Generalize the ExprVisitor to allow passing down extra values. Use this to
pass down the SubExprInfo for the current node.  NFC.
2020-04-20 15:09:44 -07:00
Chris Lattner 79cf7f52f5 Implement support for parentheses insertion in order to respect
operator precedence.
2020-04-20 14:59:00 -07:00
Chris Lattner 099efbebec Sketch out a bunch more binary operators, add testcases for some
invalid precedence and sign issues we have.
2020-04-20 11:21:45 -07:00
Chris Lattner 2d126f3772 [emitVerilog] Implement support for integer constants and remainder. 2020-04-19 18:33:45 -07:00
Chris Lattner 136ff0a547 implement skip and a few more unary operators, fill out the rest of the expr visitor. 2020-04-19 18:15:25 -07:00
Chris Lattner 1efc18e7a3 Add a testcase for multi-use expressions, which we already support. 2020-04-18 22:59:41 -07:00
Chris Lattner 359f64b77e Implement basic expression emission to verilog, starting with name
references XorR and AndR, and the error case.

This isn't correctly set up to handle signedness or precedence yet,
but that doesn't matter for these operators.
2020-04-18 22:55:03 -07:00
Chris Lattner e98d9d1429 Introduce a symbol table with proper name uniquing. Build it from
all the declarations and multiply-used expressions in a module body.
2020-04-17 17:41:12 -07:00
Chris Lattner 10a1793484 Refactor the verilog emitter into different classes, making way for
module-local state.
2020-04-17 15:38:02 -07:00
Chris Lattner b179ab36e0 Eliminate the IR subdirectory of include/spt/Dialect/FIRRTL, flattening its
contents into the parent directory.  NFC.
2020-04-17 09:53:48 -07:00
Chris Lattner 856f298cae Rearrange the firrtl dialect header and implementations, breaking them
down into a dialect/types/ops schema.  NFC.
2020-04-17 09:49:40 -07:00
Chris Lattner b418ed8044 update to mainline mlir 2020-04-15 22:05:54 -07:00
Chris Lattner da29d307e9 [EmitVerilog] Building scaffolding for the future, fix minor issues.
Implement an expression visitor for FIRRTL, fix some issues with
empty modules, make no-port modules prettier, add support for
indentation, improve the verilog emitter tests.
2020-04-15 17:12:36 -07:00
Chris Lattner cf8bff0b98 Implement support for printing out the port list in a module. 2020-04-15 14:53:38 -07:00
Chris Lattner 2b9ca28432 Completely drop 'node' definitions if their names are dropped. This
speeds up the parser by another 13%.
2020-04-15 14:04:25 -07:00
Chris Lattner e9c8af224c Introduce a simple cache of constant operations. Firrtl input has a ton
of redundant constants due to its expression oriented nature.  Caching
them avoids creating obviously pointless IR, speeding up the parser by
about 20%.
2020-04-15 13:50:18 -07:00
Chris Lattner f57236aa18 Tighten up the definition of firrtl.constant, adding verifier constraints
fixing the weird 1024 bit limitation, and tightening it up to IntType
specifically.  NFC.
2020-04-15 12:01:34 -07:00
Chris Lattner d65f385d06 Link the CSE pass into spt-opt, it deletes one half of the lines in the "low"
output I'm looking at, going from 1.2M lines of IR to 630K, largely by
eliminating duplicate constants.
2020-04-15 11:38:40 -07:00
Chris Lattner 499b89216d Start emitting the module scaffolding. 2020-04-14 21:33:23 -07:00
Chris Lattner 0d441cee3f Stub out circuit/module walking and some other boring infra. 2020-04-14 21:27:20 -07:00
Chris Lattner 628be893e0 Rename FIRToMLIR.h -> FIRParser.h, remove some dead state from FIRParser.cpp, NFC. 2020-04-14 21:01:42 -07:00
Chris Lattner c890451efc Rename FIRToMLIR.h -> FIRParser.h, remove some dead state from FIRParser. NFC. 2020-04-14 21:01:14 -07:00
Chris Lattner aa1deb3371 Stub out a (currently useless) verilog emitter. 2020-04-14 20:58:01 -07:00
Chris Lattner 46342c37bb rename the command line flag for parsing a fir file, wrap a long line
to 80 columns.
2020-04-14 20:30:24 -07:00
Chris Lattner 90b222b65a When parsing .fir files, ignore the _T* names on declarations. They
are temporary names that are not important to preserve.
2020-04-13 21:56:55 -07:00
Chris Lattner d939853cb5 Use a pretty name for constant operations to make it easier to read the IR. 2020-04-13 17:11:37 -07:00
Chris Lattner cfba8c2d08 fix a .mlir parser ambiguity with firrtl.printf, enable the
canonicalization pass in spt-opt.

Right now it seems to be doing trivial dead code elimination of
unused primitive and node operations.
2020-04-13 16:48:20 -07:00
Chris Lattner 0377defeb8 Rename test/fir to test/FIRParser to match the library name. NFC. 2020-04-13 12:48:44 -07:00