register allocation: basic blocks, liveness and next use

kphillips <kevin.phillips83@yahoo.com>
Sat, 22 Mar 2008 17:22:06 -0700 (PDT)

          From comp.compilers

Related articles
register allocation: basic blocks, liveness and next use kevin.phillips83@yahoo.com (kphillips) (2008-03-22)
Re: register allocation: basic blocks, liveness and next use gene.ressler@gmail.com (Gene) (2008-03-22)
Re: register allocation: basic blocks, liveness and next use max@gustavus.edu (Max Hailperin) (2008-03-23)
Re: register allocation: basic blocks, liveness and next use max@gustavus.edu (Max Hailperin) (2008-03-23)
Re: register allocation: basic blocks, liveness and next use max@gustavus.edu (Max Hailperin) (2008-03-23)
Re: register allocation: basic blocks, liveness and next use kevin.phillips83@yahoo.com (kphillips) (2008-03-23)
Re: register allocation: basic blocks, liveness and next use gene.ressler@gmail.com (Gene) (2008-03-23)
[3 later articles]
| List of all articles for this month |

From: kphillips <kevin.phillips83@yahoo.com>
Newsgroups: comp.compilers
Date: Sat, 22 Mar 2008 17:22:06 -0700 (PDT)
Organization: Compilers Central
Keywords: registers, code, question
Posted-Date: 22 Mar 2008 20:51:27 EDT

Hi,


I've just implemented register allocation by splitting three address
code instructions into basic blocks, and computing liveness and next
use for each block. I'm assuming that all variables are live at the
end of the block, and all temporaries dead, and move backwards.


This technique works well, except for the following scenario.
Assume the following code segment: print(a(2) + a(-3));


The TAC would be something of this sort:


== Block 1 =========
PUSHPARAM 2
CALL t1 A //call A and store the return value in
t1
== Block 2 =========
PUSHPARAM -3
CALL t2 A
== Block 3 =========
ADD t3 = t1, t2
PRINT t3
=================


The problem is that the temporaries in both block 1 (t1) and block 2
(t2) would be discarded (assumed dead since they are at the end of the
block) and block 3 can't compute the addition.


Am I missing something here?


Many thanks for all your help,
K. Phillips.


p.s. I know about the graph colouring technique, I just want to try
both techniques.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.