internal static DebugType GetLLVMDebugType(LLVMDIBuilderRef pBuilder, LLVMMetadataRef pScope, LLVMMetadataRef pFile, SmallType pType) { DebugType t = default; if (!_debugMappings.ContainsKey(pType)) { if (pType.IsArray) { var elementType = GetLLVMDebugType(pBuilder, pScope, pFile, pType.GetElementType()); var value = LLVM.DIBuilderCreateArrayType(pBuilder, elementType.Size, 0, elementType.Value, default); t = new DebugType(elementType.Size + _pointerSize, value); } else if (pType.IsTuple || pType.IsStruct || pType.IsTrait) { ulong size = 0; ulong offset = 0; LLVMMetadataRef type = default; foreach (var f in pType.GetFields()) { var memberType = GetLLVMDebugType(pBuilder, pScope, pFile, f.Type); type = LLVM.DIBuilderCreateMemberType(pBuilder, pScope, f.Name, pFile, 0, memberType.Size, 0, offset, 0, memberType.Value); offset += memberType.Size; } var value = LLVM.DIBuilderCreateStructType(pBuilder, pScope, pType.Name, pFile, 0, 0, 0, 0, default, type);
public WebAssemblyObjectWriter(string objectFilePath, NodeFactory factory, WebAssemblyCodegenCompilation compilation) { _nodeFactory = factory; _objectFilePath = objectFilePath; Module = compilation.Module; DIBuilder = compilation.DIBuilder; }
internal EmittingContext(LLVMModuleRef pModule, LLVMPassManagerRef pPass, bool pEmitDebug) { CurrentModule = pModule; _passManager = pPass; _context = LLVM.GetGlobalContext(); _deferredStatements = new Stack <List <Syntax.SyntaxNode> >(); Builder = LLVM.CreateBuilder(); _emitDebug = pEmitDebug; Locals = new ScopeCache <LocalDefinition>(); AccessStack = new AccessStack <MemberAccess>(); BreakLocations = new AccessStack <LLVMValueRef>(1); if (_emitDebug) { _debugLocations = new Stack <LLVMMetadataRef>(); _debugInfo = Utils.LlvmPInvokes.LLVMCreateDIBuilder(CurrentModule); _debugFile = Utils.LlvmPInvokes.LLVMDIBuilderCreateFile(_debugInfo, "debug", 5, ".", 1); //Set debug version var version = LLVM.MDNode(new LLVMValueRef[] { GetInt(1), //Error on mismatch LLVM.MDString("Debug Info Version", 18), //Constant string. Cannot change. GetInt(3) }); //Debug version LLVM.AddNamedMetadataOperand(CurrentModule, "llvm.module.flags", version); } }
private unsafe void DoDispose() { if (_builder.Handle != IntPtr.Zero) { LLVMSharp.Interop.LLVM.DisposeDIBuilder(_builder); _builder = new LLVMDIBuilderRef(); } }
internal DIBuilder(LLVMModuleRef module) { _builder = module.CreateDIBuilder(); Int32Type = CreateBasicType("int", 32, LLVMDWARFTypeEncoding.signed, LLVMDIFlags.LLVMDIFlagZero); }
public static extern LLVMMetadataRef LLVMDIBuilderCreateFile(LLVMDIBuilderRef @Builder, [MarshalAs(UnmanagedType.LPStr)] string @Filename, size_t @FilenameLen, [MarshalAs(UnmanagedType.LPStr)] string @Directory, size_t @DirectoryLen);
public static extern LLVMMetadataRef LLVMDIBuilderCreateCompileUnit(LLVMDIBuilderRef @Builder, LLVMDWARFSourceLanguage @Lang, LLVMMetadataRef @FileRef, [MarshalAs(UnmanagedType.LPStr)] string @Producer, size_t @ProducerLen, LLVMBool @isOptimized, [MarshalAs(UnmanagedType.LPStr)] string @Flags, size_t @FlagsLen, uint @RuntimeVer, [MarshalAs(UnmanagedType.LPStr)] string @SplitName, size_t @SplitNameLen, LLVMDWARFEmissionKind @Kind, uint @DWOId, LLVMBool @SplitDebugInlining, LLVMBool @DebugInfoForProfiling);
public static extern LLVMMetadataRef LLVMDIBuilderCreateParameterVariable(LLVMDIBuilderRef @Builder, LLVMMetadataRef @Scope, [MarshalAs(UnmanagedType.LPStr)] string @Name, uint @ArgNo, LLVMMetadataRef @File, uint @Line, LLVMMetadataRef @Ty, int AlwaysPreserve, uint Flags);