Commit Graph

2991 Commits

Author SHA1 Message Date
Schuyler Eldridge 7ea9badefd
[FIRRTL] Add very simple GroupSink pass
Add a new pass, GroupSink/firrtl-group-sink, which will sink operations
that are only used by optional groups into optional groups.  This is very
simple at present.  This pass uses `mlir::controlFlowSink` to sink ops
into regions.  This only works for very simple things in FIRRTL which have
normal SSA dominance, e.g., nodes, constants, or primitive operations.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2023-09-26 15:21:33 -04:00
Morten Borup Petersen 6735dfa983 [Ibis] Also remove reads of writes in clean-selfdrivers 2023-09-26 13:17:41 +00:00
Morten Borup Petersen c401c4c2ae
[Ibis] Fix clean selfdrivers in case of external reads (#6201) 2023-09-26 12:19:46 +02:00
Morten Borup Petersen 551629a8f7 [Ibis] Add missing dependent dialect to `ibis-clean-selfdrivers` 2023-09-26 08:34:37 +00:00
Morten Borup Petersen 290d917c02
[Pipeline] Remove internal clock, reset,stall signals. (#6196)
This also simplifies the stage enable signals, seeing as the entry enable signal will now always be the last argument of any mlir block inside the pipeline.
2023-09-25 16:25:59 +02:00
Schuyler Eldridge 7245b61676
[firtool] Add -no-dedup option
Add an option to disable structural deduplication of FIRRTL modules.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2023-09-22 23:49:35 -04:00
Schuyler Eldridge 993732aa1c
Remove GlobalRefOp, GlobalRefAttr
Remove the now unused global reference operations and attributes.  These
have been fully migrated to HierPathOp.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2023-09-22 11:11:50 -04:00
Will Dietz 81ef908d66
[FIRRTL][HoistPassthrough] Add pass to hoist must-driven output ports. (#6115)
Basic driver analysis to detect must-driven values and hoist/rematerialize them using equivalent driver at instantiation site.

Disabled for HW signals to start.  See PR for impact on some designs and discussion/details.
2023-09-22 09:57:48 -05:00
Morten Borup Petersen 0a37e57f21
[Ibis] Add Ibis CF to Handshake conversion (#6164)
Converts an `ibis.method` into an `ibis.method.df` by converting
controlflow using `cf` to `handshake` dialect conversion applied to
the `ibis.method` body region.
2023-09-22 13:43:58 +02:00
John Demme 1b901c33b8
[NFC][ESI][MSFT] Move AppIDs over to ESI (#6177)
Since AppIDs serve as system identifiers, they classify as a system
construction feature. So they should be in the ESI dialect, which will
be using them shortly.
2023-09-21 18:11:30 -07:00
Will Dietz ca5affe6a1 [NFC] Prefer (void) over (), quiet prototype warnings.
Will be same in C23, but until then be explicit.
2023-09-21 18:53:54 -05:00
John Demme 235dd22c21
[MSFT] Remove DiscoverAppIDs pass (#6175)
Replaced this with AppIDIndex API. Also cleans up a few mothballs.
2023-09-21 15:37:03 -07:00
John Demme ab58b28515
[MSFT] Rip out MSFTModule et. al. (#6161)
Closes #6109.
2023-09-21 14:55:41 -07:00
John Demme f3bd4d2f05 [Ibis] Put PathDirection enum in Ibis namespace
Accidently omitted the namespace.
2023-09-21 21:50:36 +00:00
Will Dietz 32c1db21d4
[FIRRTL] Add Double property type. (#6167)
Double-precision floating point type.

Add attribute, constant op, and parse + emit support.

Only support what we understand as floatingpoint in lexer for now, which includes exponent notation.

Add support to LowerClasses.
2023-09-21 16:22:54 -05:00
John Demme ff1f72d328
[MSFT] Finally move away from GlobalRefOp (#6168)
Switch to HierPathOp. Closes #5183.
2023-09-21 13:17:24 -07:00
Morten Borup Petersen 77630d57ec
[Ibis] Add `ibis.method.df` operation (#6163)
Ibis dataflow methods share the same interface as an `ibis.method` but without imperative CFG-based control flow. Instead, this method implements a graph region, and control flow is expected to be defined by dataflow operations.
2023-09-21 11:06:10 +02:00
Morten Borup Petersen 60db6832b4
[CFToHandshake] Refactor towards genericness (#6156)
A couple of minor refactors - more will come - to allow for using `CFToHandshake` on things other than just `func.func` as the source operation and `handshake.func` as the target operation.
2023-09-21 10:24:50 +02:00
John Demme 0510ad8caa [MSFT] AppIDIndex add methods for querying paths
- `getChildAppIDsOf` to inquire about all of the AppIDs contained by a
module.
- `getAppIDPathAttr` to get the path to an AppID from a moduled.
2023-09-21 02:29:20 +00:00
John Demme a9f55cab80
[MSFT] Make AppID discovery an index rather than a pass (#6152)
Discovering AppIDs used to be a pass and only worked on `msft.module`s. Since we're removing them, make AppID discovery an API which creates dynamic instances from AppIDs. Since it'll primarily be used from PyCDE, expose to Python. Test through Python.

Will remove the discover appid pass in a subsequent PR. Progress on #6109.
2023-09-20 13:17:43 -07:00
Prithayan Barua 7556e97987
[ExportVerilog] Add verilog debug locations to output MLIR (#6092)
Use the PrettyPrinter CallbackToken API, to record print events and store the
 verilog output locations for each operation. Record the print begin and end
 location of each op. This has a side-effect of updating the IR, location
 attribute of the op is updated to include the verilog location range. `FusedLoc`
 is used to record the location ranges and each op can correspond to multiple
verilog locations.
This feature is disabled by default under an emission flag `emitVerilogLocations`.
2023-09-20 07:26:33 -07:00
Morten Borup Petersen 6b9b69a94f
[NFC][Handshake] Adjust handshake interface defs and file locs (#6150) 2023-09-20 09:18:56 +02:00
Morten Borup Petersen 8d7abdd5f3
[Ibis] Allow multiple return values for `ibis.method` (#6151)
The prior motivation for a single return value was to enforce... well, exactly that. However, this is nothing but a pain, requiring the user to tupel/struct-ify return values at a high level. This is a trivial transformation that can be done down the line. Allowing multiple return values, however, allows this op to play much more nicely with other passes and code that expects function-like operations (and terminators of said ops) to -generally speaking - accept multiple return values.
2023-09-20 09:18:06 +02:00
Prithayan Barua 10da65bf1d
[OM] Python bindings for om integer (#6042)
Implement the python bindings for the `om.integer` attribute. Add support to
 create `om::IntegerAttr` from `mlir::IntegerAttr`. Also ensure all tests use
 `om::IntegerAttr` instead of `mlir::IntegerAttr`.
2023-09-19 13:41:46 -07:00
Hideto Ueno 8129d5de50
[HW][Python] Add name getters for ModuleType (#6149)
`argNames` and `resultNames` attributes were removed from HWModule (https://github.com/llvm/circt/pull/6095) in the presence of ModuleType but downstream python tools are relying these attributes for name look up. However currently there is no CAPI/Python API for ModuleType to query names of ports so this PR adds CAPI and bindings respectively in the same way to port types.
2023-09-20 00:45:01 +09:00
Morten Borup Petersen 6480820d96
[Ibis] Add `ibis.sblock` inlining operations and passes (#6145)
Inlines `ibis.sblock` operations, by creating MLIR blocks and `cf` operations, while adding annotations to the parent operation about `sblock`-specific attributes.
2023-09-19 12:45:13 +02:00
Sprite 7fdad47176 [Firtool] Move the remaining pass additions into lib 2023-09-19 17:45:43 +08:00
lonely eagle 89f824677d
[scf-to-calyx] Support for function call (#5965) 2023-09-18 19:24:16 -06:00
Will Dietz 05d84c1659 Add SymbolTable.h to InstanceGraphInterface.h fix build breakage.
Broken in da1802f907 .
2023-09-18 16:17:56 -05:00
Nandor Licker da1802f907 [HW][NFC] Provide default implementations to HW instance accessors 2023-09-18 10:09:25 -07:00
Nandor Licker 0fc8656168
[Seq] Switch all seq ops to use seq.clock (#6139) 2023-09-18 16:38:32 +03:00
Nandor Licker 83c10b809e
[Seq] Convert `seq.clock_gate` to use the clock type exclusively (#6134)
This PR restricts the clock gate op to solely use the clock type.

Uses in other dialects, especially Pipeline, were adjusted.

To maintain canonicalization behaviour, a clock constant op along with an attribute is also introduced to represent constant clocks and to fold ops to them.
2023-09-18 12:36:04 +03:00
Morten Borup Petersen 83abbfc0f4
[Handshake] Allow handshake ops to be used outside of a `handshake.func` (#6132)
... by requiring that handshake ops are nested within an operation that inherits the `FineGrainedDataflowRegionOpInterface`.
This is somewhat of a half-way solution, seeing as there isn't support for `HasParent` with an interface upstream. I've raised the issue and suggested a fix here https://github.com/llvm/llvm-project/pull/66196 but we'll see how long that takes to resolve.

Until then, added a `HasParentInterface` which does the same thing, albeit with a cryptic error message about which interface the parent op lacked (note: the whole issue here is that there isn't any name literal being generated for op interfaces).

I'll be monitoring the upstream stuff, and changing this over until then. For now, the motivation for adding this into circt is to unblock me in using handshake outside of a `handshake.func` while still having a restriction on where handshake ops can be used - i.e. i don't want to completely lift the `HasParent` restriction - users should still explicitly opt-into the fact that "using handshake => handshake ops is in a fine-grained dataflow region".
2023-09-18 10:42:02 +02:00
Fabian Schuiki 5f5ea8fc41
[Arc] Allow top-level logic in LowerState; detect clock edges (#6142)
Make the `LowerState` pass allow operations to remain in the top-level
`arc.model` op after state lowering. This is necessary for lowering the
model op into an `eval` function in the future. Make use of this new
flexibility by inserting logic into the model that detects edges on the
clocks of the `arc.clock_tree` ops. The clock trees no longer trigger on
the clock itself, but are given an "enable" signal that indicates
whether a clock edge has been observed.

In the future, we'll want to schedule the ops in the `arc.model` and
lower it to a separate `eval` function, instead of throwing it away. In
doing so the user will no longer have to manually call clock functions,
but can call a singular `eval` function instead. A centralized function
that performs model execution will also allow us to properly simulate
clock edges occurring at the same time -- something which is impossible
today.

Together with the `arc.clock_domain` op, this `eval` function will make
the entire clock detection and grouping a performance optimization
instead of a required transformation. Theoretically, even if we did not
separate state with the same clock into dedicated clock functions, we'll
still be able to generate an `eval` function, with all logic inlined.
This will ultimately make the Arc dialect more robust and the transforms
more composable.
2023-09-17 11:57:05 -07:00
Martin Erhart d87474fef7
[Arc] Add LowerVectorizations pass (#6141)
Adds a pass to lower  operations. Currently, only lowering the boundary and inlining the op body is supported. Lowering of the body will be added in a separate commit since that is a bit more complex.
2023-09-17 19:49:23 +02:00
Fabian Schuiki e2eb7c66b0
[Arc] Improve performance of state update legalization (#6137)
Rewrite the access analysis used in the `LegalizeStateUpdate` pass.

This pass is a known performance bottleneck in arcilator and causes poor
scaling to larger state spaces: on the `boom-small` benchmark in
`circt/arc-tests`, the analysis runs for >130s, which accounts for >95%
of the overall arcilator runtime.

This PR replaces the MLIR dataflow framework implementation of the
analysis with a custom one. The analysis requires only very sparse
traversal of the operations, which is a lot easier to implement with a
custom graph of nodes. On `boom-small` the new implementation takes
<200ms to complete.
2023-09-16 12:52:09 -07:00
Martin Erhart 089850fc53 [Arc] Include pass base only where needed
Currently, all the pass base classes are included in all files
implementing one specific pass. This aims to reduce the amount of
unnecessarily included code.
2023-09-16 17:56:04 +02:00
Nandor Licker a2f2aac4d2 [NFC] Whitespace fix 2023-09-15 22:22:59 -07:00
Andrew Lenharth 4935e1f36e
[HW] Unify port location arrays and port attribute arrays (#6116)
Finally convert HWModule*Op over to a unified port representation.  This still uses the old printer/parser which enforces input/output order.
2023-09-14 21:35:02 -05:00
John Demme e23e94542f [MSFT] Introduce AppIDPathAttr
Represents a full appid path. Just a list of AppIDAttrs components and a
root module. Expose to Python.
2023-09-14 22:43:49 +00:00
Prithayan Barua 1cab0be099
[OM] Add path append op (#6073)
Add the path append op to the OM dialect.
Co-authored-by: Andrew Young <youngar17@gmail.com>
2023-09-14 15:09:49 -07:00
Morten Borup Petersen f528189a8c
[Ibis] Rename `ibis.block` -> `ibis.sblock` (#6125) 2023-09-14 13:09:16 +02:00
Morten Borup Petersen b5ea7daabd
[Ibis] Add ibis reblock pass (#6089)
Recreates `ibis.block` operations from a CFG. Any `ibis.block.attributes` operations at the parent operation will be added to the resulting blocks.

The IR is expected to be in maximal SSA form prior to this pass, given that the pass will only inspect the terminator operation of a block for any values that are generated within the block. Maximum SSA form thus ensures that any value defined within the block is never used outside of the block.

It is expected that `ibis.call` operations have been isolated into their own basic blocks before this pass is run. This implies that all operations within a block (except for the terminator operation) can be statically scheduled with each other.

Also adds changes to the Ibis method op to make it more "imperative". This is under the assumption that we want to use the method op as the container of choice while going through "impeartive" lowering steps (i.e. all steps wherein we expect to keep around `cf` and MLIR blocks).
2023-09-14 09:21:41 +02: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
Andrew Young b47bfc20a3 [OM] Add missing OMInstanceTarget to path kind enumeration 2023-09-13 21:09:40 -07:00
Andrew Young cebe6ab866 [FIRRTL] Add missing OMInstanceTarget to path kind enumeration 2023-09-13 21:09:40 -07:00
John Demme fec17895c8 [Python] Expose OutputFileAttr to Python 2023-09-14 02:51:41 +00:00
Andrew Young a8987d4568 [OM] Add FreezePaths pass
This adds the FreezePaths pass which performs the final lowering of path
operations after ExportVerilog.  This prepares the OMIR be split from the
hardware by transforming the dynamic hardware references in to frozen
attributes.
2023-09-13 14:47:06 -07:00
Martin Erhart 4dbbf6ae67 Remove CallableOpInterface where redundant 2023-09-13 22:56:40 +02:00
Morten Borup Petersen f3c9aa13ee
[Pipeline] Add non-stallable pipeline stages (#6018)
See rationale changes for an in-depth description of the why's and how's of this change.
2023-09-13 09:09:04 +02:00
Morten Borup Petersen 8f4abacef5
[SV] Add optional `init` operand to `sv.reg` (#6002) 2023-09-13 09:00:37 +02:00
Mike Urbach 46d373bdd4
[FIRRTL] Add AnyRef cast operation, and insert during parsing. (#6108)
In situations where an object is instantiated and passed to a sink
that expects any reference, we need to cast away the object's type to
AnyRef type. This adds an operation to accomplish this, and inserts it
when necessary in the parser.
2023-09-12 20:34:38 -06:00
Adam Izraelevitz ab842053ff
Bump LLVM: 2023/09/12 (#6114)
* Updated broken reference to mlir/Interfaces/FunctionInterfaces.td

* Fixed remaining issues from FunctionInterfaces inheriting from CallableOpInterface

* Rename constant_int_op_binder to constant_int_value_binder

* Bump llvm 9/12/2023
2023-09-12 16:11:24 -07:00
Mike Urbach 6f82696996 [OM] Add C and Python API to get a ClassType name.
Now that the Python bindings for ClassType can return a Python object
of the actual ClassType Python class, it would be useful to get the
ClassType's name from such an object. This includes the usual C API
boilerplate to call the accessor in C++, and the usual Python wrapper
to return a string through pybind.
2023-09-12 15:25:12 -06:00
Mike Urbach d510b5e879 [OM] Add TypeID for ClassType so automatic downcasting works.
A relatively new feature of MLIR Python bindings allows returned
MlirTypes to automatically be downcast to the actual concrete Python
class for the type. To enable this, a C API to get the type's TypeID
must be provided, and the rest just works. Opt-in for the OM dialect's
ClassType.
2023-09-12 14:57:35 -06:00
Will Dietz 774ffd1026
[FIRRTL] Optionally look through casts for fieldref chasing. (#6093)
Don't do this by default, as code reasonably expects the returned
FieldRef has expected type if indexed to the specified fieldID,
however when this is used for producing names just walk through
the cast operations to find the originating declaration.
2023-09-12 12:41:10 -05:00
Andrew Lenharth 7d625bf48c
Remove arg and res names from module representation (#6095)
argNames and resNames are redundant with ModuleType.  Drop.
2023-09-12 10:01:24 -05:00
Hideto Ueno 668adc5f7a
[OM] Evaluator: Support Map (#6045)
This PR add Evaluator support for Map values. 
* EvaluatorValue now takes a MLIR context as a member to make it easy to 
   construct attributes from evaluated values. 
* MapValue is added and created from om.map_create. 
* CAPIs for MapType and StringType are added.
2023-09-12 20:32:46 +09:00
Morten Borup Petersen 490c62591f
[Pipeline] Remove outlined lowering (#6111)
Will be removing the outlined pipeline lowering. It's dumb to have to support two separate, but similar lowerings. Instead, rely on the inline lowering, and down the road, implement a "stage extraction" pass to extract operations that reside within the same logical stage after-the-fact by annotating ops during inline conversion.
2023-09-12 11:55:51 +02:00
John Demme f6ebce721c
[ESI] Channel bundle type and pack/unpack ops (#6066)
A channel bundle (sometimes referred to as just "bundle") is a set of channels of associated signals, along with per-channel names and directions. The prototypical example for a bundle is a request-response channel pair.
2023-09-11 16:44:57 -07:00
John Demme a81db3dba8
[MSFT] Remove the partition pass (#6110)
This was never used and it adds a bunch of complexity and maintainence
burden. If we want to revive it at some point in the future, we can but
I don't see that happening.
2023-09-11 16:14:47 -07:00
Andrew Lenharth 5ca6052d07
[HW] Convert type storage for modules over to moduletype (#6071)
Down with FunctionType, long live module type.  Next step is to remove the name arrays.
2023-09-11 17:09:26 -05:00
Mike Urbach 05993dc40e
[FIRRTL] Add AnyRef type, parser, emitter, and printed form. (#6104)
This is conceptually similar to Class type, but represents a reference
to any class. It is opaque, like a void pointer, so it can be passed
around but not "deferenced". For example, accessing a subfield of the
referred to object is illegal.
2023-09-11 14:13:47 -06:00
Mike Urbach 30c3ef0542
[OM] Add AnyType and AnyType cast. (#6105)
The AnyType is used to represent any valid OM type, without needing to
declare it. The AnyType cast can cast any value to AnyType. This is
useful when dealing with values opaquely in a limited way.
2023-09-11 12:29:25 -06:00
Will Dietz ef5a39a078 [Ibis][NFC] Fix multiple use of SingleBlock trait.
Found via warnings like:

```
OpDefinition.h:1679:28: warning: direct base 'SingleBlock<BlockOp>' is inaccessible due to ambiguity:
```
2023-09-11 11:27:24 -05:00
Will Dietz 62eb69aa82 [NFC] Convert static method to static inline. Fix warning. 2023-09-11 11:26:02 -05:00
Morten Borup Petersen b1a5c1117f
[Ibis] Add `--ibis-argify-blocks` pass (#6084)
The `ibis.block` operation defines a block wherein a group of operations are expected to be statically scheduleable. The operation is not isolated from above to facilitate ease of construction. However, once a program has been constructed and lowered to a sufficient level, the user may run `--ibis-argify-blocks` to effectively isolate the block from above, by converting SSA values referenced through dominanes into arguments of the block

The block may contain additional attributes to specify constraints on the block further down the compilation pipeline.

This operation subsumes the `ibis.schedule` in that `ibis.schedule` has the same semantics as if we attach some scheduling constraint attribute to the block.
2023-09-11 10:06:55 +02:00
Morten Borup Petersen df963abd97
[Ibis] Introduce `ibis.block` instead of `ibis.schedule` (#6082)
The `ibis.block` operation defines a block wherein a group of operations are expected to be statically scheduleable. The operation is not isolated from above to facilitate ease of construction. However, once a program has been constructed and lowered to a sufficient level, the user may run `--ibis-argify-blocks` to effectively isolate the block from above, by converting SSA values referenced through dominanes into arguments of the block

The block may contain additional attributes to specify constraints on the block further down the compilation pipeline.

This operation subsumes the `ibis.schedule` in that `ibis.schedule` has the same semantics as if we attach some scheduling constraint attribute to the block.
2023-09-11 10:05:17 +02:00
Nandor Licker d9d501d25c
[FIRRTL] Replace unrealized conversion cast with an XMR op (#6088) 2023-09-08 18:46:52 +03:00
Morten Borup Petersen ac85f16f30
[Transforms] Move generally applicable passes to transforms (#6087)
SSA maximization and merge block insertion are generally applicable transformations and so shouldn't be nested within CFToHandshake.
2023-09-08 16:03:22 +02:00
Hideto Ueno b920e64206
[FIRRTL] Don't canonicalize out-of-bounds subaccess into subfield (#6079)
Fix #6078
2023-09-08 10:09:28 +09:00
Schuyler Eldridge df3bf14f58
Fix friend struct/class Windows issue
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2023-09-07 14:39:50 -04:00
Nandor Licker 6e9b6a8065
[InstanceGraph] Add a wrapper for instance paths and fix HW enumeration (#6070)
This PR adds a light wrapper on top of instance path. With this wrapper, a subsequent PR should be able to de-duplicate instance paths to save on memory usage and provide quick comparison operators.

HW enumeration was also fixed and a unit test preserves behaviour.
2023-09-07 17:55:33 +03:00
Nandor Licker 4d379d7cc5
[FIRRTL][Seq] Lower `firrtl.clock` to `seq.clock` (#6055) 2023-09-07 01:11:35 +03:00
Andrew Lenharth 1d36f60ce6
[NFC] Replace isAnyModule with an isa test. (#6057)
This accepts slightly different operations in a couple places (more permissive), but I don't think this is a problem for any of the pipelines.
2023-09-06 15:22:58 -05:00
Nandor Licker d345d1ffbd
[ARC][Seq] Switch arc over to use seq.clock (#6054) 2023-09-06 22:12:21 +03:00
Nandor Licker b6395be4cc [NFC] Remove extra newline 2023-09-06 10:11:57 -07:00
Nandor Licker 77d4c4826e
[Seq] Permit clock types on some `seq` operations (#6053) 2023-09-06 19:57:48 +03:00
Andrew Lenharth b5773ddc85 [NFC] InsanceLike always takes HWModuleLike, so use this directly rather than guessing at attribute names. 2023-09-06 11:13:58 -05:00
Andrew Lenharth f563494a9b [NFC, HW] Inter getPortList into the modules. This reduces the dependencies on the attribute names which will go away in the future. 2023-09-06 10:55:13 -05:00
Andrew Lenharth d266ac77c2 [NFC] remove more dead code 2023-09-06 09:52:46 -05:00
Andrew Lenharth 697d07a54e [NFC] remove more mostly dead code 2023-09-06 09:50:19 -05:00
Andrew Lenharth fbf39b4318 [NFC] remove dead code 2023-09-06 09:33:42 -05:00
Andrew Lenharth 49712fb7f1 [NFC] remove mostly dead globals 2023-09-06 09:26:32 -05:00
Bea Healy 16787fa6a6
[circt-lec] Generalise LEC to handle non-SSA modules (#5319)
* Add graph region compatibility and corresponding test

* Merge `fetchExpr` and `allocateValue` into `fetchOrAllocateExpr`

* Minor cleanup
2023-09-06 12:15:52 +01:00
Morten Borup Petersen 1d6fa4813b
[SV] Fix --hw-eliminate-inout-ports (#6037)
Fixes a bug where an inout input was being eliminated which resulted in the block argument list shifting, but input->output replacements were not being updated correctly.

Fixed by keeping to-be-output values as temporary operations instead of an in-memory array of values. By doing so, any value replacements performed by other patterns will also affect the temporary output operations.
... that pattern should maybe be factored out and given a name - seems like a generic thing where we want to store a value for later use, but that value may be replaced at any point in time.
2023-09-06 10:56:07 +02:00
Nandor Licker 197c21a595 [NFC][Arc] Add accessors to the state type 2023-09-06 01:53:25 -07:00
Hideto Ueno 1656984ebe
[Verif][LTL] Add basic python binding support (#6040)
This adds basic python binding support for verif and LTL dialects so that we can parse and analyses output MLIR file with these dialects.
2023-09-06 13:45:35 +09:00
Andrew Lenharth 5723dd94c2 [NFC] Use moduletype for some simple functions. This will be slightly slower until the storage is moved over 2023-09-05 23:30:16 -05:00
Andrew Lenharth 0036e3cf42 [NFC] sanatize ModulePortInfo. InOut are computed from type. This is consistent with several other places which don't assume inout types on inout ports 2023-09-05 23:27:09 -05:00
Robert Young d0cd11f650
[FIRRTL] Implement InstanceLike for ObjectOp (#6041) 2023-09-05 16:21:04 -04:00
Prithayan Barua d5d927cc19
[OM] Add integer type (#6030)
Add Integer Type to OM dialect.
2023-09-05 07:38:20 -07:00
Robert Young d5692e2b3e
[FIRRTL] Add an ExtClassOp (#5954)
- Parser support in the FIRParser
- New ExtClassOp in the firrtl dialect for extclasses
- New ClassLike op interface in firrtl
- LowerClasses:
  - Lower firrtl.extclasses to om.class.extern
  - Legalize om.class.extern.field ops
2023-09-05 09:46:59 -04:00
Nandor Licker 68b79fc35f [NFC][Seq] Add folders to clock conversions 2023-09-05 03:12:34 -07:00
John Demme 8b3741c77e
[ESI][Cosim] Reducing MMIO data widths to 32 bit (#6017)
Some platforms only support 32 bit MMIO, so in accordance with the least
common denominator rule...
2023-09-01 13:24:38 -07:00
Will Dietz 7156eba288
[FIRRTL] Add Path + List ops to visitor + emitter. (#5959) 2023-09-01 14:21:04 -05:00
Will Dietz a515c1cd32
[FIRRTL] Bump latest to 3.2.0 optimistically. (#6026) 2023-09-01 13:29:04 -05:00
Andrew Lenharth 4d30656e81
[NFC] rename function and move interface to a file (#6021) 2023-09-01 12:53:14 -05:00
Morten Borup Petersen 630dabd8fc
[Pipeline] valid -> enable (#6003)
Be a little bit more strict about naming here - the `i1` block argument of any given stage represents the stage **enable** signal - stage **valid** is reserved for the **output** signal/register of a stage, that is fed to its successor stage (as the successor stage enable signal).
2023-09-01 10:21:14 +02:00
Morten Borup Petersen 8bad5fdbb8
[Ibis] Add ibis.schedule op (#6004)
The `ibis.schedule` operation defines a block wherein a group of operations can be placed wherein a limited number of Ibis threads can execute at once.
The operation is not isolated from above and has no return types. References to external values should be performed through SSA dominance and memrefs.
2023-09-01 10:21:04 +02:00
blakep-msft 44ab6268b5
Enable default builders for pipeline.LatencyOp (#6016) 2023-09-01 09:33:51 +02:00
Will Dietz 3668f6760f
[Seq] Use Properties for inherent attributes. (#6011) 2023-08-31 18:54:32 -05:00
Will Dietz fea5dba596
[HWArith] Use Properties for inherent attributes. (#6009) 2023-08-31 18:53:56 -05:00
Will Dietz f23d1aa5c7
[Comb] Use Properties for inherent attributes. (#6008) 2023-08-31 18:53:23 -05:00
Prithayan Barua 57432fb521
[LegalizeNames] Update all port attributes together (#5985)
Update the attribute for all the ports and set it together, instead of
 updating each individually.
This also fixes a bug with LegalizeNames, that was ignoring verilogName
 attribute when renaming ports.
Fixes: #5986
2023-08-31 15:57:19 -07:00
Prithayan Barua ec48ea0ba2
[ExportVerilog] Precompute module port index to instance port Values (#5990)
Update the interface to get the Value corresponding to each module port index.
The module ports may not be ordered input-output, so we need to iterate over
 the ModulePortInfo to compute the input/output port index from the module port
 index.
Precompute the module port index to instance port Value to avoid the
 recomputation of port to value mapping. This avoids the `getPortList` computation
 for every port index, which is very expensive.
2023-08-31 15:55:00 -07:00
Andrew Lenharth 6ddd16c997
[FIRRTL, HW] Simplify FieldID support (#5998)
Simplify FieldID support.  Types which do not support FieldIDs are assumed to be atomic.
2023-08-31 14:54:18 -05:00
John Demme c01f75ca09
[ESI] Change method of packaging collateral (#6000)
Avoid use of new CMake feature FILE_SET.
2023-08-31 11:23:50 -07:00
Schuyler Eldridge 425618643e
[FIRRTL] Add omitVersionComment to help text, NFC
This option was missing from the `firtool` help text.  Add it.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2023-08-31 13:22:06 -04:00
Schuyler Eldridge 3732166e85
[ExportVerilog] Add caseInsensitiveKeywords option
Add a new LoweringOption, "caseInsensitiveKeywords".  When set, this will
cause ExportVerilog to mangle names which conflict with keywords case
insensitively.  This exists to avoid lint warnings which error about this.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2023-08-31 13:21:36 -04:00
Will Dietz 55ae982ad2
[Verif] Use Properties for inherent attributes. (#6007) 2023-08-31 11:58:16 -05:00
Will Dietz 0395f281b6 [Verif][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz 4e17a0d744 [SystemC][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz 53a2e16194 [Seq][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz fb947a48ca [SV][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz 9603d89bc8 [SSP][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz a336c7c8fd [Pipeline][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz 63c6084c71 [OM][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz 8dc2fad102 [Moore][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz 3ffe682712 [MSFT][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz 37097c5b65 [Loop][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz 132fae19bc [LTL][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz aeed03122f [LLHD][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz fe632e7eec [Interop][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz 9f8a5abb0d [Ibis][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz f833dafc97 [Handshake][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz 03c2c9b9c2 [HWArith][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz b9ecdb71c4 [HW][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz b0dfffc304 [FSM][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz 7f99fba70a [FIRRTL][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz e07ae817f1 [CHIRRTL][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz 0abb52f6af [ESI][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz 048f52d5a1 [DC][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz cb774e8d5d [Comb][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz 08d1a9335b [Calyx][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Will Dietz a38a324f2a [Arc][NFC] Opt-out of MLIR properties for attributes for now. 2023-08-31 11:19:27 -05:00
Hideto Ueno e4f127f0fb
[OM] Evaluator: Support tuple (#5903)
This implements Evaluator implementation for tuples, CAPI and python bindings.
2023-08-31 23:30:44 +09:00
Schuyler Eldridge a27680af3a
[FIRRTL] Add noRefTypePorts option to ApplyState
Add information to LowerAnnotations ApplyState about whether or not the
"noRefTypePorts" option is set.  This indicates if lowering should never
generate reference type ports.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2023-08-30 10:54:44 -04:00
Morten Borup Petersen d138d1323d
[Ibis] Add member variable ops (#5980)
This commit adds a member variable defining operation (`ibis.var`) and a member variable dereferencing operation (`ibis.get_var`). `ibis.get_var` works by taking an ibis `scoperef` value alongside a symbol for the member variable name, and generates a `memref`-typed value. This value can then be used by `memref` ops to perform load/stores.
2023-08-30 12:21:45 +02:00
Morten Borup Petersen 99e5a3005e
[Ibis] Add container-to-HW lowering pass (#5924)
+ an end-to-end test just to document the expected order of pass execution.
2023-08-30 12:21:30 +02:00
Morten Borup Petersen 9fdecadd14
[Ibis] Add `--ibis-clean-selfdrivers` pass (#5923)
Removes `ibis.port.input`s which are driven by operations within the same container, in favor of creating a wire.
2023-08-30 10:11:29 +02:00
Nandor Licker d0fd260c54 [NFC] Reverted the removal of HW structure mutators & added tests to pin them 2023-08-30 00:49:05 -07:00
John Demme 6c088ee259
[MSFT] Switch MSFTModule off of FunctionInterface (#5995)
Follow what HWModule did.
2023-08-29 19:08:20 -07:00
John Demme ec383d9535 [HWArithToHW] Fixed bug on extern modules
Segfault since block is null on extern modules.
2023-08-30 01:01:09 +00:00
Will Dietz b377f883de
[FIRRTL] Support properties in aggregates, remove immediately. (#5993)
* Use AtomicFieldIDTypeInterface, move Properties to implement it.
* Update tests to reflect IR changes.
* LOA: Support properties as well.
2023-08-29 18:21:33 -05:00
Will Dietz 7f28c411be
[HW][FIRRTL][NFC] Add AtomicFieldIDTypeInterface for no-field types. (#5987) 2023-08-29 17:42:10 -05:00
Hideto Ueno b770199426
[OM] Add om.enum type (#5982)
This commit adds om.enum type.
2023-08-30 04:43:50 +09:00
Andrew Lenharth 196cdbeba1 [NFC] Move some port info accessors to the portlist interface rather than routing everything through moduletype. This should improve performance for several points 2023-08-29 12:11:29 -05:00
Andrew Lenharth f0647f86e8 [NFC] remove dead code 2023-08-29 10:48:53 -05:00
Andrew Lenharth b4f312143f [NFC] remove dead code 2023-08-29 10:21:17 -05:00
Andrew Lenharth af36bffb78 [NFC] remove dead code 2023-08-29 10:18:14 -05:00
Andrew Lenharth eb9715947d
[NFC] Don't directly poke location attributes from FlattenIO.cpp (#5970) 2023-08-29 10:17:38 -05:00
Andrew Lenharth aa330b360c [NFC] verifyType was redundant with TypeAttrOf 2023-08-29 10:03:07 -05:00
Andrew Lenharth 10806b5b69 [NFC] remove dead code 2023-08-29 09:44:35 -05:00
Morten Borup Petersen 5c7d2d81d9
[Ibis] Add portref lowering pass (#5922)
We do this by analyzing how a portref is used inside a container, and then creating an in- or output port based on that.
That is:
- write to `portref<in portref<in, T>>` becomes `out T`
    i.e this container wants to write to an input of another container, hence
    it will produce an output value that will drive that input port.
- read from `portref<in portref<out, T>>` becomes `in T`
    i.e. this container wants to read from an output of another container,
    hence it will have an input port that will be driven by that output port.
- write to `portref<out portref<out, T>>` becomes `out T`
    i.e. a port reference inside the module will be driven by a value from
    the outside.
- read from `portref<out portref<in, T>>` becomes `in T`
    i.e. a port reference inside the module will be driven by a value from
    the outside.

A benefit of having portref lowering separate from portref tunneling is that portref lowering can be done on an `ibis.container` granularity, allowing for a bit of parallelism in the flow.
2023-08-29 09:51:06 +02:00
Andrew Lenharth fbeed340ad [NFC] Drop a couple global port accessors and replace with per-class versions 2023-08-28 17:14:35 -05:00
Will Dietz 4cec13bb9e
[FIRRTL][NFC] Split text for types out from summary if long, tweak. (#5969)
Appears that multi-line strings get rendered differently,
so just use `summary = "...";` for the one-line summary.
2023-08-28 17:09:50 -05:00
Andrew Young b29ed8305e
[OM] Add dedicated path attribute (#5972)
This attribute represents a value of Path type, and can be used with the OM
constant operation. For now, it holds a string encoding of the path, but will
probably change in the near future.
2023-08-28 14:33:55 -07:00
Andrew Young 09df7f53ed [OM][LowerClasses] Insert lowered ClassOps into the FIRRTL circuit
OM path operations use a HierPathOp to identify their target.  To facilitate
this, it makes sense to insert OM classes under the FIRRTL circuit, as
HierPathOp should be under the same symbol table as the path operation for
lookup to work correctly. If they were not under the same symbol table, it
would be possible to craft a nested symbol reference, but that would just
complicate the LowerToHw pass.

This change removes the restriction that OM ClassOps have MLIRModuleOp as a
parent, changes LowerClasses from a MLIRModule pass to a FIRRTL CircuitOp pass,
and updates some logic to ensure that we are inserting the class operations in
to the correct location.

As a quick example of how this will look with path operations:

```mlir
module { // SymbolTable
  firrtl.circuit "Foo" { // SymbolTable
    hw.hierpath @Path [@Foo::@Wire]
    firrtl.module @Foo { // Not a SymbolTable
        %wire = firrtl.wire sym @wire : !firrtl.uint<1>
    }
    om.class @Class() { // Not a SymbolTable
      %0 = firrtl.path @Path
    }
  }
}
```
2023-08-28 14:29:26 -07:00
Andrew Young 5fb4cf5fd3 [OM] Class ops should not be symbol tables
Currently, OM class operations are symbols tables and their fields are symbols,
which is used to facilitate the lookup of fields.  The ObjectFieldOp verifier
needs to verify that it is accessing a legal field of the class, and does this
by first looking up the class in the MLIR ModuleOp, and then the field in the
OM ClassOp.  This double lookup strategy is problematic because it does not
follow the normal rules of symbol resolution as defined by the SymbolTable.
This means that anything that examines symbol uses (e.g. SymbolDCE) will be
incorrect.  We have faced this kind of problem before, which is why we invented
InnerSymbolTables and InnerSymbols.

This is also needed to properly support path operations: path ops will have a
references to HierPathOps and we need lookup to work correctly. For this, we
will need two things:
1. Since HierPathOps will live inside a FIRRTL circuit, and FIRRTL circuits are
   themselves symbol tables, we will need to put OM classes under the circuit
   as well.
2. When this happens, it will no longer be acceptable for the ObjectFieldOp
   verifier to "jump up" to the MLIRModule op's symbol table for lookup, since
   the classes will actually be under the FIRRTL circuit op.

By removing the SymbolTable interface from class operations, we can change
symbol resolution to use the normal rules, which enables both path operations
to reference NLAs and OM class operations to live in FIRRTL circuits.

This PR removes the SymbolTable op interface from ClassOps, and switches the
ObjectField verifier to perform a manual walk of the ClassOp to find the target
field. In the future, we should switch to InnerSymbols or invent something
totally new for these operations.
2023-08-28 14:29:26 -07:00
Will Dietz 81678d3e7d
[FIRRTL] Map: MapCreateOp, parsing support. (#5962)
Add operation for creating Map's, add parsing support and tests.
2023-08-28 16:10:19 -05:00
Hideto Ueno 483e09cdf4
[OM] Support graph regions in OM dialect (#5407)
This implements region kind interface for class op to support graph regions. Graph regions are useful to represent DAG or cyclic references between two objects. A follow up would be to make sure that OM evaluator works with cyclic references.
2023-08-29 01:18:42 +09:00
Andrew Lenharth 229d3754a9 [NFC] Move from free functions to interface for names and attrs 2023-08-25 19:52:24 -05:00
Will Dietz c14bfb884f
[FIRRTL] Bool: type, constant, parser/emitter. (#5956)
Pretend Bools are in 3.1.0 for now.
2023-08-25 12:45:17 -05:00
Andrew Lenharth 6aa67695c9 [NFC] simplify some HWModule api usage 2023-08-25 12:11:27 -05:00
Andrew Lenharth 00fc15b82f [NFC] missing an attribute in HWTestModule 2023-08-25 12:05:48 -05:00
Robert Young 4bd7658f78
Flow checking for propassign (#5873)
[FIRRTL] Flow checking for propassign

- An output property port cannot be read
- An Input port on an object cannot be read
- We can only assign the input ports of a local object declaration.
- A "remote" object (eg input object port, or output port of a local object)
  cannot be assigned into.
- An output object port must be assigned at the root.
2023-08-25 10:23:07 -04:00
Morten Borup Petersen edd9a82a77
[Ibis] Add tunneling pass (#5921)
Tunnels relative `get_port` ops through the module hierarchy, based on `ibis.path` ops. The result of this pass is that various new in- and output ports of `!ibis.portref<...>` type are created. After this pass, `get_port` ops should only exist at the same scope of container instantiations.
2023-08-25 13:32:09 +02:00
Morten Borup Petersen cbbeec4c7e
[Ibis] Add Wire ops, canonicalizers and SSA names (#5920)
Bunch of op-related changes grouped together by being a net quality improvement of the dialect.
2023-08-25 12:58:09 +02:00
Morten Borup Petersen 360e7d667b
[Ibis] Introduce PathOp (#5867)
The `ibis.path` operation describes an instance hierarchy path relative to the current scope. The path is specified by a list of either parent or child identifiers (navigating up or down the hierarchy, respectively).

Scopes along the path are optionally typed, however, An `ibis.path` must always terminate in a fully typed specifier, i.e. never an `!ibis.scoperef<>`.

The operation returns a single `!ibis.scoperef`-typed value representing the instance at the end of the path.
2023-08-25 11:03:27 +02:00
Morten Borup Petersen 5c955b2f21
[Pipeline] Propagate names in `-pipeline-explicit-regs` (#5936)
Detect `sv.namehint` or OpAsmOpInterface's when routing values, and use these as the basis for register/passthrough names.

e.g.:
```mlir
hw.module @testNaming(%myArg : i32, %go : i1, %clk : i1, %rst : i1) -> (out: i32) {
  %out:2 = pipeline.scheduled(%A : i32 = %myArg) clock(%c = %clk) reset(%r = %rst) go(%g = %go) -> (out: i32) {
    %res = pipeline.latency 2 -> (i32) {
      %d = comb.add %A, %A : i32
      pipeline.latency.return %d : i32
    }  {"sv.namehint" = "foo"}
    pipeline.stage ^bb1
  ^bb1(%s1_valid : i1):
    pipeline.stage ^bb2
  ^bb2(%s2_valid : i1):
    %0 = comb.add %A, %res  {"sv.namehint" = "bar"} : i32
    pipeline.stage ^bb3
  ^bb3(%s3_valid : i1):
    pipeline.return %0 : i32
  }
  hw.output %out#0 : i32
}
```

eventually results in the following RTL:
```sv
module testNaming_p0(
  input  [31:0] A,
  input         enable,
                clk,
                rst,
  output [31:0] out,
  output        valid
);

  wire [31:0] _testNaming_p0_s1_A_out;
  wire [31:0] _testNaming_p0_s1_foo_out;
  wire        _testNaming_p0_s1_valid;
  wire [31:0] _testNaming_p0_s0_A_out;
  wire [31:0] _testNaming_p0_s0_foo_out;
  wire        _testNaming_p0_s0_valid;
  testNaming_p0_s0 testNaming_p0_s0 (
    .A       (A),
    .enable  (enable),
    .clk     (clk),
    .rst     (rst),
    .A_out   (_testNaming_p0_s0_A_out),
    .foo_out (_testNaming_p0_s0_foo_out),
    .valid   (_testNaming_p0_s0_valid)
  );
  testNaming_p0_s1 testNaming_p0_s1 (
    .A_in    (_testNaming_p0_s0_A_out),
    .foo_in  (_testNaming_p0_s0_foo_out),
    .enable  (_testNaming_p0_s0_valid),
    .clk     (clk),
    .rst     (rst),
    .A_out   (_testNaming_p0_s1_A_out),
    .foo_out (_testNaming_p0_s1_foo_out),
    .valid   (_testNaming_p0_s1_valid)
  );
  testNaming_p0_s2 testNaming_p0_s2 (
    .A_in    (_testNaming_p0_s1_A_out),
    .foo_in  (_testNaming_p0_s1_foo_out),
    .enable  (_testNaming_p0_s1_valid),
    .clk     (clk),
    .rst     (rst),
    .bar_out (out),
    .valid   (valid)
  );
endmodule

module testNaming_p0_s0(
  input  [31:0] A,
  input         enable,
                clk,
                rst,
  output [31:0] A_out,
                foo_out,
  output        valid
);

  reg [31:0] A_0;
  always_ff @(posedge clk)
    A_0 <= A;
  reg        stage0_valid;
  always_ff @(posedge clk) begin
    if (rst)
      stage0_valid <= 1'h0;
    else
      stage0_valid <= enable;
  end
  assign A_out = A_0;
  assign foo_out = {A[30:0], 1'h0};
  assign valid = stage0_valid;
endmodule

module testNaming_p0_s1(
  input  [31:0] A_in,
                foo_in,
  input         enable,
                clk,
                rst,
  output [31:0] A_out,
                foo_out,
  output        valid
);

  reg [31:0] A;
  always_ff @(posedge clk)
    A <= A_in;
  reg        stage1_valid;
  always_ff @(posedge clk) begin
    if (rst)
      stage1_valid <= 1'h0;
    else
      stage1_valid <= enable;
  end
  assign A_out = A;
  assign foo_out = foo_in;
  assign valid = stage1_valid;
endmodule

module testNaming_p0_s2(
  input  [31:0] A_in,
                foo_in,
  input         enable,
                clk,
                rst,
  output [31:0] bar_out,
  output        valid
);

  reg [31:0] bar;
  always_ff @(posedge clk)
    bar <= A_in + foo_in;
  reg        stage2_valid;
  always_ff @(posedge clk) begin
    if (rst)
      stage2_valid <= 1'h0;
    else
      stage2_valid <= enable;
  end
  assign bar_out = bar;
  assign valid = stage2_valid;
endmodule

module testNaming(
  input  [31:0] myArg,
  input         go,
                clk,
                rst,
  output [31:0] out
);

  testNaming_p0 testNaming_p0 (
    .A      (myArg),
    .enable (go),
    .clk    (clk),
    .rst    (rst),
    .out    (out),
    .valid  (/* unused */)
  );
endmodule
```
2023-08-25 09:27:17 +02:00
Morten Borup Petersen 7a3b9e478b
[Handshake] `StandardToHandshake` -> `CFToHandshake` (#5938)
... long awaited.
2023-08-25 09:24:26 +02:00
Andrew Young bdf3c5b363 [OM] Add path operation
This new operation represents the path to a hardware entity.  It is similar to
the FIRRTL path operation, but instead of relying on annotations it uses a
HierPathOp to reference its target.
2023-08-24 17:07:04 -07:00
Andrew Young 32e2b1f7a6 [OM] Add path type
This adds a type for representing paths to the OM Dialect.  A value of path
type represents the location of a hardware component.
2023-08-24 17:07:04 -07:00
Andrew Young 55014a4378 [FIRRTL] Add ResolvePathsPass
This pass transforms all UnresolvedPathOps in to PathOps.
2023-08-24 16:08:07 -07:00
Andrew Young ef63bcd878
[OM] Add TargetKind attribute for path operations (#5943)
This attribute encodes the different kinds of targets used by OMIR.  These will
be used by the Path oepration.
2023-08-24 13:31:00 -07:00
Nandor Licker ee30b74271
[Seq] Added seq.clock_div_2 to divide a clock by 2 (#5937) 2023-08-24 23:22:15 +03:00
Nandor Licker 66ba2ac7ca
[Seq] Introduce a clock type (#5919)
The clock type will be used to carry the clock signal in a design.
This PR allows it to be placed on module ports and wires, without forcing its use on all ops.
Subsequent PRs will switch `seq` ops over to use it and generate it from FIRRTL.
2023-08-24 22:39:19 +03:00
Andrew Young 51cb010306
[FIRRTL] re-work PathOp to use annotations (#5933)
The PathOp is being re-worked to remotely reference hardware objects using
(possibly non-local) annotations.  The hardware target recieves an annotation
with class `circt.tracker` and an identifier.  The Path operation tracks the
original reference kind and the target identifier. It is legal to optimize away
the hardware target, which will leave the Path op with a dangling identifier
reference. A later pass will lower this pick bb5ad82a6 [FIRRTL] Add enumeration
for OM path kinds FIRRTL PathOp to an OM specific Path operation, which will
not use annotations.  See the example in FIRRTLExpressions.td for what this
looks like in FIRRTL.
2023-08-24 12:20:39 -07:00
Andrew Lenharth 22daf52f1d
[HW] HWModules don't implement FunctionOpInterface (#5939) 2023-08-24 13:21:35 -05:00
John Demme a1b50a21ca
[ESI][Cosim] Add low-level MMIO functionality (#5934)
Add base-level MMIO functionality to cosim. Exposes an AXI-lite master interface which is driven by capnp messages. This provides the ability to build a BSP with MMIO services (which works in any system with AXI-lite style MMIO).
2023-08-24 11:20:47 -07:00
Andrew Lenharth 84ce0ab991 [NFC] don't drop attributes when rewriting modules 2023-08-24 11:48:27 -05:00
Morten Borup Petersen 63aab570d6
[SV] Add suffix options to --hw-eliminate-inout-ports (#5925) 2023-08-24 11:19:59 +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
Andrew Young 56e98bed36
[FIRRTL][LowerToHW] Copy InnerSymAttrs to lowered ops (#5928)
This change ensures that when lowering InnerSymbol operations, we copy the
existing inner symbol to the target, as well as properly adding a symbol on
fieldID 0 when required.  This fixes an assumption of symbol name uniqueness,
and they are now uniqued in the module's symbol namespace. A side effect of
this change is that the used symbol names are always of the form `@sym_1`.
This also fixes a bug where an `InnerSymAttr` was assumed to target field ID 0,
and could result in an incorrect lowering of the `DontTouch` annotation.
2023-08-23 16:44:15 -07:00
Andrew Young dc9bd49027
[FIRRTL] Add enumeration for OM path kinds (#5931)
This adds OMIR path kind attribute for use in Path operations.  We will have to
keep track of which kind of path was specified by the user throughout the
pipeline, as it is not information which can be reconstructed later.
2023-08-23 15:34:53 -07:00
Andrew Young f082971ed9
[FIRRTL] Add UnresolvedPathOp (#5930)
This operation is meant to read in an encoded OM target string, with a pass
later resolving the string target to a real target and validating the contents.
This new operation purposefully does not contain much in the way of
verification.
2023-08-23 15:34:40 -07:00
Andrew Lenharth a5bef3dfb0 [NFC] more decoupling from FunctionOpInterface 2023-08-23 16:39:53 -05:00
Andrew Lenharth 4ed922751c [NFC] move printer to file 2023-08-23 13:50:05 -05:00
Will Dietz dc4b8c6cba
[FIRRTL][NFC] Drop use of AnnoTarget for getting inner symbols (#5927)
* [Dedup] Use getOrAddInnerSym instead of temp AnnoTarget.
* [NFC] Drop unused AnnoTarget and friends' getInnerSym method.
2023-08-23 12:14:12 -05:00
Andrew Lenharth ee7a1433ea [NFC] Fix some hwmodulelike member naming to be more uniform 2023-08-23 11:52:11 -05:00
Andrew Lenharth 4fc0e2cbf0 [NFC] minor HWModuleLike accessors, unused 2023-08-23 10:57:31 -05:00
Will Dietz 7b39fb27f5
[HW][IRN/IST] Make hw modules IST's, add verif pass. (#5917)
Until have proper container op to put the trait on,
add a dummy struct we can classof to classify IRN-like,
and add a simple pass that drives verification on these
if they aren't self-verifying.

Add verification pass to pipeline, basic test for duplicate
inner symbols and invalid InnerRef user.

Let's all promise ourselves this is temporary! ;)

cc #3526 (nearly fixes), #4453.
cc #5716.

Co-authored-by: Robert Young <rwy0717@gmail.com>
2023-08-23 09:47:35 -05:00
Hideto Ueno becb4c0ef3
[OM] Add om.map_create op (#5870)
This PR adds om.map_create op for om.map object creation which takes a variadic length of operands whose type is a same tuple.
2023-08-23 18:07:40 +09:00
Nandor Licker 325d74c1a0
[OM] Add python accessors to the `om.map` attribute (#5914) 2023-08-23 08:42:50 +03:00
Hideto Ueno 7d0c88281d
[OM] Add om.map attribute (#5869)
This implement  a `om.map` attribute as constant of map types.
2023-08-23 13:14:17 +09:00
Andrew Lenharth 34ded4fb5c
[NFC] Add a Module Signature Converter which operates on HWModuleLike not FunctionOpInterface (#5906)
Further reduce dependencies on FunctionOpInterface with a signature converter for the Dialect Converter framework.
2023-08-22 15:05:21 -05:00
Andrew Young 953a2e3cf4
[FIRRTL] Add HierPathCache to reuse HierPathOps (#5909)
This change takes a common pattern in LowerAnnotations, which avoids creating
duplicate HierPathOps by maintaining a cache, and moves it into a dedicated
class for easier re-use.  Since the HierPathCache maintains an insertion point
instead of always inserting to the top of the circuit's block, HierPathOps are
now in reverse order after LowerAnnotations.
2023-08-22 12:47:24 -07:00
Andrew Young 64ad7c2edc
Add DistinctAttr type constraints (#5912)
DistinctAttr does not have proper upstream exposure through OpBase.td as type
constraint, so we have to declare it ourselves.  This should be a temporary
workaround.
2023-08-22 12:38:13 -07:00
Andrew Young eac0a81e9b
[FIRRTL] Add InnerSymTarget implicit constructors for brace initialization (#5911)
This switches to non-explicit constructors in cases where it would not lead to
automatic conversions. This helps write shorter code to when creating new
InnerSymTargets.
2023-08-22 12:37:58 -07:00
Andrew Young a09cfefbf7
[FIRRTL] Add InnerSymbolNamespaceCollection (#5910)
It is a common pattern for passes to have a map from a modules to an
InnerSymbolNamespace.  This captures the pattern for reuse in a
InnerSymbolNamespaceCollection.
2023-08-22 12:37:37 -07:00
Nandor Licker ac141282dc
[Seq] Merge Seq-to-SV lowering passes (#5901)
The pattern rewriter can be applied alongside the FIR register lowering transforms to eliminate the need for two separate passes.
2023-08-22 22:12:11 +03:00
Andrew Young c2d744c8bf
[FIRRTL] Put ODS enumerations in the FIRRTL namespace (#5907)
These enumerations were being generated into the global namespace.  This change
sets the `cppNamespace` field of all FIRRTL enumerations.
2023-08-22 11:39:23 -07:00
Andrew Young 354bb1c8c5 [FIRRTL] Make InnerSymTarget printer more suitable for error messages
It will help to create error messages using InnerSymTarget if it is printed in
a natural language kind of way.
2023-08-22 11:21:31 -07:00
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
Nandor Licker 21edc0ec23
[Seq] Add a clock multipler op (#5872)
Co-authored-by: Nandor Licker <nandorl@sifive.com>
2023-08-22 08:12:56 +03:00
Andrew Lenharth dce0793f0a [NFC] Allow setting the type of a module via a module type 2023-08-21 18:37:32 -05:00
Andrew Lenharth 2c5611384c [NFC] Use ArrayRefs to convert fn to mod types 2023-08-21 18:15:13 -05:00
Andrew Lenharth bd1a4c1dff [NFC] add attribute name accessors 2023-08-21 18:04:15 -05:00
Andrew Lenharth dbb521a3cc [NFC] Further reduce dependencies on FunctionOpInterface 2023-08-21 12:52:36 -05:00
Will Dietz b6797ea8c9
[FIRRTL] Add ListCreateOp. (#5890)
Test creation of lists with elements of primitive,
aggregate, and object/class types.
2023-08-21 09:31:24 -05:00
Hideto Ueno 8c9734ef90 [OM] Move `attr-dict` to th econsistent position in assembly format, NFC
Attr dict is generally placed just before `:`. OM dialect operations didn't
follow that convention so thic commit fixes the position.
2023-08-20 22:37:56 -07:00
Hideto Ueno e3381acf15
[OM] Add OM tuple operations (#5878)
This commit adds `tuple_create` and `tuple_get` operations.
2023-08-21 14:01:30 +09:00
Prithayan Barua b3619523bd
[PrettyPrinter] Add a callback token to record print events (#5514)
Introduce `Callback` token type. The callback token is associated with a
 listener. The listener is invoked only after all the tokens
 that were preceding the callback token have been printed. This enables the
 listener to record the output stream state (for example current output file
 location) after the last token is printed on the stream.
The Callback token provides a generic mechanism by which any state can be
 tracked and necessary updates can be made as per the client requirements.
The unit tests demonstrate a mechanism to log the token print line and
 column information on the output stream.
This will be used to record Verilog output file location information in a future PR.
2023-08-18 15:27:00 -07:00
Andrew Lenharth 01c7dc11a7
[NFC] Make FIRRTL modules not implement hwmodulelike (#5889)
HWModuleLike provides almost no value to firrtl and is a a relic of instancegraph. Remove it and move required functionality.
2023-08-18 15:37:09 -05:00
Andrew Lenharth 82c48260a3 [NFC] Add port-based (rather than arg/result) accessors for attributes and locations to HWModuleLike.
HWModuleLike is transitioning to being unified input/output.  This adds some missing functions on the interface.
2023-08-17 17:14:17 -05:00
Will Dietz 4cf3b722f9
[HW] Verify non-empty inner symbol, symbol names. (#5874) 2023-08-17 15:19:03 -05:00
Robert Young 1a33d53a96
[FIRRTL] Keep classes around (#5866)
* [FIRRTL] Class symbols can not be deleted

Prevent symbolDCE from deleting classes. We cannot always find the users of
class symbols, because sometimes that class could be referenced only by the
type of a port.

* [FIRRTL] Do not delete classes in the module inliner
2023-08-17 15:21:49 -04:00
Robert Young 5943cc9dfe
[FIRRTL] Skirt around the GCC major/minor macros (#5871)
GCC defines function-like macros major(x) and minor(x), for extracting
information from device IDs. These macros conflict with, and cause compilation
errors in, FIRVersion's constructor. This commit changes FIRVersion to
initialize it's major and minor fields using brace-initialization, so that the
initialization isn't mistaken for a macro invocation.

Fixes: #5868
2023-08-17 10:13:24 -04:00
Will Dietz 82054e3753
[FIRRTL] Rework internal paths array, cover all ports, maintain. (#5860)
We need to support having paths for some ref-type ports but not others
(ABI + GCT's internalPath mechanism) so change to have entry per port,
with empty entries for non-ref and ref ports that should use ABI.

Handle in LowerTypes (just propagate, don't support lowering).
2023-08-17 08:57:19 -05:00
Rachit Nigam b7d08125b8
[Calyx] Support lowering of `arith.select` (#5857)
* Add calyx mux op

* legalize lowering for arith.select in scf-to-calyx

* hitting assert

* basic lowering works

* lowering works!

* calyx emitter supports std_mux

* add arith lowering test

* emission test

* line length nit
2023-08-17 16:43:52 +05:30
Morten Borup Petersen 33d868974a [Support] Expose constructors of InstanceGraph
`igraph::InstanceGraph` should be able to serve as a standalone graph implementation, without needing specialization (`getTopLevelNode` is the only pure virtual function, whereas there's always the alternative of using `getInferredTopLevelNodes`).
Allow so, by publicly exposing the constructors, and make `getTopLevelNode` opt-in.
2023-08-17 07:10:58 +00:00
Robert Young eefcce8509
[FIRRTL] Clean up FIRVersion checking (#5865) 2023-08-16 21:21:33 -04:00
Mike Urbach fa41bff9bf
[FIRRTL] Rewrite ExtractClasses as LowerClasses. (#5843)
This is a fairly significant rewrite, so I've chosen to rename the
pass, but otherwise share some of the good parts. A lot of warts are
hopefully removed.

The pass lowers both FIRRTL modules with property ports as well as
FIRRTL classes into OM classes. It does a linear walk to initially
create the OM classes, and then processes each in parallel.

The logic to move ops into the new class body is greatly
simplified--ops are copied over, in order, if they have property
operands or results. We might make this even simpler with a trait at
some point.

Instantiations and the instance graph no longer need to be kept in
sync--only FIRRTL Object instantiations are effected. These are
converted to OM Object instantiations. It's actually impossible to
represent a FIRRTL Object that takes inputs with the current
flow-checking. I tried to write out an implementation for it, even
though I can't test it.

Besides the structural changes, I've also added type conversion from
the FIRRTL ops to the OM versions. I'm using DialectConversion for
this, which actually helps for this sort of thing. There are fairly
simple patterns for converting the constant property ops to the OM
versions. These could almost be templated on the operation class, but
minor differences made that more trouble than its worth. There are
also patterns for legalizing OM class fields and OM classes, which are
just there to let the type converter do its thing.

I've added a basic unit test for the kind of IR we want to support
here. One more parser and flow-checking support is in, I will also
include an end-to-end test from FIRRTL through ExportVerilog to the
final MLIR.
2023-08-16 17:03:45 -06:00
Andrew Lenharth 9b8ca36e12 [NFC] reduce dependencies on FunctionOpInterface for HWModule* 2023-08-15 23:23:18 -05:00
Andrew Lenharth 93ed8cf29d [NFC] Add port location and port attribute getters to HWModuleLike 2023-08-15 22:49:13 -05:00
Andrew Lenharth aa4942baaa
[NFC] Use ModuleType to compute many properties (#5715)
In anticipation of most modules converting from functions to portlists using module type, route most of the HWModuleLike interface through the ModuleType.  Modules like things must now be able to produce a moduletype from which many accessors are derived.  getNumPorts is separate from this as non-function-like modules need this to compute the module type.
2023-08-15 16:41:55 -05:00
Nandor Licker 24f3858255
[LowerToHW] Avoid creating undriven wires for 0-width seq mems (#5848)
Instead, a constant X is materialized to drive the dummy port of the `seq` memory.
A subsequent PR should consider whether these memories can be removed altogether.
2023-08-15 21:07:47 +03:00
Hideto Ueno 7bf850eb71
[OM] Add map types (#5852)
This commit adds `!om.map<key, element>` type and restrict a key type to be either integer or string.
2023-08-16 01:49:08 +09:00
Andrew Lenharth f096d83dc4 [NFC] make attributes explicit 2023-08-15 11:46:26 -05:00
Hideto Ueno 11a9683301
[OM] Change evaluator value representation and evaluate ListCreateOp. (#5820)
This is a PR for new representation of Evaluator and list_create support.

`std::variant` has been used as runtime representation of Evaluator but it's difficult to use it as
data structure for more structured values such as list or map. So this PR instead introduces a base class `EvaluatorValue ` and derived classes, `AttributeValue`, `ListValue` and `ObjectValue`, as runtime representation of values.

Also terminology `ObjectValue` is changed to `EvaluatorValue` since runtime values will not be limited to Object.
Python and C bindings are changed accordingly.
2023-08-16 01:41:10 +09:00
Mike Urbach 5c20f56072 [FIRRTL] Add a folder for FIntegerConstantOp.
This isn't used by much yet, but some parts of the MLIR
infrastructure (e.g., Dialect Conversion) assume ConstantLike ops have
a folder. This adds the usual folder, same as StringConstantOp and
others.
2023-08-14 22:18:59 -06:00
Andrew Lenharth 2df81c9747 [NFC] indexed arg name accessor 2023-08-14 22:23:39 -05:00
Andrew Lenharth 09ed7a67fa [NFC] SystemC.SCModuleOp narrowed from HWModuleLike 2023-08-14 13:58:13 -05:00
Andrew Lenharth 55dcf09f76 [NFC] FSM.MachineOp narrowed from HWModuleLike 2023-08-14 13:56:28 -05:00
Andrew Lenharth 0d3c6be456 [NFC] SystemC.InstanceDeclOp narrow opinterface to InstanceGraphInstanceOpInterface 2023-08-14 13:51:25 -05:00
Andrew Lenharth f288615340 [NFC] MSFT.InstanceOp narrow opinterface to InstanceGraphInstanceOpInterface 2023-08-14 13:49:15 -05:00
Andrew Lenharth eaec7cca3c [NFC] FIRRTL.InstanceOp narrow opinterface to InstanceGraphInstanceOpInterface 2023-08-14 13:35:24 -05:00
Andrew Lenharth aa37eec09f [NFC] FSM.HWInstanceOp narrow opinterface to InstanceGraphInstanceOpInterface 2023-08-14 12:36:06 -05:00
Morten Borup Petersen c366ef0f77
[HW/Support] Introduce InstanceGraph interface (#5833)
This change moves InstanceGraphBase to support, and introduces an interface for driving the implementation, `InstanceGraphInterface`, which essentially is an extraction of the name- and lookup related functions of `HWModuleLike/HWInstanceLike` (which now inherit from the `InstanceGraph` interfaces).
The motivation for this is that multiple things in CIRCT may benefit from having graph iterators, and most/all of these will need an implementation exactly as what is given in InstanceGraphBase. My immediate usecase is to provide a graph for Ibis classes/containers, but things like handshake and FSM are other obvious users of this.

The interface is named `InstanceGraphInterface`, but in practice naming it `CIRCTModuleInterface` or something similar would probably be more apt, seeing as the `InstanceGraph` is just a generic view of module-like things in CIRCT (which in turn is more generic than HWModule like) - LMKWYT.

Implementing this change also performs some housekeeping in ensuring that all ops who inherit from the `HWModuleLike/HWInstanceLike` interfaces actually implements the name-related parts of the interface.

Co-authored-by: Morten Borup Petersen <mpetersen@microsoft.com>
Co-authored-by: Andrew Lenharth <andrew@lenharth.org>
2023-08-14 12:12:54 -05:00
Will Dietz e4e6e4a60a
[FIRRTL][Emitter] Sync to use "latest", and bump that to 3.1.0. (#5839)
Match behavior of `mlirExportFIRRTL`.

Update test.
2023-08-14 11:47:59 -05:00
Sprite 17947c6047 [FIRRTL][CAPI] Get latest `FIRVersion` from a new static function 2023-08-14 23:27:24 +08:00
Will Dietz 2e87b4998c
[FIRRTL][Emitter] RWProbeOp, RefCast, better forceable support. (#5779) 2023-08-14 08:20:46 -05:00
Morten Borup Petersen ea9ac11ead [Ibis] Add directions to portrefs 2023-08-14 09:18:20 +00:00
Will Dietz 7f0c1c685a
[FIRRTL] RWProbeOp: support width inference. (#5782)
Rework RWProbeOp to explicitly track result type,
don't "infer" from target type argument (removed).

This is a better fit for this op, particualrly in that no
useful "inference" is performed that way.
(not inferring through symbol target)

Teach InferWidths about the type constraint,
getting inner symbol analysis for resolution.

Loosen parsing, but still only use RWProbeOp
for ports.

With these changes, it's nearly possible to remove
"Forceable" entirely in favor of the one mechanism.
2023-08-11 13:31:54 -05:00
Will Dietz 5bb2f20e73
[FIRRTL][HW] Replace ModuleNamespace with InnerSymbol one. (#5819)
Combine identical "ModuleNamespaces" into a new common one
for anything with inner symbols.

First step towards dropping use of a "Namespace" for generating
inner symbols entirely, once other pieces are in place.

Also sets the stage for moving the utility functions that help
create inner symbols and inner refs out of FIRRTL.

NFCI.
2023-08-10 15:40:27 -05:00
John Demme 0cd11eee40
[ESI] Remove auto-wrap functionality (#5823)
This functionality was used primarily wrap handshake modules. Now that
handshake uses ESI channels it's no longer necessary. I don't think
there are any other users.
2023-08-10 12:35:18 -07:00
Robert Young 0346f20df5
[FIRRTL] Add ObjectSubfieldOp (#5768) 2023-08-10 10:29:30 -04:00
Morten Borup Petersen 71beb7e850
[Ibis] Add containerize pass (#5810)
This pass converts Ibis classes to containers, and outlines containers inside classes.
2023-08-09 17:11:25 -04:00
Andrew Young a3f189b2bf
[FIRRTL] Add PathOp (#5808) 2023-08-09 11:54:57 -07:00