Is t0 / x5 preserved across calls?
No. t0-t6 are temporary registers and are not preserved across calls.
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.
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.
The psABI marks t0-t6 as temporary registers. They are not callee-saved; callers must save any value that needs to survive a call.
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.
The psABI marks t0 as a temporary register that is not preserved across calls.
If the caller needs a t0 value after a call, the caller must save it first.
The ISA notes that x5 is available as an alternate link register, but that does not change t0's ABI preservation rule.
# Use 1: as an ordinary temporary
add t0, a0, a1 # t0 = a0 + a1
slli t0, t0, 2 # t0 = t0 << 2
# If the result must survive a call, save it to an ABI-valid location first
# Use 2: understand x5 as an available alternate link register
# exact syntax depends on the call sequence and assembler pseudoinstructionsThe 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.
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.
No. t0-t6 are temporary registers and are not preserved across calls.
The caller must save it before the call, usually to the stack or another suitable location, and restore it afterward.