Register Guide

RISC-V t5 / x30 Register: Temporary

Temporary register 5 (x30). The psABI classifies t5 as a temporary register for caller-managed short-lived values; its value is not preserved across calls.

ABI name: t5; physical register: x30.
Save rule: Caller.
Read it through its psABI role first, then inspect how each instruction reads or writes it.
Physical Name x30ABI Name t5Save Rule Caller
Role
Temporary
Convention
Caller-saved
Remember This First
t5 is a caller-saved temporary register, so callees may overwrite it.
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

t5 / x30 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.
If a t5 value is still needed across a call, the caller must save it explicitly.

When It Fits Best

  • - Hold short-lived temporary computation results.
  • - Use it for local computations that do not need to survive calls.
  • - Use it as a caller-managed scratch register.

When Not To Use It This Way

  • - Do not keep values in it across a call unless you save them yourself first.
  • - Do not expect callees to restore it for you.

What Happens Around A Call

1

t5 is a caller-saved temporary register, so callees may overwrite it.

2

If the caller still needs the t5 value after a call, it must save it in advance.

3

Values that must survive calls should usually live in s* registers or on the stack.

Save t5 Before A Call If Needed

Examples explain the rule, not a complete program
addi t5, a0, 1
# If t5 is needed after the call, the caller must save it to an ABI-valid location first
call foo
# restore t5 from that saved location after the call returns

FAQ

Is t5 / x30 preserved across calls?

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

What if a t5 value is needed after a call?

The caller must save it before the call, usually to the stack or another suitable location, and restore it afterward.