On 2019-09-01 13:22, Johnny Billquist wrote:
On 2019-09-01 09:14, Anders Magnusson wrote:
Den 2019-08-31 kl. 17:58, skrev Johnny Billquist:
On 2019-08-31 16:19, Anders Magnusson wrote:
Saving/restoring regs take the same time whether or not CALLS is
used, so I removed that from the calculation.
AP is never needed, and FP only if VLAs are used (or alloca called).
You mean it is not used? So then the compiler is constantly
computing the offsets from SP? Well, I guess you could definitely
do this, but it's a lot messier.
Well, no. Since SP/FP/AP have the same values during the whole
function execution (modulo VLAs etc...) it's just a matter of which
offset is used.
How can that be?
If I do a
void foo(int x)
{
char foo[x];
}
the compiler have no clue about how much stack it will need.
And before anyone starts screaming that you cannot do this, since
the size have to be a constant known at compile time, this was
changed to be allowed in C11.
Sorry, have to correct myself.
Variable length arrays was introduced as mandatory in C99. C11 moved
them into optional.