-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
There is a need to enable certain extensions for RISC-V coreclr builds. For example, emitLoadImmediate
makes heavy use of bit count intrinsics.
runtime/src/coreclr/jit/emitriscv64.cpp
Line 1312 in 456e1fe
void emitter::emitLoadImmediate(emitAttr size, regNumber reg, ssize_t imm) |
We can increase the JIT throughput of this function by enabling Zbb
extension. This is only one example where we could improve RISC-V JIT throughput by enabling certain extensions. Other extensions, such as Zba
and Zicond
can improve throughput at various places.
Currently, the compiler (clang) uses the default configuration for RISC-V target, which "only" enables the rv64gc
"profile".
We can use CLR_ADDITIONAL_COMPILER_OPTIONS
to pass in -march=rv64gc_zbb
to clang:
runtime/eng/native/configurecompiler.cmake
Lines 785 to 787 in 11afd86
if(CLR_CMAKE_HOST_UNIX) | |
add_compile_options(${CLR_ADDITIONAL_COMPILER_OPTIONS}) | |
endif(CLR_CMAKE_HOST_UNIX) |
But I was wondering if we should introduce a better way to enable these extensions, akin to what we have for ARM:
runtime/eng/native/configurecompiler.cmake
Lines 753 to 756 in 11afd86
if(CLR_CMAKE_HOST_UNIX_ARM) | |
if (NOT DEFINED CLR_ARM_FPU_TYPE) | |
set(CLR_ARM_FPU_TYPE vfpv3) | |
endif(NOT DEFINED CLR_ARM_FPU_TYPE) |
There are several alternative proposals that I would like to suggest:
- Introduce
RISCV_EXTENSIONS
CMake option. User can pass inZba_Zicond_...
. - Introduce
RISCV_PROFILE
CMake option. User can pass inrv22
,rv23
, etc. - Introduce options for each extension that might be useful, e.g.
RISCV_ZBB=1
, adding it only when a need arises. - Change the default profile to RVA20/22/23.
cc @dotnet/samsung