简体   繁体   English

为什么RV64引入了32位操作的新操作码而不是64位操作

[英]Why did RV64 introduce new opcodes for 32-bit operations instead of the 64-bit ones

While going through the RISC-V Specification I've noticed that the 64-bit version differs from the 32-bit one in the fact, that it 在通过RISC-V规范时,我注意到64位版本与32位版本的不同之处在于它

  1. Widened the registers to 64-bit 将寄存器扩展为64位
  2. Changed the instructions to act on the whole 64-bit range. 更改了指令以在整个64位范围内执行操作。
  3. Added new instruction to perform 32-bit operations 添加了执行32位操作的新指令

This makes RV32 code incompatible to RV64. 这使RV32代码与RV64不兼容。 However if the 64-bit version had been implemented by: 但是,如果64位版本已通过以下方式实现:

  1. Widening the registers to 64-bit 将寄存器扩展为64位
  2. Renaming ADD/SUB/SHL/.. to ADDW/SUBW/SHLW/.. and keep them operating only on 32-bit with sign extend. ADD/SUB/SHL/..重命名为ADDW/SUBW/SHLW/..并使它们仅在符号扩展的32位上运行。
  3. Add new instructions ADD/SUB/SHL/.. or ADDD/SUBD/SHLD/.. to act on the full 64-bit 添加新指令ADD/SUB/SHL/..ADDD/SUBD/SHLD/..以对完整的64位进行操作

This would have allowed RV32 programs to run on RV64 as well. 这样就可以让RV32程序在RV64上运行。 For implementing the CPU the effort would remain the same since in both cases the 64-bit and the 32-bit instructions would have to be implemented and only the opcodes for the 64-bit and the 32-bit versions would have been swapped in contrast to the specification. 为了实现CPU,工作量将保持不变,因为在这两种情况下都必须实现64位和32位指令,并且只有64位和32位版本的操作码才会被交换对比符合规范。 (Except maybe for the multiply instruction.) (除了可能是乘法指令。)

So why did RISC-V decided to assign new opcodes to the 32-bit operations instead of to the 64-bit operations in RV64? 那么为什么RISC-V决定将新的操作码分配给32位操作而不是RV64中的64位操作呢?

The RV64 and RV32 are quite compatible. RV64和RV32完全兼容。 If the program don't rely on implicit modulo 32-bit arithmetic and all addresses fit into 32-bit, the machine code could be the same. 如果程序不依赖于隐式模32位算术且所有地址都适合32位,则机器代码可能相同。 However it is very easy to add complete RV32 user mode to RV64 processor. 但是,将完整的RV32用户模式添加到RV64处理器非常容易。

The 64-bit superset of RV32 would be too complicated. RV32的64位超集太复杂了。 There are not enough opcode space for AUIPC, JAL, LOAD, STORE and BRANCH. AUIPC,JAL,LOAD,STORE和BRANCH没有足够的操作码空间。 It is worse with additional extensions. 附加扩展会更糟糕。

The few 32-bit instructions in RV64 are mostly for programs overusing modulo 32-bit arithmetic. RV64中的少数32位指令主要用于过度使用模32位算术的程序。 This is very common problem. 这是非常常见的问题。 The fast and portable code should avoid them, though. 但是,快速和可移植的代码应该避免使用它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM