rdinstreth
RISC-V rdinstreth 伪指令详解
汇编器伪指令RISC-V rdinstreth 伪指令展开为 csrrs rd, instreth, x0;它只在 RV32 中读取 instret 计数器的 bits 63:32。
你写下的是
rdinstreth rd
常见真实展开
csrrs rd, instreth, x0
这条伪指令到底在帮你省什么
RISC-V Assembly Programmer's Manual用 rdinstret[h] 为读取 instructions-retired counter 的 CSRRS 形式命名。
RISC-V rdinstreth 伪指令展开为 csrrs rd, instreth, x0;它只在 RV32 中读取 instret 计数器的 bits 63:32。
官方语义核对重点
rdinstreth 展开为 csrrs rd, instreth, x0;RV32 时读取 instret 的高 32 位。
rdinstreth 只在 XLEN=32 时存在;不要把它作为 RV64 指令。
h 后缀形式只在 XLEN=32 时读取高32位。
可用性与扩展条件
基础条件
- Zicntr 依赖 Zicsr。
备注
- rdinstreth 只在 XLEN=32 时存在;不要把它作为 RV64 指令。
展开过程怎么理解
步骤 1
rdinstreth 展开为 csrrs rd, instreth, x0;RV32 时读取 instret 的高 32 位。
官方依据与阅读顺序
本页把伪指令当作汇编器层面的别名或宏来解释:先看它会展开成哪些真实指令,再回到官方 ISA 手册理解真实指令的行为。涉及 ABI、重定位或链接器松弛时,以 psABI 文档为准。
什么时候优先想到它
在 RV32 上读取 64 位 instret 计数器的高半部分。
容易混淆 / 常见误区
rdinstreth 只在 XLEN=32 时存在;不要把它作为 RV64 指令。
常见问题
rdinstreth 在何种 XLEN 下可用?
rdinstreth 只在 XLEN=32 时存在;不要把它作为 RV64 指令。