Reputation: 21655
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
.
Upvotes: 5
Views: 3412
Reputation: 273706
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::ParseIRFile
function, defined in header include/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.
Upvotes: 6