Webcentive RISC-V Reference

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

1513121176210
010imm[5]rd≠0imm[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.

FieldBitsriscv-opcodes name
imm[5]12c_imm6hi
rd≠011:7rd_n0
imm[4:0]6:2c_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.

Specification and related pages