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 <anchao@lixiang.com>
This commit is contained in:
chao an 2024-04-19 09:20:21 +08:00 committed by Xiang Xiao
parent d11b1ba9cb
commit d59f9186ca
3 changed files with 24 additions and 0 deletions

View File

@ -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 ""

View File

@ -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})

View File

@ -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)