ARCMWDT: Add compiler support for nSIM RMX platform

Add MetaWare compiller support for nSIM RMX platform

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
This commit is contained in:
Nikolay Agishev 2024-06-12 17:18:51 +03:00 committed by Anas Nashif
commit efedf1cff3
6 changed files with 84 additions and 6 deletions

View file

@ -39,7 +39,7 @@ either `DesignWare ARC nSIM`_ or `DesignWare ARC Free nSIM`_ is required.
Building & Running Sample Applications
======================================
Most board targets support building with GNU toolchains, however
Most board targets support building with both GNU and ARC MWDT toolchains, however
there might be exceptions from that, especially for newly added targets. You can check supported
toolchains for the board targets in the corresponding ``.yaml`` file.
@ -54,7 +54,12 @@ The supported toolchains are listed in ``toolchain:`` array in ``.yaml`` file, w
``zephyr`` toolchain support because corresponding target CPU support hasn't been added to Zephyr
SDK yet. You can find more information about its usage here: :ref:`here <other_x_compilers>`.
* **arcmwdt** - implies proprietary ARC MWDT toolchain. You can find more information about its
usage here: :ref:`here <toolchain_designware_arc_mwdt>`. Not yet supported: work in progress.
usage here: :ref:`here <toolchain_designware_arc_mwdt>`.
.. note::
Note that even if both GNU and MWDT toolchain support is declared for the target some tests or
samples can be only built with either GNU or MWDT toolchain due to some features limited to a
particular toolchain.
Use this configuration to run basic Zephyr applications and kernel tests in
nSIM, for example, with the :zephyr:code-sample:`synchronization` sample:
@ -134,7 +139,7 @@ new one it's required to maintain alignment between
* Zephyr OS configuration
* nSIM configuration
* GNU toolchain compiler options
* GNU & MWDT toolchain compiler options
.. note::
The ``.tcf`` configuration files are not supported by Zephyr directly. There are multiple
@ -170,7 +175,7 @@ exceptions:
* The UART model is added
* CLINT model is added
GNU toolchain compiler options
GNU & MWDT toolchain compiler options
=====================================
The hardware-specific compiler options are set in corresponding SoC cmake file. For ``nsim_arc_v`` board

View file

@ -7,6 +7,7 @@ arch: riscv
toolchain:
- zephyr
- cross-compile
- arcmwdt
testing:
ignore_tags:
- net

View file

@ -180,7 +180,11 @@ set_compiler_property(PROPERTY security_fortify_compile_time)
set_compiler_property(PROPERTY security_fortify_run_time)
# Required C++ flags when using mwdt
set_property(TARGET compiler-cpp PROPERTY required "-Hcplus" "-Hoff=Stackcheck_alloca")
set_property(TARGET compiler-cpp PROPERTY required "-Hcplus" )
if(CONFIG_ARC)
set_property(TARGET compiler-cpp PROPERTY required "-Hoff=Stackcheck_alloca")
endif()
# Compiler flag for turning off thread-safe initialization of local statics
set_property(TARGET compiler-cpp PROPERTY no_threadsafe_statics "-fno-threadsafe-statics")

View file

@ -30,7 +30,11 @@ set(NOSTDINC ${TOOLCHAIN_HOME}/arc/inc)
# common compile options, no copyright msg, little-endian, no small data,
# no MWDT stack checking
list(APPEND TOOLCHAIN_C_FLAGS -Hnocopyr -HL -Hnosdata -Hoff=Stackcheck_alloca)
list(APPEND TOOLCHAIN_C_FLAGS -Hnocopyr -HL -Hnosdata)
if(CONFIG_ARC)
list(APPEND TOOLCHAIN_C_FLAGS -Hoff=Stackcheck_alloca)
endif()
# The MWDT compiler can replace some code with call to builtin functions.
# We can't rely on these functions presence if we don't use MWDT libc.
@ -39,3 +43,9 @@ list(APPEND TOOLCHAIN_C_FLAGS -Hnocopyr -HL -Hnosdata -Hoff=Stackcheck_alloca)
if(NOT CONFIG_ARCMWDT_LIBC)
list(APPEND TOOLCHAIN_C_FLAGS -fno-builtin)
endif()
# The MWDT compiler requires different macro definitions for ARC and RISC-V
# architectures. __MW_ASM_RV_MACRO__ allows to select appropriate compilation branch.
if(CONFIG_RISCV)
list(APPEND TOOLCHAIN_C_FLAGS -D__MW_ASM_RV_MACRO__)
endif()

View file

@ -20,6 +20,26 @@
#define FUNC_CODE()
#define FUNC_INSTR(a)
#ifdef __MW_ASM_RV_MACRO__
.macro section_var_mwdt, section, symbol
.section \section().\symbol, "aw"
\symbol :
.endm
.macro section_func_mwdt, section, symbol
.section \section().\symbol, "ax"
FUNC_CODE()
PERFOPT_ALIGN
\symbol :
FUNC_INSTR(symbol)
.endm
.macro section_subsec_func_mwdt, section, subsection, symbol
.section \section().\subsection, "ax"
PERFOPT_ALIGN
\symbol :
.endm
#else
.macro section_var_mwdt, section, symbol
.section .\&section\&.\&symbol, "aw"
symbol :
@ -38,12 +58,34 @@
PERFOPT_ALIGN
symbol :
.endm
#endif /* __MW_ASM_RV_MACRO__ */
#define SECTION_VAR(sect, sym) section_var_mwdt sect, sym
#define SECTION_FUNC(sect, sym) section_func_mwdt sect, sym
#define SECTION_SUBSEC_FUNC(sect, subsec, sym) \
section_subsec_func_mwdt sect, subsec, sym
#ifdef __MW_ASM_RV_MACRO__
.macro glbl_text_mwdt, symbol
.globl \symbol
.type \symbol, @function
.endm
.macro glbl_data_mwdt, symbol
.globl \symbol
.type \symbol, @object
.endm
.macro weak_data_mwdt, symbol
.weak \symbol
.type \symbol, @object
.endm
.macro weak_text_mwdt, symbol
.weak \symbol
.type \symbol, @function
.endm
#else
.macro glbl_text_mwdt, symbol
.globl symbol
.type symbol, @function
@ -59,9 +101,16 @@
.type symbol, @object
.endm
.macro weak_text_mwdt, symbol
.weak symbol
.type symbol, @function
.endm
#endif /* __MW_ASM_RV_MACRO__ */
#define GTEXT(sym) glbl_text_mwdt sym
#define GDATA(sym) glbl_data_mwdt sym
#define WDATA(sym) weak_data_mwdt sym
#define WTEXT(sym) weak_text_mwdt sym
#else /* defined(_ASMLANGUAGE) */

View file

@ -1,3 +1,12 @@
# SPDX-License-Identifier: Apache-2.0
if(COMPILER STREQUAL arcmwdt)
# CCAC:
zephyr_compile_options_ifdef(CONFIG_SOC_SERIES_RMX
-av5rmx -Zicsr -Zifencei -Zihintpause -Zba -Zbb
-Zbs -Zca -Zcb -Zcmp -Zcmt -Za -Zm -Zicbom)
zephyr_ld_options(-Hlib=rmx100)
endif()
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/riscv/common/linker.ld CACHE INTERNAL "")