I know the title isn't good, but i don't know any other way of saying it.
Let's say i have an array:
%1 = alloca [2 x i32] In LLVM-C, how would i get the type, or in this case, the i32 from %1? the reason i need the variable is to use a 'store' instruction, and i need to convert [2 x i32] to i32*
here is an example:
LLVMTypeRef arrty = LLVMArrayType(LLVMIntTypeInContext(context, 32), 2); LLVMValueRef alloca = LLVMBuildAlloca(builder, arrty, ""); LLVMValueRef gep = LLVMBuildGEP2( builder, LLVMGetAllocatedType(alloca), alloca, [tmp], 1, "" ); LLVMValueRef x = LLVMConstInt(LLVMIntTypeInContext(context, 32), 2, 0); LLVMBuildStore(builder, x, gep); // gep type is [2 x i32]*, i want i32* this would generate to:
%1 = alloca [2 x i32] %2 = gep [2 x i32], [2 x i32]* %1, i32 1 store i32 2, [2 x i32]* %2 but i want it to generate:
%1 = alloca [2 x i32] %2 = gep [2 x i32], [2 x i32]* %1, i32 0, i32 1 store i32 2, i32* %2 Sorry if the example is bad, i had to translate from rust to C.