arch/risc-v: Improve LLVM CPU type detection with findstring

Use findstring instead of direct equality checks for LLVM_CPUTYPE
conditions to better handle ARCHCPUEXTFLAGS that may contain additional
ISA extensions. This makes the CPU type detection more robust when
dealing with extended instruction sets while still ensuring the required
base ISA extensions are present.

For example, ARCHCPUEXTFLAGS="imc_zicsr_zifencei" will now correctly
match as sifive-e20 rather than failing the exact match check.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2025-01-08 19:15:26 +08:00 committed by Xiang Xiao
parent ae9815a888
commit 00794b92c4

View file

@ -277,17 +277,17 @@ endif
# These models can't cover all implementation of RISCV, but it's enough for most cases. # These models can't cover all implementation of RISCV, but it's enough for most cases.
ifeq ($(CONFIG_ARCH_RV32),y) ifeq ($(CONFIG_ARCH_RV32),y)
ifeq ($(ARCHCPUEXTFLAGS), imc) ifeq ($(findstring imc,$(ARCHCPUEXTFLAGS)),imc)
LLVM_CPUTYPE := sifive-e20 LLVM_CPUTYPE := sifive-e20
else ifeq ($(ARCHCPUEXTFLAGS), imac) else ifeq ($(findstring imac,$(ARCHCPUEXTFLAGS)),imac)
LLVM_CPUTYPE := sifive-e31 LLVM_CPUTYPE := sifive-e31
else ifeq ($(ARCHCPUEXTFLAGS), imafc) else ifeq ($(findstring imafc,$(ARCHCPUEXTFLAGS)),imafc)
LLVM_CPUTYPE := sifive-e76 LLVM_CPUTYPE := sifive-e76
endif endif
else else
ifeq ($(ARCHCPUEXTFLAGS), imac) ifeq ($(findstring imac,$(ARCHCPUEXTFLAGS)),imac)
LLVM_CPUTYPE := sifive-s51 LLVM_CPUTYPE := sifive-s51
else ifeq ($(ARCHCPUEXTFLAGS), imafdc) else ifeq ($(findstring imafdc,$(ARCHCPUEXTFLAGS)),imafdc)
LLVM_CPUTYPE := sifive-u54 LLVM_CPUTYPE := sifive-u54
endif endif
endif endif