c.li
Load the sign-extended 6-bit immediate
- Extension
- C
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
c.li xd, imm- Length
- 16-bit (compressed)
Encoding
| 1513 | 12 | 117 | 62 | 10 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 010 | imm[5] | rd≠0 | imm[4:0] | 01 | |||||||||||
Match 0x4001, mask 0xe003. Source: c.li rd_n0 c_imm6lo c_imm6hi 1..0=1 15..13=2 in riscv-opcodes/extensions/rv_c.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| imm[5] | 12 | c_imm6hi |
| rd≠0 | 11:7 | rd_n0 |
| imm[4:0] | 6:2 | c_imm6lo |
Description
C.LI loads the sign-extended 6-bit immediate, imm, into register xd.
C.LI expands into addi xd, x0, imm.
C.LI is only valid when xd ≠ x0; the code points with xd=x0 encode HINTs.
Description from riscv-unified-db, reformatted.
Operation
if (implemented?(ExtensionName::C) && MISA_CSR_IMPLEMENTED && (CSR[misa].C == 1'b0)) {
reserved_instruction($encoding);
}
X[xd] = $signed(imm);Pseudocode in riscv-unified-db’s IDL, quoted unchanged.