[Mlir-commits] [mlir] 1dc533c - [mlir][python] ExecutionEngine can dump to object file

Nicolas Vasilache llvmlistbot at llvm.org
Mon Apr 19 12:36:35 PDT 2021


Author: Nicolas Vasilache
Date: 2021-04-19T19:33:27Z
New Revision: 1dc533cea4ae6b9f72f7df53516c9f5c152ce35a

URL: https://github.com/llvm/llvm-project/commit/1dc533cea4ae6b9f72f7df53516c9f5c152ce35a
DIFF: https://github.com/llvm/llvm-project/commit/1dc533cea4ae6b9f72f7df53516c9f5c152ce35a.diff

LOG: [mlir][python] ExecutionEngine can dump to object file

Differential Revision: https://reviews.llvm.org/D100786

Added: 
    

Modified: 
    mlir/include/mlir-c/ExecutionEngine.h
    mlir/lib/Bindings/Python/ExecutionEngine.cpp
    mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir-c/ExecutionEngine.h b/mlir/include/mlir-c/ExecutionEngine.h
index 5210f108ee6b0..4a5d6ad9f648f 100644
--- a/mlir/include/mlir-c/ExecutionEngine.h
+++ b/mlir/include/mlir-c/ExecutionEngine.h
@@ -67,6 +67,11 @@ MLIR_CAPI_EXPORTED void
 mlirExecutionEngineRegisterSymbol(MlirExecutionEngine jit, MlirStringRef name,
                                   void *sym);
 
+/// Dump as an object in `fileName`.
+MLIR_CAPI_EXPORTED void
+mlirExecutionEngineDumpToObjectFile(MlirExecutionEngine jit,
+                                    MlirStringRef fileName);
+
 #ifdef __cplusplus
 }
 #endif

diff  --git a/mlir/lib/Bindings/Python/ExecutionEngine.cpp b/mlir/lib/Bindings/Python/ExecutionEngine.cpp
index 0e8ae8b38b3cb..b5c8dde7563f5 100644
--- a/mlir/lib/Bindings/Python/ExecutionEngine.cpp
+++ b/mlir/lib/Bindings/Python/ExecutionEngine.cpp
@@ -93,5 +93,13 @@ void mlir::python::populateExecutionEngineSubmodule(py::module &m) {
                 mlirStringRefCreate(name.c_str(), name.size()),
                 reinterpret_cast<void *>(sym));
           },
-          "Lookup function `func` in the ExecutionEngine.");
+          "Lookup function `func` in the ExecutionEngine.")
+      .def(
+          "dump_to_object_file",
+          [](PyExecutionEngine &executionEngine, const std::string &fileName) {
+            mlirExecutionEngineDumpToObjectFile(
+                executionEngine.get(),
+                mlirStringRefCreate(fileName.c_str(), fileName.size()));
+          },
+          "Dump ExecutionEngine to an object file.");
 }

diff  --git a/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp
index 345eac2193d8f..36f24ed889650 100644
--- a/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp
+++ b/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp
@@ -66,3 +66,8 @@ extern "C" void mlirExecutionEngineRegisterSymbol(MlirExecutionEngine jit,
     return symbolMap;
   });
 }
+
+extern "C" void mlirExecutionEngineDumpToObjectFile(MlirExecutionEngine jit,
+                                                    MlirStringRef name) {
+  unwrap(jit)->dumpToObjectFile(unwrap(name));
+}


        


More information about the Mlir-commits mailing list