<div dir="ltr">I assume you mean "use your own code to parse some text representation of LLVM IR and then use the LLVM API to create the appropriate data stuctures".<div><br></div><div>Certainly you can do that with C++ code. With the C API, I don't know.</div><div><br></div><div>But it's probably easier to use something like the parseAssemblyInto() function in include/llvm/AsmParser/Parser.h. You pass it a memory buffer containing IR text to be parsed, and a Module (possibly empty, possibly one your compiler has already added things to) to insert the parsed items into.</div><div><br></div><div>That's in C++, of course, but you can make a wrapper and export your own pure C interface to it if you want.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 8, 2017 at 6:53 PM, Mahdi Mohammadi 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><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">Hi,</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">I'm writing a compiler and I am thinking of mixing LLVM IR inside the source code I'm compiling. So user can write normal code and write some functions using LLVM IR.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Is it possible to use LLVM C API to parse those sections of the source code and convert them into `LLVMValueRef`s pointing to parsed functions?</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Thanks,</div><div class="gmail_default" style="font-family:tahoma,sans-serif">Mahdi</div></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">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/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>