2024-05-31 09:37:19 +02:00
|
|
|
cmake_minimum_required(VERSION 3.18)
|
2023-07-19 08:19:38 +02:00
|
|
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
2024-01-08 17:17:59 +01:00
|
|
|
|
|
|
|
# ##############################################################################
|
2021-08-16 16:59:23 +02:00
|
|
|
#
|
2024-01-08 17:17:59 +01:00
|
|
|
# ##############################################################################
|
2021-07-27 15:55:08 +02:00
|
|
|
project(dbt-rise-tgc VERSION 1.0.0)
|
2019-06-11 18:49:37 +02:00
|
|
|
|
2020-05-30 13:57:01 +02:00
|
|
|
include(GNUInstallDirs)
|
2023-07-19 08:19:38 +02:00
|
|
|
include(flink)
|
2019-06-11 18:49:37 +02:00
|
|
|
|
2022-03-08 11:23:07 +01:00
|
|
|
find_package(elfio QUIET)
|
2022-12-05 09:15:48 +01:00
|
|
|
find_package(jsoncpp)
|
2023-07-30 13:55:57 +02:00
|
|
|
find_package(Boost COMPONENTS coroutine REQUIRED)
|
2019-06-11 18:49:37 +02:00
|
|
|
|
2019-06-11 21:22:07 +02:00
|
|
|
add_subdirectory(softfloat)
|
|
|
|
|
2024-01-08 17:17:59 +01:00
|
|
|
set(LIB_SOURCES
|
2022-05-21 11:55:24 +02:00
|
|
|
src/iss/plugin/instruction_count.cpp
|
2024-01-08 17:17:59 +01:00
|
|
|
src/iss/arch/tgc5c.cpp
|
|
|
|
src/vm/interp/vm_tgc5c.cpp
|
|
|
|
src/vm/fp_functions.cpp
|
2024-07-23 11:30:33 +02:00
|
|
|
src/vm/instruction_decoder.cpp
|
2024-01-08 17:17:59 +01:00
|
|
|
src/iss/semihosting/semihosting.cpp
|
2020-05-30 13:57:01 +02:00
|
|
|
)
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2023-07-09 22:20:50 +02:00
|
|
|
if(WITH_TCC)
|
2024-01-08 17:17:59 +01:00
|
|
|
list(APPEND LIB_SOURCES
|
|
|
|
src/vm/tcc/vm_tgc5c.cpp
|
2023-08-30 10:05:42 +02:00
|
|
|
)
|
2023-05-04 16:08:33 +02:00
|
|
|
endif()
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2023-07-29 17:55:37 +02:00
|
|
|
if(WITH_LLVM)
|
2024-01-08 17:17:59 +01:00
|
|
|
list(APPEND LIB_SOURCES
|
|
|
|
src/vm/llvm/vm_tgc5c.cpp
|
|
|
|
src/vm/llvm/fp_impl.cpp
|
|
|
|
)
|
2023-05-04 16:08:33 +02:00
|
|
|
endif()
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2023-10-22 15:10:55 +02:00
|
|
|
if(WITH_ASMJIT)
|
2024-01-08 17:17:59 +01:00
|
|
|
list(APPEND LIB_SOURCES
|
|
|
|
src/vm/asmjit/vm_tgc5c.cpp
|
2023-10-22 15:10:55 +02:00
|
|
|
)
|
|
|
|
endif()
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2023-07-09 22:20:50 +02:00
|
|
|
# library files
|
|
|
|
FILE(GLOB GEN_ISS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/iss/arch/*.cpp)
|
|
|
|
FILE(GLOB GEN_VM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/interp/vm_*.cpp)
|
2023-10-21 17:26:03 +02:00
|
|
|
FILE(GLOB GEN_YAML_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/contrib/instr/*.yaml)
|
2023-07-09 22:20:50 +02:00
|
|
|
list(APPEND LIB_SOURCES ${GEN_ISS_SOURCES} ${GEN_VM_SOURCES})
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2023-07-09 22:20:50 +02:00
|
|
|
foreach(FILEPATH ${GEN_ISS_SOURCES})
|
|
|
|
get_filename_component(CORE ${FILEPATH} NAME_WE)
|
|
|
|
string(TOUPPER ${CORE} CORE)
|
|
|
|
list(APPEND LIB_DEFINES CORE_${CORE})
|
|
|
|
endforeach()
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2023-07-30 13:55:57 +02:00
|
|
|
message(STATUS "Core defines are ${LIB_DEFINES}")
|
2021-05-13 14:03:10 +02:00
|
|
|
|
2020-05-30 13:57:01 +02:00
|
|
|
if(WITH_LLVM)
|
2024-01-08 17:17:59 +01:00
|
|
|
FILE(GLOB LLVM_GEN_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/llvm/vm_*.cpp)
|
|
|
|
list(APPEND LIB_SOURCES ${LLVM_GEN_SOURCES})
|
2021-10-12 14:24:55 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_TCC)
|
2024-01-08 17:17:59 +01:00
|
|
|
FILE(GLOB TCC_GEN_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/tcc/vm_*.cpp)
|
|
|
|
list(APPEND LIB_SOURCES ${TCC_GEN_SOURCES})
|
2020-05-30 13:57:01 +02:00
|
|
|
endif()
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2023-10-22 15:10:55 +02:00
|
|
|
if(WITH_ASMJIT)
|
2024-01-08 17:17:59 +01:00
|
|
|
FILE(GLOB TCC_GEN_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/asmjit/vm_*.cpp)
|
|
|
|
list(APPEND LIB_SOURCES ${TCC_GEN_SOURCES})
|
2023-10-22 15:10:55 +02:00
|
|
|
endif()
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2023-09-30 22:10:24 +02:00
|
|
|
if(TARGET yaml-cpp::yaml-cpp)
|
2024-01-08 17:17:59 +01:00
|
|
|
list(APPEND LIB_SOURCES
|
|
|
|
src/iss/plugin/cycle_estimate.cpp
|
|
|
|
src/iss/plugin/instruction_count.cpp
|
2023-07-30 13:55:57 +02:00
|
|
|
)
|
2023-07-09 22:20:50 +02:00
|
|
|
endif()
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2019-06-11 21:22:07 +02:00
|
|
|
# Define the library
|
2023-07-30 09:14:58 +02:00
|
|
|
add_library(${PROJECT_NAME} SHARED ${LIB_SOURCES})
|
2020-12-30 08:29:52 +01:00
|
|
|
|
2021-10-10 19:56:33 +02:00
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
2023-07-29 17:55:37 +02:00
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-shift-count-overflow)
|
2021-10-10 19:56:33 +02:00
|
|
|
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE /wd4293)
|
2021-10-10 19:06:41 +02:00
|
|
|
endif()
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2022-05-21 11:55:24 +02:00
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC src)
|
2022-05-21 12:27:13 +02:00
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC src-gen)
|
2023-07-30 09:14:58 +02:00
|
|
|
|
2023-07-30 13:55:57 +02:00
|
|
|
target_force_link_libraries(${PROJECT_NAME} PRIVATE dbt-rise-core)
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2023-07-30 13:55:57 +02:00
|
|
|
# only re-export the include paths
|
|
|
|
get_target_property(DBT_CORE_INCL dbt-rise-core INTERFACE_INCLUDE_DIRECTORIES)
|
|
|
|
target_include_directories(${PROJECT_NAME} INTERFACE ${DBT_CORE_INCL})
|
|
|
|
get_target_property(DBT_CORE_DEFS dbt-rise-core INTERFACE_COMPILE_DEFINITIONS)
|
2024-01-08 17:17:59 +01:00
|
|
|
|
|
|
|
if(NOT(DBT_CORE_DEFS STREQUAL DBT_CORE_DEFS-NOTFOUND))
|
|
|
|
target_compile_definitions(${PROJECT_NAME} INTERFACE ${DBT_CORE_DEFS})
|
2023-09-20 15:17:43 +02:00
|
|
|
endif()
|
2023-07-30 09:14:58 +02:00
|
|
|
|
2023-07-30 13:55:57 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC elfio::elfio softfloat scc-util Boost::coroutine)
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2023-09-30 22:10:24 +02:00
|
|
|
if(TARGET yaml-cpp::yaml-cpp)
|
2024-01-08 17:17:59 +01:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC WITH_PLUGINS)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC yaml-cpp::yaml-cpp)
|
2022-02-01 19:28:11 +01:00
|
|
|
endif()
|
|
|
|
|
2023-09-04 12:37:30 +02:00
|
|
|
if(WITH_LLVM)
|
2023-09-19 16:26:07 +02:00
|
|
|
find_package(LLVM)
|
2024-01-08 17:17:59 +01:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC ${LLVM_DEFINITIONS})
|
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC ${LLVM_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${LLVM_LIBRARIES})
|
|
|
|
endif()
|
2023-09-04 12:37:30 +02:00
|
|
|
endif()
|
|
|
|
|
2021-03-23 18:13:32 +01:00
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
2024-01-08 17:17:59 +01:00
|
|
|
VERSION ${PROJECT_VERSION}
|
|
|
|
FRAMEWORK FALSE
|
2019-06-11 21:22:07 +02:00
|
|
|
)
|
2021-08-16 16:59:23 +02:00
|
|
|
install(TARGETS ${PROJECT_NAME} COMPONENT ${PROJECT_NAME}
|
2024-01-08 17:17:59 +01:00
|
|
|
EXPORT ${PROJECT_NAME}Targets # for downstream dependencies
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # static lib
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # binaries
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # shared lib
|
|
|
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} # for mac
|
|
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} # headers for mac (note the different component -> different package)
|
|
|
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers
|
2021-08-16 16:59:23 +02:00
|
|
|
)
|
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss COMPONENT ${PROJECT_NAME}
|
2024-01-08 17:17:59 +01:00
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # target directory
|
|
|
|
FILES_MATCHING # install only matched files
|
|
|
|
PATTERN "*.h" # select header files
|
|
|
|
)
|
2023-10-20 20:38:59 +02:00
|
|
|
install(FILES ${GEN_YAML_SOURCES} DESTINATION share/tgc-vp)
|
2024-01-08 17:17:59 +01:00
|
|
|
|
|
|
|
# ##############################################################################
|
2021-08-16 16:59:23 +02:00
|
|
|
#
|
2024-01-08 17:17:59 +01:00
|
|
|
# ##############################################################################
|
2023-10-18 11:17:20 +02:00
|
|
|
set(CMAKE_INSTALL_RPATH $ORIGIN/../${CMAKE_INSTALL_LIBDIR})
|
2021-05-13 14:03:10 +02:00
|
|
|
project(tgc-sim)
|
2021-07-27 15:55:08 +02:00
|
|
|
find_package(Boost COMPONENTS program_options thread REQUIRED)
|
2021-07-26 12:03:40 +02:00
|
|
|
|
2021-03-23 18:13:32 +01:00
|
|
|
add_executable(${PROJECT_NAME} src/main.cpp)
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2023-05-13 16:57:01 +02:00
|
|
|
if(TARGET ${CORE_NAME}_cpp)
|
|
|
|
list(APPEND TGC_SOURCES ${${CORE_NAME}_OUTPUT_FILES})
|
|
|
|
else()
|
|
|
|
FILE(GLOB TGC_SOURCES
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src-gen/iss/arch/*.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/interp/vm_*.cpp
|
|
|
|
)
|
|
|
|
list(APPEND TGC_SOURCES ${GEN_SOURCES})
|
|
|
|
endif()
|
|
|
|
|
2021-11-25 19:59:50 +01:00
|
|
|
foreach(F IN LISTS TGC_SOURCES)
|
2024-01-08 17:17:59 +01:00
|
|
|
if(${F} MATCHES ".*/arch/([^/]*)\.cpp")
|
|
|
|
string(REGEX REPLACE ".*/([^/]*)\.cpp" "\\1" CORE_NAME_LC ${F})
|
2023-05-16 08:54:08 +02:00
|
|
|
string(TOUPPER ${CORE_NAME_LC} CORE_NAME)
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME})
|
|
|
|
endif()
|
2021-11-25 19:59:50 +01:00
|
|
|
endforeach()
|
|
|
|
|
2024-01-08 17:17:59 +01:00
|
|
|
# if(WITH_LLVM)
|
|
|
|
# target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_LLVM)
|
|
|
|
# #target_link_libraries(${PROJECT_NAME} PUBLIC ${llvm_libs})
|
|
|
|
# endif()
|
|
|
|
# if(WITH_TCC)
|
|
|
|
# target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_TCC)
|
|
|
|
# endif()
|
2023-07-30 13:55:57 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC dbt-rise-tgc fmt::fmt)
|
|
|
|
|
2021-07-26 12:03:40 +02:00
|
|
|
if(TARGET Boost::program_options)
|
2021-11-02 10:24:34 +01:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::program_options)
|
2021-07-26 12:03:40 +02:00
|
|
|
else()
|
2021-11-02 10:24:34 +01:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${BOOST_program_options_LIBRARY})
|
2021-07-26 12:03:40 +02:00
|
|
|
endif()
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2021-10-10 19:06:41 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${CMAKE_DL_LIBS})
|
2024-01-08 17:17:59 +01:00
|
|
|
|
|
|
|
if(Tcmalloc_FOUND)
|
2021-10-10 19:06:41 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${Tcmalloc_LIBRARIES})
|
2019-06-11 21:22:07 +02:00
|
|
|
endif(Tcmalloc_FOUND)
|
|
|
|
|
2021-08-16 16:59:23 +02:00
|
|
|
install(TARGETS tgc-sim
|
2024-01-08 17:17:59 +01:00
|
|
|
EXPORT ${PROJECT_NAME}Targets # for downstream dependencies
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # static lib
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # binaries
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # shared lib
|
|
|
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} # for mac
|
|
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} # headers for mac (note the different component -> different package)
|
|
|
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers
|
2019-06-11 21:22:07 +02:00
|
|
|
)
|
2023-07-30 13:55:57 +02:00
|
|
|
|
|
|
|
if(BUILD_TESTING)
|
2024-01-08 17:17:59 +01:00
|
|
|
# ... CMake code to create tests ...
|
|
|
|
add_test(NAME tgc-sim-interp
|
|
|
|
COMMAND tgc-sim -f ${CMAKE_BINARY_DIR}/../../Firmwares/hello-world/hello --backend interp)
|
|
|
|
|
|
|
|
if(WITH_TCC)
|
|
|
|
add_test(NAME tgc-sim-tcc
|
|
|
|
COMMAND tgc-sim -f ${CMAKE_BINARY_DIR}/../../Firmwares/hello-world/hello --backend tcc)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_LLVM)
|
|
|
|
add_test(NAME tgc-sim-llvm
|
|
|
|
COMMAND tgc-sim -f ${CMAKE_BINARY_DIR}/../../Firmwares/hello-world/hello --backend llvm)
|
|
|
|
endif()
|
|
|
|
|
2023-10-22 15:10:55 +02:00
|
|
|
if(WITH_ASMJIT)
|
2024-01-08 17:17:59 +01:00
|
|
|
add_test(NAME tgc-sim-asmjit
|
|
|
|
COMMAND tgc-sim -f ${CMAKE_BINARY_DIR}/../../Firmwares/hello-world/hello --backend asmjit)
|
|
|
|
endif()
|
2023-07-30 13:55:57 +02:00
|
|
|
endif()
|
2024-01-08 17:17:59 +01:00
|
|
|
|
|
|
|
# ##############################################################################
|
2021-08-16 16:59:23 +02:00
|
|
|
#
|
2024-01-08 17:17:59 +01:00
|
|
|
# ##############################################################################
|
2023-05-11 23:43:12 +02:00
|
|
|
if(TARGET scc-sysc)
|
2024-01-08 17:17:59 +01:00
|
|
|
project(dbt-rise-tgc_sc VERSION 1.0.0)
|
|
|
|
set(LIB_SOURCES
|
|
|
|
src/sysc/core_complex.cpp
|
|
|
|
src/sysc/register_tgc_c.cpp
|
|
|
|
)
|
|
|
|
FILE(GLOB GEN_SC_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/sysc/register_*.cpp)
|
|
|
|
list(APPEND LIB_SOURCES ${GEN_SC_SOURCES})
|
2023-07-14 12:51:51 +02:00
|
|
|
add_library(${PROJECT_NAME} ${LIB_SOURCES})
|
2023-07-14 11:11:03 +02:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC WITH_SYSTEMC)
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME})
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2021-11-26 17:56:40 +01:00
|
|
|
foreach(F IN LISTS TGC_SOURCES)
|
2024-01-08 17:17:59 +01:00
|
|
|
if(${F} MATCHES ".*/arch/([^/]*)\.cpp")
|
|
|
|
string(REGEX REPLACE ".*/([^/]*)\.cpp" "\\1" CORE_NAME_LC ${F})
|
2023-05-16 08:54:08 +02:00
|
|
|
string(TOUPPER ${CORE_NAME_LC} CORE_NAME)
|
2023-07-14 11:11:03 +02:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME})
|
2023-05-16 08:54:08 +02:00
|
|
|
endif()
|
2021-11-26 17:56:40 +01:00
|
|
|
endforeach()
|
2024-01-08 17:17:59 +01:00
|
|
|
|
2023-07-14 11:11:03 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC dbt-rise-tgc scc-sysc)
|
2024-01-08 17:17:59 +01:00
|
|
|
|
|
|
|
# if(WITH_LLVM)
|
|
|
|
# target_link_libraries(${PROJECT_NAME} PUBLIC ${llvm_libs})
|
|
|
|
# endif()
|
|
|
|
set(LIB_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/sysc/core_complex.h)
|
2023-07-14 11:11:03 +02:00
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
2024-01-08 17:17:59 +01:00
|
|
|
VERSION ${PROJECT_VERSION}
|
|
|
|
FRAMEWORK FALSE
|
|
|
|
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
|
2021-07-27 15:55:08 +02:00
|
|
|
)
|
2023-07-14 11:11:03 +02:00
|
|
|
install(TARGETS ${PROJECT_NAME} COMPONENT ${PROJECT_NAME}
|
2024-01-08 17:17:59 +01:00
|
|
|
EXPORT ${PROJECT_NAME}Targets # for downstream dependencies
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # static lib
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # binaries
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # shared lib
|
|
|
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} # for mac
|
|
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sysc # headers for mac (note the different component -> different package)
|
|
|
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers
|
|
|
|
)
|
2021-07-27 15:55:08 +02:00
|
|
|
endif()
|