Since C bundles mirror the structure of C ++ code, it is usually a good idea to get to know how everything is done in C ++. First you need to start the LLVM Programmer Manual .
ValueRef You specify only Value* in the C code. Here, as described in the manual :
The Value class is the most important class in the LLVM source database. It represents a typed value that can be used (among other things) as an operand to an instruction. There are many different types of Values , for example Constants , Arguments . Even Instructions and Functions Values .
Now, the IRBuilder class is usually used to build base blocks. In C code, this corresponds to the LLVMBuild* family of functions. For example, here is the function signature for creating the sub statement:
LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name);
The first parameter is a reference to the IRBuilder object, the second is the first operand, the third is the second operand, and the last is an optional name for the resulting value. Thus, your example will look something like this (not verified):
LLVMBuilderRef builder = LLVMCreateBuilder(); LLVMPositionBuilderAtEnd(builder, bb); LLVMValueRef lhs = LLVMBuildAdd(builder, LLVMConstInt(LLVMInt32Type(), 1, 0), LLVMConstInt(LLVMInt32Type(), 2, 0), NULL); LLVMValueRef rhs = LLVMBuildAdd(builder, LLVMConstInt(LLVMInt32Type(), 3, 0), LLVMConstInt(LLVMInt32Type(), 4, 0), NULL); LLVMBuildSub(build, lhs, rhs, NULL);
Regarding LLVMGetFirstUse : given Value , you can LLVMGetFirstUse over all the places where it was used. LLVMGetFirstUse gives you an iterator ( LLVMUseRef ) pointing to the use list header, which you can increase ( LLVMGetNextUse ) and dereference ( LLVMGetUser ). See llvm/Use.h .