13#include "mlir-c/Support.h"
14#include "mlir/Bindings/Python/NanobindAdaptors.h"
15#include "mlir/CAPI/Wrap.h"
18#include <nanobind/nanobind.h>
24using namespace mlir::python::nanobind_adaptors;
28 m.doc() =
"Synth dialect Python native extension";
31 nb::class_<SynthLongestPathAnalysis>(m,
"_LongestPathAnalysis")
34 [](SynthLongestPathAnalysis *self, MlirOperation module,
35 bool collectDebugInfo,
bool keepOnlyMaxDelayPaths,
36 bool lazyComputation,
const std::string &topModuleName) {
38 module, collectDebugInfo, keepOnlyMaxDelayPaths,
40 mlirStringRefCreateFromCString(topModuleName.c_str())));
42 nb::arg(
"module"), nb::arg(
"collect_debug_info") =
false,
43 nb::arg(
"keep_only_max_delay_paths") =
false,
44 nb::arg(
"lazy_computation") =
false, nb::arg(
"top_module_name") =
"")
46 [](SynthLongestPathAnalysis &self) {
50 [](SynthLongestPathAnalysis *self, MlirValue value, int64_t bitPos,
51 bool elaboratePaths) -> SynthLongestPathCollection {
54 *self, value, bitPos, elaboratePaths));
57 throw nb::value_error(
58 "Failed to get all paths, see previous error(s).");
62 .def(
"get_internal_paths",
63 [](SynthLongestPathAnalysis *self,
const std::string &moduleName,
64 bool elaboratePaths) -> SynthLongestPathCollection {
65 MlirStringRef moduleNameRef =
66 mlirStringRefCreateFromCString(moduleName.c_str());
68 auto collection = SynthLongestPathCollection(
73 throw nb::value_error(
74 "Failed to get all paths, see previous error(s).");
80 .def(
"get_paths_from_input_ports_to_internal",
81 [](SynthLongestPathAnalysis *self,
82 const std::string &moduleName) -> SynthLongestPathCollection {
83 MlirStringRef moduleNameRef =
84 mlirStringRefCreateFromCString(moduleName.c_str());
86 auto collection = SynthLongestPathCollection(
88 *self, moduleNameRef));
91 throw nb::value_error(
92 "Failed to get paths from input ports to internal, see "
93 "previous error(s).");
99 .def(
"get_paths_from_internal_to_output_ports",
100 [](SynthLongestPathAnalysis *self,
101 const std::string &moduleName) -> SynthLongestPathCollection {
102 MlirStringRef moduleNameRef =
103 mlirStringRefCreateFromCString(moduleName.c_str());
105 auto collection = SynthLongestPathCollection(
107 *self, moduleNameRef));
110 throw nb::value_error(
111 "Failed to get paths from internal to output ports, see "
112 "previous error(s).");
117 nb::class_<SynthLongestPathCollection>(m,
"_LongestPathCollection")
119 [](SynthLongestPathCollection &self) {
123 [](SynthLongestPathCollection &self) {
127 [](SynthLongestPathCollection &self,
128 int pathIndex) -> SynthLongestPathDataflowPath {
131 .def(
"merge", [](SynthLongestPathCollection &self,
132 SynthLongestPathCollection &src) {
136 nb::class_<SynthLongestPathDataflowPath>(m,
"_LongestPathDataflowPath")
137 .def_prop_ro(
"delay",
138 [](SynthLongestPathDataflowPath &self) {
141 .def_prop_ro(
"start_point",
142 [](SynthLongestPathDataflowPath &self) {
145 .def_prop_ro(
"end_point",
146 [](SynthLongestPathDataflowPath &self) {
149 .def_prop_ro(
"history",
150 [](SynthLongestPathDataflowPath &self) {
153 .def_prop_ro(
"root", [](SynthLongestPathDataflowPath &self) {
157 nb::class_<SynthLongestPathHistory>(m,
"_LongestPathHistory")
158 .def_prop_ro(
"empty",
159 [](SynthLongestPathHistory &self) {
163 [](SynthLongestPathHistory &self) {
164 SynthLongestPathObject object;
166 MlirStringRef comment;
169 return std::make_tuple(
object, delay, comment);
171 .def_prop_ro(
"tail", [](SynthLongestPathHistory &self) {
175 nb::class_<SynthLongestPathObject>(m,
"_LongestPathObject")
176 .def_prop_ro(
"instance_path",
177 [](SynthLongestPathObject &self) {
180 return std::vector<MlirOperation>();
182 std::vector<MlirOperation> result;
183 for (
size_t i = 0; i < size; ++i)
188 [](SynthLongestPathObject &self) {
191 .def_prop_ro(
"bit_pos", [](SynthLongestPathObject &self) {
MLIR_CAPI_EXPORTED MlirOperation synthLongestPathDataflowPathGetRoot(SynthLongestPathDataflowPath dataflowPath)
MLIR_CAPI_EXPORTED bool synthLongestPathHistoryIsEmpty(SynthLongestPathHistory history)
MLIR_CAPI_EXPORTED SynthLongestPathHistory synthLongestPathHistoryGetTail(SynthLongestPathHistory history)
MLIR_CAPI_EXPORTED void synthLongestPathCollectionDestroy(SynthLongestPathCollection collection)
MLIR_CAPI_EXPORTED void synthLongestPathHistoryGetHead(SynthLongestPathHistory history, SynthLongestPathObject *object, int64_t *delay, MlirStringRef *comment)
MLIR_CAPI_EXPORTED size_t synthLongestPathCollectionGetSize(SynthLongestPathCollection collection)
MLIR_CAPI_EXPORTED size_t synthLongestPathObjectBitPos(SynthLongestPathObject object)
MLIR_CAPI_EXPORTED SynthLongestPathObject synthLongestPathDataflowPathGetStartPoint(SynthLongestPathDataflowPath dataflowPath)
MLIR_CAPI_EXPORTED IgraphInstancePath synthLongestPathObjectGetInstancePath(SynthLongestPathObject object)
MLIR_CAPI_EXPORTED SynthLongestPathObject synthLongestPathDataflowPathGetEndPoint(SynthLongestPathDataflowPath dataflowPath)
MLIR_CAPI_EXPORTED SynthLongestPathCollection synthLongestPathAnalysisGetInternalPaths(SynthLongestPathAnalysis analysis, MlirStringRef moduleName, bool elaboratePaths)
MLIR_CAPI_EXPORTED SynthLongestPathCollection synthLongestPathAnalysisGetPaths(SynthLongestPathAnalysis analysis, MlirValue value, int64_t bitPos, bool elaboratePaths)
MLIR_CAPI_EXPORTED SynthLongestPathCollection synthLongestPathAnalysisGetPathsFromInternalToOutputPorts(SynthLongestPathAnalysis analysis, MlirStringRef moduleName)
MLIR_CAPI_EXPORTED SynthLongestPathHistory synthLongestPathDataflowPathGetHistory(SynthLongestPathDataflowPath dataflowPath)
MLIR_CAPI_EXPORTED bool synthLongestPathCollectionIsNull(SynthLongestPathCollection collection)
MLIR_CAPI_EXPORTED SynthLongestPathDataflowPath synthLongestPathCollectionGetDataflowPath(SynthLongestPathCollection collection, size_t pathIndex)
MLIR_CAPI_EXPORTED SynthLongestPathAnalysis synthLongestPathAnalysisCreate(MlirOperation module, bool collectDebugInfo, bool keepOnlyMaxDelayPaths, bool lazyComputation, MlirStringRef topModuleName)
MLIR_CAPI_EXPORTED SynthLongestPathCollection synthLongestPathAnalysisGetPathsFromInputPortsToInternal(SynthLongestPathAnalysis analysis, MlirStringRef moduleName)
MLIR_CAPI_EXPORTED void synthLongestPathCollectionMerge(SynthLongestPathCollection dest, SynthLongestPathCollection src)
MLIR_CAPI_EXPORTED void synthLongestPathAnalysisDestroy(SynthLongestPathAnalysis analysis)
MLIR_CAPI_EXPORTED MlirStringRef synthLongestPathObjectName(SynthLongestPathObject object)
MLIR_CAPI_EXPORTED int64_t synthLongestPathDataflowPathGetDelay(SynthLongestPathDataflowPath dataflowPath)
MLIR_CAPI_EXPORTED size_t igraphInstancePathSize(IgraphInstancePath path)
MLIR_CAPI_EXPORTED MlirOperation igraphInstancePathGet(IgraphInstancePath path, size_t index)
void populateDialectSynthSubmodule(nanobind::module_ &m)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.