<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Apr 16, 2013 at 10:09 AM, bob zhang <span dir="ltr"><<a href="mailto:bobzhang1988@gmail.com" target="_blank">bobzhang1988@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br></div><div class="gmail_extra">
Thanks for your reply.<br></div><div class="gmail_extra"><div class="gmail_quote"><div class="im">On Mon, Apr 15, 2013 at 9:15 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>On Mon, Apr 15, 2013 at 3:32 PM, Hongbo Zhang <<a href="mailto:bobzhang1988@gmail.com" target="_blank">bobzhang1988@gmail.com</a>> wrote:<br>


> Hi all,<br>
>    I am trying to compile my toy language to LLVM back end. (I am new to<br>
> LLVM, so my questions may sound naive)<br>
>    I am looking at some tutorials about LLVM, most are about how to use LLVM<br>
> IRBuilder, however, I find the API provided by IRBuilder is quite imperative<br>
> and verbose, and the API changes so fast that most of the tutorials are out<br>
> of dated.<br>
>    So I am wondering what's the benefit of emitting LLVM IR using IRBuilder<br>
> compared with designing my own abstract syntax in a high-level programming<br>
> language(e.g. Haskell or OCaml) and unparsing it to LLVM IR.<br>
<br>
</div>To be clear you're suggesting having your frontend (say, for<br>
argument's sake, written in C++) parse your toy language and then emit<br>
a (say) Haskell representation of IR? Using some Haskell APIs you'll<br>
write that will emit LLVM bitcode? And then running the resulting<br>
Haskell program to produce your bitcode that you'll load back in to<br>
LLVM to optimize/compile?<br>
<div><br></div></blockquote></div><div> Yes, that's what I am doing, in OCaml though. Functional languages are excellent <br></div><div>for program transformation and manipulation. Where is the specification for the bitcode format?<br>
</div></div></div></div></blockquote><div><br></div><div><a href="http://llvm.org/docs/BitCodeFormat.html">http://llvm.org/docs/BitCodeFormat.html</a></div><div><br></div><div style>-- Sean Silva</div></div></div></div>