Skip to content

Commit

Permalink
Relax gp could be platform specific register rather than reserved for…
Browse files Browse the repository at this point in the history
… 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 <asb@asbradbury.org>
  • Loading branch information
kito-cheng and asb committed Apr 7, 2023
1 parent 2fab064 commit bb0df41
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions riscv-cc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ endif::[]
In the standard ABI, procedures should not modify the integer registers tp and
gp, because signal handlers may rely upon their values.

The presence of a frame pointer is optional. If a frame pointer exists,
it must reside in x8 (s0); the register remains callee-saved.

If a platform requires use of a dedicated general-purpose register for a
platform-specific purpose, it is recommended to use gp (x3). The platform ABI
specification must document the use of this register. For such platforms, care
must be taken to ensure all code (compiler generated or otherwise) avoids using
gp in a way incompatible with the platform specific purpose, and that global
pointer relaxation is disabled in the toolchain.

=== Frame Pointer Convention

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

0 comments on commit bb0df41

Please sign in to comment.