c.addi
Add a sign-extended non-zero immediate
This instruction is defined by:
Synopsis
C.ADDI adds the non-zero sign-extended 6-bit immediate to the value in register rd then writes the result to rd.
C.ADDI expands into addi rd, rd, imm
.
C.ADDI is only valid when rd ≠ x0 and imm ≠ 0.
The code points with rd=x0 encode the C.NOP instruction; the remaining code points with imm=0 encode HINTs.
Execution
-
Pruned, XLEN == 64
-
Original
if ((%%LINK%csr_field;misa.C;CSR[misa].C%% == 1'b0)) {
%%LINK%func;raise;raise%%(ExceptionCode::IllegalInstruction, %%LINK%func;mode;mode%%(), $encoding);
}
X[rd] = X[rd] + $signed(imm);
if (%%LINK%func;implemented?;implemented?%%(ExtensionName::C) && (%%LINK%csr_field;misa.C;CSR[misa].C%% == 1'b0)) {
%%LINK%func;raise;raise%%(ExceptionCode::IllegalInstruction, %%LINK%func;mode;mode%%(), $encoding);
}
X[rd] = X[rd] + $signed(imm);