Search code examples
c++llvmllvm-c++-api

Where can I find what C++ API correspond to what llvm commands?


What is a general way to look at LLVM and find the corresponding calls in the C++ API? For example, I have the logical and instruction which corresponds to the Language reference here. How can I find a corresponding C++ API reference? My general approach would be to put "llvm add instruction C++ API" into a search engine, but this isn't consistently useful.


Solution

  • Usually for an someinst instruction there is a SomeInstInst class. For instance, alloca is implemented by AllocaInst.

    But not for add, that's what confused you. Binary arithmetic and logical instructions are implemented using single class called BinaryOperator.

    Another exception is a phi instruction - it is implemented in the PHINode class. Other than that, figuring what class you need should be pretty straightforward.