From 88b38f531adb90af752eb5af0f90eab0ee4343ae Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Wed, 23 Mar 2022 10:53:58 +0000 Subject: ADSP: Support both VDSP++ and CCES for ADSP compilers --- Help/release/dev/adsp-platform-and-compilers.rst | 5 +++++ Modules/Compiler/ADSP-DetermineCompiler.cmake | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 Help/release/dev/adsp-platform-and-compilers.rst diff --git a/Help/release/dev/adsp-platform-and-compilers.rst b/Help/release/dev/adsp-platform-and-compilers.rst new file mode 100644 index 0000000..0eeda43 --- /dev/null +++ b/Help/release/dev/adsp-platform-and-compilers.rst @@ -0,0 +1,5 @@ +adsp-platform-and-compilers +--------------------------- + +* The ADSP compiler (SHARC and Blackfin) now supports + both CCES and VDSP++ installations. diff --git a/Modules/Compiler/ADSP-DetermineCompiler.cmake b/Modules/Compiler/ADSP-DetermineCompiler.cmake index 0340f69..96c88f9 100644 --- a/Modules/Compiler/ADSP-DetermineCompiler.cmake +++ b/Modules/Compiler/ADSP-DetermineCompiler.cmake @@ -1,10 +1,11 @@ -set(_compiler_id_pp_test "defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)") +set(_compiler_id_pp_test "defined(_ADI_COMPILER)") set(_compiler_id_version_compute " -#if defined(__VISUALDSPVERSION__) - /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ -# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__VISUALDSPVERSION__>>24) -# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__VISUALDSPVERSION__>>16 & 0xFF) -# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_HEX@(__VISUALDSPVERSION__>>8 & 0xFF) +#if defined(__VERSIONNUM__) + /* __VERSIONNUM__ = 0xVVRRPPTT */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__VERSIONNUM__ >> 24 & 0xFF) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__VERSIONNUM__ >> 16 & 0xFF) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__VERSIONNUM__ >> 8 & 0xFF) +# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__VERSIONNUM__ & 0xFF) #endif") -- cgit v0.12 From e9eabb0dcdb2fd8084135e02a1ad63047f8ae772 Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Thu, 24 Mar 2022 09:52:39 +0000 Subject: ADSP: Configure compiler in compiler module --- Help/release/dev/adsp-platform-and-compilers.rst | 4 +++- Modules/CMakeDetermineCompilerId.cmake | 11 +++++++++- Modules/CMakePlatformId.h.in | 9 ++++++++ Modules/Compiler/ADSP-C.cmake | 11 ++++++++++ Modules/Compiler/ADSP-CXX.cmake | 16 +++++++++++++++ Modules/Compiler/ADSP.cmake | 26 ++++++++++++++++++++++++ 6 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 Modules/Compiler/ADSP-C.cmake create mode 100644 Modules/Compiler/ADSP-CXX.cmake create mode 100644 Modules/Compiler/ADSP.cmake diff --git a/Help/release/dev/adsp-platform-and-compilers.rst b/Help/release/dev/adsp-platform-and-compilers.rst index 0eeda43..3b8ac5a 100644 --- a/Help/release/dev/adsp-platform-and-compilers.rst +++ b/Help/release/dev/adsp-platform-and-compilers.rst @@ -2,4 +2,6 @@ adsp-platform-and-compilers --------------------------- * The ADSP compiler (SHARC and Blackfin) now supports - both CCES and VDSP++ installations. + both CCES and VDSP++ installations, + with required configuration now done in the compiler module itself + rather than the Generic-ADSP platform module. diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 0317f34..a90fa5d 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -841,15 +841,24 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) set(ARCHITECTURE_ID) set(SIMULATE_ID) set(SIMULATE_VERSION) + set(CMAKE_${lang}_COMPILER_ID_STRING_REGEX ".?I.?N.?F.?O.?:.?[A-Za-z0-9_]+\\[[^]]*\\]") foreach(encoding "" "ENCODING;UTF-16LE" "ENCODING;UTF-16BE") file(STRINGS "${file}" CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 38 ${encoding} - REGEX ".?I.?N.?F.?O.?:.?[A-Za-z0-9_]+\\[[^]]*\\]") + REGEX "${CMAKE_${lang}_COMPILER_ID_STRING_REGEX}") if(NOT CMAKE_${lang}_COMPILER_ID_STRINGS STREQUAL "") break() endif() endforeach() + # Some ADSP processors result in characters being detected as separate strings + if(CMAKE_${lang}_COMPILER_ID_STRINGS STREQUAL "") + file(STRINGS "${file}" CMAKE_${lang}_COMPILER_ID_STRINGS LENGTH_MAXIMUM 1) + string(REGEX REPLACE ";" "" CMAKE_${lang}_COMPILER_ID_STRING "${CMAKE_${lang}_COMPILER_ID_STRINGS}") + string(REGEX MATCHALL "${CMAKE_${lang}_COMPILER_ID_STRING_REGEX}" + CMAKE_${lang}_COMPILER_ID_STRINGS "${CMAKE_${lang}_COMPILER_ID_STRING}") + endif() + # With the IAR Compiler, some strings are found twice, first time as incomplete # list like "?". Remove the incomplete copies. list(FILTER CMAKE_${lang}_COMPILER_ID_STRINGS EXCLUDE REGEX "\\? ${_CMAKE_${lang}_ADSP_FLAGS} -o -c ") + + set(CMAKE_${lang}_CREATE_STATIC_LIBRARY + " ${_CMAKE_${lang}_ADSP_FLAGS} -build-lib -o ") + + set(CMAKE_${lang}_LINK_EXECUTABLE + " ${_CMAKE_${lang}_ADSP_FLAGS} -o ") + + unset(_CMAKE_${lang}_ADSP_FLAGS) + + set(CMAKE_${lang}_CREATE_SHARED_LIBRARY) + set(CMAKE_${lang}_CREATE_MODULE_LIBRARY) +endmacro() -- cgit v0.12 From 87142bbd5f94de9591b0a5531e427a5f491f56fd Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Thu, 24 Mar 2022 11:35:40 +0000 Subject: ADSP: Add dedicated platform module --- Help/envvar/ADSP_ROOT.rst | 8 ++++++ Help/manual/cmake-env-variables.7.rst | 1 + Help/manual/cmake-toolchains.7.rst | 22 +++++++++++++++ Help/manual/cmake-variables.7.rst | 1 + Help/release/dev/adsp-platform-and-compilers.rst | 6 ++++ Help/variable/CMAKE_ADSP_ROOT.rst | 9 ++++++ Modules/Compiler/ADSP.cmake | 2 +- Modules/Platform/ADSP-C.cmake | 2 ++ Modules/Platform/ADSP-CXX.cmake | 2 ++ Modules/Platform/ADSP-Common.cmake | 36 ++++++++++++++++++++++++ Modules/Platform/ADSP-Determine.cmake | 26 +++++++++++++++++ Modules/Platform/ADSP.cmake | 4 +++ 12 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 Help/envvar/ADSP_ROOT.rst create mode 100644 Help/variable/CMAKE_ADSP_ROOT.rst create mode 100644 Modules/Platform/ADSP-C.cmake create mode 100644 Modules/Platform/ADSP-CXX.cmake create mode 100644 Modules/Platform/ADSP-Common.cmake create mode 100644 Modules/Platform/ADSP-Determine.cmake create mode 100644 Modules/Platform/ADSP.cmake diff --git a/Help/envvar/ADSP_ROOT.rst b/Help/envvar/ADSP_ROOT.rst new file mode 100644 index 0000000..fabf1bb --- /dev/null +++ b/Help/envvar/ADSP_ROOT.rst @@ -0,0 +1,8 @@ +ADSP_ROOT +--------- + +.. include:: ENV_VAR.txt + +The ``ADSP_ROOT`` environment variable specifies a default value +for the :variable:`CMAKE_ADSP_ROOT` variable when there is no explicit +configuration given on the first run while creating a new build tree. diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst index fc14262..737b22c 100644 --- a/Help/manual/cmake-env-variables.7.rst +++ b/Help/manual/cmake-env-variables.7.rst @@ -28,6 +28,7 @@ Environment Variables that Control the Build .. toctree:: :maxdepth: 1 + /envvar/ADSP_ROOT /envvar/CMAKE_APPLE_SILICON_PROCESSOR /envvar/CMAKE_BUILD_PARALLEL_LEVEL /envvar/CMAKE_BUILD_TYPE diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst index a941310..e194df0 100644 --- a/Help/manual/cmake-toolchains.7.rst +++ b/Help/manual/cmake-toolchains.7.rst @@ -301,6 +301,28 @@ Windows Store may look like this: set(CMAKE_SYSTEM_NAME WindowsStore) set(CMAKE_SYSTEM_VERSION 8.1) +.. _`Cross Compiling for ADSP SHARC/Blackfin`: + +Cross Compiling for ADSP SHARC/Blackfin +--------------------------------------- + +Cross-compiling for ADSP SHARC or Blackfin can be configured +by setting the :variable:`CMAKE_SYSTEM_NAME` variable to ``ADSP`` +and the :variable:`CMAKE_SYSTEM_PROCESSOR` variable +to the "part number", excluding the ``ADSP-`` prefix, +for example, ``21594``, ``SC589``, etc. +This value is case insensitive. + +CMake will automatically search for CCES or VDSP++ installs +in their default install locations +and select the most recent version found. +CCES will be selected over VDSP++ if both are installed. +Custom install paths can be set via the :variable:`CMAKE_ADSP_ROOT` variable +or the :envvar:`ADSP_ROOT` environment variable. + +The compiler (``cc21k`` vs. ``ccblkfn``) is selected automatically +based on the :variable:`CMAKE_SYSTEM_PROCESSOR` value provided. + .. _`Cross Compiling for Android`: Cross Compiling for Android diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 0b81677..f8ae337 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -346,6 +346,7 @@ Variables that Control the Build .. toctree:: :maxdepth: 1 + /variable/CMAKE_ADSP_ROOT /variable/CMAKE_AIX_EXPORT_ALL_SYMBOLS /variable/CMAKE_ANDROID_ANT_ADDITIONAL_OPTIONS /variable/CMAKE_ANDROID_API diff --git a/Help/release/dev/adsp-platform-and-compilers.rst b/Help/release/dev/adsp-platform-and-compilers.rst index 3b8ac5a..396b29d 100644 --- a/Help/release/dev/adsp-platform-and-compilers.rst +++ b/Help/release/dev/adsp-platform-and-compilers.rst @@ -5,3 +5,9 @@ adsp-platform-and-compilers both CCES and VDSP++ installations, with required configuration now done in the compiler module itself rather than the Generic-ADSP platform module. + +* A dedicated ``ADSP`` platform has been added + to replace the existing ``Generic-ADSP`` implementation. + This features automatic detection of the latest CCES/VDSP++ install + and compiler selection (``cc21k`` vs. ``ccblkfn``) + based off of the :variable:`CMAKE_SYSTEM_PROCESSOR` variable. diff --git a/Help/variable/CMAKE_ADSP_ROOT.rst b/Help/variable/CMAKE_ADSP_ROOT.rst new file mode 100644 index 0000000..e6d903d --- /dev/null +++ b/Help/variable/CMAKE_ADSP_ROOT.rst @@ -0,0 +1,9 @@ +CMAKE_ADSP_ROOT +--------------- + +When :ref:`Cross Compiling for ADSP SHARC/Blackfin`, +this variable holds the absolute path to the latest CCES or VDSP++ install. +The directory is expected to contain the ``cc21k.exe`` and ``ccblkfn.exe`` compilers. +This will be set automatically if a default install of CCES or VDSP++ can be found. + +See also the :envvar:`ADSP_ROOT` environment variable. diff --git a/Modules/Compiler/ADSP.cmake b/Modules/Compiler/ADSP.cmake index 2633997..62566a0 100644 --- a/Modules/Compiler/ADSP.cmake +++ b/Modules/Compiler/ADSP.cmake @@ -8,7 +8,7 @@ macro(__compiler_adsp lang) set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-flags-link" " ") set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",") - set(_CMAKE_${lang}_ADSP_FLAGS "-proc=${CMAKE_SYSTEM_PROCESSOR}") + set(_CMAKE_${lang}_ADSP_FLAGS "-proc=${CMAKE_ADSP_PROCESSOR}") set(CMAKE_${lang}_COMPILE_OBJECT " ${_CMAKE_${lang}_ADSP_FLAGS} -o -c ") diff --git a/Modules/Platform/ADSP-C.cmake b/Modules/Platform/ADSP-C.cmake new file mode 100644 index 0000000..c85e746 --- /dev/null +++ b/Modules/Platform/ADSP-C.cmake @@ -0,0 +1,2 @@ +include(Platform/ADSP-Common) +__platform_adsp(C) diff --git a/Modules/Platform/ADSP-CXX.cmake b/Modules/Platform/ADSP-CXX.cmake new file mode 100644 index 0000000..d827c80 --- /dev/null +++ b/Modules/Platform/ADSP-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/ADSP-Common) +__platform_adsp(CXX) diff --git a/Modules/Platform/ADSP-Common.cmake b/Modules/Platform/ADSP-Common.cmake new file mode 100644 index 0000000..2ba90b2 --- /dev/null +++ b/Modules/Platform/ADSP-Common.cmake @@ -0,0 +1,36 @@ +include_guard() + +macro(__platform_adsp_init) + if(NOT CMAKE_ADSP_PLATFORM_INITIALIZED) + if(NOT CMAKE_SYSTEM_PROCESSOR) + message(FATAL_ERROR "ADSP: CMAKE_SYSTEM_PROCESSOR is required but not set") + endif() + + set(CMAKE_ADSP_PROCESSOR "ADSP-${CMAKE_SYSTEM_PROCESSOR}") + string(TOUPPER "${CMAKE_ADSP_PROCESSOR}" CMAKE_ADSP_PROCESSOR) + + set(CMAKE_ADSP_COMPILER_NAME cc21k.exe) + if(CMAKE_ADSP_PROCESSOR MATCHES "^ADSP-BF") + set(CMAKE_ADSP_COMPILER_NAME ccblkfn.exe) + endif() + + set(CMAKE_ADSP_PLATFORM_INITIALIZED TRUE) + endif() +endmacro() + +macro(__platform_adsp lang) + __platform_adsp_init() + set(CMAKE_${lang}_COMPILER "${CMAKE_ADSP_ROOT}/${CMAKE_ADSP_COMPILER_NAME}") + + execute_process( + COMMAND "${CMAKE_${lang}_COMPILER}" "-proc=${CMAKE_ADSP_PROCESSOR}" "-version" + OUTPUT_QUIET ERROR_QUIET + RESULT_VARIABLE _adsp_is_valid_proc + ) + if(NOT _adsp_is_valid_proc EQUAL 0) + message(FATAL_ERROR + "ADSP: unsupported processor '${CMAKE_ADSP_PROCESSOR}' for CMAKE_${lang}_COMPILER:\n" + " ${CMAKE_${lang}_COMPILER}" + ) + endif() +endmacro() diff --git a/Modules/Platform/ADSP-Determine.cmake b/Modules/Platform/ADSP-Determine.cmake new file mode 100644 index 0000000..6ccf1ea --- /dev/null +++ b/Modules/Platform/ADSP-Determine.cmake @@ -0,0 +1,26 @@ +if(IS_DIRECTORY "$ENV{ADSP_ROOT}") + file(TO_CMAKE_PATH "$ENV{ADSP_ROOT}" CMAKE_ADSP_ROOT) +endif() + +macro(_find_adsp_root path_pattern) + set(CMAKE_ADSP_ROOT "") + set(_adsp_root_version "0") + file(GLOB _adsp_root_paths "${path_pattern}") + foreach(_current_adsp_root_path IN LISTS _adsp_root_paths) + string(REGEX MATCH "([0-9\\.]+)/?$" _current_adsp_root_version "${_current_adsp_root_path}") + if(_current_adsp_root_version VERSION_GREATER _adsp_root_version) + set(CMAKE_ADSP_ROOT "${_current_adsp_root_path}") + set(_adsp_root_version "${_current_adsp_root_version}") + endif() + endforeach() +endmacro() + +if(NOT CMAKE_ADSP_ROOT) + _find_adsp_root("C:/Analog Devices/CrossCore Embedded Studio *") +endif() +if(NOT CMAKE_ADSP_ROOT) + _find_adsp_root("C:/Program Files (x86)/Analog Devices/VisualDSP *") +endif() +if(NOT IS_DIRECTORY "${CMAKE_ADSP_ROOT}") + message(FATAL_ERROR "ADSP: could not find CCES/VDSP++ install directory ${CMAKE_ADSP_ROOT}") +endif() diff --git a/Modules/Platform/ADSP.cmake b/Modules/Platform/ADSP.cmake new file mode 100644 index 0000000..15e9dd2 --- /dev/null +++ b/Modules/Platform/ADSP.cmake @@ -0,0 +1,4 @@ +include(Platform/ADSP-Common) +__platform_adsp_init() + +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) -- cgit v0.12