<div dir="ltr">I want to keep the translation short and simple (My IR doesn't have control flow so it's basically on basic block) that's why I don't want to rely on alloca/load/store.</div><div class="gmail_extra"><br><div class="gmail_quote">2016-02-08 6:08 GMT+01:00 George Burgess IV <span dir="ltr"><<a href="mailto:george.burgess.iv@gmail.com" target="_blank">george.burgess.iv@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi!</div><div><br></div>I don't know what "the right way" to do this is, but is there any reason you're against just using alloca/load/store? That's what clang emits for most locals/parameters/..., and LLVM tends to do a very good job of SSAifying that where it can. :)<div><br><div>George</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Sun, Feb 7, 2016 at 3:00 PM, Paul Peet via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hello,<div><br></div><div>I am currently trying to translate some custom IR to LLVM-IR and came across and issue.</div><div>The custom IR has several registers and I am basically try to SSAfy it so it can be easily translated/converted to LLVM-IR.</div><div><br></div><div>The problem:</div><div><br></div><div>Since in my custom IR I can reassign every register I have to reassign every new expression with a new llvm Value. But my IR has something like this:</div><div><br></div><div>REG A = VAR C + CONST 2</div><div>REG A = CONST 12</div><div><br></div><div>So my workaround looks like:</div><div><br></div><div>; I am returning the registers in an anonymous struct</div><div><div>define { i32, i32, i32 } @test(i32 %var_c) {</div><div> ; Initializing registers</div><div> %reg_a_0 = select i1 true, i32 0, i32 0</div><div> %reg_b_0 = select i1 true, i32 0, i32 0</div><div> %reg_c_0 = select i1 true, i32 0, i32 0</div><div><br></div><div> ; Translated instructions</div><div> %reg_a_1 = add i32 %var_c, 2</div><div> %reg_a_2 = select i1 true, i32 12, i32 0</div><div><br></div><div> ; Prepare return values</div><div> %ret_0 = insertvalue { i32, i32, i32 } undef, i32 %reg_a_2, 0</div><div> %ret_1 = insertvalue { i32, i32, i32 } %ret_0, i32 %reg_b_0, 1</div><div> %ret_2 = insertvalue { i32, i32, i32 } %ret_1, i32 %reg_c_0, 2</div><div> </div><div> ret { i32, i32, i32 } %ret_2</div><div>}</div></div><div><br></div><div>I am basically using "select i1 true, i32 1, i32 0" so after optimization it gets:</div><div>%val = i32 1</div><div><br></div><div>But as I said this looks like a hack to me and I can't simply use "%val = i32 1".</div><div>So what's the proper way to do this without actually using alloca/load/store.</div><div><br></div><div>Regards,</div><div>Paul</div></div>
<br></div></div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br></div>