compiler construction - Convert 3 Address codes in Assembly -
i trying convert 3 address codes in assembly code [code generation].
consider,
the assembly code sequence is:
if order changed t2 t3 t1 t4, then
add
done memory operand + register operandsub
never done memory operand. similarly, have seenmul
never done memory operand. there rule ?why
mov r0,t1
used? isn't better use 1 more register , keep usingr0
?bring
t1
down,t2-t3-t1-t4
new sequence , save instructions i.e. can use reg keeps value oft1
in next instruction. use register after immediate instruction have store in memory?
typically, operands have involve @ least 1 register cannot, example, subtract t1 t2 directly. therefore, have move op1 register , apply operation op2 - result going register. in case, e-t1 cannot used register (it's on wrong side of operand) whereas t1-e could.
one alternative negate , add t1 used without resorting memory. so:
mov a, r0 add b, r0 ; t1 (r0) := a+b mov c, r1 add d, r1 ; t2 (r1) := c+d neg r1 add e, r1 ; t3 (r1) := e+(-t2) neg r1 add r0, r1 ; t4 (r1) := t1+(-t3)
Comments
Post a Comment