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
X[rd + 8] = X[2] + imm;
if (implemented?(ExtensionName::C) && (CSR[misa].C == 1'b0)) {
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
X[rd + 8] = X[2] + imm;