I have LLVM IR code in text format. What I wanna do is to be able to parse it and modify that code. Is there an API which can help in parsing the LLVM IR code? What libraries should I have in my system? At this moment I have clang compiler installed as well LLVM, as I can use commands such as llc, opt and llvm-link.
I have LLVM IR code in text format. What I wanna do is to
Share
LLVM is primarily a C++ library. It has all the tools you can imagine to parse, manipulate and produce IR in both textual and bitcode (binary) formats.
To get started, take a look at the
llvm::ParseIRFilefunction, defined in headerinclude/llvm/Support/IRReader.h.The best way to proceed would be to download the LLVM source code and build it, following these instructions. It’s then easy to write your own code that uses the LLVM libraries.