File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,17 @@ config FLOAT_HARD
1919 This option enables the hard-float calling convention.
2020 Adds eight floating-point argument registers.
2121
22+ config RISCV_USE_MSAVE_RESTORE
23+ bool "Compile with -msave-restore to reduce some code foodprint"
24+ help
25+ The `-msave-restore` option enables the compiler to emit calls to library
26+ routines `__riscv_save_X` and `__riscv_restore_X` for preserving the
27+ callee-saved registers instead of inlining them in every function. This
28+ can reduce code size in large functions. However, it introduces extra
29+ branching overhead, which may slightly impact performance in hot paths.
30+
31+ If supported by your SoC, the `Zcmp` ISA extension should be preferred.
32+
2233choice RISCV_GP_PURPOSE
2334 prompt "Purpose of the global pointer (GP) register"
2435 default RISCV_GP if RISCV_SOC_HAS_GP_RELATIVE_ADDRESSING
Original file line number Diff line number Diff line change @@ -136,6 +136,10 @@ if(NOT CONFIG_RISCV_ISA_EXT_M AND
136136 string (APPEND riscv_march "_zmmul" )
137137endif ()
138138
139+ if (CONFIG_RISCV_USE_MSAVE_RESTORE)
140+ list (APPEND RISCV_C_FLAGS -msave-restore)
141+ endif ()
142+
139143list (APPEND RISCV_C_FLAGS
140144 -mabi=${riscv_mabi}
141145 -march=${riscv_march}
You can’t perform that action at this time.
0 commit comments