3 ms·
> Which is of course exactly the wrong thing because registers got much faster than RAM. Why not cache the top N words then? Stacks are local to a CPU, so yo
by amelius 4y ago
> Which is of course exactly the wrong thing because registers got much faster than RAM.
Why not cache the top N words then?
Stacks are local to a CPU, so you don't have to deal with coherence.
- nine_k 4y agoIt would be fun to imagine an architecture that would be needed for OoO / speculative execution in presence of a on-die stack (say, a few KB of SRAM). Would it be harder than register renaming? What kind of data structure would it take>
- mgsouth 4y agoA stack is register renaming. Instead of "Register #n" you refer to it as "SP - n". The difference is that it's rebased with every op, and in ops the registers are almost always implied: "ADD" always loads reg #0 and #1, always puts results back in #1, then renames #1 .. n to #0 .. n-1. OoO should handle the continuous renaming OK, I think. ADD + PUSH would add (orig #0, orig #1), place result in orig #1, put new data in new #0, alias new #0 as "SP-0". Only the aliasing would need to be ordered. Maybe it could be part of the decode. As I noted elsewhere, some HP 3000 models had multiple ALUs so some form of OoO.
- kragen 4y agoRenaming is one way to implement a stack, but you can also physically shift the bits around every cycle.
- int_19h 4y agoAn example of this is Intel x87 floating point, although the stack discipline isn't strict there: https://en.wikibooks.org/wiki/X86_Assembly/Floating_Point#FPU_Register_Stack https://en.wikibooks.org/wiki/X86_Assembly/Floating_Point#FP...
- mgsouth 4y agoDone. The HP 3000 "Classic" hardware had 2 to 8 16-bit words of top-of-stack registers. There was only one CPU, so CPU-level coherence wasn't an issue. There were memory caches and sometimes multiple ALUs, that was handled by the microcode pipeline logic. I imagine DMA required some bus snooping. The "hot" area of the stack didn't need to be very deep. Most code loaded a word or two on the stack from some locations in memory, maybe re-used a word on the stack, ran an op which pushed a word back on the stack, and then the result was read or popped & stored back in general memory. Sometimes you'd DUP one of the operands. If you're familiar with HP RPN calculators, it was a lot like that. The HP-41 and -42, for example, only have 4 words for the whole stack.