Register Guide

RISC-V t0 / x5 Register: Temporary Values, Call Clobbering, and Alternate Link Register

t0 is a psABI temporary register and is not preserved across calls; values that must survive a call cannot live only in t0. The RISC-V ISA also notes that the standard calling convention uses x1 for the return address, with x5 available as an alternate link register.

psABI: x5-x7 / t0-t2 are temporary registers and are not preserved across calls.
ISA: x5 is available as an alternate link register.
Beginner rule: use t0 for short-lived temporaries and save it yourself before a call if needed.
Physical Name x5ABI Name t0Save Rule Not preserved across calls

t0 is caller-saved. Using x5 as an alternate link register does not change that preservation rule; if it must survive a call, the caller must save it.

Role
Temporary / alternate link register
Convention
Not preserved across calls
Remember This First
The psABI marks t0 as a temporary register that is not preserved across calls.
psABI Reference

Temporary register

The psABI marks t0-t6 as temporary registers. They are not callee-saved; callers must save any value that needs to survive a call.

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

t0 / x5 belongs to the t0-t6 temporary-register group. The psABI marks it not preserved across calls; callers must save any value that needs to survive a call.

t0-t6 are temporary registers and are not preserved across calls.
The ISA notes x5 as an alternate link register, but the psABI still classifies t0 as a temporary register.

When It Fits Best

  • - Recognize x5/t0 as a temporary register not preserved across calls in the standard psABI.
  • - Understand that the standard software calling convention uses x1 for the return address, with x5 available as an alternate link register.
  • - Understand the ISA note that x5 is available as an alternate link register.

When Not To Use It This Way

  • - Do not assume a pre-call t0 value remains available after a call.
  • - Do not read the ISA alternate-link-register statement as a psABI preservation rule.

What Happens Around A Call

1

The psABI marks t0 as a temporary register that is not preserved across calls.

2

Under the standard calling convention, contents not specified as return values or callee-saved are unspecified on procedure exit.

3

The ISA notes that x5 is available as an alternate link register, but that does not change t0's ABI preservation rule.

t0 Normative Boundaries

Examples explain the rule, not a complete program
# x5/t0: temporary register, not preserved across calls
# x5: alternate link register in the standard software calling convention

Relationship With Other Registers

t0 vs ra (Alternate vs Primary Link Register)

The RISC-V ISA says the standard calling convention uses x1 as the return address register and that x5 is available as an alternate link register. The psABI still names x1 as ra and x5 as t0, a temporary register; neither is preserved across calls. In hand-written assembly, the call sequence must make clear which register a later return sequence will read.

Preservation Across Calls

Although the ISA notes x5 as an available alternate link register, the psABI still classifies t0 as a temporary register that is not preserved across calls. If later code still needs the value in t0, the caller must save it before the call; if it is used for a return address, make sure the return sequence reads t0 rather than ra.

FAQ

Is t0 / x5 preserved across calls?

No. t0-t6 are temporary registers and are not preserved across calls.