Move most python sources to the include and lib tree.

pull/1/head
Stella Laurenzo 2020-06-18 18:02:39 -07:00
parent b21b5322f6
commit 213041449f
15 changed files with 66 additions and 44 deletions

View File

@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//
#ifndef NPCOMP_PYTHON_MLIRINIT_H
#define NPCOMP_PYTHON_MLIRINIT_H
#include "mlir/Support/LogicalResult.h"
#include "llvm/ADT/StringRef.h"
@ -14,7 +17,6 @@
// here for parts of the code that are not RTTI-compatible.
namespace mlir {
namespace npcomp {
namespace python {
@ -24,3 +26,5 @@ bool npcompMlirInitialize();
} // namespace python
} // namespace npcomp
} // namespace mlir
#endif // NPCOMP_PYTHON_MLIRINIT_H

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef NPCOMP_PYTHON_NATIVE_MLIR_IR_H
#define NPCOMP_PYTHON_NATIVE_MLIR_IR_H
#ifndef NPCOMP_PYTHON_MLIR_IR_H
#define NPCOMP_PYTHON_MLIR_IR_H
#include "PybindUtils.h"
@ -198,4 +198,4 @@ protected:
} // namespace mlir
#endif // NPCOMP_PYTHON_NATIVE_MLIR_IR_H
#endif // NPCOMP_PYTHON_MLIR_IR_H

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef NPCOMP_PYTHON_NATIVE_MLIR_PASS_H
#define NPCOMP_PYTHON_NATIVE_MLIR_PASS_H
#ifndef NPCOMP_PYTHON_MLIR_PASS_H
#define NPCOMP_PYTHON_MLIR_PASS_H
#include "MlirIr.h"
#include "PybindUtils.h"
@ -29,4 +29,4 @@ private:
} // namespace mlir
#endif // NPCOMP_PYTHON_NATIVE_MLIR_PASS_H
#endif // NPCOMP_PYTHON_MLIR_PASS_H

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef NPCOMP_PYTHON_NATIVE_NPCOMP_MODULE_H
#define NPCOMP_PYTHON_NATIVE_NPCOMP_MODULE_H
#ifndef NPCOMP_PYTHON_NPCOMP_MODULE_H
#define NPCOMP_PYTHON_NPCOMP_MODULE_H
#include "PybindUtils.h"
@ -25,4 +25,4 @@ void defineNpcompDialect(py::module m);
} // namespace npcomp
} // namespace mlir
#endif // NPCOMP_PYTHON_NATIVE_NPCOMP_MODULE_H
#endif // NPCOMP_PYTHON_NPCOMP_MODULE_H

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef NPCOMP_PYTHON_NATIVE_PYBIND_UTILS_H
#define NPCOMP_PYTHON_NATIVE_PYBIND_UTILS_H
#ifndef NPCOMP_PYTHON_PYBIND_UTILS_H
#define NPCOMP_PYTHON_PYBIND_UTILS_H
#include <string>
@ -52,4 +52,4 @@ inline pybind11::error_already_set raiseValueError(const std::string &message) {
} // namespace pybind11
#endif // NPCOMP_PYTHON_NATIVE_PYBIND_UTILS_H
#endif // NPCOMP_PYTHON_PYBIND_UTILS_H

View File

@ -1,6 +1,7 @@
add_subdirectory(Conversion)
add_subdirectory(Dialect)
add_subdirectory(E2E)
add_subdirectory(Python)
################################################################################
# Setup the initialization target.

View File

@ -0,0 +1,27 @@
add_library(NPCOMPPythonCommon
MlirInit.cpp
MlirIr.cpp
MlirPass.cpp
NpcompDialect.cpp
PybindUtils.cpp
CoreDialects.cpp
)
target_link_libraries(NPCOMPPythonCommon
pybind11::module
NPCOMPInitAll
# Core dialects
MLIRSCF
# Upstream depends
LLVMSupport
MLIRDialect
MLIREDSC
MLIREDSCInterface
MLIRIR
MLIRLLVMIR
MLIRPass
MLIRTransforms
)

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#include "MlirIr.h"
#include "NpcompModule.h"
#include "npcomp/Python/MlirIr.h"
#include "npcomp/Python/NpcompModule.h"
#include "mlir/Dialect/SCF/SCF.h"

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "MlirInit.h"
#include "npcomp/Python/MlirInit.h"
#include "mlir/IR/Dialect.h"
#include "mlir/InitAllDialects.h"

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#include "MlirIr.h"
#include "NpcompModule.h"
#include "npcomp/Python/MlirIr.h"
#include "npcomp/Python/NpcompModule.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/IR/Attributes.h"

View File

@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
#include "MlirPass.h"
#include "MlirInit.h"
#include "NpcompModule.h"
#include "npcomp/Python/MlirPass.h"
#include "npcomp/Python/MlirInit.h"
#include "npcomp/Python/NpcompModule.h"
#include "mlir/Pass/PassRegistry.h"

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#include "MlirIr.h"
#include "NpcompModule.h"
#include "npcomp/Python/MlirIr.h"
#include "npcomp/Python/NpcompModule.h"
#include "npcomp/Dialect/Basicpy/IR/BasicpyDialect.h"
#include "npcomp/Dialect/Basicpy/IR/BasicpyOps.h"

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "PybindUtils.h"
#include "npcomp/Python/PybindUtils.h"
namespace pybind11 {

View File

@ -25,21 +25,15 @@ set(NPCOMP_PYEXT_LIBADD ${PYTHON_LIBRARIES})
# compiled separately for now.
set(extension_target NPCOMPNativePyExt)
set(extension_llvm_sources
MlirInit.cpp
)
set(extension_pybind_sources
MlirIr.cpp
MlirPass.cpp
NpcompDialect.cpp
NpcompModule.cpp
PybindUtils.cpp
CoreDialects.cpp
)
set_source_files_properties(
${extension_pybind_sources}
PROPERTIES COMPILE_FLAGS
PROPERTIES COMPILE_FLAGS
"-frtti -fexceptions")
add_library(${extension_target} ${NPCOMP_PYEXT_LINK_MODE}
add_library(${extension_target} ${NPCOMP_PYEXT_LINK_MODE}
${extension_pybind_sources}
${extension_llvm_sources}
)
@ -47,10 +41,10 @@ add_library(${extension_target} ${NPCOMP_PYEXT_LINK_MODE}
set_target_properties(${extension_target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_CURRENT_BINARY_DIR}")
set_target_properties(${extension_target} PROPERTIES OUTPUT_NAME _npcomp)
set_target_properties(${extension_target} PROPERTIES PREFIX
set_target_properties(${extension_target} PROPERTIES PREFIX
"${PYTHON_MODULE_PREFIX}")
set_target_properties(${extension_target} PROPERTIES SUFFIX
"${PYTHON_MODULE_EXTENSION}")
set_target_properties(${extension_target} PROPERTIES SUFFIX
"${PYTHON_MODULE_EXTENSION}")
# pybind requires binding code to be compiled with -fvisibility=hidden
# Better code can be generated if the entire project compiles that way, but
@ -65,16 +59,12 @@ get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
# llvm_update_compile_flags(${extension_target})
target_link_libraries(${extension_target}
target_link_libraries(${extension_target}
PRIVATE
${dialect_libs}
${conversion_libs}
pybind11::module
NPCOMPInitAll
# Core dialects
MLIRSCF
NPCOMPPythonCommon
# Upstream depends
LLVMSupport

View File

@ -9,9 +9,9 @@
#include <cstddef>
#include <unordered_map>
#include "MlirInit.h"
#include "NpcompModule.h"
#include "PybindUtils.h"
#include "npcomp/Python/MlirInit.h"
#include "npcomp/Python/NpcompModule.h"
#include "npcomp/Python/PybindUtils.h"
#include "llvm/Support/CommandLine.h"