650 B
650 B
Code Generation 2
Stack Machine
Consider two instructions
push iadd i
It is not efficient because all stack is considered as memory (which is slower than register).
Utilizing Register Files
Keep the top of the stack in a register, so add requires only a single memory access.
acc <- ipush accpopadd
Code Generation From Stack Machine
Assume that stack grows towards lower addresses.
MIPS
32 regs
$sp, $a0, $t1
lwaddswaddilimv
Converting Stack to MIPS ISA
acc <- ili $a0 i
Optimizing
Branch
beq $1 $2 lbl
b lbl