#include "llvm/CodeGen/MachineOperand.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; int main() { MachineOperand MO(MachineOperand::CreateImm(42)); Type* Ty = MO.getType(); errs() << "Type: " << *Ty << "\n"; return 0; }
clang++ -std=c++11 -Ipath/to/llvm/include -Lpath/to/llvm/lib -lLLVMCodeGen -lLLVMCore -lLLVMSupport example.cppOverall, the getType method is useful for analyzing and manipulating machine-level instructions in LLVM-based compilers and tools.