RISC-V rdinstret Pseudo-Instruction Details
Assembler pseudo-instructionRead-instret-counter pseudo-instruction, expanding to csrrs rd, instret, x0. It reads the low XLEN bits of the retired-instruction counter.
What This Pseudo Instruction Is Saving You From Writing
Counters are read-only CSRs; the pseudo-instruction hides the fixed CSRRS rd, csr, x0 form and makes performance/time reads clearer.
Official Semantics Checklist
Availability And Extension Conditions
- Zicntr counter CSR semantics
- Reads the low XLEN bits of instret
- The target platform allows the current privilege level to read instret
- instret counts retired instructions and differs from cycle and time.
How To Read The Expansion
What You May See In objdump / Disassembly
Official References And Reading Order
This page treats pseudo-instructions as assembler-level aliases or macros: first read what real instructions they expand to, then use the official ISA manual for the behavior of those real instructions. ABI, relocation, and linker-relaxation details follow the psABI document.
When To Think Of It First
Pitfalls / Common Confusions
FAQ
Is rdinstret a real RISC-V instruction?
rdinstret is an assembler pseudo-instruction or alias, not a separate hardware opcode. The “Typical Real Expansion” section lists the official expansion, and behavior is defined by the expanded ISA instructions.
What is the main trap when using rdinstret?
On RV32, reading a complete 64-bit counter usually needs the h-suffixed form and rollover handling