Register Guide

RISC-V t2 / x7 Register: Temporary

Temporary register 2 (x7). The psABI classifies t2 as a temporary register whose value is not preserved across calls.

ABI name: t2; physical register: x7.
Save rule: Not preserved across calls.
Read it through its psABI role first, then inspect how each instruction reads or writes it.
Physical Name x7ABI Name t2Save Rule Not preserved across calls
Role
Temporary
Convention
Not preserved across calls
Remember This First
t2 is a standard-psABI temporary register and 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

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

When It Fits Best

  • - Recognize t2 as a temporary register not preserved across calls in the standard psABI.
  • - On procedure exit, contents not specified as return values or callee-saved are unspecified.
  • - The RISC-V Assembly Programmer's Manual names t2 as tail's implicit scratch register only when Zicfilp is available.

When Not To Use It This Way

  • - Do not assume a pre-call t2 value remains available after a call.
  • - Do not describe the psABI temporary classification as special hardware behavior.

What Happens Around A Call

1

t2 is a standard-psABI temporary register and is not preserved across calls.

2

Contents not specified as return values or callee-saved are unspecified on procedure exit.

3

This rule applies to the standard calling convention.

Standard psABI Rule For t2

Examples explain the rule, not a complete program
# t2: temporary register, not preserved across calls
# Scope: standard psABI calling convention

FAQ

Is t2 / x7 preserved across calls?

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