The textual pass pipeline has a bit more overhead due to the string parsing, but it reduces the required maintenance as we don't have to write CAPI and Python bindings for all the pass options.
Basically did
set(CMAKE_CXX_CLANG_TIDY local/clang-tidy -checks=-*,llvm-use-new-mlir-op-builder -fix)
and then fixed cases where temporary OpBuilders were used (as passed in
by reference now).
* Initiate datapath to comb pass
* Add tests and tidy datapath to compress implementation
* Improve comments
* Formatting and test corrections
* Correct CAPI
* Move wallace tree reduction and full-adder to comb ops
* Adding integration tests using circt-lec and correcting review comments
* Fix bug in Booth code for final sign correction row and add testing using lec. Add a forceBooth option largely for testing purposes
* Minor fix
* Formatting
* Removing populate patterns function
* Formatting
This commit refactors the AIG longest path analysis C API to use native C structures instead of JSON strings, providing better performance and type safety.
The API changes replace `aigLongestPathCollectionGetPath` returning JSON with `aigLongestPathCollectionGetDataflowPath` returning native objects. New opaque handle types are added including `AIGLongestPathObject`, `AIGLongestPathHistory`, and `AIGLongestPathDataflowPath`. Comprehensive APIs are provided for accessing path data, history, and object properties.
InstancePath C API support is introduced in `circt-c/Support/InstanceGraph.h`. Currently `InstancePathCache` itself is not provided, as the use of LongestPathAnalysis is read-only and there is no need to mutate/construct InstancePath. Unfortunately due to that testing of CAPI of InstancePath got a bit tricky. For now AIGLongestPathAnalysis is used to produce InstancePath in CAPI.
The Python binding updates refactor Object, DataflowPath, and LongestPathHistory classes to use the native C API. JSON parsing dependencies and from_json_string() methods are removed. Proper property accessors using the new C API are added while maintaining backward compatibility for existing Python interfaces. So the existing integration tests cover most of the APIs.
Testing updates include comprehensive coverage in the existing C API tests in `test/CAPI/aig.c`. A new `test/CAPI/support.c` is added for InstancePath API testing. Python integration tests are updated to work with the new API.
This change improves performance by eliminating JSON serialization/deserialization overhead and provides a more robust, type-safe interface for accessing longest path analysis results.
The builtin tuple type does not allow empty tuples, but they can avoid special casing in the frontend and can also be used as indicators (something like a none type could otherwise be used for but which we don't have in RTG).
To verify correctness of transformations involving datapath operations,
include a lowering from datapath to SMT. Will later be integrated into
circt-lec to enable verification of these operators. Each operator
satisfied a contract, rather than providing a precise semantics for
every operator. This is because the datapath operators return values in
redundant number representations, meaning there are many valid
implementations.
For example:
```mlir
%0:2 = datapath.compress %a, %b, %c : i8 [3 -> 2]
```
Will be verified by introducing free variables for each return value
`(%0#0, %0#1)` then asserting that the sum of the associated free
variables is equal to the sum of the inputs:
`assert(%0#0 + %0#1 == %a + %b + %c)`.
Whilst this is encoded as an assert it really represents an assumption
that must be satisfied by a valid implementation of datapath.compress.
This commit introduces a standardized synthesis pipeline and restructures the codebase:
* Creates a new SynthesisPipeline class to define the default synthesis pipeline. This pipeline serves both circt-synth and is exposed through the C API for Python bindings.
* Added a dedicated Synthesis directory under `lib/` to house synthesis-related code. This architectural change is aimed to promote synthesis capabilities to a first-class component within CIRCT rather than limiting it to the circt-synth tool.
This commit introduces C API bindings for AIG LongestPathAnalysis and LongestPathCollection, enabling longest path analysis of AIG circuits from C and other languages.
The API uses JSON serialization for path data exchange, providing a stable interface while the underlying data structures evolve. Paths are automatically sorted by delay in descending order for efficient critical path analysis.
Remove some defensive coding that added a default case to a fully covered
switch statement. This is a compile time warning if not removed.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
This commit adds comprehensive Python bindings for the AIG (And-Inverter Graph) dialect.
The implementation includes an AIG C API header with dialect registration and an AIG C API implementation with pass registration.
It adds an AIG Python dialect TableGen file and Python dialect module. The AIG Python module C++ bindings are implemented using nanobind.
The implementation follows the pattern used by other CIRCT dialects
and enables Python users to work with AIG operations like and_inv through the
circt.dialects.aig module.
- Register the kanagawa dialect in Python bindings
- Register kanagawa dialect passes
- Add C API header and implementation for kanagawa dialect
- Add integration test for kanagawa dialect and passes
Follows the same pattern as pipeline dialect registration in commit 5c4d8ae.
Add support for passing Python strings and lists directly as arguments to
the OM evaluator's instantiate method:
* Fix Attribute value creation to work well with list evaluation.
* Add StringType C API to construct typed strings in Python bindings
* Implement conversion between Python lists and OM ListAttr
Move the `LowerLayers` pass after the `LowerXMR` pass. To do this, all
passes at the end of the CHIRRTL to Low FIRRTL pipeline are moved after
`LowerXMR`. This is necessary because the `LowerLayers` pass cannot, at
present, be moved after the passes at the end of the pipeline.
This is done to enable forcing out of layers. By lowering probes to XMRs,
the layers can be lowered trivially to modules/instances and their XMRs
will now (seemingly) magically just work. By doing the loweirng in this
way, it avoids ever having to represent an input probe in the FIRRTL
dialect.
A consequence of this is that there are now simplifying
assumptions (preconditions) that can be made about the `LowerLayers` pass:
1. It will never see a number of probe ops because the `LowerXMR` pass has
a postcondition that all of these are removed.
2. Input and output ports can never be created on modules created from
layer blocks.
While I am generally always in favor of passes being relocatable anywhere
in the pipeline, this is one pass that really does _not_ make sense to be
relocatable. In effect, this pass is part of the lowering from FIRRTL to
HW. There is no point in being able to use it earlier in the pipeline.
That said, it still is tested to work with things which we may one-day
preserve, like `WhenOp`s.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
This adds an immediate type and attribute that support any bitwidth and will replace the immediate types and attributes in the RTGTest dialect. Also adds a constant operation that can create an SSA value for any typed attribute. I also moved the labels type to form a kind of ISA subdialect with the immediates and made that explicit in the textual IR. We can do the same for relevant ops in the future.
We already have a binding for the OutputFileAttr, but it didn't
provide any useful accessor. This adds a safe, typed accessor to read
out the filename as a string.
Allow type parameters in the sequence type and attach it as a type attribute to the sequence op. That way ops referring to a sequence don't have to access the operation's body to verify the type.
- Adds a `castable` method to Type which passes through to the
`checkInnerTypeMatch` C++ function.
- Use that method to type check the results of BundleSignal.unpack.