notesonly.in

One notebook for every subject — open it anywhere.

Log in

Code generation and register allocation

Compiler Design · Engineering

Study notes

Generate code for 't1 = b + c' on x86 with b,c in memory: mov eax, [b]; add eax, [c]; mov [t1], eax. Register allocation decided eax holds t1: liveness analysis showed b dead after, so its register was reused. With 20 live variables and 8 registers, 12 spill to stack with load/store around uses.

← Back to topics for Engineering