@@ -103,7 +103,7 @@ namespace mlir::rlc
103103 std::map<const void *, mlir::rlc::FunctionOp> dropFunction;
104104 std::map<const void *, mlir::rlc::FunctionOp> assignFunction;
105105 };
106- static void printPrelude (StreamWriter& writer)
106+ static void printPrelude (StreamWriter& writer, bool isMac, bool isWindows )
107107 {
108108 writer.writenl (" import ctypes" );
109109 writer.writenl (" import os" );
@@ -112,9 +112,16 @@ namespace mlir::rlc
112112 writer.writenl (" import builtins" );
113113 writer.writenl (" from collections import defaultdict" );
114114
115+ std::string libName = " lib.so" ;
116+ if (isMac)
117+ libName = " lib.dylib" ;
118+ if (isWindows)
119+ libName = " lib.dll" ;
115120 writer.writenl (
116121 " lib = ctypes.CDLL(os.path.join(Path(__file__).resolve().parent, "
117- " \" lib.so\" ))" );
122+ " \" " ,
123+ libName,
124+ " \" ))" );
118125 writer.writenl (" actions = defaultdict(list)" );
119126 writer.writenl (" wrappers = defaultdict(list)" );
120127 writer.writenl (" signatures = {}" );
@@ -854,12 +861,11 @@ namespace mlir::rlc
854861 OS.endLine ();
855862 }
856863
857- #define GEN_PASS_DEF_NEOPRINTPYTHONPASS
864+ #define GEN_PASS_DEF_PRINTPYTHONPASS
858865#include " rlc/dialect/Passes.inc"
859- struct NeoPrintPythonPass : impl::NeoPrintPythonPassBase<NeoPrintPythonPass >
866+ struct PrintPythonPass : impl::PrintPythonPassBase<PrintPythonPass >
860867 {
861- using impl::NeoPrintPythonPassBase<
862- NeoPrintPythonPass>::NeoPrintPythonPassBase;
868+ using impl::PrintPythonPassBase<PrintPythonPass>::PrintPythonPassBase;
863869
864870 void runOnOperation () override
865871 {
@@ -878,7 +884,7 @@ namespace mlir::rlc
878884 matcher.add <AliasToPythonAlias>();
879885
880886 // emit includes
881- printPrelude (matcher.getWriter ());
887+ printPrelude (matcher.getWriter (), isMac, isWindows );
882888
883889 // emit declarations of types
884890 for (auto t : ::rlc::postOrderTypes (getOperation ()))
0 commit comments