private static LLVMValueRef DeclareCxaVoidPointerRtti( LLVMModuleBuilder ModuleBuilder, LLVMModuleRef LLVMModule) { var type = PrimitiveTypes.Void.MakePointerType(PointerKind.TransientPointer); var result = ModuleBuilder.DeclareGlobal(ModuleBuilder.Declare(type), "_ZTIPv"); result.SetGlobalConstant(true); return(result); }
/// <summary> /// Defines the global variable that backs a vtable. /// </summary> /// <param name="Module">The module to declare the global in.</param> /// <param name="Type">The type that owns the vtable.</param> /// <param name="VTableEntryImpls"> /// The list of virtual function pointers in the vtable. /// </param> /// <returns>A vtable global variable.</returns> public static LLVMValueRef DefineVTableGlobal( LLVMModuleBuilder Module, IType Type, LLVMValueRef[] VTableEntryImpls) { var fields = new LLVMValueRef[3]; fields[0] = ConstInt(Int64Type(), Module.GetTypeId(Type), false); fields[1] = ConstInt(Int64Type(), Module.GetTypeIndex(Type), false); fields[2] = ConstArray( PointerType(Int8Type(), 0), VTableEntryImpls); var vtableContents = ConstStruct(fields, false); var vtable = Module.DeclareGlobal( vtableContents.TypeOf(), Type.FullName.ToString() + ".vtable"); vtable.SetGlobalConstant(true); vtable.SetLinkage(LLVMLinkage.LLVMInternalLinkage); vtable.SetInitializer(vtableContents); return(vtable); }