Register Guide

RISC-V gp / x3 Register: Global Pointer and Unallocatable ABI Convention

gp is the global pointer in the psABI and is marked unallocatable. Normal procedures should not modify gp; the standard ABI says this because signal handlers and similar runtime contexts may rely on its value.

psABI: x3 is named gp and means Global pointer.
psABI: gp is unallocatable and is not part of the normal temporary pool.
Beginner rule: treat gp as a runtime-reserved value and do not borrow it for calculations.
Physical Name x3ABI Name gpSave Rule N/A
Role
Global pointer; unallocatable and not modified by normal procedures.
Convention
Unallocatable
Remember This First
The psABI marks gp as unallocatable.
psABI Reference

Unallocatable register

gp is marked unallocatable by the psABI. Normal procedures should not modify it because signal handlers, runtimes, or platform conventions may rely on its value.

Preserved across calls: Not applicable
RISC-V psABI integer register convention
Quick Understanding & Search Notes

gp / x3 is marked unallocatable by the psABI. Normal procedures should not modify it; it is not a normal caller-saved or callee-saved choice.

The psABI marks x3/gp as unallocatable.
Normal procedures should not modify gp/tp because signal handlers and similar runtime contexts may rely on their values.

When It Fits Best

  • - Recognize it as the psABI global pointer, not a normal temporary register.
  • - When reading disassembly, first treat gp as a value reserved by the platform or runtime environment.
  • - If a target platform uses gp for a platform-specific purpose, consult that platform's ABI documentation.

When Not To Use It This Way

  • - Do not modify gp in normal procedures.
  • - Do not use gp as a general-purpose or temporary register.
  • - Do not assume gp has the same platform meaning in every environment.

What Happens Around A Call

1

The psABI marks gp as unallocatable.

2

The psABI says normal procedures should not modify gp because signal handlers may rely on it.

3

It is not a normal caller-saved/callee-saved choice; it should not be allocated to ordinary code.

Read gp As A Reserved ABI Value

Examples explain the rule, not a complete program
# Do not borrow gp in a normal function
# If the platform ABI assigns gp a purpose, follow that platform ABI
# Use t0-t6 for temporaries, or save other registers according to the calling convention

FAQ

Can gp / x3 be used as an ordinary temporary?

It should not. The psABI marks it unallocatable, and normal procedures should not modify it.

Is gp caller-saved or callee-saved?

Neither in the usual sense; it is unallocatable, so ordinary code should not borrow it.