Commit Graph

65 Commits

Author SHA1 Message Date
Stella Laurenzo cdc0dc114d
[POC] Create a python facility for custom/out of tree types. (#996)
* 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.
2021-05-03 15:08:18 -07:00
John Demme 8183b7a961
[MSFT] [Python] Export tcl API call (#939)
* [MSFT] [Python] Export tcl API call

* clang-format
2021-04-21 10:50:24 -07:00
John Demme c15faa7fc4
[MSFT] [Python] Physically locate an op (#937)
Adds an API call to physically place an op's sub-entity.
2021-04-20 16:20:22 -07:00
John Demme ac14de2630
[Python] Register passes, export_verilog, and stack traces (#930)
- 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.
2021-04-19 22:05:40 -07:00
John Demme d3cfca3c6b
[ESI] C API and Python bindings (#870)
Just the ability to 'import' ESI into Python.
2021-04-02 14:09:20 -07:00
mikeurbach ca20bd3617
[CAPI] Add CAPI for RTL InOutType getters and isa. (#845) 2021-03-30 10:26:02 -06:00
George Lyon 2343f692d0
Bind more API to C (#705) 2021-03-02 09:38:29 -08:00
Andrew Young e1ca6eaaf9 Remove `using namespace mlir` from header files
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.
2021-02-16 02:25:06 -08:00
George Lyon b03db32b0f
[CAPI] Modernize dialect registration (#560) 2021-02-10 10:41:18 -08:00
George Lyon eb092323e6
[ExportVerilog][SV] C API (#481)
Co-authored-by: George <989903+GeorgeLyon@users.noreply.github.com>
2021-01-20 15:42:02 -08:00
Shivam Gupta fa58cbc431
Make dialects naming consistence by having foo/foobar.cpp rather than foo/bar.cpp (#372)
* 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/
2020-12-27 09:42:19 -08:00
Shivam Gupta d98d2a1364
Rename library from libMLIRfoo to libCIRCTfoo (#357)
* 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
2020-12-24 23:16:37 +05:30
Shivam Gupta 9f34d3742b
Add missing LLVM license info to file headers (#352)
* 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
2020-12-24 23:11:01 +05:30
Andrew Young 77f9520ea1
[CMAKE] Add circt library declaration helpers (#304) 2020-12-10 14:53:04 -05:00
George Lyon 2a9eb3506d
Create a minimal C API (#196)
* 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 <>
2020-11-04 11:37:51 -08:00