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. Standard ABI procedures should not modify gp because signal handlers 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 an unallocatable ABI register and do not borrow it for calculations.
Physical Name x3ABI Name gpSave Rule Unallocatable
Role
Global pointer; unallocatable and not modified by standard ABI procedures.
Convention
Unallocatable
Remember This First
The psABI marks gp as unallocatable.
psABI Reference

Unallocatable register

gp is marked unallocatable by the psABI. Procedures should not modify it because signal handlers 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. Standard ABI procedures should not modify it; it is not a normal caller-saved or callee-saved choice.

The psABI marks x3/gp as unallocatable.
Standard ABI procedures should not modify gp/tp because signal handlers 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 an unallocatable psABI register.
  • - For environment-specific conventions beyond the psABI table, consult that environment's official ABI documentation.

When Not To Use It This Way

  • - Do not modify gp in standard ABI procedures.
  • - Do not use gp as a general-purpose or temporary register.
  • - Do not infer environment-specific behavior not stated by the ABI from gp's name.

What Happens Around A Call

1

The psABI marks gp as unallocatable.

2

The psABI says standard ABI 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 standard ABI 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 standard ABI 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.