Skip to content

Commit

Permalink
[SMT][python] enable python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Jan 12, 2025
1 parent bf9f0dc commit a75d771
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 0 deletions.
24 changes: 24 additions & 0 deletions include/circt-c/Dialect/SMT.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//===- SMT.h - C interface for the SMT dialect ----------------*- C -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef CIRCT_C_DIALECT_SMT_H
#define CIRCT_C_DIALECT_SMT_H

#include "mlir-c/IR.h"

#ifdef __cplusplus
extern "C" {
#endif

MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(SMT, smt);

#ifdef __cplusplus
}
#endif

#endif // CIRCT_C_DIALECT_SMT_H
5 changes: 5 additions & 0 deletions lib/Bindings/Python/CIRCTModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "circt-c/Dialect/SV.h"
#include "circt-c/Dialect/Seq.h"
#include "circt-c/Dialect/Verif.h"
#include "circt-c/Dialect/SMT.h"
#include "circt-c/ExportVerilog.h"
#include "mlir-c/Bindings/Python/Interop.h"
#include "mlir-c/IR.h"
Expand Down Expand Up @@ -135,6 +136,10 @@ PYBIND11_MODULE(_circt, m) {
MlirDialectHandle verif = mlirGetDialectHandle__verif__();
mlirDialectHandleRegisterDialect(verif, context);
mlirDialectHandleLoadDialect(verif, context);

MlirDialectHandle smt = mlirGetDialectHandle__smt__();
mlirDialectHandleRegisterDialect(smt, context);
mlirDialectHandleLoadDialect(smt, context);
},
"Register CIRCT dialects on a PyMlirContext.");

Expand Down
9 changes: 9 additions & 0 deletions lib/Bindings/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ set(PYTHON_BINDINGS_LINK_LIBS
CIRCTCAPIRTG
CIRCTCAPIRtgTool
CIRCTCAPISeq
CIRCTCAPISMT
CIRCTCAPISV
CIRCTCAPIVerif
MLIRCAPITransforms
Expand Down Expand Up @@ -212,6 +213,14 @@ declare_mlir_dialect_python_bindings(
dialects/verif.py
DIALECT_NAME verif)

declare_mlir_dialect_python_bindings(
ADD_TO_PARENT CIRCTBindingsPythonSources.Dialects
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
TD_FILE dialects/SMTOps.td
SOURCES
dialects/smt.py
DIALECT_NAME smt)

declare_mlir_dialect_python_bindings(
ADD_TO_PARENT CIRCTBindingsPythonSources.Dialects
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
Expand Down
14 changes: 14 additions & 0 deletions lib/Bindings/Python/dialects/SMTOps.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//===- SMTOps.td - Entry point for SMT bindings --------*- tablegen -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef BINDINGS_PYTHON_SMT_OPS
#define BINDINGS_PYTHON_SMT_OPS

include "circt/Dialect/SMT/SMT.td"

#endif
5 changes: 5 additions & 0 deletions lib/Bindings/Python/dialects/smt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from ._smt_ops_gen import *
9 changes: 9 additions & 0 deletions lib/CAPI/Dialect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set(LLVM_OPTIONAL_SOURCES
RTGTest.cpp
SV.cpp
Seq.cpp
SMT.cpp
Verif.cpp
)

Expand Down Expand Up @@ -224,3 +225,11 @@ add_circt_public_c_api_library(CIRCTCAPIEmit
MLIRCAPIIR
CIRCTEmit
)

add_circt_public_c_api_library(CIRCTCAPISMT
SMT.cpp

LINK_LIBS PUBLIC
MLIRCAPIIR
CIRCTSMT
)
14 changes: 14 additions & 0 deletions lib/CAPI/Dialect/SMT.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//===- SMT.cpp - C interface for the SMT dialect ----------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "circt-c/Dialect/SMT.h"
#include "circt/Dialect/SMT/SMTDialect.h"

#include "mlir/CAPI/Registration.h"

MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(SMT, smt, circt::smt::SMTDialect)

0 comments on commit a75d771

Please sign in to comment.