Skip to content

Commit

Permalink
refactor: use cmake to generate code from tablegen
Browse files Browse the repository at this point in the history
  • Loading branch information
mocusez committed Aug 8, 2024
1 parent efba48e commit 3c87baf
Show file tree
Hide file tree
Showing 63 changed files with 120 additions and 23,659 deletions.
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,23 @@ find_package(MLIR REQUIRED CONFIG)
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${MLIR_INCLUDE_DIRS})

list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")

include(TableGen)
include(AddLLVM)
include(AddMLIR)
include(HandleLLVMOptions)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")

add_custom_target(Toy)
macro(add_toy_chapter name)
add_dependencies(Toy ${name})
add_llvm_example(${name} ${ARGN})
endmacro(add_toy_chapter name)

add_subdirectory(Ch1)
add_subdirectory(Ch2)
Expand Down
2 changes: 1 addition & 1 deletion Ch1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set(LLVM_LINK_COMPONENTS
Support
)

add_executable(toyc-ch1
add_toy_chapter(toyc-ch1
toyc.cpp
parser/AST.cpp
)
Expand Down
9 changes: 7 additions & 2 deletions Ch2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ set(LLVM_LINK_COMPONENTS
Support
)

add_executable(toyc-ch2
add_toy_chapter(toyc-ch2
toyc.cpp
parser/AST.cpp
mlir/MLIRGen.cpp
mlir/Dialect.cpp
)

DEPENDS
ToyCh2OpsIncGen

)

include_directories(include/)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
target_link_libraries(toyc-ch2
Expand Down
7 changes: 6 additions & 1 deletion Ch2/include/toy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@

set(LLVM_TARGET_DEFINITIONS Ops.td)
mlir_tablegen(Ops.h.inc -gen-op-decls)
mlir_tablegen(Ops.cpp.inc -gen-op-defs)
mlir_tablegen(Dialect.h.inc -gen-dialect-decls)
mlir_tablegen(Dialect.cpp.inc -gen-dialect-defs)
add_public_tablegen_target(ToyCh2OpsIncGen)
23 changes: 0 additions & 23 deletions Ch2/include/toy/Dialect.cpp.inc

This file was deleted.

26 changes: 0 additions & 26 deletions Ch2/include/toy/Dialect.h.inc

This file was deleted.

Loading

0 comments on commit 3c87baf

Please sign in to comment.