<div dir="ltr">Hi, Diego,<div><br></div><div>Thanks for your quick reply. Inserting a copy instruction may not work here because I have a limitation of virtual register number. I need to assign registers with ssa form to registers without ssa form. I will look the source code you point out.</div><div><br></div><div>Thanks</div><div><br></div><div>Xiangyang</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 24, 2015 at 4:19 PM, Diego Novillo <span dir="ltr"><<a href="mailto:dnovillo@google.com" target="_blank">dnovillo@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Fri, Apr 24, 2015 at 3:17 PM, Xiangyang Guo <span dir="ltr"><<a href="mailto:xguo6@ncsu.edu" target="_blank">xguo6@ncsu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>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. </div></div></blockquote><div><br></div></span><div>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.</div><div><br></div><div>This is, of course, very inefficient, but it's the main idea.</div><div><br></div><div>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.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div><br></div><div>Diego.</div></font></span></div></div></div>
</blockquote></div><br></div>