c.lui

Load Upper Immediate

C.LUI loads the non-zero 6-bit immediate field into bits 17-12 of the destination register, clears the bottom 12 bits, and sign-extends bit 17 into all higher bits of the destination. C.LUI expands into lui xd, imm. C.LUI is only valid when xd≠x0 and xd≠x2, and when the immediate is not equal to zero. The code points with imm=0 are reserved; the remaining code points with xd=x0 are HINTs; and the remaining code points with xd=x2 correspond to the C.ADDI16SP instruction

This instruction must have data-independent timing when extension Zkt is enabled.

Assembly format

c.lui xd, imm

Decode Variables

signed Bits<18> imm = sext({$encoding[12], $encoding[6:2], 12'd0}, 18);
Bits<5> xd = $encoding[11:7];

Execution

if (implemented?(ExtensionName::C) && (CSR[misa].C == 1'b0)) {
  raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
X[xd] = $signed(imm);

Exceptions

This instruction may result in the following synchronous exceptions:

  • IllegalInstruction

Encoding

svg

Defining extension

Zca

Access

M

Always

Containing profiles

  • Mandatory: None

  • Optional: RVA20S64, RVA20U64, RVA22S64, RVA22U64, RVA23S64, RVA23U64, RVB23S64, RVB23U64, RVI20U32, RVI20U64