From 77b063e50c58a76f6496714dfb62318fcb308821 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Thu, 13 May 2021 15:55:25 +0200 Subject: [PATCH] fix CoreDSL based code generation --- cmake/CodeGen.cmake | 35 +++++++++++++++++++---------------- coredsl | 2 +- tgfs | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/cmake/CodeGen.cmake b/cmake/CodeGen.cmake index c381b62..b2cc4e1 100644 --- a/cmake/CodeGen.cmake +++ b/cmake/CodeGen.cmake @@ -1,13 +1,16 @@ cmake_minimum_required(VERSION 3.11) option(ENABLE_CODEGEN "Enable code generation for supported cores" ON) -#helper to setup code generation and generate outputs -set(GENERATOR_JAR ${dbt-core-tgc_SOURCE_DIR}/../coredsl/com.minres.coredsl.generator.repository/target/com.minres.coredsl.generator-2.0.0-SNAPSHOT.jar) +set(ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/..) +set(DBT_CORE_TGC_DIR ${ROOT_DIR}/tgfs) -if(EXISTS ${dbt-core-tgc_SOURCE_DIR}/../coredsl/pom.xml AND NOT EXISTS ${GENERATOR_JAR}) +#helper to setup code generation and generate outputs +set(GENERATOR_JAR ${ROOT_DIR}/coredsl/com.minres.coredsl.generator.repository/target/com.minres.coredsl.generator-2.0.0-SNAPSHOT.jar) + +if(EXISTS ${ROOT_DIR}/coredsl/pom.xml AND NOT EXISTS ${GENERATOR_JAR}) execute_process( COMMAND mvn package - WORKING_DIRECTORY ${dbt-core-tgc_SOURCE_DIR}/../coredsl + WORKING_DIRECTORY ${ROOT_DIR}/coredsl RESULT_VARIABLE return_code) endif() @@ -47,29 +50,29 @@ set(JAVA_OPTS --add-modules ALL-SYSTEM --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/java.rmi.server=ALL-UNNAMED --add-opens=java.sql/java.sql=ALL-UNNAMED) set(GENERATOR java ${JAVA_OPTS} -jar ${GENERATOR_JAR}) -set(INPUT_DIR ${dbt-core-tgc_SOURCE_DIR}/gen_input) -set(REPO_DIR ${dbt-core-tgc_SOURCE_DIR}/gen_input/CoreDSL-Instruction-Set-Description) -set(TMPL_DIR ${dbt-core-tgc_SOURCE_DIR}/gen_input/templates/) +set(INPUT_DIR ${DBT_CORE_TGC_DIR}/gen_input) +set(REPO_DIR ${DBT_CORE_TGC_DIR}/gen_input/CoreDSL-Instruction-Set-Description) +set(TMPL_DIR ${DBT_CORE_TGC_DIR}/gen_input/templates/) if(ENABLE_CODEGEN AND EXISTS ${GENERATOR_JAR}) macro(gen_coredsl CORE_NAME INPUT_FILE BACKEND) - message(STATUS "Adding generation steps for ${CORE_NAME} in ${dbt-core-tgc_SOURCE_DIR} for ${BACKEND}") + message(STATUS "Adding generation steps for ${CORE_NAME} in ${DBT_CORE_TGC_DIR} for ${BACKEND}") string(TOUPPER ${BACKEND} BE_UPPER) string(TOLOWER ${CORE_NAME} CORE_NAMEL) - if(EXISTS ${dbt-core-tgc_SOURCE_DIR}/generate.sh AND NOT EXISTS ${dbt-core-tgc_SOURCE_DIR}/incl/iss/arch/${CORE_NAMEL}.h) + if(EXISTS ${DBT_CORE_TGC_DIR}/generate.sh AND NOT EXISTS ${DBT_CORE_TGC_DIR}/incl/iss/arch/${CORE_NAMEL}.h) # make sure source file exist initially execute_process( - COMMAND /bin/bash ${dbt-core-tgc_SOURCE_DIR}/../generate.sh $CORE_NAME $BACKEND - WORKING_DIRECTORY ${dbt-core-tgc_SOURCE_DIR}/.. + COMMAND /bin/bash ${DBT_CORE_TGC_DIR}/../generate.sh $CORE_NAME $BACKEND + WORKING_DIRECTORY ${DBT_CORE_TGC_DIR}/.. RESULT_VARIABLE return_code) endif() - list(APPEND ${CORE_NAME}_MAPPING -m "${TMPL_DIR}/CORENAME.h.gtl:${dbt-core-tgc_SOURCE_DIR}/incl/iss/arch/${CORE_NAMEL}.h") - list(APPEND ${CORE_NAME}_MAPPING -m "${TMPL_DIR}/CORENAME.cpp.gtl:${dbt-core-tgc_SOURCE_DIR}/src/iss/${CORE_NAMEL}.cpp") - list(APPEND ${CORE_NAME}_MAPPING -m "${TMPL_DIR}/${BACKEND}/CORENAME.cpp.gtl:${dbt-core-tgc_SOURCE_DIR}/src/vm/interp/vm_${CORE_NAMEL}.cpp") - set(${CORE_NAME}_OUTPUT_FILES ${dbt-core-tgc_SOURCE_DIR}/incl/iss/arch/${CORE_NAMEL}.h ${dbt-core-tgc_SOURCE_DIR}/src/iss/${CORE_NAMEL}.cpp ${dbt-core-tgc_SOURCE_DIR}/src/vm/interp/vm_${CORE_NAMEL}.cpp) + list(APPEND ${CORE_NAME}_MAPPING -m "${TMPL_DIR}/CORENAME.h.gtl:${DBT_CORE_TGC_DIR}/incl/iss/arch/${CORE_NAMEL}.h") + list(APPEND ${CORE_NAME}_MAPPING -m "${TMPL_DIR}/CORENAME.cpp.gtl:${DBT_CORE_TGC_DIR}/src/iss/${CORE_NAMEL}.cpp") + list(APPEND ${CORE_NAME}_MAPPING -m "${TMPL_DIR}/${BACKEND}/CORENAME.cpp.gtl:${DBT_CORE_TGC_DIR}/src/vm/interp/vm_${CORE_NAMEL}.cpp") + set(${CORE_NAME}_OUTPUT_FILES ${DBT_CORE_TGC_DIR}/incl/iss/arch/${CORE_NAMEL}.h ${DBT_CORE_TGC_DIR}/src/iss/${CORE_NAMEL}.cpp ${DBT_CORE_TGC_DIR}/src/vm/interp/vm_${CORE_NAMEL}.cpp) add_custom_command( COMMAND ${GENERATOR} -b ${BE_UPPER} -c ${CORE_NAME} -r ${REPO_DIR} ${${CORE_NAME}_MAPPING} ${INPUT_FILE} DEPENDS ${GENERATOR_JAR} ${INPUT_FILE} ${TMPL_DIR}/CORENAME.h.gtl ${TMPL_DIR}/CORENAME.cpp.gtl ${TMPL_DIR}/${BACKEND}/CORENAME.cpp.gtl @@ -82,6 +85,6 @@ if(ENABLE_CODEGEN AND EXISTS ${GENERATOR_JAR}) else() macro(gen_coredsl CORE_NAME INPUT_FILE BACKEND) add_custom_target(${CORE_NAME}_src) - message(STATUS "Not adding generation steps for ${CORE_NAME}") + message(STATUS "Not adding generation steps for ${CORE_NAME}(${ENABLE_CODEGEN}, ${GENERATOR_JAR})") endmacro() endif() diff --git a/coredsl b/coredsl index 4343194..012eb1b 160000 --- a/coredsl +++ b/coredsl @@ -1 +1 @@ -Subproject commit 43431946e3b5d168901feaead9a026091e69662b +Subproject commit 012eb1b929dabbb5cf08b9fd2993d78f08fe685e diff --git a/tgfs b/tgfs index f2bf6d6..c57884c 160000 --- a/tgfs +++ b/tgfs @@ -1 +1 @@ -Subproject commit f2bf6d682a1b3eeabe416339b77275ed5c9e8e53 +Subproject commit c57884caeea1e3e37ec4addebb96ed19ed817852