为什么没有处理器有非对称寄存器?
Why do no processors have asymmetric registers?
我遇到的所有 CPU 架构都有对称寄存器 - 即您读取的值就是您写入的值。
对于寄存器限制的 16 位指令,是否存在非对称寄存器的情况?
例如
- 寄存器 0-6 是 "local" 函数调用。在此函数调用中写入的值是将要读取的值。每一级函数调用都有自己的寄存器硬件,因此局部寄存器被隐式保存。
- 寄存器 7-9 是 "global",在 SMP CPU 上可能是 "thread local"。
- 写入 "call" 寄存器 10-13 的值不影响从中读取的内容 在此函数调用上下文。
- 从 "call" 寄存器 10-13 读取的值是写入调用函数的值,即函数的寄存器参数是不可变的。
- 写入 "return" 寄存器 14-15 的值不影响在此函数调用上下文中从中读取的值。
- 从 "return" 寄存器 14-15 中读取的值是写入最近返回到当前函数的函数中的值。
每个函数级别的寄存器都有自己的硬件,仅当调用深度超过硬件时才会溢出到堆栈。
(local) (global) ( call ) (ret)
global regset 07 .. 09
.
.
.
. | | ^ ^
. v v | |
regsetN-1 00 .. 06 10 .. 13 14 15
|^ |^ | | ^ ^
v| v| v v | |
fnN-1 RW RW RW RW RW RW
| | ^ ^
v v | |
regsetN 00 .. 06 10 .. 13 14 15
|^ |^ | | ^ ^
v| v| v v | |
fnN RW RW RW RW RW RW
| | ^ ^
v v | |
regsetN+1 00 .. 06 10 .. 13 14 15
|^ |^ | | ^ ^
v| v| v v | |
像这样的方案会减少两个或更多寄存器在每个函数调用中的寄存器压力吗?
我并不期待这是一个新想法,但我很想知道它是否已经完成,如果没有,为什么不呢?如果这不是一个疯狂的想法,或者已经完成,我可以在 FPGA 上实现它 CPU。
是不是太复杂了,不值得为寄存器省钱?
llvm 的困难是没有完成的主要原因吗?
P.S。我知道超标量处理器已经比这复杂得多,具有寄存器重命名方案等。我只是在思考微控制器-class 架构。
更新:看起来 SPARC 架构就是这样做的。为什么后来的 ISA 设计者认为它没有用?
When a procedure is called, the register window shifts by sixteen registers, hiding the old input registers and old local registers and making the old output registers the new input registers.
SPARC 的寄存器 windows 就是这样工作的。虽然单独看来是个好主意,但与系统其余部分的交互会降低整体系统性能。
来自http://ieng9.ucsd.edu/~cs30x/sparcstack.html
That was the idea, anyway. The drawback is that upon interactions with the system the registers need to be flushed to the stack, necessitating a long sequence of writes to memory of data that is often mostly garbage. Register windows was a bad idea that was caused by simulation studies that considered only programs in isolation, as opposed to multitasking workloads, and by considering compilers with poor optimization. It also caused considerable problems in implementing high-end Sparc processors such as the SuperSparc, although more recent implementations have dealt effectively with the obstacles. Register windows is now part of the compatibility legacy and not easily removed from the architecture.
我遇到的所有 CPU 架构都有对称寄存器 - 即您读取的值就是您写入的值。
对于寄存器限制的 16 位指令,是否存在非对称寄存器的情况?
例如
- 寄存器 0-6 是 "local" 函数调用。在此函数调用中写入的值是将要读取的值。每一级函数调用都有自己的寄存器硬件,因此局部寄存器被隐式保存。
- 寄存器 7-9 是 "global",在 SMP CPU 上可能是 "thread local"。
- 写入 "call" 寄存器 10-13 的值不影响从中读取的内容 在此函数调用上下文。
- 从 "call" 寄存器 10-13 读取的值是写入调用函数的值,即函数的寄存器参数是不可变的。
- 写入 "return" 寄存器 14-15 的值不影响在此函数调用上下文中从中读取的值。
- 从 "return" 寄存器 14-15 中读取的值是写入最近返回到当前函数的函数中的值。
每个函数级别的寄存器都有自己的硬件,仅当调用深度超过硬件时才会溢出到堆栈。
(local) (global) ( call ) (ret)
global regset 07 .. 09
.
.
.
. | | ^ ^
. v v | |
regsetN-1 00 .. 06 10 .. 13 14 15
|^ |^ | | ^ ^
v| v| v v | |
fnN-1 RW RW RW RW RW RW
| | ^ ^
v v | |
regsetN 00 .. 06 10 .. 13 14 15
|^ |^ | | ^ ^
v| v| v v | |
fnN RW RW RW RW RW RW
| | ^ ^
v v | |
regsetN+1 00 .. 06 10 .. 13 14 15
|^ |^ | | ^ ^
v| v| v v | |
像这样的方案会减少两个或更多寄存器在每个函数调用中的寄存器压力吗?
我并不期待这是一个新想法,但我很想知道它是否已经完成,如果没有,为什么不呢?如果这不是一个疯狂的想法,或者已经完成,我可以在 FPGA 上实现它 CPU。
是不是太复杂了,不值得为寄存器省钱?
llvm 的困难是没有完成的主要原因吗?
P.S。我知道超标量处理器已经比这复杂得多,具有寄存器重命名方案等。我只是在思考微控制器-class 架构。
更新:看起来 SPARC 架构就是这样做的。为什么后来的 ISA 设计者认为它没有用?
When a procedure is called, the register window shifts by sixteen registers, hiding the old input registers and old local registers and making the old output registers the new input registers.
SPARC 的寄存器 windows 就是这样工作的。虽然单独看来是个好主意,但与系统其余部分的交互会降低整体系统性能。
来自http://ieng9.ucsd.edu/~cs30x/sparcstack.html
That was the idea, anyway. The drawback is that upon interactions with the system the registers need to be flushed to the stack, necessitating a long sequence of writes to memory of data that is often mostly garbage. Register windows was a bad idea that was caused by simulation studies that considered only programs in isolation, as opposed to multitasking workloads, and by considering compilers with poor optimization. It also caused considerable problems in implementing high-end Sparc processors such as the SuperSparc, although more recent implementations have dealt effectively with the obstacles. Register windows is now part of the compatibility legacy and not easily removed from the architecture.