RISC-V rdtime Pseudo-Instruction Details
Assembler pseudo-instructionRead-time-counter pseudo-instruction, expanding to csrrs rd, time, x0. It reads the low XLEN bits of the platform-provided real-time 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/time counter CSR semantics
- Reads the low XLEN bits of time
- The target platform provides time and allows the current privilege level to read it
- Do not equate time directly with CPU cycle count.
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 rdtime a real RISC-V instruction?
rdtime 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 rdtime?
On RV32, reading a complete 64-bit counter usually needs the h-suffixed form and rollover handling