12 #include "mlir-c/Bindings/Python/Interop.h"
14 #include "mlir/Bindings/Python/PybindAdaptors.h"
15 #include "mlir/CAPI/IR.h"
16 #include "mlir/CAPI/Support.h"
18 #include "llvm/ADT/SmallVector.h"
21 #include <pybind11/pybind11.h>
22 #include <pybind11/stl.h>
25 using namespace mlir::python::adaptors;
28 m.doc() =
"SV Python Native Extension";
33 [](py::object cls, std::string name, py::object expressionObj,
34 bool emitAsComment, MlirContext
ctxt) {
37 MlirStringRef expression = {
nullptr, 0};
38 if (!expressionObj.is_none()) {
39 expr = expressionObj.cast<std::string>();
40 expression = mlirStringRefCreateFromCString(expr.c_str());
43 ctxt, mlirStringRefCreateFromCString(name.c_str()), expression,
46 "Create a SystemVerilog attribute", py::arg(), py::arg(
"name"),
47 py::arg(
"expression") = py::none(),
48 py::arg(
"emit_as_comment") = py::none(), py::arg(
"ctxt") = py::none())
49 .def_property_readonly(
"name",
50 [](MlirAttribute
self) {
53 return std::string(name.data, name.length);
55 .def_property_readonly(
57 [](MlirAttribute
self) -> py::object {
59 if (name.data ==
nullptr)
61 return py::str(std::string(name.data, name.length));
63 .def_property_readonly(
"emit_as_comment", [](MlirAttribute
self) {
MLIR_CAPI_EXPORTED MlirAttribute svSVAttributeAttrGet(MlirContext, MlirStringRef name, MlirStringRef expression, bool emitAsComment)
MLIR_CAPI_EXPORTED MlirStringRef svSVAttributeAttrGetExpression(MlirAttribute)
MLIR_CAPI_EXPORTED bool svSVAttributeAttrGetEmitAsComment(MlirAttribute)
MLIR_CAPI_EXPORTED bool svAttrIsASVAttributeAttr(MlirAttribute)
MLIR_CAPI_EXPORTED MlirStringRef svSVAttributeAttrGetName(MlirAttribute)
void populateDialectSVSubmodule(pybind11::module &m)