Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions arch/riscv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ config FLOAT_HARD
This option enables the hard-float calling convention.
Adds eight floating-point argument registers.

config RISCV_USE_MSAVE_RESTORE
bool "Compile with -msave-restore to reduce some code footprint"
help
The `-msave-restore` option enables the compiler to emit calls to library
routines `__riscv_save_X` and `__riscv_restore_X` for preserving the
callee-saved registers instead of inlining them in every function. This
can reduce code size in some large functions. However, it introduces extra
branching overhead, which may impact the performance in hot paths.

If supported by your SoC, the `Zcmp` ISA extension should be preferred.

choice RISCV_GP_PURPOSE
prompt "Purpose of the global pointer (GP) register"
default RISCV_GP if RISCV_SOC_HAS_GP_RELATIVE_ADDRESSING
Expand Down
4 changes: 4 additions & 0 deletions cmake/compiler/gcc/target_riscv.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ if(NOT CONFIG_RISCV_ISA_EXT_M AND
string(APPEND riscv_march "_zmmul")
endif()

if(CONFIG_RISCV_USE_MSAVE_RESTORE)
list(APPEND RISCV_C_FLAGS -msave-restore)
endif()

list(APPEND RISCV_C_FLAGS
-mabi=${riscv_mabi}
-march=${riscv_march}
Expand Down