From d59f9186ca52c0c4885c9db45e31d9f8c537301c Mon Sep 17 00:00:00 2001 From: chao an Date: Fri, 19 Apr 2024 09:20:21 +0800 Subject: [PATCH] arch/risc-v: add llvm experimental extensions into command line LLVM supports (to various degrees) a number of experimental extensions. All experimental extensions have experimental- as a prefix. There is explicitly no compatibility promised between versions of the toolchain, and regular users are strongly advised not to make use of experimental extensions before they reach ratification. Fix compile error: riscv64-unknown-elf-clang: error: invalid arch name 'rv64gcv_zfh_zvfh', requires '-menable-experimental-extensions' for experimental extension 'zvfh' Signed-off-by: chao an --- arch/risc-v/Kconfig | 12 ++++++++++++ arch/risc-v/src/cmake/Toolchain.cmake | 6 ++++++ arch/risc-v/src/common/Toolchain.defs | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/arch/risc-v/Kconfig b/arch/risc-v/Kconfig index cf97f0c306..7f6f0c3954 100644 --- a/arch/risc-v/Kconfig +++ b/arch/risc-v/Kconfig @@ -371,6 +371,18 @@ config ARCH_RV_ISA_ZICSR_ZIFENCEI clang < 17 or GCC < 11.3.0, for which this is not possible or need special treatment. +config ARCH_RV_EXPERIMENTAL_EXTENSIONS + string "LLVM RISC-V Experimental Extensions" + default "" + depends on RISCV_TOOLCHAIN_CLANG + ---help--- + This option allows the platform to enable experimental extensions, + LLVM supports (to various degrees) a number of experimental extensions. + All experimental extensions have experimental- as a prefix. There is + explicitly no compatibility promised between versions of the toolchain, + and regular users are strongly advised not to make use of experimental + extensions before they reach ratification. + config ARCH_RV_ISA_VENDOR_EXTENSIONS string "Vendor Custom RISC-V Instruction Set Architecture Extensions" default "" diff --git a/arch/risc-v/src/cmake/Toolchain.cmake b/arch/risc-v/src/cmake/Toolchain.cmake index e475238d53..7beca6b3a4 100644 --- a/arch/risc-v/src/cmake/Toolchain.cmake +++ b/arch/risc-v/src/cmake/Toolchain.cmake @@ -264,6 +264,12 @@ if(${CONFIG_RISCV_TOOLCHAIN} STREQUAL GNU_RVG) endif() endif() + if(CONFIG_ARCH_RV_EXPERIMENTAL_EXTENSIONS) + set(ARCHCPUEXTFLAGS + ${ARCHCPUEXTFLAGS}_${CONFIG_ARCH_RV_EXPERIMENTAL_EXTENSIONS}) + add_compile_options(-menable-experimental-extensions) + endif() + if(CONFIG_ARCH_RV_ISA_VENDOR_EXTENSIONS) set(ARCHCPUEXTFLAGS ${ARCHCPUEXTFLAGS}_${CONFIG_ARCH_RV_ISA_VENDOR_EXTENSIONS}) diff --git a/arch/risc-v/src/common/Toolchain.defs b/arch/risc-v/src/common/Toolchain.defs index 27d3c0c678..a8fb39e163 100644 --- a/arch/risc-v/src/common/Toolchain.defs +++ b/arch/risc-v/src/common/Toolchain.defs @@ -211,6 +211,12 @@ ifeq ($(CONFIG_RISCV_TOOLCHAIN),GNU_RVG) endif endif + ARCH_RV_EXPERIMENTAL_EXTENSIONS = $(strip $(subst ",,$(CONFIG_ARCH_RV_EXPERIMENTAL_EXTENSIONS))) + ifneq ($(ARCH_RV_EXPERIMENTAL_EXTENSIONS),) + ARCHCPUEXTFLAGS := $(ARCHCPUEXTFLAGS)_$(ARCH_RV_EXPERIMENTAL_EXTENSIONS) + ARCHOPTIMIZATION += -menable-experimental-extensions + endif + ARCH_RV_ISA_VENDOR_EXTENSIONS = $(strip $(subst ",,$(CONFIG_ARCH_RV_ISA_VENDOR_EXTENSIONS))) ifneq ($(ARCH_RV_ISA_VENDOR_EXTENSIONS),) ARCHCPUEXTFLAGS := $(ARCHCPUEXTFLAGS)_$(ARCH_RV_ISA_VENDOR_EXTENSIONS)