RISC-V rdcycle Pseudo-Instruction Details
Assembler pseudo-instructionRISC-V rdcycle is the pseudo-instruction for the cycle CSR and expands to csrrs rd, cycle, x0. It reads the low XLEN bits; when XLEN is at least 64, it reads the full 64-bit counter.
What This Pseudo Instruction Is Saving You From Writing
The assembly manual lists rdcycle as the standard counter-read spelling for csrrs rd, cycle, x0.
Availability And Extension Conditions
- Zicntr depends on Zicsr
- Reads the low XLEN bits of cycle
- The execution environment permits counter access
- The cycle rate depends on the implementation and execution environment.
How To Read The Expansion
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, rdcycle reads only the low 32 bits; a high-low-high comparison retry obtains a valid full cycle value.