Commit Graph

1970 Commits

Author SHA1 Message Date
Chris Lattner 2821d08959 [HW] rename the parameter attributes to be more consistent.
The declaration of a parameter is now a ParamDeclAttr.  A reference
expression to it is a ParamDeclRefAttr, verbatim expres are
ParamVerbatimAttr.
2021-09-21 17:12:05 -07:00
mikeurbach f5526f992a
[StaticLogic] Add new PipelineWhile operation. (#1759)
https://llvm.discourse.group/t/rfc-representing-pipelined-loops/4171/1
for more discussion.

This defines the operation's syntax more or less as discussed,
including round-trip tests for the five running examples we've had.

In order to reduce test churn, the existing PipelineOp and the
StandardToStaticLogic pass are left untouched for now. Ultimately, the
new pipeline operation could replace the existing PipelineOp.
2021-09-21 17:45:36 -06:00
Prithayan Barua 34d3ed999e
[SV][ExportVerilog] Add symbol to verbatim macro substitution (#1798)
The verbatim op can be used for macro substitution with values. This PR adds 
support for macro substitution with symbols.
For example, 
```mlir 
sv.verbatim  "MACRO({{0}}, {{1}} reg={{4}}, {{3}})"
          (%add, %xor)  : i8,i8
          {symbols= [@reg1, @module1, @instance1]}
```
In the above operation, `0` and `1` will be replaced by `%add` and `%xor` ,
 `4` with the verilog name of the symbol `@instance1`  and `3` with the 
verilog name of the symbol `@module1`.

Changes in this commit:
1. Add the optional array of symbols as an attribute to the `VerbatimOp`
2. Add a type constraint for an array of `FlatSymbolRefAttr`, this can be pushed to `mlir`.
3. Update `ExportVerilog` to get the verilog name for any symbol. Most of the changes 
                     in `ExportVerilog` is just to ensure the final symbol names can be tracked.                    
4. Update docs and test cases.
2021-09-21 16:09:35 -07:00
Andrew Lenharth 58290113fa [ExtractTestCode] Don't put the directory on every single op, just store it for the circuit.
Individual ops in modules shouldn't be specifying output files.  This is a global option passed to the system from annotations.
2021-09-21 15:06:14 -07:00
Morten Borup Petersen c2254dc399
[SCFToCalyx] Add partial lowering infrastructure [4/13] (#1815)
* [SCFToCalyx] Add partial lowering infrastructure [4/13]

This commit adds a partial lowering infrastructure to the SCFToCalyx pass. Similarly to `StandardToHandshake`, `SCFToCalyx` structures its conversion into multiple distinct stages. Some of these stages perform IR modifications instead of IR replacements. The partial lowering infrastructure allows for writing passes which are driven by the conversion infrastructure, but relaxes the requirement of "if a conversion pattern matches, the matched operation should be replaced or erased".

`FuncOpPartialLoweringPattern`s are patterns which intend to match on `FuncOp`s and then perform their own walking from these. These patterns are initialized with access to the `ComponentLoweringState` for corresponding component of the matched `FuncOp`.
2021-09-21 22:31:51 +01:00
Andrew Young 88ffdb2345
[FIRRTL][LowerToHW] Pass through `sv.verbatim` ops (#1827)
The LowerToHW pass will emit an error for any unrecognized operation it
finds in the Circuit while lowering.  We need to pass through
`sv.verbatim` operations which are created during metadata generation.
The `sv.interface` operation is already passed directly through when
lowering, and this change extends this to include `sv.verbatim`
operations.  If we find that there are too many operations being
white-listed, we could modify it to pass-through anything by default.
2021-09-21 13:19:48 -07:00
Andrew Young 5116bd811f
[FIRRTL][Inliner] Don't delete unknown ops when deleting dead modules (#1826)
The inliner removes any module which is left uninstantiated after all
inlining is complete.  It was mistakenly deleting non-module operations
because there was no instance of them.  For example, an `sv.verbatim`
operation would be deleted since it is not the sort of thing that could
be instantiated.  This adds a check that the operation it is considering
for deletion is in fact a module operation before removing it.
2021-09-21 12:26:01 -07:00
Morten Borup Petersen 49090aab38
[SCFToCalyx] Add program- and component lowering state [3/13] (#1814)
This commit introduces the `ProgramLoweringState` and `ComponentLoweringState` classes. These are used as key-value stores for a variety of mappings used during lowering, which will be introduced in the following commits.
A `ProgramLoweringState` stores `calyx::ProgramOp`-level information, where `ComponentLoweringState` stores `calyx::ComponentOp`-level information.
2021-09-21 19:28:35 +01:00
Morten Borup Petersen 728406e122
[SCFToCalyx] Add calyx::ProgramOp conversion [2/13] (#1813)
* [SCFToCalyx] Add calyx::ProgramOp conversion [2/13]

This commit introduces logic for converting a top-level MLIR 'module' into a calyx::ProgramOp.
The implementation works around an issue/restriction of the current infrastructure, being that a top-level 'module' cannot be overwritten. see: https://llvm.discourse.group/t/de-privileging-moduleop-in-translation-apis/3733/26

Furthermore, an input program is legalized using a `ConversionTarget`.
2021-09-21 18:41:59 +01:00
Chris Lattner 13deb2bed5 [HW] Fix Issue #1822, explicit argNames attributes.
This is important to support for port names that aren't valid
MLIR SSA names.
2021-09-21 09:51:18 -07:00
Chris Lattner bf377f964b Note that this can go away after the next LLVM merge. 2021-09-21 09:47:30 -07:00
Chris Gyurgyik 9e58c585e8
[Calyx] Add entry-point component attribute to ProgramOp. (#1819)
This takes a similar approach to the FIRRTL structure. We define an entry-point component by 
using its name in the ProgramOp. This is guaranteed to be unique since each ComponentOp 
name is a `Symbol`.
2021-09-21 08:52:13 -07:00
Andrew Lenharth 11f5a51c95 [SV] Make sure we get the ifdefs in the extracted modules.
The output directory specification is broken, but at least make the output work better.
2021-09-21 08:42:15 -07:00
Andrew Lenharth 16934f4ac1 [FIRRTL] Generate module hierarchy in the correct directory. 2021-09-21 07:32:19 -07:00
Morten Borup Petersen 69c5ecf4c4 [Handshake] Also support memref::alloca operations 2021-09-21 10:21:34 +01:00
Schuyler Eldridge 8d79077020
[FIRRTL][HW] Add Support for "Port Order" Write-Under-Write to HWMemSimImpl, Use for FIRRTL Lowering (#1805)
Change the way that FIRRTL memories are lowered to HW memories to
propagate the write-under-write behavior.  Modify HWMemSimImpl (which
generate a simulation model of a memory) to respect a new
write-under-write attribute.

This new write-under-write attribute can either be "undefined"
indicating that the resulting simulation memory should put each write
port in an independent always block, regardless of whether or not they
are on the same clock.  If the write-under-write behavior is set to
"port order" then write ports that are trivially driven by the same
clock are put in the same always block and ordered sequentially by port
order.  I.e., later ports will override earlier ports if they both write
to the same address.

This behavior is added because the Scala FIRRTL Compiler (SFC) will
lower write ports in this way and a deviation from it is a formal
equivalence mismatch.

Add tests of "port order" write-under-write behavior for simulation
memory generation.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-09-21 01:14:28 -04:00
Morten Borup Petersen e4731d4b5b
[SCFToCalyx] Add SCFToCalyx boilerplate [1/13] (#1812)
This is the initial commit for the SCFToCalyx pass. The commit sets up the boilerplate required for adding a new conversion pass.
2021-09-20 23:56:47 +01:00
cgyurgyik 642975a5b4 [Calyx] [nfc] Calyx control emitter only needs to take in a Block. 2021-09-20 14:29:47 -07:00
Andrew Young f57dfdc357
[ESI] Use new ParameterAttr for module parameters (#1817)
This fixes a compilation error in the integration test where ESI was not
switched to use a new dedicated ParameterAttr introduced in 471e60ce.
2021-09-20 13:25:56 -07:00
Morten Borup Petersen f353f91267 [Handshake][NFC] Iterate using getOps() where applicable 2021-09-20 09:50:07 +01:00
Morten Borup Petersen c30bb840ce [Handshake][NFC] Remove excess whitespace 2021-09-20 09:46:24 +01:00
Morten Borup Petersen 13eab41880 [Handshake][NFC] Simplify removeAllocOps 2021-09-20 09:43:24 +01:00
Morten Borup Petersen 29d84f0a58 [Handshake][NFC] Pass vectors by ArrayRef instead of by-value std::vector 2021-09-20 09:38:06 +01:00
Morten Borup Petersen ebaf6a7544 [Handshake][NFC] Address various static analysis warnings 2021-09-20 09:33:02 +01:00
Morten Borup Petersen 4c0cd77956 [Handshake][NFC] Use TypeSwitch in replaceMemOps 2021-09-20 09:27:02 +01:00
Morten Borup Petersen 98c7636031 [Handshake][NFC] Reduce use of large nested control statements 2021-09-20 09:20:42 +01:00
Morten Borup Petersen e1d50dcfa7 [Handshake][NFC] Simplify getControlMerge/getStartOp 2021-09-20 09:01:30 +01:00
Morten Borup Petersen 3053fcbbe3 [Handshake] Pass MergeLikeOpInterface directly to checkMergePredecessors 2021-09-20 08:52:37 +01:00
Morten Borup Petersen fdf0964182
[Handshake] Postpone adding ctrl arg to handshake::FuncOp until end of conversion (#1807)
No functional change, but a major step in the debug-ability of the pass. Previously, there was a discrepancy between the # of args of the Handshake FuncOp and the inlined body of the source FuncOp. This meant that any attempt at dump'ing the IR during conversion would crash, due a mismatch between the type signature of the handshake funcop and its entry block arguments.

This commit postpones adding the control argument to (and modifying the type signature of) the handshake funcOp until end of conversion.
2021-09-20 08:43:02 +01:00
Chris Lattner c0de60c9bb [HW] Add a ParameterAttr::getWithName member to consolidate helpers. 2021-09-19 21:36:26 -07:00
Chris Lattner ddb16da7a1 [HW] Replace getParameterNoValue with ParameterAttr::get members, NFC. 2021-09-19 21:33:26 -07:00
Chris Lattner 9d1a362dfd [HW] Move ParameterAttr from StructAttr to AttrDef
This makes it more efficient by storing it as a first-class attribute,
rather than as an interpreted dictionary.  This exposes a bunch of
ways in which StructAttr is unnecessarily different than AttrDef,
which is filed as LLVM PR 51909
2021-09-19 21:17:55 -07:00
Chris Lattner d5c1010efb [HWLegalizeNames] Handle renamed ParameterRefAttr's. 2021-09-19 17:47:05 -07:00
Chris Lattner c8d11ec6e4 [HW] Verify parameter values for modules and localparam. 2021-09-19 17:04:29 -07:00
Chris Lattner 08e46ac976 [HW] Verify that instance parameters are structurally correct. 2021-09-19 15:58:39 -07:00
Chris Lattner cb1d8bf727 [HW] Inline a function into its only caller to simplify code, NFC. 2021-09-19 15:31:21 -07:00
Chris Lattner d22f1dc019 Move sv.verbatim.parameter up to the HW dialect.
This also renames it to hw.verbatim.parameter.value, and gives it a
proper type.  This makes it possible to do attribute checking without
the overhead of introducing an attribute interface.
2021-09-19 15:28:50 -07:00
Chris Lattner 3390221cdd Two files that were supposed to go with the previous patch. 🤦 2021-09-19 13:58:00 -07:00
Chris Lattner 12ab97af33 [HW] Introduce ParameterRefAttr, allowing use of parameter values in a module body.
This is still missing validation of the attributes, but does include
ExportVerilog support.
2021-09-19 13:55:28 -07:00
Chris Lattner e1e7e0feaf [SV] Switch LocalParamOp to take an attribute instead of SSA value.
This keeps params and attributes in different domains.  This will
allow better enforcement of valid parameter values in the verifier.
2021-09-19 12:33:01 -07:00
John Demme 0f7bb1b2ce [ESI] Fixing Capnp code to use new parameters model 2021-09-18 18:44:52 -07:00
Chris Lattner 6e21c285bd [HW] Remove support for old-style parameters entirely.
This completes Issue #1489.
2021-09-18 17:49:31 -07:00
Chris Lattner b2d60da553 [ESI] Switch to the new parameter model. 2021-09-18 17:48:42 -07:00
Chris Lattner cdfe44bc23 [HWStubExternalModules] Correctly handle parameters now that we can represent them. 2021-09-18 17:45:48 -07:00
Chris Lattner 74eda94c4f [LowerToHW] Switch to the new HW parameter module.
This also switches the module build() methods to take an ArrayAttr for
parameters instead of an ArrayRef<ParameterAttr>.  This is more consistent
with instances and is easier to work with.
2021-09-18 17:12:22 -07:00
Chris Lattner 4a48372658 [ExportVerilog] Add support for instance parameters. 2021-09-18 16:43:40 -07:00
Chris Lattner 2ac8f90d84 [HWLegalizeNames] Propagate renamed parameters to instances correctly. 2021-09-18 16:25:58 -07:00
Chris Lattner 18746a3b4f [HW] Add IR parser/printer/verifier support for new-style instance parameters. 2021-09-18 15:57:47 -07:00
Chris Lattner 47a6ddbe59 [HW] rename "defaultValue" to just "value" in ParameterAttr. NFC. 2021-09-18 15:20:49 -07:00
Chris Lattner 1bb45c820b [HW] One more change for hw.instance parameters -> oldParameters. 2021-09-18 15:00:06 -07:00