Skip to content

Commit bb0df41

Browse files
kito-chengasb
andcommitted
Relax gp could be platform specific register rather than reserved for linker relaxation
The usage of gp register has discussed serveral times (e.g. #298), and it reserved as special register used for linker relaxation, that could be improve perfomance and code size. However it come with some limitation, like it can't applicable on shared libraries, and it also not work well when program come with large datas since the relaxable range is only +-2KiB. Some platform like FreeBSD and Haiku never use gp in the whole system, and also this might not useful in some baremetal system with specialized memory layout, so we might consider to release the gp usage with a non-hard-ABI-breakage way. Co-authored-by: Alex Bradbury <[email protected]>
1 parent 2fab064 commit bb0df41

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

riscv-cc.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ endif::[]
2828
In the standard ABI, procedures should not modify the integer registers tp and
2929
gp, because signal handlers may rely upon their values.
3030

31+
The presence of a frame pointer is optional. If a frame pointer exists,
32+
it must reside in x8 (s0); the register remains callee-saved.
33+
34+
If a platform requires use of a dedicated general-purpose register for a
35+
platform-specific purpose, it is recommended to use gp (x3). The platform ABI
36+
specification must document the use of this register. For such platforms, care
37+
must be taken to ensure all code (compiler generated or otherwise) avoids using
38+
gp in a way incompatible with the platform specific purpose, and that global
39+
pointer relaxation is disabled in the toolchain.
40+
3141
=== Frame Pointer Convention
3242

3343
The presence of a frame pointer is optional. If a frame pointer exists,

0 commit comments

Comments
 (0)