<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Aug 11, 2008, at 2:02 PM, Benedict Gaster wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div> <font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt">We would like to develop a code generator using LLVM for a target language that does not support conditional branches and in fact only supports structured control flow, eg. If and while. </span></font></div></blockquote><div><br></div><div>What's the difference between an "if" and a conditional branch?</div><br><blockquote type="cite"><div><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt">As far as I can tell that the problem with doing this in LLVM today, is that it does not support these high-level constructs and instead all control flow is implemented as branches. <br> <br> It is “fairly” straightforward to restructure a program written with conditional/unconditional branches into to one that uses completely high-level control flow structures, the algorithm I have in mind is described in [1], the problem is how to best represent the resulting IL within the LLVM framework:<br> <br> </span></font><ol><li><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt">Extend LLVM with news ops to support if/loop. </span></font></li><li><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt">Implement this with the insertion of intrinsics to represent high-level control-flow, introducing “false” dependencies if necessary to allow optimizations to be applied without changing the semantics. </span></font></li><li><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt">Implement some structure of to the side that represents this high-level flow.<br> </span></font></li></ol><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt"><br> Thoughts?<br></span></font></div></blockquote></div><br><div>One downside of this is that it means eliminating all instances of irreducible control flow, which can lead to an exponential increase in code size.</div><div><br></div><div>--Owen</div></body></html>