c.addi
Add a sign-extended non-zero immediate
C.ADDI adds the non-zero sign-extended 6-bit immediate to the value in register xd then writes the result to xd.
C.ADDI expands into addi xd, xd, imm.
C.ADDI is only valid when xd ≠ x0 and imm ≠ 0.
The code points with xd=x0 encode the C.NOP instruction; the remaining code points with imm=0 encode HINTs.
| This instruction must have data-independent timing when extension Zkt is enabled. |
Decode Variables
signed Bits<6> imm = sext({$encoding[12], $encoding[6:2]}, 6);
Bits<5> xd = $encoding[11:7];
Execution
if (implemented?(ExtensionName::C) && (CSR[misa].C == 1'b0)) {
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
X[xd] = X[xd] + $signed(imm);