c.addi4spn
Add a zero-extended non-zero immediate, scaled by 4, to the stack pointer
This instruction is defined by:
Synopsis
Adds a zero-extended non-zero immediate, scaled by 4, to the stack pointer, x2, and writes the result to rd'.
This instruction is used to generate pointers to stack-allocated variables.
It expands to addi rd', x2, nzuimm[9:2]
.
C.ADDI4SPN is only valid when nzuimm ≠ 0; the code points with nzuimm=0 are reserved.
Decode Variables
Bits<10> imm = {$encoding[10:7], $encoding[12:11], $encoding[5], $encoding[6], 2'd0};
Bits<3> rd = $encoding[4:2];
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[%%LINK%func;creg2reg;creg2reg%%(rd)] = X[2] + 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[%%LINK%func;creg2reg;creg2reg%%(rd)] = X[2] + imm;