Commit Graph

1155 Commits

Author SHA1 Message Date
Julian Oppermann 926bfbad2b
[Scheduling] Get problem instances via factory methods. (#2227)
Replaces the public single-argument constructors that initialize the containingOp in the Problem hierarchy with factory methods.
2021-11-30 09:53:49 +01:00
Schuyler Eldridge f3f595237e
[FIRRTL] Move Attribute ODS to separate file, NFC
Move FIRRTL dialect attribute definitions into their own file as opposed
to having these live in the same file as type definitions.  This is done
in preparation for adding more attributes representing parameters in the
FIRRTL dialect.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-11-29 17:42:12 -05:00
mikeurbach e52e7e9c6e
Reapply "[HW][SV][ExportVerilog] Add Comment to HWModuleOp, Verilog Emission (#2066)"
This reapplies the original change, with a small update to the Python
bindings to set a default for the new attribute when needed.
2021-11-28 11:26:21 -08:00
Hideto Ueno c2a836158a [FIRRTL/IMConstantProp] Add basic statistics, NFC
This commit adds basic basic statistics to IMConstantProp based on
mlir::Pass::Statistic. Here, `numFoldedOp`(number of operations
any of whose results are folded) and `numErasedOp` are added.
We can see stats by passing `--pass-statistics` to a command line.
2021-11-29 02:47:33 +09:00
Chris Lattner 606d024a2f [CombFolds] Simplify "extract of and" from a contiguous range.
This reduces the size of the extract, which allows recursive
folding into other operations.  This shrinks the .v file generated
for RocketCore.fir by 3.3%, from 2994 to 2897 lines.
2021-11-25 21:42:51 -08:00
Chris Lattner 495c145196
Revert "[HW][SV][ExportVerilog] Add Comment to HWModuleOp, Verilog Emission (#2066)" (#2240)
This reverts commit 89db86979c.
2021-11-25 18:28:47 -08:00
Fabian Schuiki 93562bb255
[LLHD] Remove TerminatorOp (#2236)
Since MLIR has gained the `NoTerminator` op trait in the meantime,
remove the LLHD `TerminatorOp` that was originally introduced to get
around a lack of this trait. This requires adjusting the code in a few
places where the terminator is handled explicitly.
2021-11-25 09:03:30 +01:00
Schuyler Eldridge 89db86979c
[HW][SV][ExportVerilog] Add Comment to HWModuleOp, Verilog Emission (#2066)
Add a new mandatory attribute, "comment", to HWModuleOp that describes a
string comment that should be attached to that module when this module
is emitted by a backend.

Add support for emitting comments associated with HWModuleOps during
ExportVerilog.  Use a simple line breaking algorithm to try to respect
the emittedLineLength option when reasonably possible.  Respect manual
line breaks that a user may have included in the comment.

Add tests that comments are emitted and that line breaking changes as
expected with changes to emittedLineLength.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-11-25 02:15:11 -05:00
Morten Borup Petersen fe32c20d96
[Transforms] add a `memref` flattening pass (#2230)
This is a pass which flattens statically sized memories and indexing into them by elaborating multi-dimensional indexing into a tree of multipliers and adders. The motivation of this is currently to be able to lower programs having multi-dimensional memories through the handshake flow, which currently only supports single-dimensional memories when lowering to FIRRTL.

Co-authored-by: Mike Urbach <mikeurbach@gmail.com>
2021-11-24 21:38:18 +00:00
Fabian Schuiki 56d7fa356d
[LLHD] Add pointer extract ops
LLHD has the various `llhd.sig.*` operations to extract values from
structs and arrays behind signals. This adds the same for pointers,
which are necessary to capture Moore's output.
2021-11-21 13:11:47 +01:00
Fabian Schuiki 58279f46dc
[LLHD] Add time attribute C API
Extend the LLHD C API to allow for `TimeAttr` to be created and
inspected.
2021-11-21 13:11:47 +01:00
Fabian Schuiki 36c2d395d2
[LLHD] Add type C API
Add a few functions to LLHD's C API to interact with the LLHD dialect
types.
2021-11-21 13:11:47 +01:00
Julian Oppermann 7fab996c4d [Scheduling] Shorten problem name, NFC.
s/SharedPipelinedOperatorsProblem/SharedOperatorsProblem

The "pipelined" in the name is kind of redundant because fully-pipelined operators currently are the default assumption in the modeling.
2021-11-20 21:57:34 +01:00
Prithayan Barua 05293191a1
[HW] Simplify module/instance input/output size computation. NFC (#2217)
Simplify the function to get the number of input and output ports 
for modules and instances, since they all have the same argument names.
2021-11-19 13:51:00 -08:00
mikeurbach 71a6e1976d
[HW][ExportVerilog] Treat typedecls like any other statement. (#2215)
This removes the restriction that a type scope is at the top-level,
and its special-cased visitors. Now, a type scope and its type
declarations can be visited just like any other statements. This
allows them to compose with other region-carrying ops, like ifdef.

Co-authored-by: John Demme <john.demme@microsoft.com>
2021-11-19 13:31:28 -08:00
Prithayan Barua 47a4cd2063
[ExportVerilog] Avoid getAllModulePortInfos for getting individual port name (#2208)
Avoid calling `getAllModulePortInfos` for getting the name of every port.
The `port id` should be enough to compute the required information.
The `emitTextWithSubstitutions` was calling `getAllModulePortInfos` and
was causing a run-time blow up for a large design with a module > 100 ports,
 with symbols on each of them which were used on a `VerbatimOp`.

(In particular, the `EmitOMIR` pass is creating this `VerbatimOp` and
adding a symbol to all the ports in the design.)
`ExportVerilog` runtime for a test case reduced from  580.3 sec to 152.1 sec
2021-11-19 11:04:50 -08:00
Fabian Schuiki aa1c294e99 [FIRRTL] Allow zero-width ConstantOp
Since the limitations on zero-width `APInt`s have disappeared upstream,
the `firrtl.constant` operation can now properly create a zero-width
constant. This is useful since these degenerate types do tend to appear
in real designs.
2021-11-19 16:55:05 +01:00
Fabian Schuiki 2c6f3cec3e
[FIRRTL] Add erasePorts helper function to InstanceOp
Add a helper function to `InstanceOp` that replaces the instance with
a new operation that has certain ports entirely dropped. This reflects
the `erasePorts` method that is available on modules as well.
2021-11-19 13:18:45 +01:00
Morten Borup Petersen f0e4a641f3
[Handshake] Major overhaul of the Handshake IR (#2206)
This (fairly monolithic) commit introduces a major overhaul of the Handshake IR syntax. The goal is to reduce verbosity by implementing custom parsers/printers. In doing so, we fold various attributes into being parts of the op syntax. This commits includes changes prior proposed by @stephenneuendorffer. Some work is still needed reducing the verbosity of `handshake.memory` operations, but I've decided to keep this commit as-is. While a major change, this is a mostly syntactical change, and underlying tests remain (largely) unmodified from a functional point of view.

Changes:
- the `handshake` dialect is now the default dialect within `handshake.func` operations, removing the need to prefix every single operation with `handshake.`
- Factors out "isControl" logic to an interface implemented by all handshake operations.
- Most ops now have "size, dataType" and "control" attributes as part of their arguments. This, alongside a shared operation syntax, is leveraged in the parsers. You'll notice that a SOST abbreviation is present in `HandshakeOps.cpp`. SOST being Sized Operation with Single Type.
- The `control` attribute is inferred from the "dataType" of the operation. This means that we no longer have "control = true" littered al over the IR. `control` is assumed whenever `dataType.isa<NoneType>()`.
- Examples added for all handshake ops in the TableGen file.

New syntaxes:
```mlir
%1:2 = fork [2] %0 : i32
%0 = merge %a, %b, %c : i32
%0 = mux %select [%data0, %data1, %data2] {attributes}: index, i32
%0, %idx = control_merge %a, %b, %c : i32
%1 = br %0 : i32
%true, %false = cond_br %cond, %data : i32
sink %data : i32
%0 = constant %ctrl {value = 42 : i32} : i32
%dataToSucc, %addr1ToMem, %addr2ToMem = load [%addr1, %addr2] %dataFromMem, %ctrl : i8, i16, index
%dataToMem, %addrToMem = store [%addr1, %addr2] %dataFromPred , %ctrl : i8, i16, index
%0 = join %a, %b, %c : i32
```
2021-11-19 08:48:25 +00:00
Fabian Schuiki 54723918c1
[FIRRTL] Add utility to change width of IntType; NFC
Add a handy helper function that returns an integer type of the same
kind but with an updated width.
2021-11-19 07:29:39 +01:00
mikeurbach b01caf0eb2
[StaticLogic] Make II required; document the current restrictions. (#2205)
For now, the pipeline is expected to be created after it has been
fully scheduled. Make the II required to reflect this, and add
documentation about this restriction, with a link to an open issue for
discussion.
2021-11-18 09:35:55 -08:00
Hideto Ueno 1d23fcdb15
[HW] Fix IndexBitWidthConstraint when the size is 1 (#2201) 2021-11-18 07:30:45 +09:00
Fabian Schuiki 2c47356c31
[FIRRTL] Add canonicalization for `pad(invalid) -> invalid` (#2198)
Add a canonicalization that maps a pad on an invalid value to an invalid
value of the appropriate width. This fixes #2197 and unblocks certain
parts of constant propagation around registers.
2021-11-17 18:41:57 +01:00
Morten Borup Petersen 83152e911e
[Handshake] Move fork/sink insertion pass out of StandardToHandshake (#2186)
This also slightly modifies the fork insertion logic by adding the missing forks to handshake function arguments.
2021-11-16 21:11:15 +00:00
Stephen Neuendorffer 24cd21820f Revert "Add default dialect for handshake.func (#2182)"
This reverts commit 117c566862.
2021-11-15 16:47:16 -08:00
stephenneuendorffer 117c566862
Add default dialect for handshake.func (#2182)
This avoids the need for the 'handshake' prefix in the textual IR.
2021-11-15 16:36:03 -08:00
mikeurbach bd05d96c11
[PyCDE] Add entry method for PhysicalRegions and their references. (#2174)
This add the necessary Python binding boilerplate to create
PhysicalBounds and PhysicalRegionRef attributes. A new API is added to
System, which inserts a PhysicalRegion. A wrapper class for
PhysicalRegion allows creating a region, adding bounds, and getting a
reference attribute suitable for use with the add_attribute API.
2021-11-15 10:02:34 -08:00
mikeurbach ad9237b58f
[StaticLogic] Add initiation interval attribute for pipelines. (#2171)
This attribute represents the initiation interval (II) of a
pipeline. For now, it is a simple integer representing the II computed
by the Scheduling infrastructure.
2021-11-15 09:06:52 -08:00
Prithayan Barua a26041e57f
[SV] Add folder for IndexedPartSelectInOutOp (#2178)
Remove the `IndexedPartSelectInOutOp` if input and output type are same.
Fixes https://github.com/llvm/circt/issues/2175
2021-11-15 07:25:56 -08:00
Fabian Schuiki 30fdc34aad
[FIRRTL] Add port symbol setters to FModuleLike (#2166)
Extend the `FModuleLike` interface to provide a somewhat more convenient
way of setting the optional symbols on ports.
2021-11-13 09:05:44 +01:00
Fabian Schuiki bb56a553ea
[FIRRTL] Refactor CircuitNamespace, add ModuleNamespace (#2165)
Factor the common base of `CircuitNamespace` into a new `NamespaceBase`
class and add a `ModuleNamespace` which captures the inner symbols of
the ports and declarations within a module. Also rename the header they
are in to `Namespace.h`.

Also, since `llvm::StringSet` internalizes the strings added to it and
`insert()` returns an iterator with the allocated key as a `StringRef`,
change the `newName()` function to return a `StringRef` instead of the
copying `std::string`.
2021-11-13 00:16:12 +01:00
mikeurbach 72b5a9d0c2
Staticlogic conversion revert (#2169)
* Revert "Revert "[StaticLogic] Add conversion pass for Affine loop nests. (#2157)""

This reverts commit 0ce0e99b7c.

The new pass wassing missing a CMake dependency on generated files.
2021-11-12 13:00:21 -07:00
Mike Urbach 0ce0e99b7c Revert "[StaticLogic] Add conversion pass for Affine loop nests. (#2157)"
This reverts commit 0308cf325e.

It was reported that this broke the Windows build.
2021-11-12 12:30:24 -07:00
Morten Borup Petersen 6b6cb024fd
[Handshake] Add support for external memories (#1982)
This commit adds a new operation `handshake.extmemory` to the handshake dialect, for accessing external memories.
The `handshake.extmemory` operation has identical semantics to the `handshake.memory` operation in terms of how `handshake.load` and `handshake.store` interacts with it.

The op is lowered by creating a handshake interface for each referencing load- and store operation that referenced the `handshake.extmemory`. This is equivalent to taking the interface that would be generated for a similar `handshake.memory` and moving that interface to the top-level module. It is then up to the external environment to define the handshake'd access to the external memory.
2021-11-12 18:22:24 +00:00
mikeurbach 0308cf325e
[StaticLogic] Add conversion pass for Affine loop nests. (#2157)
This is just the start of a pass, but this is enough to use the
scheduling tools and build a pipeline. At the moment, this doesn't
make use of the schedule, it just sets up a loop template. This is
just enough to lower a single loop and generate the appropriate
induction variable increments. Checkpointing here before moving any
further.

After this, I plan to add a helper class to this pass to answer the
questions we will need to flesh out createStaticLogicPipeline.

My goal is to take something as simple as this and start threading it
through the Calyx lowering to get a very thin path working before
adding support for more cases.

Co-authored-by: Julian Oppermann <oppermann@esa.tu-darmstadt.de>
2021-11-12 10:28:27 -07:00
Morten Borup Petersen e81bc63c1f [Handshake] Move resolveInstanceGraph out of HandshakeToFIRRTL
Resolving a top-level module is not exclusively needed by HandshakeToFIRRTL, so make it generally available.
2021-11-12 14:31:38 +00:00
Morten Borup Petersen 831eb661f4 [Handshake] Remove commented out code 2021-11-12 14:20:48 +00:00
Morten Borup Petersen a7b21383fa [Handshake] Move analysis passes out of StandardToHandshake
The dot printing and resource usage printing passes have nothing to do with StandardToHandshake. Passes are moved to a separate file, defining a new Handshake transformation library. Furthermore, dot printing and resource count are split to two separate passes.
2021-11-12 14:17:47 +00:00
Prithayan Barua fc831b8f8b
[SV] Add part-select operation to SV dialect (#2082)
Add indexed part-select op to the SV dialect.
Added two ops named `sv.part_select` and `sv.part_select_inout`,
that is lowered to the `indexed part-select` operation in SystemVerilog.
The `sv.part_select` is defined on `Integer` type input and
 `sv.part_select_inout` is defined on `inout` type.

 Part-select consists of 3 arguments, the input value,
 a `width` and a `base` and an optional boolean attribute `decrement`.
 The `width` shall be a compile-time constant expression.
 The `base` can be a runtime integer expression.

 The operation selects bits starting at the `base` and ascending
 or descending the bit range. The number of bits selected is equal to the
 `width` expression. The bit addressing is always ascending starting from the
 `base`, unless the `decrement` attribute is specified.
 
 Part-select is defined in section 11.5.1 of 1800-2017 spec.
2021-11-12 04:57:28 -08:00
Morten Borup Petersen c9fd34d59a
[Handshake] Add more specialized IO names (#2161) 2021-11-12 09:54:39 +00:00
Morten Borup Petersen 4346e0bb69
[Handshake] Ensure `argNames` and `resNames` attributes (#2144)
This commit ensures that the `argNames` and `resNames` attributes are always present in a `handshake.func` operation. The names are either partially (if some names were already provided to the op during conversion) or fully inferred based on whatever information available when parsing or building the `handshake.func` op.
In doing so, we move signal name generation from handshakeToFIRRTL into being part of the operation itself.
2021-11-12 08:47:11 +00:00
Morten Borup Petersen 6875a3130b
[Handshake] Add interface for specializing port naming (#2151)
This commit introduces a new interface `NamedIOInterface` for handshake operations. This interface is intended to capture the naming of the in- and output operands of a handshake operation. The interface implements a default naming convention equal to what's currently being used (in#, out#). However, operations can override this interface to provide more specialized naming, such as the `MuxOp` example used in the commit.

The interface is used in in HandshakeToFIRRTL through a class `PortNameGenerator`. This class handles port name generation for all operands which may be lowered into handshake modules. If the source operand was a handshake operand (which implements the `NamedIOInterface`) the interface is used to generate port names. Else, default names are generated.
2021-11-12 08:46:02 +00:00
John Demme 75c6cca442
[PyCDE] [MSFT] Emit modules into separate SV files (#2158)
Add an attribute to `msft.module` specifying the filename in which the
generated SystemVerilog should be placed. In PyCDE, use the module name
as the output filename.
2021-11-11 20:13:13 -08:00
Mike Urbach e3463b758d [StaticLogic] Add more helper methods to pipeline and stage ops, NFC.
This adds a helper build method to PipelineStageOp, which creates an
empty stage given the result types. Also adds accesors to get blocks
from the PipelineWhileOp and PipelineStageOp. These will be used in a
new pass.
2021-11-11 18:00:39 -07:00
Mike Urbach 3ecc825821 [StaticLogic] Add helper build method to PipelineWhileOp, NFC.
This creates the op with its two single-block regions populated. The
blocks have the correct block arguments and a blank terminator. This
will be helpful for an upcoming pass to use.
2021-11-11 17:04:06 -07:00
mikeurbach a1a53a650b
[MSFT] Add Tcl export support for PhysicalRegions. (#2155)
This is a very simple start to Tcl support for PhysicalRegions. For
now physical region references and the PlacedInstances making the
reference are just stored in a vector that can be walked to emit the
necessary Tcl. More complex storage and queries for PhysicalRegions
can be added as the need arises.
2021-11-11 15:34:37 -07:00
mikeurbach e31c9c38d2
[MSFT] Add PhysicalRegion op and related attributes. (#2153)
A PhysicalRegion is a Symbol which can be referred to by ops to be
placed within it. It contains potentially multiple rectangular bounds
on the physical device.
2021-11-11 14:35:02 -07:00
Fabian Schuiki 0814c3a0a6
[FIRRTL] Add option to treat non-const async reset as warning/error (#2149)
Add an option to decide whether `LowerToHW` should treat non-constant
async reset values as warning or error. Have firtool keep these as
errors unless IMConstProp is disabled, in which case it is highlgy
likely that the user does not care about a full stop of the compilation
and his downstream tools will possibly break for a lot of other reasons.
2021-11-11 20:36:44 +01:00
Fabian Schuiki 419758c3ef
[FIRRTL] Add port symbols to module and extmodule ops (#2083)
Extend the FIRRTL dialect such that the `FModuleOp` and `FExtModuleOp`
operations can carry an optional symbol for each of their ports. This is
done in a similar fashion as port names, directions, and annotations, in
that there is a separate array attribute which tracks the symbol for
each port. Since leaving null attributes in the IR is a bit yucky, the
absence of a symbol is encoded as an empty string.

This extends module-like port lists to support the following:

    firrtl.module @Foo(
      in %a: !firrtl.uint<1> sym @symbolA,
      out %b: !firrtl.uint<1> sym @symbolB
    )

The change to the IR itself is pretty trivial, but causes a whole bunch
of follow-up fixes in all the places that build or modify modules. These
places are surprisingly numerous and would benefit from some later
cleanup. @youngar has looked into moving the module-like signature into
a separate single attribute, which may go a long way towards making this
prettier.

This also adds tests to ensure port symbols are properly represented
within the FIRRTL dialect, they carry over into the HW dialect as
expected, and that using FIRRTL port symbols in `sv.verbatim` operations
has the intended Verilog output result.

This PR enables a whole bunch of follow-up work to make metadata and
OMIR emission cleaner and more robust in the presence of renaming.
2021-11-11 18:02:00 +01:00
Chris Gyurgyik 08f2af49b6
[Calyx] Add unsigned multiply and divide operators. (#2137)
Adds unsigned multiply and divide pipeline operators as Calyx primitives.
2021-11-11 07:04:27 -08:00