如何获取结构的LLVMTypeRef?

Despite the tag, I'm actually using the llvm-sys Rust library, but I believe the API should be the same.

I'm using LLVM to compile a toy programming language I'm creating. In the RTS library for my language, I have a structure MyStruct. In the emitted LLVM, this becomes

%struct.MyStruct = /* definition of struct */

From the documentation, its unclear how I'm meant to get an LLVMTypeRef corresponding to this structure:

let myStructTypeRef: LLVMTypeRef = /* unsure how to write this code */
let myStructVariable: LLVMValueRef = LLVMBuildAlloca(builder, myStructTypeRef, "myStruct");
评论