c.srai
Shift right arithmetical immediate
This instruction is defined by:
-
anyOf:
-
C, version >= 0
-
Zca, version >= 0
-
This instruction is included in the following profiles:
Synopsis
Arithmetic shift (the original sign bit is copied into the vacated upper bits) the value in rd right by shamt, and store the result in rd.
The rd register index should be used as rd+8 (registers x8-x15).
C.SRAI expands into srai rd, rd, shamt
.
Execution
-
IDL
-
Sail
X[rd + 8] = X[rd + 8] >>> shamt;
{
let rd_val = X(rd+8);
/* the decoder guard should ensure that shamt[5] = 0 for RV32 */
let result : xlenbits = match op {
RISCV_SLLI => if sizeof(xlen) == 32
then rd_val << shamt[4..0]
else rd_val << shamt,
RISCV_SRLI => if sizeof(xlen) == 32
then rd_val >> shamt[4..0]
else rd_val >> shamt,
RISCV_SRAI => if sizeof(xlen) == 32
then shift_right_arith32(rd_val, shamt[4..0])
else shift_right_arith64(rd_val, shamt)
};
X(rd+8) = result;
RETIRE_SUCCESS
}