Skip to content

Commit

Permalink
[REFACTOR][CODEGEN] codegen->target, build_module->driver (apache#4742)
Browse files Browse the repository at this point in the history
This PR moves the codegen related code into the target folder,
as they are target specific functionalities.

We also adopt the term "compiler driver" in common compiler infra
such as rust, GHC and clang.
As a result, build_module is moved into the driver folder.
  • Loading branch information
tqchen authored and zhiics committed Mar 2, 2020
1 parent d0c1d19 commit 7bb2798
Show file tree
Hide file tree
Showing 119 changed files with 952 additions and 854 deletions.
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,17 @@ assign_source_group("Include" ${GROUP_INCLUDE})
file(GLOB_RECURSE COMPILER_SRCS
src/node/*.cc
src/ir/*.cc
src/target/*.cc
src/arith/*.cc
src/top/*.cc
src/api/*.cc
src/autotvm/*.cc
src/tir/*.cc
src/driver/*.cc
src/api/*.cc
)

file(GLOB CODEGEN_SRCS
src/codegen/*.cc
src/target/*.cc
src/target/source/*.cc
)

list(APPEND COMPILER_SRCS ${CODEGEN_SRCS})
Expand Down Expand Up @@ -171,7 +172,7 @@ if(USE_VM_PROFILER)
list(APPEND COMPILER_SRCS ${BACKEND_VM_PROFILER_SRCS})
endif(USE_VM_PROFILER)

file(GLOB DATATYPE_SRCS src/codegen/datatype/*.cc)
file(GLOB DATATYPE_SRCS src/target/datatype/*.cc)
list(APPEND COMPILER_SRCS ${DATATYPE_SRCS})

file(GLOB TOPI_SRCS
Expand All @@ -197,7 +198,7 @@ if(USE_RPC)
endif(USE_RPC)

file(GLOB STACKVM_RUNTIME_SRCS src/runtime/stackvm/*.cc)
file(GLOB STACKVM_CODEGEN_SRCS src/codegen/stackvm/*.cc)
file(GLOB STACKVM_CODEGEN_SRCS src/target/stackvm/*.cc)
list(APPEND COMPILER_SRCS ${STACKVM_CODEGEN_SRCS})
if(USE_STACKVM_RUNTIME)
message(STATUS "Build with stackvm support in runtime...")
Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/CUDA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if(USE_CUDA)
message(STATUS "Build with CUDA support")
file(GLOB RUNTIME_CUDA_SRCS src/runtime/cuda/*.cc)
list(APPEND RUNTIME_SRCS ${RUNTIME_CUDA_SRCS})
list(APPEND COMPILER_SRCS src/codegen/opt/build_cuda_on.cc)
list(APPEND COMPILER_SRCS src/target/opt/build_cuda_on.cc)

list(APPEND TVM_LINKER_LIBS ${CUDA_NVRTC_LIBRARY})
list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDART_LIBRARY})
Expand All @@ -54,5 +54,5 @@ if(USE_CUDA)
endif(USE_CUBLAS)

else(USE_CUDA)
list(APPEND COMPILER_SRCS src/codegen/opt/build_cuda_off.cc)
list(APPEND COMPILER_SRCS src/target/opt/build_cuda_off.cc)
endif(USE_CUDA)
2 changes: 1 addition & 1 deletion cmake/modules/LLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if(NOT USE_LLVM STREQUAL "OFF")
message(STATUS "Set TVM_LLVM_VERSION=" ${TVM_LLVM_VERSION})
# Set flags that are only needed for LLVM target
add_definitions(-DTVM_LLVM_VERSION=${TVM_LLVM_VERSION})
file(GLOB COMPILER_LLVM_SRCS src/codegen/llvm/*.cc)
file(GLOB COMPILER_LLVM_SRCS src/target/llvm/*.cc)
list(APPEND TVM_LINKER_LIBS ${LLVM_LIBS})
list(APPEND COMPILER_SRCS ${COMPILER_LLVM_SRCS})
if(NOT MSVC)
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/Metal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ if(USE_METAL)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${MPS_CONTRIB_LIB})
endif()
else(USE_METAL)
list(APPEND COMPILER_SRCS src/codegen/opt/build_metal_off.cc)
list(APPEND COMPILER_SRCS src/target/opt/build_metal_off.cc)
endif(USE_METAL)
6 changes: 3 additions & 3 deletions cmake/modules/OpenCL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if(USE_SDACCEL)
set(USE_OPENCL ON)
endif()
else()
list(APPEND COMPILER_SRCS src/codegen/opt/build_sdaccel_off.cc)
list(APPEND COMPILER_SRCS src/target/opt/build_sdaccel_off.cc)
endif(USE_SDACCEL)

if(USE_AOCL)
Expand All @@ -45,7 +45,7 @@ if(USE_AOCL)
set(USE_OPENCL ON)
endif()
else()
list(APPEND COMPILER_SRCS src/codegen/opt/build_aocl_off.cc)
list(APPEND COMPILER_SRCS src/target/opt/build_aocl_off.cc)
endif(USE_AOCL)

if(USE_OPENCL)
Expand All @@ -55,5 +55,5 @@ if(USE_OPENCL)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${OpenCL_LIBRARIES})
list(APPEND RUNTIME_SRCS ${RUNTIME_OPENCL_SRCS})
else()
list(APPEND COMPILER_SRCS src/codegen/opt/build_opencl_off.cc)
list(APPEND COMPILER_SRCS src/target/opt/build_opencl_off.cc)
endif(USE_OPENCL)
2 changes: 1 addition & 1 deletion cmake/modules/OpenGL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ if(USE_OPENGL)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${OpenGL_LIBRARIES} glfw)
list(APPEND RUNTIME_SRCS ${RUNTIME_OPENGL_SRCS})
else(USE_OPENGL)
list(APPEND COMPILER_SRCS src/codegen/opt/build_opengl_off.cc)
list(APPEND COMPILER_SRCS src/target/opt/build_opengl_off.cc)
endif(USE_OPENGL)
2 changes: 1 addition & 1 deletion cmake/modules/ROCM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ if(USE_ROCM)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${ROCM_ROCBLAS_LIBRARY})
endif(USE_ROCBLAS)
else(USE_ROCM)
list(APPEND COMPILER_SRCS src/codegen/opt/build_rocm_off.cc)
list(APPEND COMPILER_SRCS src/target/opt/build_rocm_off.cc)
endif(USE_ROCM)
2 changes: 1 addition & 1 deletion cmake/modules/Vulkan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if(USE_VULKAN)
endif()
message(STATUS "Build with Vulkan support")
file(GLOB RUNTIME_VULKAN_SRCS src/runtime/vulkan/vulkan.cc)
file(GLOB COMPILER_VULKAN_SRCS src/codegen/spirv/*.cc)
file(GLOB COMPILER_VULKAN_SRCS src/target/spirv/*.cc)
list(APPEND RUNTIME_SRCS ${RUNTIME_VULKAN_SRCS})
list(APPEND COMPILER_SRCS ${COMPILER_VULKAN_SRCS})
list(APPEND TVM_LINKER_LIBS ${Vulkan_SPIRV_TOOLS_LIBRARY})
Expand Down
Loading

0 comments on commit 7bb2798

Please sign in to comment.