Thank you for yours response :)<div>I know that LLVM Pass was designed to transform IR, but lets focus on an example - LLVM Pass is a function that transform some set of input into output. It can transform IR into graph of lets say strongly connected components and then other passes can use it (that data - not IR) to generate other data OR to manipulate the IR.</div>
<div><br></div><div>So why I can not create passes, that would need data generated by other passes (ie. graph loaded from disk) and then transform it into LLVM IR? I do not see any difference between these cases.</div><div>
Am I wrong?<br><br><div class="gmail_quote">2012/11/17 David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Sat, Nov 17, 2012 at 4:44 AM, Wojciech Daniło<br>
<<a href="mailto:wojtek.danilo.ml@gmail.com">wojtek.danilo.ml@gmail.com</a>> wrote:<br>
> Hi!<br>
> I'm new to LLVM but I've read tons of articles, I want to implement my own<br>
> compiler and I came across a big problem.<br>
> I have several questions, that I cannot answer myself:<br>
><br>
> 1) If I'm writing custom compiler do I have to "hardcode" passes that it<br>
> uses (like in Kaleidoscope example:<br>
> <a href="http://llvm.org/docs/tutorial/LangImpl4.html" target="_blank">http://llvm.org/docs/tutorial/LangImpl4.html</a>) or I have to generate LLVM IR<br>
> and then use the 'opt' tool to run selected passes on generated code?<br>
> I think the solution with opt is not quite good, because the opt tool has to<br>
> parse the LLVM IR (or BC) input file, which is not needed, because we are<br>
> generating it, so we have had it in memory before.<br>
> Maybe there is another better solution allowing for enabling and disabling<br>
> passes in custom compiler with argument options like in opt?<br>
<br>
</div>I believe Clang just hardcodes passes. If you a user wants to<br>
experiment with different pass options they can use the option to<br>
generate LLVM bitcode from Clang then pass that to opt themselves.<br>
<div class="im"><br>
> 2) I want to write compiler that does NOT generate LLVM IR by its own, it<br>
> should simply run one of available module passes and such pass will generate<br>
> LLVM IR.<br>
> The motivation behind this decision is that I want to have a graph (C++<br>
> serialized structure) as compiler input and I want to load this graph as<br>
> pass, run other passes (which will modify this graph) and then run a<br>
> "conversion module pass", which will convert this graph into LLVM IR.<br>
> Additional I want to be able to read several formats and because of that I<br>
> want to load this graph as a pass. (This pass will be of course grouped with<br>
> other "load passes")<br>
<br>
</div>LLVM's pass system is for IR transformations only. Anything else you<br>
want to do you'll have to build separately/in front of LLVM. Once your<br>
other system generates IR, then you can pass it to LLVM.<br>
<div class="im"><br>
><br>
> Could you please tell me what will be the best (most flexible and easy)<br>
> solution to do this, keeping in mind the first question?<br>
><br>
> I have an idea of solution (which does not work completely) - the idea is to<br>
> create an compiler which will initialize the base module and will do nothing<br>
> at all. Then I can use the opt tool with my module passes, which will load,<br>
> modify graph and convert it to LLVM IR (with IRBUilder) - the problem is if<br>
> the opt could be run without input file and if it will handle correctly this<br>
> situation.<br>
><br>
> I was researching very long and I have not found any good answer for these<br>
> problems.<br>
> I would be very thankful for any help!<br>
><br>
</div>> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
</blockquote></div><br></div>