[llvm-dev] Parse LLVM IR using LLVM C API
Bruce Hoult via llvm-dev
llvm-dev at lists.llvm.org
Fri Dec 8 09:39:47 PST 2017
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".
Certainly you can do that with C++ code. With the C API, I don't know.
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.
That's in C++, of course, but you can make a wrapper and export your own
pure C interface to it if you want.
On Fri, Dec 8, 2017 at 6:53 PM, Mahdi Mohammadi via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Hi,
>
> 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.
>
> 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?
>
> Thanks,
> Mahdi
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171208/110b488c/attachment.html>
More information about the llvm-dev
mailing list