=== Register allocation example === Rules: * t <- num * mov t,num * t <- var (if var can be stored in reg) * mov t,t_var * t <- Exp1 + Exp2 * t1 <- Exp1 * t2 <- Exp2 * mov t,t1 * add t,t2 * var := Exp (if var can be in reg) * t_var <- Exp Example: y := y+1; x := x + 2 - y; * mov t1,ty ;t1 ty * mov t2,1 ;t1 ty t2 * mov ty,t1 ;t1 ty t2 * add ty,t2 ; ty t2 * mov t3,tx ; ty tx t3 * mov t4,2 ; ty tx t3 t4 * mov t5,t3 ; ty tx t3 t4 * add t5,t4 ; ty tx t4 t5 * mov t6,ty ; ty tx t5 t6 * mov t7,t5 ; tx t6 t7 * sub t7,t6 ; tx t6 t7 * mov tx,t7 ; tx t7 {{mscfordprog:regalloc.png}}