<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Mar 18, 2008, at 16:39, Erick Tryzelaar wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">This is the last of the wrapped method calls in order to get the kaleidoscope tutorials to work. In short, this patch adds some new passes, and allows for the builder to be set at the start of a block.<br></blockquote><br></div><div>Erick,</div><div><br class="webkit-block-placeholder"></div><div>Your type qualifiers aren't quite right for the pass bindings; <font class="Apple-style-span" face="Courier">'a PassManager.t</font> uses the closed type model as we've discussed, so you should specify <font class="Apple-style-span" face="Courier">[<PassManager.any] PassManager.t</font>. Please resubmit that part.</div><div><br class="webkit-block-placeholder"></div><div>As for <font class="Apple-style-span" face="Courier">position_at_start</font>, I'd prefer to provide the tools to synthesize that. I've committed C bindings for the APIs I think are necessary.</div><div><br class="webkit-block-placeholder"></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080317/059869.html">http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080317/059869.html</a></blockquote><div><br class="webkit-block-placeholder"></div><div>I think these prototypes make sense for Ocaml bindings:</div><div><br class="webkit-block-placeholder"></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><font class="Apple-style-span" face="Courier"><font class="Apple-style-span" color="#0000FF">val</font> first_instr : llbasicblock -> llvalue option<br><font class="Apple-style-span" color="#0000FF">val</font> last_instr : llbasicblock -> llvalue option<br><font class="Apple-style-span" color="#0000FF">val</font> next_instr : llbasicblock -> llvalue option<br><font class="Apple-style-span" color="#0000FF">val</font> prev_instr : llbasicblock -> llvalue option<br></font></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><font class="Apple-style-span" color="#008040" face="Courier"><br class="webkit-block-placeholder"></font></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><font class="Apple-style-span" face="Courier"><font class="Apple-style-span" color="#008040">(* ... likewise for *_function, *_global, and *_block. *)</font></font></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><font class="Apple-style-span" face="Courier"><br class="webkit-block-placeholder"></font></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><font class="Apple-style-span" face="Courier"><font class="Apple-style-span" color="#008040"><span class="Apple-style-span" style="background-color: transparent;">(* This is strictly redundant to position_before and position_at_end. *)</span></font><br><font class="Apple-style-span" color="#0000FF">val</font> position_builder : llbuilder -> llbasicblock -> llvalue option</font></blockquote><div><br class="webkit-block-placeholder"></div>I considered using exceptions here, but it's not exceptional for these to be blank, and I think raising <font class="Apple-style-span" face="Courier">Not_found</font> is much uglier as a result:<br class="webkit-block-placeholder"><div><div><br class="webkit-block-placeholder"></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><font class="Apple-style-span" face="Courier"><font class="Apple-style-span" color="#008040">(* first_instr : llbasicblock -> llvalue option *)</font></font></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><font class="Apple-style-span" face="Courier"><br class="webkit-block-placeholder"></font></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><font class="Apple-style-span" face="Courier"><font class="Apple-style-span" color="#0000FF">let</font> position_at_start bb b =</font></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><font class="Apple-style-span" face="Courier">  position_builder bb (first_instr bb) b<br><br><font class="Apple-style-span" color="#0000FF">let</font> iter_block bb f =<br>  <font class="Apple-style-span" color="#0000FF">let</font> helper i f =<br>    f i;<br>    <font class="Apple-style-span" color="#0000FF">match</font> next_instr i with<br>    | <i>Some</i> j -> helper j<br>    | <i>None</i> -> ()<br>  <font class="Apple-style-span" color="#0000FF">in</font> helper (first_instr bb) f</font></blockquote><div><div><br class="webkit-block-placeholder"></div></div><div>or</div><div><br class="webkit-block-placeholder"></div><div><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font class="Apple-style-span" face="Courier"><font class="Apple-style-span" color="#008040">(* first_instr : llbasicblock -> llvalue</font></font></blockquote><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font class="Apple-style-span" face="Courier"><font class="Apple-style-span" color="#008040">   @raise Not_found if the basic block is empty. *)</font></font></blockquote><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font class="Apple-style-span" face="Courier"><br class="webkit-block-placeholder"></font></blockquote><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font class="Apple-style-span" face="Courier"><font class="Apple-style-span" color="#0000FF">let</font> position_at_start bb b =</font></blockquote><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font class="Apple-style-span" face="Courier">  <font class="Apple-style-span" color="#0000FF">try</font> position_before (first_instr bb) b</font></blockquote><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font class="Apple-style-span" face="Courier">  <font class="Apple-style-span" color="#0000FF">with</font> <i>Not_found</i> -> position_at_end bb b<br><br><font class="Apple-style-span" color="#0000FF">let</font> iter_block bb f =<br>  <font class="Apple-style-span" color="#0000FF">let</font> helper i f =<br>    f i;</font></blockquote><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font class="Apple-style-span" face="Courier">    <font class="Apple-style-span" color="#008040">(* avoid masking Not_found from f! *)</font></font></blockquote><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span class="Apple-style-span" style="font-family: Courier; ">    <font class="Apple-style-span" color="#0000FF">match</font> <span class="Apple-style-span" style="font-family: 'Trebuchet MS'; "><span class="Apple-style-span" style="font-family: Courier; "><font class="Apple-style-span" color="#0000FF">try</font> <i>Some</i> (next_instr i)<br></span><span class="Apple-style-span" style="font-family: Courier; ">          <font class="Apple-style-span" color="#0000FF">with</font> <i>Not_found</i> -> <i>None<br></i></span></span><font class="Apple-style-span" color="#0000FF">    with<span class="Apple-style-span" style="color: rgb(0, 0, 0); "> <i>Some</i> j -> helper j</span></font></span></blockquote><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font class="Apple-style-span" face="Courier">       | <i>None</i> -> ()</font></blockquote><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font class="Apple-style-span" face="Courier">  <font class="Apple-style-span" color="#0000FF">in</font> helper (first_instr bb) f</font></blockquote><div></div></div><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><br class="webkit-block-placeholder"></div><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Of course, this does penalize the case where the user knows that there is a link in the list, so I could be convinced to go either way. Alternatively, first/last could be exceptional, while next/prev could use options. I'm not strongly opinionated on the matter except that I don't think there's any cause to bind <font class="Apple-style-span" face="Courier">position_builder</font> if <font class="Apple-style-span" face="Courier">first_instr</font> raises.</div><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><br class="webkit-block-placeholder"></div><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">If you can cook up the ocaml bindings on top of those, that would be great. Otherwise, I'll try to get to them sometime this week.</div><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><br class="webkit-block-placeholder"></div><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Thanks Erick!</div><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><br class="webkit-block-placeholder"></div><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; ">— Gordon<br class="Apple-interchange-newline"></span></span></span></span></span></div></span> </div><br></body></html>