|
@@ -4,10 +4,18 @@ set(CMAKE_BUILD_TYPE Debug)
|
|
|
set(CMAKE_VERBOSE_MAKEFILE 0)
|
|
set(CMAKE_VERBOSE_MAKEFILE 0)
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
|
|
|
|
|
|
|
-set(CMAKE_C_COMPILER arm-none-eabi-gcc) #tested with: clang, arm-none-eabi-gcc
|
|
|
|
|
|
|
+# user configurations: use -D option to change these on command line
|
|
|
|
|
+set(IMC_INSERT_COMPILER_CHECKPOINTS 1 CACHE BOOL "" FORCE)
|
|
|
|
|
+set(IMC_ENABLE_EXTENSION 1 CACHE BOOL "" FORCE)
|
|
|
|
|
+
|
|
|
|
|
+# set(CMAKE_C_COMPILER arm-none-eabi-gcc) #tested with: clang, arm-none-eabi-gcc
|
|
|
|
|
+set(CMAKE_C_COMPILER /home/ybkim/workspace/imc/llvm/llvm-17/build/bin/clang)
|
|
|
set(CMAKE_SYSROOT "/opt/gcc-arm-none-eabi/arm-none-eabi")
|
|
set(CMAKE_SYSROOT "/opt/gcc-arm-none-eabi/arm-none-eabi")
|
|
|
-set(ARM_CORTEXM_MULTI_DIR "/opt/gcc-arm-none-eabi/arm-none-eabi/lib/thumb/v7e-m+fp/hard")
|
|
|
|
|
-set(ARM_CORTEXM_BUILTINS_DIR "/opt/gcc-arm-none-eabi/lib/gcc/arm-none-eabi/11.2.1/thumb/v7e-m+fp/hard")
|
|
|
|
|
|
|
+set(ARM_CORTEXM_MULTI_DIR "/opt/gcc-arm-none-eabi/arm-none-eabi/lib/thumb/v8-m.main+fp/hard")
|
|
|
|
|
+set(ARM_CORTEXM_BUILTINS_DIR "/opt/gcc-arm-none-eabi/lib/gcc/arm-none-eabi/11.2.1/thumb/v8-m.main+fp/hard")
|
|
|
|
|
+set(OPT_BIN /home/ybkim/workspace/imc/llvm/llvm-17/build/bin/opt)
|
|
|
|
|
+set(LLC_BIN /home/ybkim/workspace/imc/llvm/llvm-17/build/bin/llc)
|
|
|
|
|
+set(LLVM_OPT_PLUGIN /home/ybkim/workspace/imc/loop_duplication/build/lib/libImcInsertCheckpoints.so)
|
|
|
|
|
|
|
|
set(SRC_FILES
|
|
set(SRC_FILES
|
|
|
USB_Device/Target/usbd_conf.c
|
|
USB_Device/Target/usbd_conf.c
|
|
@@ -65,7 +73,6 @@ set(SRC_FILES
|
|
|
Core/Src/ImC/decoder.c
|
|
Core/Src/ImC/decoder.c
|
|
|
Core/Src/ImC/imc_api.c
|
|
Core/Src/ImC/imc_api.c
|
|
|
Core/Src/ImC/imc_kernel.c
|
|
Core/Src/ImC/imc_kernel.c
|
|
|
- # Core/Src/ImC/uartBufferIT.c
|
|
|
|
|
Core/Src/app_freertos.c
|
|
Core/Src/app_freertos.c
|
|
|
Core/Src/main.c
|
|
Core/Src/main.c
|
|
|
Core/Src/stm32l5xx_hal_msp.c
|
|
Core/Src/stm32l5xx_hal_msp.c
|
|
@@ -74,6 +81,7 @@ set(SRC_FILES
|
|
|
Core/Src/syscalls.c
|
|
Core/Src/syscalls.c
|
|
|
Core/Src/sysmem.c
|
|
Core/Src/sysmem.c
|
|
|
Core/Src/system_stm32l5xx.c
|
|
Core/Src/system_stm32l5xx.c
|
|
|
|
|
+ Core/Src/benchmarks/benchmark_driver.c
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
include_directories(
|
|
include_directories(
|
|
@@ -91,6 +99,21 @@ include_directories(
|
|
|
Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure
|
|
Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+link_directories(
|
|
|
|
|
+ ${ARM_CORTEXM_BUILTINS_DIR}
|
|
|
|
|
+ ${ARM_CORTEXM_MULTI_DIR}
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+if(IMC_ENABLE_EXTENSION)
|
|
|
|
|
+ include(imc_extension.cmake)
|
|
|
|
|
+ add_compile_definitions(imcUSE_IMC_EXTENSION=1)
|
|
|
|
|
+else()
|
|
|
|
|
+ add_compile_definitions(imcUSE_IMC_EXTENSION=0)
|
|
|
|
|
+ set(IMC_APP_FILES
|
|
|
|
|
+ Core/Src/benchmarks/conv2d/conv2d.c
|
|
|
|
|
+ )
|
|
|
|
|
+endif()
|
|
|
|
|
+
|
|
|
# compile flags
|
|
# compile flags
|
|
|
|
|
|
|
|
add_compile_definitions(USE_HAL_DRIVER STM32L552xx)
|
|
add_compile_definitions(USE_HAL_DRIVER STM32L552xx)
|
|
@@ -101,13 +124,12 @@ set(FPU "-mfpu=fpv5-sp-d16")
|
|
|
set(FLOAT-ABI "-mfloat-abi=hard")
|
|
set(FLOAT-ABI "-mfloat-abi=hard")
|
|
|
set(MCU "${CPU} -mthumb ${FPU} ${FLOAT-ABI}")
|
|
set(MCU "${CPU} -mthumb ${FPU} ${FLOAT-ABI}")
|
|
|
set(OPT "-O1")
|
|
set(OPT "-O1")
|
|
|
-#set(C_FLAGS_NO_ASM "-g -gdwarf-2")
|
|
|
|
|
set(C_FLAGS_NO_ASM )
|
|
set(C_FLAGS_NO_ASM )
|
|
|
-set(C_FLAGS_EXTRA "-Wall -Wno-char-subscripts -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -nostdlib -fdata-sections -ffunction-sections")
|
|
|
|
|
|
|
+set(C_FLAGS_EXTRA "-Wall -Wno-char-subscripts -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-format -nostdlib -fdata-sections -ffunction-sections")
|
|
|
|
|
|
|
|
set(COMPILER_SPECIFIC_CFLAGS )
|
|
set(COMPILER_SPECIFIC_CFLAGS )
|
|
|
if (CMAKE_C_COMPILER MATCHES "clang")
|
|
if (CMAKE_C_COMPILER MATCHES "clang")
|
|
|
- set(TARGET-TRIPPLE "--target=arm-none-eabi --sysroot=${CMAKE_SYSROOT}")
|
|
|
|
|
|
|
+ set(TARGET-TRIPPLE "--target=armv8m-none-eabi --sysroot=${CMAKE_SYSROOT}")
|
|
|
set(COMPILER_SPECIFIC_CFLAGS "${TARGET-TRIPPLE}")
|
|
set(COMPILER_SPECIFIC_CFLAGS "${TARGET-TRIPPLE}")
|
|
|
endif()
|
|
endif()
|
|
|
|
|
|
|
@@ -124,18 +146,45 @@ set(ARM_CORTEXM_BUILTINS "-L${ARM_CORTEXM_BUILTINS_DIR}")
|
|
|
set(LD_ADDITIONAL_FILES "${ARM_CORTEXM_BUILTINS_DIR}/crti.o ${ARM_CORTEXM_BUILTINS_DIR}/crtn.o")
|
|
set(LD_ADDITIONAL_FILES "${ARM_CORTEXM_BUILTINS_DIR}/crti.o ${ARM_CORTEXM_BUILTINS_DIR}/crtn.o")
|
|
|
|
|
|
|
|
set(LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/STM32L552ZETX_FLASH.ld")
|
|
set(LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/STM32L552ZETX_FLASH.ld")
|
|
|
|
|
+set(CMAKE_EXE_LINKER_FLAGS "${LD_ADDITIONAL_FILES} -T ${LINKER_SCRIPT}")
|
|
|
|
|
|
|
|
-set(LIBDIR "-L${ARM_CORTEXM_MULTI_DIR} ${ARM_CORTEXM_BUILTINS}")
|
|
|
|
|
-set(VERBOSE_LINKER_OUTPUT "") #-v for verbose output
|
|
|
|
|
-#set(LDFLAGS "${VERBOSE_LINKER_OUTPUT} -lc -lm -lnosys -lgcc -u _printf_float")
|
|
|
|
|
-set(LDFLAGS "${VERBOSE_LINKER_OUTPUT} -lc -lm -lnosys -lgcc")
|
|
|
|
|
-
|
|
|
|
|
-set(COMPILER_SPECIFIC_LDFLAGS )
|
|
|
|
|
|
|
+project(imc_freeRTOS C ASM)
|
|
|
|
|
+add_executable(imc_freeRTOS ${SRC_FILES})
|
|
|
|
|
|
|
|
-set(CMAKE_EXE_LINKER_FLAGS "${LD_ADDITIONAL_FILES} ${LIBDIR} ${LDFLAGS} ${COMPILER_SPECIFIC_LDFLAGS} -T ${LINKER_SCRIPT}")
|
|
|
|
|
|
|
+if(IMC_INSERT_COMPILER_CHECKPOINTS)
|
|
|
|
|
+ if(NOT CMAKE_C_COMPILER MATCHES "clang")
|
|
|
|
|
+ message(FATAL_ERROR "compiler must be clang 17 to enable compiler checkpoint insertion")
|
|
|
|
|
+ endif()
|
|
|
|
|
+ add_compile_definitions(imcUSE_IMC_KERNEL=1)
|
|
|
|
|
+ get_target_property(SRC_INCLUDES imc_freeRTOS INCLUDE_DIRECTORIES)
|
|
|
|
|
+ foreach(dir ${SRC_INCLUDES})
|
|
|
|
|
+ list(APPEND INCLUDE_DIRS "-I${dir}")
|
|
|
|
|
+ endforeach()
|
|
|
|
|
+ string(REPLACE " " ";" C_FLAGS ${CMAKE_C_FLAGS})
|
|
|
|
|
+
|
|
|
|
|
+ set(BASIC_OPT_PASSES "loop-simplify,loop-rotate,mem2reg,instcombine,instsimplify,dce,simplifycfg")
|
|
|
|
|
+ set(IMC_OPT_PASSES "imc-insert-checkpoints")
|
|
|
|
|
+ set(IMC_FLAGS ${IMC_BASE})
|
|
|
|
|
+ set(TARGET_TRIPPLE "--target=armv7em-none-eabi --sysroot=${CMAKE_SYSROOT}")
|
|
|
|
|
+
|
|
|
|
|
+ foreach(APP_SRC ${IMC_APP_FILES})
|
|
|
|
|
+ add_custom_command(
|
|
|
|
|
+ OUTPUT ${PROJECT_BINARY_DIR}/${APP_SRC}.s
|
|
|
|
|
+ DEPENDS ${APP_SRC}
|
|
|
|
|
+ # COMMAND ${CLANG_BIN} --target=armv8m-none-eabi --sysroot=${CMAKE_SYSROOT} -g ${C_FLAGS} -O0 -Xclang -disable-O0-optnone ${INCLUDE_DIRS} -D USE_HAL_DRIVER -D STM32L552xx -c -emit-llvm ${PROJECT_SOURCE_DIR}/${APP_SRC} -o ${PROJECT_BINARY_DIR}/${APP_SRC}.bc
|
|
|
|
|
+ COMMAND ${CMAKE_C_COMPILER} -g ${C_FLAGS} -O0 -Xclang -disable-O0-optnone ${INCLUDE_DIRS} -D USE_HAL_DRIVER -D STM32L552xx -c -emit-llvm ${PROJECT_SOURCE_DIR}/${APP_SRC} -o ${PROJECT_BINARY_DIR}/${APP_SRC}.bc
|
|
|
|
|
+ COMMAND ${OPT_BIN} -o ${PROJECT_BINARY_DIR}/${APP_SRC}_imc.bc -load-pass-plugin=${LLVM_OPT_PLUGIN} -passes=${BASIC_OPT_PASSES},${IMC_OPT_PASSES} ${PROJECT_BINARY_DIR}/${APP_SRC}.bc
|
|
|
|
|
+ COMMAND ${OPT_BIN} ${OPT} -o ${PROJECT_BINARY_DIR}/${APP_SRC}.opt.bc ${PROJECT_BINARY_DIR}/${APP_SRC}_imc.bc
|
|
|
|
|
+ COMMAND ${LLC_BIN} ${IMC_FLAGS} ${CPU} ${OPT} -o ${PROJECT_BINARY_DIR}/${APP_SRC}.s ${PROJECT_BINARY_DIR}/${APP_SRC}.opt.bc
|
|
|
|
|
+ )
|
|
|
|
|
+ list(APPEND APP_OPTS ${PROJECT_BINARY_DIR}/${APP_SRC}.s)
|
|
|
|
|
+ endforeach()
|
|
|
|
|
+ add_library(imc_apps "${APP_OPTS}")
|
|
|
|
|
+else()
|
|
|
|
|
+ add_library(imc_apps "${IMC_APP_FILES}")
|
|
|
|
|
+endif()
|
|
|
|
|
|
|
|
-project(imc_freeRTOS C ASM)
|
|
|
|
|
|
|
+target_link_libraries(imc_freeRTOS PRIVATE imc_apps c m nosys gcc)
|
|
|
|
|
|
|
|
-add_executable(imc_freeRTOS ${SRC_FILES})
|
|
|
|
|
target_compile_options(imc_freeRTOS PRIVATE "-g")
|
|
target_compile_options(imc_freeRTOS PRIVATE "-g")
|
|
|
set_target_properties(imc_freeRTOS PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT})
|
|
set_target_properties(imc_freeRTOS PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT})
|