Liste des Groupes | Revenir à c arch |
On 4/9/2024 1:24 PM, Thomas Koenig wrote:I wrote:
MitchAlsup1 <mitchalsup@aol.com> schrieb:Maybe one more thing: In order to justify the more complex encoding,Thomas Koenig wrote:
>
I was going for 64 registers, and that didn't work out too well
(missing bits).
Having learned about M-Core in the meantime, pure 32-register,
21-bit instruction ISA might actually work better.
For 32-bit instructions at least, 64 GPRs can work out OK.
Though, the gain of 64 over 32 seems to be fairly small for most "typical" code, mostly bringing a benefit if one is spending a lot of CPU time in functions that have large numbers of local variables all being used at the same time.
Seemingly:
16/32/48 bit instructions, with 32 GPRs, seems likely optimal for code density;
32/64/96 bit instructions, with 64 GPRs, seems likely optimal for performance.
Where, 16 GPRs isn't really enough (lots of register spills), and 128 GPRs is wasteful (would likely need lots of monster functions with 250+ local variables to make effective use of this, *, which probably isn't going to happen).16 GPRs would be "almost" enough if IP, SP, FP, TLS, GOT were not part of GPRs AND you have good access to constants.
*: Where, it appears it is most efficient (for non-leaf functions) if the number of local variables is roughly twice that of the number of CPU registers. If more local variables than this, then spill/fill rate goes up significantly, and if less, then the registers aren't utilized as effectively.
Well, except in "tiny leaf" functions, where the criteria is instead that the number of local variables be less than the number of scratch registers. However, for many/most small leaf functions, the total number of variables isn't all that large either.The vast majority of leaf functions use less than 16 GPRs, given one has
Where, function categories:You are forgetting about FP, GOT, TLS, and whatever resources are required
Tiny Leaf:
Everything fits in scratch registers, no stack frame, no calls.
Leaf:
No function calls (either explicit or implicit);
Will have a stack frame.
Non-Leaf:
May call functions, has a stack frame.
There is a "static assign everything" case in my case, where all of the variables are statically assigned to registers (for the scope of the function). This case typically requires that everything fit into callee save registers, so (like the "tiny leaf" category, requires that the number of local variables is less than the available registers).
On a 32 register machine, if there are 14 available callee-save registers, the limit is 14 variables. On a 64 register machine, this limit might be 30 instead. This seems to have good coverage.The apparent number of registers goes up when one does not waste a register
Les messages affichés proviennent d'usenet.