I found it hard to understand the LLVM C++ API.
Is there any relationship between LLVM C++ API and LLVM IR? Also, how could one use the LLVM C++ API?
相关问题
- CMakeList file to generate LLVM bitcode file from
- LLVM OPT not giving optimised file as output.
- Python numba / llvmlite on Debian 8 - i can't
- llvm::DIInstruction getFilename returns filename w
- Specifically what does a compiler do to aggressive
相关文章
- How to clone or create an AST Stmt node of clang?
- Libclang API to get function definitions defined i
- No format security warnings in Xcode 4.4
- LLVM retrieve name of AllocaInst
- In LLVM IR, I want to copy a set of Instructions a
- compiling with clang and plugin
- How to get the filename and directory from a LLVM
- At which level does one unit test lock-free code?
You can use the CPP backend (
llc -march=cpp
) to find out the mapping from any given IR to the C++ API.To (greatly) simplify, LLVM is a C++ library for writing compilers. Its C++ API is the external interface users of the library employ to implement their compiler.
There's a degree of symmetry between LLVM IR and part of the LLVM C++ API - the part used to build IR. A very good resource for getting a feel for this symmetry is http://llvm.org/demo/. For example, you can compile this C code:
Into LLVM IR:
As well as to C++ API calls (I won't paste it here because the output is long, but you can try it yourself). Doing this, you'll see, for example the
icmp
instruction from the IR code above done as:ICmpInst
is a class that's part of the C++ API used to createicmp
instructions. A good reference for the C++ API is the Programmer's manual.