2008/12/4 Diego Novillo <[EMAIL PROTECTED]>: > On Thu, Dec 4, 2008 at 11:20, John Freeman <[EMAIL PROTECTED]> wrote: >> There are documented methods of SSA decomposition. The naive method is a >> simple reversal of SSA composition: >> >> SSA composition: rename variables (typically by adding suffix), add phi >> nodes >> SSA decomposition: rename variables (by dropping suffix), remove phi nodes >> >> The short answer to your question is that there is no C equivalent of a phi >> node. You simply drop it. > > That's only true if the program was not rewritten into SSA form or no > overlapping live ranges in SSA names exist. > > If the program was rewritten into SSA and different SSA names for the > same symbol have overlapping live ranges (due to code motion and copy > propagation mostly), then dropping the PHIs gives you an invalid > program. You have to convert the PHIs into copies. > > If the SSA form you use is simply a factored use-def representation, > then dropping the PHIs is fine, of course. GCC uses both forms: local > scalars are rewritten into SSA. Memory symbols (arrays, aggregates, > aliased symbols) are represented with a FUD web. > > > Diego. >
The actual task I am doing is transforming a .o file back to a .c file. The aim is only that the resulting .c can be recompiled and functionally perform identically to the original .o file. I have done the work so far that converts the .o file back to a form of SSA contained in a bi-directional tree so it is easy to step forwards and backwards through a particular branch of the tree. I started using a method I thought I invented of renaming the variable each time it changed. I ran into the problem of what to do when program joins two branches. I searched and found that SSA is essentially the same problem. So, I wanted to use SSA so that the resulting .c file would be able to better describe the scope of use of each variable so the observer could easily see that variable X is a temporary one, only used in loop X, for example. So, I think the solution is therefore to only rename the variables contained in the Phi statement. a3 = $(a1, a2); would result in all instances of a1 to be renamed to a3, and all instances of a2 to be renamed to a3. I can see problems with this approach, but they only occur when complexity increases, so I will cross that bridge when I come to it. I am just doing a proof of concept at the moment and have written 30 sample .o files that I would like my tool to be able to process. Kind Regards James