Let's say I have some data:
int a;
int b;
int c;
int d;
int e;
// etc..
And imagine some long expression, like:
int f = (a * b) + (c * d * e);
Consider that the actual expression could be much longer, where you cannot store all intermediate values in registers.
I am interested in how are intermediate values of "sub-expressions" (say (a * b)
stored, in particular:
-
What is the simplest algorithm to implement, from perspective of development time? If you don't have to use all registers and don't have to optimise anything, if using stack for everything is fine.
-
What methods do mainstream compilers use, say 'gcc'?
-
Any thoughts on an implementation where you have virtual infinite number of registers and once you run out of physical registers the virtual registers get spilled to memory.
-
Any thoughts on an implementation where you allocate your current stack frame into physical registers and once there is no register space anymore you spill the extra stack into the real stack in memory.
Aucun commentaire:
Enregistrer un commentaire