Webcentive RISC-V Reference

rolw

Rotate left word (Register)

Extension
Zbb, Zbkb, Zk, Zkn, Zks
XLEN
RV64 only
Assembly (riscv-unified-db)
rolw xd, xs1, xs2
Length
32-bit

Encoding

31252420191514121176210
0110000rs2rs1001rd0111011

Match 0x6000103b, mask 0xfe00707f. Source: rolw rd rs1 rs2 31..25=0x30 14..12=1 6..2=0x0E 1..0=3 in riscv-opcodes/extensions/rv64_zbb.

FieldBitsriscv-opcodes name
rs224:20rs2
rs119:15rs1
rd11:7rd

Description

Performs a rotate left of the least-significant word of xs1 by the amount in least-significant 5 bits of xs2. The resulting word value is sign-extended by copying bit 31 to all of the more-significant bits.

Description from riscv-unified-db, reformatted.

Operation

XReg xs1_word = X[xs1][31:0];
XReg shamt = X[xs2][4:0];

XReg unextended_result = (xs1_word << shamt) | (xs1_word >> (32 - shamt));

X[xd] = {{32{unextended_result[31]}}, unextended_result};

Pseudocode in riscv-unified-db’s IDL, quoted unchanged.

Specification and related pages