コード例 #1
0
        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);
コード例 #2
0
 public WebAssemblyObjectWriter(string objectFilePath, NodeFactory factory, WebAssemblyCodegenCompilation compilation)
 {
     _nodeFactory    = factory;
     _objectFilePath = objectFilePath;
     Module          = compilation.Module;
     DIBuilder       = compilation.DIBuilder;
 }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
ファイル: DIBuilder.cs プロジェクト: sfuller/MonC
 private unsafe void DoDispose()
 {
     if (_builder.Handle != IntPtr.Zero)
     {
         LLVMSharp.Interop.LLVM.DisposeDIBuilder(_builder);
         _builder = new LLVMDIBuilderRef();
     }
 }
コード例 #5
0
ファイル: DIBuilder.cs プロジェクト: sfuller/MonC
 internal DIBuilder(LLVMModuleRef module)
 {
     _builder  = module.CreateDIBuilder();
     Int32Type = CreateBasicType("int", 32, LLVMDWARFTypeEncoding.signed, LLVMDIFlags.LLVMDIFlagZero);
 }
コード例 #6
0
 public static extern LLVMMetadataRef LLVMDIBuilderCreateFile(LLVMDIBuilderRef @Builder, [MarshalAs(UnmanagedType.LPStr)] string @Filename, size_t @FilenameLen, [MarshalAs(UnmanagedType.LPStr)] string @Directory, size_t @DirectoryLen);
コード例 #7
0
 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);
コード例 #8
0
ファイル: LLVMPInvokes.cs プロジェクト: btbaggin/SmallerLang
 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);