[LLVMdev] convert LLVM IR to another IR without SSA

Diego Novillo dnovillo at google.com
Fri Apr 24 13:19:01 PDT 2015


On Fri, Apr 24, 2015 at 3:17 PM, Xiangyang Guo <xguo6 at ncsu.edu> wrote:

> Hi,
>
> I want to convert LLVM IR to another type of IR, which has no SSA form. So
> the most important thing I need to handle is Phi node and register
> allocation because another type of IR has a limitation of virtual register
> number. The first thing I can think about is to learn how LLVM Backend
> works because LLVM Backend handles these things. But I'm not familiar with
> Backend. After reading some source code and online tutorials, I think a
> Backend is too much for my purpose. I really appreciate that if someone can
> give me hints.
>

The easiest way to think about PHI nodes is to consider them copies on CFG
edges.  If you do the naive translation of inserting a copy instruction on
the corresponding edge for each PHI argument, you'll get a rough
approximation for the corresponding normal form.

This is, of course, very inefficient, but it's the main idea.

If you can look at GCC's source code, take a look at the algorithm in file
gcc/tree-outof-ssa.c.  That implements an SSA->Normal transformation. I'm
not really sure where in the LLVM's backend this is done.


Diego.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150424/6d9f2835/attachment.html>


More information about the llvm-dev mailing list