csrrc
riscv_unified_db)RV32 / RV64 (Ratified & Standard Extensions)
main
userZicsrSummary
The CSRRC (Atomic Read and Clear Bits in CSR) instruction reads the value of the CSR, zero-extends the value to XLEN bits, and writes it to integer register xd. The initial value in integer register xs1 is treated as a bit mask that specifies bit positions to be cleared in the CSR. Any bit that is high in xs1 will cause the corresponding bit to be cleared in the CSR, if that CSR bit is writable.
Syntax / Encoding
csrrc xd, csr, xs1 | xxxxxxxxxxxxxxxxx011xxxxx1110011 (mask=0x0000707f match=0x00003073)
Cross-Chip Latency & Throughput (11 cores)
| Microarchitecture | Latency (cycles) | Recip. TP | uops | Ports | Source |
|---|---|---|---|---|---|
| Andes 45-Series | 1 | 1 | 1 | Andes45CSR | llvm_sched_models |
| MIPS P8700 (RISC-V) | 1 | 1 | 1 | p8700ALQ | llvm_sched_models |
| SiFive 7-Series (U74) | 1 | 1 | 1 | PipeB | llvm_sched_models |
| SiFive P670 / P600 | 1 | 1 | 1 | SiFiveP600SYS | llvm_sched_models |
| SiFive P870 / P800 | 1 | 1 | 1 | SiFiveP800SYS | llvm_sched_models |
| SpacemiT X100 | 1 | 0.5 | 1 | SMTX100_IQ0 | llvm_sched_models |
| SpacemiT X60 (K1) | 1 | 0.5 | 1 | SMX60_IEU | llvm_sched_models |
| Syntacore SCR7 | 1 | 1 | 1 | — | llvm_sched_models |
| Tenstorrent Ascalon-X | 1 | 1 | 1 | AscalonFXA | llvm_sched_models |
| XiangShan KunMingHu | 1 | 1 | 1 | XSPipeBJU3 | llvm_sched_models |
| XiangShan NanHu | 1 | 1 | 1 | XS2MISC | llvm_sched_models |
Binary Encodings (1)
| Width | Format | Bit Pattern | Mask / Match |
|---|---|---|---|
| 32 | RV | xxxxxxxxxxxxxxxxx011xxxxx1110011 | 0x0000707f / 0x00003073 |
Operands
| Name | Description |
|---|---|
csr | bits [31:20] |
xs1 | bits [19:15] |
xd | bits [11:7] |
Reference Notes
The CSRRC (Atomic Read and Clear Bits in CSR) instruction reads the value of the CSR, zero-extends the value to XLEN bits, and writes it to integer register `xd`. The initial value in integer register `xs1` is treated as a bit mask that specifies bit positions to be cleared in the CSR. Any bit that is high in `xs1` will cause the corresponding bit to be cleared in the CSR, if that CSR bit is writable. For CSRRC, if `xs1=x0`, then the instruction will not write to the CSR at all, and so shall not cause any of the side effects that might otherwise occur on a CSR write, nor raise illegal- instruction exceptions on accesses to read-only CSRs. CSRRC always reads the addressed CSR and cause any read side effects regardless of `xs1` and `xd` fields. Note that if `xs1` specifies a register other than `x0`, and that register holds a zero value, the instruction will not action any attendant per-field side effects, but will action any side effects caused by writing to the entire CSR.