Skip to content

Commit

Permalink
updated cmake setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Gysi committed Dec 14, 2019
1 parent b5c1db1 commit 6a7fc22
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 90 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
*.log
build/
.clangd/
.vscode/

.clang-format
compile_commands.json

35 changes: 18 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
cmake_minimum_required(VERSION 3.12.4)

project(mlir-sten LANGUAGES CXX)
project(oec-opt LANGUAGES CXX)

find_package(LLVM REQUIRED CONFIG
HINTS /home/vogtha/projects/mlir_standalone/llvm-project/install
)
find_package(LLVM REQUIRED CONFIG)

include_directories(${LLVM_INCLUDE_DIR})

Expand All @@ -17,7 +15,10 @@ set(MLIR_MAIN_SRC_DIR ${LLVM_INCLUDE_DIR}) # --src-root
set(MLIR_INCLUDE_DIR ${LLVM_INCLUDE_DIR}) # --includedir
set(MLIR_TABLEGEN_EXE mlir-tblgen)

include(${LLVM_CMAKE_DIR}/TableGen.cmake)
# import llvm functionality
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(AddLLVM)
include(TableGen)

function(mlir_tablegen ofn)
tablegen(MLIR ${ARGV} "-I${MLIR_MAIN_SRC_DIR}" "-I${MLIR_INCLUDE_DIR}" "-I${PROJECT_SOURCE_DIR}/include")
Expand All @@ -26,25 +27,25 @@ function(mlir_tablegen ofn)
endfunction()

function(whole_archive_link target)
# if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
# set(link_flags "-L${CMAKE_BINARY_DIR}/lib ")
# FOREACH(LIB ${ARGN})
# string(CONCAT link_flags ${link_flags} "-Wl,-force_load ${CMAKE_BINARY_DIR}/lib/lib${LIB}.a ")
# ENDFOREACH(LIB)
# elseif(MSVC)
# FOREACH(LIB ${ARGN})
# string(CONCAT link_flags ${link_flags} "/WHOLEARCHIVE:${LIB} ")
# ENDFOREACH(LIB)
# else()
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(link_flags "-L${CMAKE_BINARY_DIR}/lib ")
FOREACH(LIB ${ARGN})
string(CONCAT link_flags ${link_flags} "-Wl,-force_load ${CMAKE_BINARY_DIR}/lib/lib${LIB}.a ")
ENDFOREACH(LIB)
elseif(MSVC)
FOREACH(LIB ${ARGN})
string(CONCAT link_flags ${link_flags} "/WHOLEARCHIVE:${LIB} ")
ENDFOREACH(LIB)
else()
set(link_flags "-L${LLVM_LIBRARY_DIR} -Wl,--whole-archive,")
FOREACH(LIB ${ARGN})
string(CONCAT link_flags ${link_flags} "-l${LIB},")
ENDFOREACH(LIB)
string(CONCAT link_flags ${link_flags} "--no-whole-archive")
# endif()
endif()
set_target_properties(${target} PROPERTIES LINK_FLAGS ${link_flags})
endfunction(whole_archive_link)

add_subdirectory(include/sten)
add_subdirectory(lib)
add_subdirectory(tools/mlir-opt)
add_subdirectory(tools/oec-opt)
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
# mlir_tutorial
# stencil-dialect

- Build llvm with mlir

tested with
- llvm commit 40dfc6dff10bd8881c6df31884e2184bbaab5698
- mlir commit 0eee0ba2e75c7c5f1430621aa13d2f0367f297ad

needs a small tweek to the CMakeLists.txt of mlir
- install also *.td files and *.def files

Build this repository in the standard way, pointing to the LLVM installation
Development repository for the open earth compiler. Buld llvm and mlir in a separate folder and generate a build folder using the following commands:

```
mkdir build && cd build
Expand Down
10 changes: 3 additions & 7 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Dialect/Sten/CMakeLists.txt

add_library(MLIRSten
add_llvm_library(MLIRSten
DialectRegistration.cpp
StenDialect.cpp
StenOps.cpp
StenTypes.cpp

# ADDITIONAL_HEADER_DIRS
# ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Sten
)
StenTypes.cpp)

# Make sure that the TableGen generated files are up-to-date
add_dependencies(MLIRSten
Expand All @@ -19,6 +15,6 @@ target_link_libraries(MLIRSten
MLIRParser
MLIRSupport)

# specify header directories
target_include_directories(MLIRSten PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_include_directories(MLIRSten PUBLIC ${PROJECT_BINARY_DIR}/include)
target_compile_options(MLIRSten PRIVATE -fno-rtti) #TODO use llvm_update_compile_flags
55 changes: 0 additions & 55 deletions tools/mlir-opt/CMakeLists.txt

This file was deleted.

52 changes: 52 additions & 0 deletions tools/oec-opt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
set(LIBS
MLIRAnalysis
MLIRAffineOps
MLIRAffineToStandard
#MLIRLoopsToGPU
#MLIRLinalgToLLVM

MLIRLoopToStandard
MLIREDSC
MLIRFxpMathOps
#MLIRGPU
#MLIRGPUtoNVVMTransforms
#MLIRGPUtoROCDLTransforms
#MLIRGPUtoSPIRVTransforms
#MLIRLinalg
MLIRLLVMIR
MLIRLoopOps
#MLIRNVVMIR
MLIROptMain
MLIRParser
MLIRPass
MLIRQuantizerTransforms
MLIRQuantOps
#MLIRROCDLIR
#MLIRSPIRV
#MLIRStandardToSPIRVTransforms
#MLIRSPIRVTransforms
MLIRStandardOps
MLIRStandardToLLVM
MLIRTransforms
#MLIRTestDialect
#MLIRTestIR
#MLIRTestPass
#MLIRTestTransforms
MLIRSupport
MLIRVectorOps
MLIRVectorToLLVM
MLIRVectorToLoops
)
#if(MLIR_CUDA_CONVERSIONS_ENABLED)
# list(APPEND LIBS
# MLIRGPUtoCUDATransforms
# )
#endif()

add_executable(oec-opt
oec-opt.cpp
)
llvm_update_compile_flags(oec-opt)
whole_archive_link(oec-opt ${LIBS})
target_link_libraries(oec-opt PRIVATE MLIRIR MLIRMlirOptLib ${LIBS} LLVMSupport)

File renamed without changes.

0 comments on commit 6a7fc22

Please sign in to comment.