Skip to content

Commit 6f466f2

Browse files
arch: riscv: Add -msave-restore option to reduce code footprint
Add `-msave-restore` option to reduce the code footprint of function prologue and epilogue. Signed-off-by: Andy Lin <andylinpersonal@gmail.com>
1 parent b70f7d2 commit 6f466f2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

‎arch/riscv/Kconfig‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ 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+
Enable -msave-restore to reduce some code foodprint
26+
2227
choice RISCV_GP_PURPOSE
2328
prompt "Purpose of the global pointer (GP) register"
2429
default RISCV_GP if RISCV_SOC_HAS_GP_RELATIVE_ADDRESSING

‎cmake/compiler/gcc/target_riscv.cmake‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ if(NOT CONFIG_RISCV_ISA_EXT_M AND
136136
string(APPEND riscv_march "_zmmul")
137137
endif()
138138

139+
if(CONFIG_RISCV_USE_MSAVE_RESTORE)
140+
list(APPEND RISCV_C_FLAGS -msave-restore)
141+
endif()
142+
139143
list(APPEND RISCV_C_FLAGS
140144
-mabi=${riscv_mabi}
141145
-march=${riscv_march}

0 commit comments

Comments
 (0)