RISC-V rdcycle Pseudo-Instruction Details
Assembler pseudo-instructionRead-cycle-counter pseudo-instruction, expanding to csrrs rd, cycle, x0. It reads the low XLEN bits of the processor cycle 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 cycle
- The target platform allows the current privilege level to read cycle
- The interpretation of cycle can depend on platform, hart, and frequency policy.
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 rdcycle a real RISC-V instruction?
rdcycle 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 rdcycle?
On RV32, reading a complete 64-bit counter usually needs the h-suffixed form and rollover handling