The bit-manipulation (bitmanip) extension collection is comprised of several component extensions to the base RISC-V architecture that are intended to provide some combination of code size reduction, performance improvement, and energy reduction. While the instructions are intended to have general use, some instructions are more useful in some domains than others. Hence, several smaller bitmanip extensions are provided, rather than one large extension. Each of these smaller extensions is grouped by common function and use case, and each has its own Zb*-extension name.
Each bitmanip extension includes a group of several bitmanip instructions that have similar purposes and that can often share the same logic. Some instructions are available in only one extension while others are available in several. The instructions have mnemonics and encodings that are independent of the extensions in which they appear. Thus, when implementing extensions with overlapping instructions, there is no redundancy in logic or encoding.
The bitmanip extensions are defined for RV32 and RV64. Most of the instructions are expected to be forward compatible with RV128. While the shift-immediate instructions are defined to have at most a 6-bit immediate field, a 7th bit is available in the encoding space should this be needed for RV128.
The bitmanip extension follows the convention in RV64 that w-suffixed instructions (without a dot before the w) ignore the upper 32 bits of their inputs, operate on the least-significant 32-bits as signed values and produce a 32-bit signed result that is sign-extended to XLEN.
Bitmanip instructions with the suffix .uw have one operand that is an unsigned 32-bit value that is extracted from the least significant 32 bits of the specified register. Other than that, these perform full XLEN operations.
Bitmanip instructions with the suffix .b, .h and .w only look at the least significant 8-bits, 16-bits and 32-bits of the input (respectively) and produce an XLEN-wide result that is sign-extended or zero-extended, based on the specific instruction.
The semantics of each instruction in [insns] is expressed in a SAIL-like syntax.
The first group of bitmanip extensions to be released for Public Review are:
Below is a list of all of the instructions (and pseudoinstructions) that are included in these extensions along with their specific mapping:
RV32 | RV64 | Mnemonic | Instruction | Zba | Zbb | Zbc | Zbs |
---|---|---|---|---|---|---|---|
✓ |
add.uw rd, rs1, rs2 |
✓ |
|||||
✓ |
✓ |
andn rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
clmul rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
clmulh rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
clmulr rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
clz rd, rs |
✓ |
||||
✓ |
clzw rd, rs |
✓ |
|||||
✓ |
✓ |
cpop rd, rs |
✓ |
||||
✓ |
cpopw rd, rs |
✓ |
|||||
✓ |
✓ |
ctz rd, rs |
✓ |
||||
✓ |
ctzw rd, rs |
✓ |
|||||
✓ |
✓ |
max rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
maxu rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
min rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
minu rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
orc.b rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
orn rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
rev8 rd, rs |
✓ |
||||
✓ |
✓ |
rol rd, rs1, rs2 |
✓ |
||||
✓ |
rolw rd, rs1, rs2 |
✓ |
|||||
✓ |
✓ |
ror rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
rori rd, rs1, shamt |
✓ |
||||
✓ |
roriw rd, rs1, shamt |
✓ |
|||||
✓ |
rorw rd, rs1, rs2 |
✓ |
|||||
✓ |
✓ |
bclr rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
bclri rd, rs1, imm |
✓ |
||||
✓ |
✓ |
bext rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
bexti rd, rs1, imm |
✓ |
||||
✓ |
✓ |
binv rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
binvi rd, rs1, imm |
✓ |
||||
✓ |
✓ |
bset rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
bseti rd, rs1, imm |
✓ |
||||
✓ |
✓ |
sext.b rd, rs |
✓ |
||||
✓ |
✓ |
sext.h rd, rs |
✓ |
||||
✓ |
✓ |
sh1add rd, rs1, rs2 |
✓ |
||||
✓ |
sh1add.uw rd, rs1, rs2 |
✓ |
|||||
✓ |
✓ |
sh2add rd, rs1, rs2 |
✓ |
||||
✓ |
sh2add.uw rd, rs1, rs2 |
✓ |
|||||
✓ |
✓ |
sh3add rd, rs1, rs2 |
✓ |
||||
✓ |
sh3add.uw rd, rs1, rs2 |
✓ |
|||||
✓ |
slli.uw rd, rs1, imm |
✓ |
|||||
✓ |
✓ |
xnor rd, rs1, rs2 |
✓ |
||||
✓ |
✓ |
zext.h rd, rs |
✓ |
||||
✓ |
zext.w rd, rs |
✓ |