Commit Graph

116 Commits

Author SHA1 Message Date
Hideto Ueno 694f03773c
[circt-opt] Export symbols for MLIR plugins (#6278)
This commit adds pupport for MLIR plugins for circt-opt
2023-10-11 20:47:26 +09:00
Martin Erhart 1e1a461ba0
[Arc] Introduce vectorize operation (#6120)
Hardware designs commonly have a considerable amount of duplicated logic
for parallel execution (e.g., multiple cores). This logic can be
collected and vectorized. This operation allows us to separate the
concerns of finding logic to vectorize, applying a cost model on whether
it is actually worth vectorizing the found set of operations (since
gather, scatter, shuffling might be more expensive than what we save
from vectorizing), and performing the actual vectorization to SIMD
registers or pack them within a scalar register.
2023-09-14 08:23:47 +02:00
Morten Borup Petersen 7a3b9e478b
[Handshake] `StandardToHandshake` -> `CFToHandshake` (#5938)
... long awaited.
2023-08-25 09:24:26 +02:00
Rachit Nigam d35c2de896
Calyx native callout pass (#5879)
* start working on adding a calyx native callout pass

* missing entry in CMakeLists for circt-opt

* emit calyx in pass

* progress

* specify primitives lib

* it works!!

* fewer imports

* fix CMakeList

* cleaup and comments

* remove useless stringref

* better error message when `calyx` binary is missing

* header style

* remove primitives folder option and define pass-pipeline

* remove braces

* add native pass to calyx namespace

* remove empty namespace

* add dependency to CAPI

* clang-tidy
2023-08-24 09:16:54 +05:30
Nandor Licker 62f5672b3e
[Seq] Lower both registers and memories in the same pass (#5853)
This PR moves the conversion of FIRRTL-specific `seq` ops to their own conversion pass, `SeqToSV`.
The existing register & memory lowering passes are packaged as re-usable utilities to keep them available as individual transformations.
Both the memory and register lowering utilities are packaged into a single parallelized lowering.
2023-08-22 20:31:20 +03:00
Vito Gamberini 11d61f80a5
[CMake] Implement add_circt_tool() (#5821)
- Adds/renames the associated CMake variables:
   * CIRCT_BUILD_TOOLS
   * CIRCT_INCLUDE_TOOLS
   * CIRCT_TOOLS_INSTALL_DIR

- Actually uses the CIRCT_INCLUDE_TOOLS variable now
2023-08-10 18:37:45 -05:00
Hideto Ueno 380ed1d945
[OM] Implement OM linker pass (#5743)
This implements LinkModulesPass that is a core logic of `om-linker`.
The input IR consists of multiple mlir::ModuleOp that have their own
symbol namespaces. LinkModulesPass first constructs a map from
symbols to ClassLike operations and checks whether it’s legal to link the classes.

We consider a symbol used as an external module to be "public" thus we
cannot rename such symbols when symbols collide. We require a public symbol
to have exactly one definition so otherwise raise an error.

Also a definition and declarations must have the same input types and fields.
2023-08-03 01:23:33 +09:00
John Demme d4b591e20f
[Ibis] Call preparation pass -- part 1 (#5683)
Lowering the Ibis control flow starts with converting all calls to the DC dialect's values with one struct representing the packed arguments.

In the interest of incremental development, this only implements narrowing the arguments to one struct. Part 2 will then wrap them in DC values.
2023-07-27 13:58:15 -07:00
Morten Borup Petersen 2b14a00cba
[Verif] Add `format_verilog_string, print` operations (#5616)
#5577, #5575

Re. the lowering; `verif.print` lowers directly to a `sv.fwrite` via. inspection of its source operand (which is expected to be a `verif.format_verilog_string`). The source `format_verilog_string` is `not` deleted in the process (there may be other users). However, i marked `verif.format_verilog_string` as `Pure` meaning that it'll get removed if `canonicalize` is run after `lower-verif-to-sv` and there are no more users of the result.
It's expected that `verif.print` will reside inside *something* that eventually lowers to a procedural SV region, if one is going the SV route. I'd imagine that most users will embed `verif.print` inside `hw.triggered` regions.
2023-07-20 13:12:31 +02:00
John Demme db0e895874
[Ibis] Boilerplate for a new dialect (#5609)
We will be porting an internal language over to CIRCT. This dialect will
be the entry point into CIRCT. Eventually, all of the backend will be
part of CIRCT and the frontend parser will be open sourced.

We plan on developing this dialect in the open so as to not dump a giant
PR at some point months down the road.
2023-07-18 11:37:36 -07:00
Morten Borup Petersen fac5bc8625
[HW] Add `hw.triggered` op (#5582)
Here's a stab at the `hw.triggered` operation.
I think the main issue is to decide where to place the lowering. AFAICT, the closest we have to a "hw to sv" conversion pass is `hw-legalize-modules` (which really should be named to `sv-legalize-modules` seeing as it's lowering away HW constructs in favor of SV constructs).
I chose to introduce a new pass - `lower-hw-to-sv` which could serve as a clear home for these kinds of lowerings (maybe some things in `HWLegalizeModules` could be moved to here?).

Lastly, just went with a simple assembly format. If people would like to see something more fancy, e.g. an initializer-list style format with an elided entry block:
> `hw.triggered postedge %t (%a0 : i32 = %in) { ...`
let me know.
2023-07-17 09:51:33 +02:00
Marco Balboni e8ec7d73e3
[LLVM] Bump to e105141 (#5414)
* Ensure the ControlFlow dialect is registered in the context where needed and linked against (not sure where exactly this stems from)
* LLVM IR cttz and ctlz intrinsics moved from undef to poison and take an attribute instead of value now: https://reviews.llvm.org/D151692
* Function inliner extension is a promised interface: https://reviews.llvm.org/D120368
* New replaceOp added to Rewriter: https://reviews.llvm.org/D152814

---------

Co-authored-by: Martin Erhart <maerhart@outlook.com>
2023-06-21 13:20:27 +02:00
John Demme 3a62185526
[Comb] Lower comb pass boilerplate (#5433)
Some operations in the comb dialect (e.g. comb.truth_table) are not directly supported by ExportVerilog. They need to be lowered into ops which are supported. There are many ways to lower these ops so we do this in a separate pass. This also allows the lowered form to participate in optimizations like the comb canonicalizers. This change is just to introduce the pass boilerplate. It currently doesn't do anything.
2023-06-20 14:39:39 -07:00
Morten Borup Petersen dcf8d1b0bd
[DCToHW] Add DCToHW conversion pass (#5298)
This commit adds a lowering of DC operation to a combination of
`comb,seq` and `hw` operations. The implementations are identical to
those of the `handshake` dialect (i.e. `handshake-to-hw` sans the
arithmetic operations).

- ESI-typed I/O
- DC buffers lower to ESI buffers
  - This is just a temporary solution. I anticipate more complexity here
    in the future when we want to do more with the FIFOs that connect
    DC circuits.
- In case the IR contains DC operations that need to be clocked (fork, buffer),
  there must exist a clock and reset signal in the parent `FunctionLike`
  operation. These arguments are to be marked with a `dc.clock` and `dc.reset`
  attribute, respectively.
- Only a single integration test for now. Will add more once #5297 lands
  (allows us to do some high-level tests through handshake).
2023-06-20 15:18:53 +02:00
Fabian Schuiki 1460774177
Add LTL and Verif dialects (#5255)
Add two new dialects to CIRCT.

The `ltl` dialect represents Linear Temporal Logic expressions and
borrows from SystemVerilog's rich assertion system (SVAs). The current
implementation is fairly minimal, but is sufficient to capture basic
liveness properties and something akin to "regular expressions over
time". Since the mapping from SVAs to this dialect is non-trivial, there
is an `LTL.md` doc accompanying the dialect to capture some of the
design decisions.

The `verif` dialect captures various verification-related operations.
It currently contains just a trivial flavor of assert, assume, and
cover, without any labels, messages, or value interpolation. The
intention is for these operations to be expanded in the future until
they can replace the corresponding operations in the SV dialect. The
`verif` dialect will also be a good place to introduce
verification-specific concepts such as test programs, clock generators,
pre- and post-condition checks.

The LTL operations have a few basic folds and canonicalizations defined
on them, to be expanded later. Something like a "never" sequence or
property would be useful to have unreachable/unmatachable sequences fold
to something.

Support for emission in ExportVerilog will be done in a separate commit.
2023-05-26 18:22:10 -07:00
Morten Borup Petersen fca113cf89
[HandshakeToDC] Add conversion (#5214)
... progressive lowering of handshake!
This obviously requires a future addition of an `arith-to-comb/hw` pass to map arith stuff to comb/external hardware/pipelines, ...
2023-05-19 12:28:55 +02:00
Morten Borup Petersen dcc4b03ce7
[DC] Add fork/sink materialization passes (#5159) 2023-05-17 10:43:55 +02:00
Morten Borup Petersen fc453c51cd
[DC] Add rationale and boilerplate (#5156)
This PR adds the DC dialect rationale and most of the dialect-related boilerplate.
2023-05-10 11:53:19 +02:00
Morten Borup Petersen 36289534c6
[HandshakeToFIRRTL] <- deprecate (#5130)
Removes the handshake to FIRRTL lowering pass.

Also:
* All handshake integration tests now run through the handshake to HW pass (thanks to 936db150)
* Some changes were required to the handshake cocotb test runner, seeing as struct are not flattened in HandshakeToHW.
2023-05-05 13:56:41 +02:00
Nandor Licker acadcaf9dc
LLVM Bump (#5070)
TypedAttr changed requiring adjustments to HWAttributes.
Affine was moved to its own namespace.
2023-04-25 08:43:56 -07:00
Andrew Butt 80c76afb86
[LoopSchedule] Move PipelineWhile and Related Ops from Pipeline to LoopSchedule (#4947) 2023-04-18 11:56:07 -04:00
Morten Borup Petersen cca008cabe
Enable `--view-op-graph` for circt-opt (#5046) 2023-04-15 17:43:27 +02:00
Andrew Butt 5061640e30
[LoopSchedule] Add initial LoopSchedule dialect (#4935) 2023-04-05 11:58:08 -04:00
Fabian Schuiki 90832beed7
[Arc] Add basic LLVM lowering (#4685)
Add two passes to lower a design to a software model.

The `LowerClocksToFuncs` pass outlines all `arc.clock_tree` and
`arc.passthrough` operations into separate MLIR functions. This
conceptually converts clocks from being a signal in the design into a
function that can be called in order to execute the state update
triggered by that clock.

The `LowerArcToLLVM` conversion pass does exactly as it says: it sets up
a dialect conversion from Arc and the core CIRCT dialects to Func/SCF,
and from there to the LLVM dialect.

Also add an output format option to the arcilator tool that allows for
the direct emission of LLVM IR (as opposed to the MLIR's LLVM dialect).

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-03-28 14:04:49 -07:00
Mike Urbach 44d360705e
[OM] Initial implementation of the OM dialect. (#4836)
This defines the dialect boilerplate, as well as a rationale document
that explains the intended use case and initial core constructs that
will be added in future patches.
2023-03-20 12:45:08 -06:00
Fabian Schuiki ee95300b53
[Conversion] Add Comb to MLIR Arith conversion pass (#4728)
Add an experimental pass to convert operations in the Comb dialect to
their equivalent in the Arith dialect. The pass isn't used anywhere yet,
but conversion to Arith allows all canonicalizations defined on that
dialect to take effect before mapping things to LLVM to generate a
software model.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
2023-03-15 21:54:35 -07:00
Fabian Schuiki 034a9e9825
[Arc] Add deduplication pass (#4698)
Add the `Dedup` pass which deduplicates arcs with identical definitions.
If arcs differ only by constant values, the pass outlines the constants
such that the arcs can be deduplicated.

Identical arcs are surprisingly common since splitting modules along the
fundamental state elements yields a finer-grained subdivision than the
modules themselves, which has the potential to uncover additional
redundancies.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-03-12 16:37:35 -07:00
Hideto Ueno c187f68b3f [circt-opt] Print a version string
This commit adds `cl::AddExtraVersionPrinter` to circt-opt as we are doing
in firtool.
2023-03-07 04:31:56 -08:00
Fabian Schuiki 55e2230e3f
[Arc] Add arc conversion pass (#4697)
Add the `ConvertToArcs` conversion which collects the combinational
operations in a module body, divides them into distinct sets split along
registers and a few other potentially state-holding operations, and
outlines these sets into arc definitions, inserting an `arc.state` op in
place of the original combinational ops.

Note that this merely replaces logic and registers with arc invocations,
but keeps the module hierarchy intact.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-02-23 22:27:01 -08:00
Fabian Schuiki 037bd2b012
[Arc] Add dialect (#4681)
Add the `Arc` dialect which is useful for capturing a canonical
representation of the state transfer in a circuit. It does this by
introducing function-like arc definitions (`arc.define`) and call-like
arc invocations (`arc.state`). The state op represents a transfer
function, given by the arc definition, and zero or more registers, as
specified by its latency attribute.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-02-22 01:24:22 -08:00
Julian Oppermann 2d0430eac4
[Scheduling] Purge test passes. (#4572)
Use the SSP dialect and `-ssp-schedule` instead.
2023-01-24 08:38:48 +13:00
Julian Oppermann fa61059d0a
[SSP] Add pass to print instances as DOT graphs. (#4363) 2022-11-29 12:27:29 +13:00
Schuyler Eldridge c676bc9173
[tools] Change tools to use CIRCT-specific bug msg
Change all existing CIRCT tools to use a CIRCT-specific bug report
message.  Previously a crash would tell people to file a bug on LLVM
which isn't correct.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-11-12 18:10:54 -05:00
Martin Erhart d6ca0e6ff9
[SystemC] Lower Interop pass for verilated operation (#4143) 2022-10-26 21:09:29 +02:00
Martin Erhart c0f0d4c97d
[RFC] Interoperability dialect (#4126) 2022-10-25 10:50:46 +02:00
Andrew Lenharth 5498d926f4
Don't read lowering options from hidden global options (#4038)
Add a pass to overwrite lowering options on a module. This lets us get rid of the in-library cmdline option and move it to the two tools which need it. With this, prepare and export never change the lowering options.

Also make prepare a nested pass.
2022-10-04 15:41:03 -05:00
Mike Urbach d4aade214b
Bump LLVM to c4ca3a2c4b00033c393f694c1d92d28ff55c69cd. (#4048)
This included three renames:
* Arithmetic -> Arith
* FunctionOpInterface::getBody -> FunctionOpInterface::getBodyBlock
* MemRef dialect switching to prefixed accessors (memref -> getMemref, etc.)
2022-10-03 20:36:21 -06:00
Will Dietz d7892c8a8c
[FIRRTL] Reuse HierPathOp's when creating in LA, fix GC(T) cleanup, add SymbolDCE to pipeline (#3979)
We create and manage many thousands of HierPathOp's unnecessarily.
Fix this by addressing the primary location they're added to the IR: LowerAnnotations, by using a simple cache to avoid emitting duplicate ops.
This reduces the count from thousands to tens on even small-ish designs.

Modify GC and GCT passes to stop deleting HierPathOp's as they don't know if they're still used. Indeed, in our tests we were deleting these ops despite them still being alive (breadcrumbs).

Add SymbolDCE to the pipeline to do this cleanup instead, thanks to various recent changes using private visibility in many places, particularly the HierPathOp's themselves (#3871).
2022-09-23 10:02:28 -05:00
Morten Borup Petersen 616649b4b6
[Pipeline] Add pipeline stage register materialization pass (#3876)
[Pipeline] Add pipeline stage register materialization pass

This commit adds an intermediate transformation to the Pipeline dialect
which is responsible for converting `pipeline.stage` to `pipeline.stage.register`
operations. The purpose of this transformation is to 'fix' where
registers needs to be placed in the pipeline, after all stages have been
defined and placed.

In short, the transformation will scan through the pipeline (in order,
top to bottom) and insert `pipeline.stage.register` operations in place
of `pipeline.stage` operations. Any operand used in any operation will
be analyzed to determine if it originates in between the last seen stage
and the operation itself. If not, this means that the operand crossed
a pipeline stage, and as such, the value will be routed through the
predecessor stage (`routeThroughStage`).
2022-09-16 15:03:58 +02:00
Morten Borup Petersen e7405f7be9
[Pipeline] Add `pipeline.pipeline` HW lowering (#3874)
This is a fairly straight-forward transformation since the brunt of the
work of detecting which values will be registered in a given pipeline
stage has already been performed by a prior pass.
This pass simply elaborates the `pipeline.stage.register` operations
into `seq.compreg` operations and stitches up the circuit.
2022-09-14 17:41:29 +02:00
Martin Erhart 485952a28c
[SystemC] Add NewOp and DeleteOp (#3798) 2022-09-01 11:57:52 +02:00
Daniel Resnick 5f91346570
[ExportChiselInterface] Basic infrastructure for Chisel Interface file emission (#3760)
* [ExportChiselInterface] Basic infrastructure for Chisel Interface file emission

This commit adds a pass for FIRRTL that generates a Scala file with a module
class that represents the interface for the top module of the FIRRTL circuit.
This is to support the development of separable compilation of FIRRTL circuits.
The details about linking circuits together are to be determined. The generated
Scala module extends ExtModule, although a new module class may be introduced
in the future.
2022-08-25 11:56:50 -06:00
Mike Urbach b706f4d78d
[Pipeline] Remove original PipelineOp and conversion. (#3685)
This representation and conversion aren't being used, and never
connected to Verilog output. The newer PipelineWhileOp could subsume
this use-case, and further evolution is coming to this dialect, so it
seems like a good time to clean out the older parts that aren't used.
2022-08-08 11:26:20 -07:00
Morten Borup Petersen b078252e67
[MSFT][NFC] Split MSFT passes into separate files (#3683)
Motivation:
1. This file is nearing 2000 LOC. I personally find that having a single file per pass helps in quickly navigating to/between implementations of different passes. Bunching everything into one file makes locating things just a bit harder.
2. This is the style used in the remainder of CIRCT.
3. Uses canonical CMake structure for declaring passes.
2022-08-08 19:41:59 +02:00
Martin Erhart 6e81996914
[ExportSystemC] Move pass from circt-opt to circt-translate (#3664)
Move to circt-translate because the pass does not modify the IR in any
way. Add basic code to emit each module or function to a separate file.
2022-08-05 20:28:48 +02:00
Morten Borup Petersen b3359685c7
[StaticLogic] Rename dialect to 'Pipeline' (#3648)
It is probably fair to conclude that naming this dialect `StaticLogic` has been a pain point for a while. This commit proposes a dialect renaming to `Pipeline`, for a couple of reaons:

1. So far, we've only been working with pipeline abstractions within this dialect.
2. Pipeline representations aren't necessarily statically scheduled - we plan on adding switches to select between latency sensitive and latency insensitive lowerings of pipelines.

This name change does not preclude renamings in the future if we want to fit more stuff into this dialect. Personally, i think it is prudent to maintain a dialect name which reflects what's actually being done within the dialect, as well as the (near/mid/"someone actually intends to work on this"-term) future plans for the dialect.
2022-08-04 10:58:40 +02:00
Bea Healy 2c95a38a71
[LLHDToLLVM] Refactor conversion patterns of each dialect to separate files (#3599)
Moves Comb to LLVM and HW to LLVM conversions out of the LLHDToLLVM pass and into their own dedicated lowering passes, as proposed in #3539.

The methods convertToLLVMEndianess and llvmIndexOfStructField are also encapsulated here within a HWToLLVMEndianessConverter class, in order to allow easier re-use between different passes.
2022-07-29 12:29:32 +02:00
Julian Oppermann 6c0681e95c
[SSP][Scheduling] SSP dialect rationale and boilerplate. (#3558) 2022-07-26 09:35:53 +02:00
Morten Borup Petersen 14ca56c139
[CalyxToFSM] Add CalyxToFSM conversion pass (#3213)
This commit represents a lowering pass for converting a Calyx control schedule (seq/if/while/enable) into an FSM representation. The FSM is embedded within the Calyx component, and references both the group symbols and cell SSA values.

The lowering method is a fairly straight forward conversion, which leaves plenty of canonicalization opportunities to remove redundant states in the generated FSM. However, doing it as presented in this PR lends itself to some very clean code (which I prefer, rather than prematurely optimizing during lowering) as well as meaningful naming of states (which i think is fairly important).
2022-07-21 18:54:37 +02:00
Martin Erhart 4069407da9
[SystemC] Add exporter skeleton (#3523) 2022-07-19 21:59:50 +02:00