4 ms·
> when it knows how many GP registers there are But compilers don't know this! They know how many registers there are in the ISA, but not how many there really
by chrisseaton 11y ago
> when it knows how many GP registers there are
But compilers don't know this! They know how many registers there are in the ISA, but not how many there really are in the physical architecture.
Physical architectures map ISA register names into register file locations. It's an abstraction! You can really use a register more than once at the same time because they will be renamed. Your parent is suggesting that we read and write from memory as normal, and just map memory locations into the register file, rather than ISA register names.
Registers may be more of an abstraction than you realise.
(Maybe compilers do know about how large the register rename buffer really is on certain physical chips and take this into account when allocating them. Sounds like something Intel's C compiler might do. I'm not an expert.)
- vardump 11y ago> You can really use a register more than once at the same time because they will be renamed. What do you mean by this? Do you realize register renaming is only done for instruction scheduling purposes, to avoid bubbles in the pipeline?
- Someone 11y agoI guess he refers to pipelining, which sort-of can give you a logical register twice. For example, you may be able write a new value to a register before the instruction writing out the old value has completed.
- chrisseaton 11y agoYes. I'm not an architecture expert but I understand that if you do something like: addl %ebx, %eax movl %eax, foo(%rip) addl %ecx, %eax movl %eax, bar(%rip) Then the second add can start while the first and the first mov are still running, because the logical reuse of eax is independent of the first and so will receive a different entry in the rename buffer. Happy to be confirmed or corrected by someone who knows more.
- marcosdumay 11y agoYes, on AMD64. I'm a big fan of the Mill's idea of a specialized compiler that reencodes a general code into your architecture. It solves this problem, allows for JIT optimization of compiled languages, and is a nice portability layer available for virtualizing other architectures. It also adds a nice layer for malware to hide, but well, we can't have everything.
- monocasa 11y agoYou should look at the AS/400. They've actually been shipping a product using this scheme for almost 40 years.