RISCV RV32IM:MULHSU - 哪个操作数是带符号的?

RISCV RV32IM: MULHSU - which operand is the signed one?

问题

在risc-v RV32IM中,对于指令MULHSU,操作数rs1rs2中哪个是有符号操作数?

背景

RISC-V指令集手册 第一卷:非特权 ISA 文档版本 20190608-Base-Ratified 说以下内容(靠近第 43 页底部):

MULH, MULHU, and MULHSU perform the same multiplication but return the upper XLEN bits of the full 2 × XLEN-bit product, for signed × signed, unsigned × unsigned, and signed rs1 × unsigned rs2 multiplication, respectively.

所以这表明带符号的操作数是 rs1。 但是解释性说明(第43页底部)说:

MULHSU is used in multi-word signed multiplication to multiply the most-significant word of the multiplier (which contains the sign bit) with the less-significant words of the multiplicand (which are unsigned).

来自指令的定义(也是第 43 页):

 31    25 24      20 19         15 14          12 11  7 6      0
+--------+----------+-------------+--------------+-----+--------+
| funct7 | rs2      | rs1         | funct3       | rd  | opcode |
+--------+----------+-------------+--------------+-----+--------+
  7        5          5             3              5     7
  MULDIV   multiplier multiplicand  MUL/MUL[[S]U]  dest  OP

我看到乘数是rs2。所以解释说明带符号的操作数是rs2

我认为图表或 "explicatory note" 有错字。我的所有测试都显示 rs1 已签名,而 rs2 未签名 MULHSU。

可以找到更全面的指令格式和伪代码摘要 here. More detail of pseudo-instructions and other things to help write assembly code for RISC-V can be found here(同一网站)。它的文档具体表达 MULHSU 如下:

MULHSU rd, rs1, rs2     #rd ← (sx(rs1) × ux(rs2)) » xlen 

其中 sx(r) 表示签名版本,ux(r) 表示未签名版本。

如果您发现任何证据表明情况并非如此,请告诉我。

与riscv基金会沟通后:rs1是有符号操作数。 参见 https://github.com/riscv/riscv-isa-manual/issues/463