Closes#1810
The changes to `hw.module` and `hw.instance` make them incompatible with `msft.module` and `msft.instance` as far as the python bindings are concerned. I'm not sure what I want to do here so I've marked that test as `xfail` for the moment.
A RootedInstancePath is just an instance path prepended with the root (aka top) module which the instance path is relative to. If we structure the placements based on this, we no longer have to walk the instance hierarchy while exporting TCL! This patch also removes support for locations not inside of instance switches. That use case required the design be fully elaborated which isn't really done.
There were some bits of the ESI and MSFT native pybind11 modules that
directly called into the CIRCT C++ libraries. This moves that
functionality out of the modules and behind the C-API. This proper
layering needs to be enforced before we can implement the upcoming
migration to use the improved upstream Python binding mechanism.
Also, this ensures all of the C-API functions used by the Python
bindings are annotated with MLIR_CAPI_EXPORTED, which will also become
required.
This adds straightforward support for the TypeAliasType, as it stands
today, in the CAPI, then layers the Bindings directly on top of that.
Later improvements to the TypeAliasType's builder will of course
require refactoring part of this, but for now, this opens it up for
use in PyCDE.
Previously, different parameterizations of the same module would end
up using the most-recently registered generator and the
parameterization used when it was registered.
This includes the parameterization in the registered mapping, and
looks for that same parameterization when looking up generators. This
is trivially supported since we already store the parameterization as
an attribute on the Operation.
Added a few lines to the polynomial integration test to ensure the
behavior.
Prototype of "generators". This version runs the generator for each and every op to lower and each time it is called, a new HWModuleOp is created at the top level. To fix this, I plan on unique'ing on the operation's attributes, result types, and operand types. This'll involve some refactoring since as of this PR the HWModuleOp creation and instantiation are both in the same callback.
This makes sure not to rename FIRRTL to HWRTL :-), and I spot checked a
many things to avoid changing general references to RTL (e.g. when referring
to external tools) but I suspect that I missed some. Please let me know (or
directly correct) any mistakes in this mechanical patch.
* C API fails to link on builds that have CAPNP disabled, since some of
the symbols in the C++ API get dropped. Make the corresponding uses in
the C API conditional on the presence of the same ifdef, so things
link again.
* Uses it to create a sample ChannelType.
* Requires: https://reviews.llvm.org/D101734
* See https://gist.github.com/stellaraccident/4a73e395e5cc68a5244c8d88dd291396 for a hacky sample of this working.
* Attributes would be incremantal on top of this.
With this, defining a custom type is pretty simple:
```
mlir_type_subclass(m, "ChannelType", circtESITypeIsAChannelType)
.def_static("get",
[](MlirType inner) {
return py::cast(circtESIChannelTypeGet(inner));
})
.def_property_readonly(
"inner", [](MlirType self) { return circtESIChannelGetInner(self); });
```
I feel good enough about this mechanism to suggest that we just upstream it as a public header and then refactor the builtin types to use it, deprecating PyConcreteType and PyConcreteAttribute. It isn't necessary to couple these together, though, and landing in circt could let us get some mileage on it first.
I'm aware that to the uninitiated, some of the pybind goo may seem magic, but this is actually the *less* magical way to do this: it isn't using any spooky Pybind11/C++ level sharing and is doing the exact same thing as if you literally spelled out "class MyType(mlir.ir.Type):" in Python -- but of course, meta-programming that in C++ is a bit thicker :) It also interops pretty well with the existing CAPI<->Python casters, making this (I think) a strict improvement over even what we have upstream.
One thing I didn't get to is a `DefaultingMlirContext` helper (ended up not needing it), but this would be pretty easy to add.
- Registers the SV passes when the 'circt' Python module is imported and the ESI passes when 'circt.esi' is imported.
- Adds a Python 'export_verilog' call.
- Enables LLVM 'pretty' stack traces for easier debugging. Makes assertion messages appear in Python instead of just crashing with no output.
This change aims to remove all instances of `using namespace mlir` from
our header files. Many types have been manually imported into the
`circt` namespace in `circt/Support/LLVM.h`. These types include all
core MLIR functionality types (IR, Diagnostic), utility types, rewrite
patterns and conversions, builtin IR types and attrs, and the module op.
Not imported were any operations (other than ModuleOp), matchers (e.g.
m_Zero), anything in the `impl` namespace, and interfaces. There are
some problems with interface code generation from ODS, so some
interfaces were imported.
Some further cleanup would be useful to remove the `mlir::` namespace
qualifier where we no longer need it.
* make consistency in FIRRTL naming
* make consistency in RTL naming
* make consistency in StaticLogic naming
* make consistency in SV naming
* header naming correction
* minor fix
* run clang-format
* clang-format
* td format and fix lib/SV/ naming
* clang-format on /SV/
* change library name from libMLIRCAPIRTL to libCIRCTCAPIRTL
* change library name from liblibMLIRLLHDTransforms to libCIRCTLLHDTransforms
* change library name from liblibMLIRRTLToLLHD to libCIRCTRTLToLLHD
* rename library from liblibMLIRLLHDToLLVM to libCIRCTLLHDToLLVM
* rename library from libMLIRFIRRTLToLLHD to libCIRCTFIRRTLToLLHD
* rename library from libMLIRFIRRTLToRTL to libCIRCTFIRRTLToRTL
* rename library from libMLIRHandshakeToFIRRTL to libCIRCTHandshakeToFIRRTL
* rename library from libMLIRStandardToHandshake to libCIRCTStandardToHandshake
* rename library from libMLIRStandardToStaticLogic to libCIRCTStandardToStaticLogic
* rename library from libMLIRRTL to libCIRCTRTL
* rename library from libMLIRSV to libCIRCTSV
* rename library from libMLIRESI to libCIRCTESI
* rename library from libMLIRFIRRTL to libCIRCTFIRRTL
* rename library from libMLIRLLHD to libCIRCTLLHD
* rename library from libMLIRHandshakeOps to libCIRCTHandshakeOps
* rename library from libMLIRStaticLogicOps to libCIRCTStaticLogicOps
* alphabetically rearrange LIBS in CMakeLists.txt
* add LLVM license info to files header
* Add LLVM license info to files header
* Add LLVM license info to files header
* Add LLVM license info to file headers
* Revert "Add LLVM license info to files header"
This reverts commit 22869676ad.
* Add LLVM license info to file headers
* run git-clang-format
* add missing file descriptions
* run git clang-format
* Add LLVM license info to file headers
* Add LLVM license info to files header
* Enable cloning llvm submodule over HTTP
* Introduce C API
* Undo unrelated changes
* clang-format
* More format
* Add Header Comments
* Format
* Add basic test
* Add missing incantation
* Format
Co-authored-by: George <>