Пример #1
0
 public void EmitToFile(LLVMModuleRef module, string fileName, LLVMCodeGenFileType codegen)
 {
     if (!TryEmitToFile(module, fileName, codegen, out string Error))
     {
         throw new ExternalException(Error);
     }
 }
Пример #2
0
        public static void EmitModule(LLVMExecutionEngineRef ee, LLVMModuleRef mod, LLVMCodeGenFileType fileType, string filename)
        {
            IntPtr error;
            IntPtr ptr = Marshal.StringToHGlobalAnsi(filename);

            LLVM.TargetMachineEmitToFile(LLVM.GetExecutionEngineTargetMachine(ee), mod, ptr, fileType, out error);
            Console.WriteLine(StringifyMessage(error));
        }
Пример #3
0
        public MemoryBuffer EmitToMemoryBuffer(Module m, LLVMCodeGenFileType codegen)
        {
            if (LLVM.TargetMachineEmitToMemoryBuffer(this.Unwrap(), m.Unwrap(), codegen, out IntPtr error, out LLVMMemoryBufferRef buf).Failed())
            {
                TextUtilities.Throw(error);
            }

            return(buf.Wrap());
        }
Пример #4
0
        public bool TryEmitToFile(LLVMModuleRef module, string fileName, LLVMCodeGenFileType codegen, out string message)
        {
            using var marshaledFileName = new MarshaledString(fileName);

            sbyte *errorMessage;
            int    result = LLVM.TargetMachineEmitToFile(this, module, marshaledFileName, codegen, &errorMessage);

            if (errorMessage is null)
            {
                message = string.Empty;
            }
            else
            {
                var span = new ReadOnlySpan <byte>(errorMessage, int.MaxValue);
                message = span.Slice(0, span.IndexOf((byte)'\0')).AsString();
                LLVM.DisposeErrorMessage(errorMessage);
            }

            return(result == 0);
        }
Пример #5
0
 public static extern int TargetMachineEmitToFile(LLVMTargetMachineRef* T, LLVMModuleRef* M, [In][MarshalAs(UnmanagedType.LPStr)] string Filename, LLVMCodeGenFileType codegen, [MarshalAs(UnmanagedType.LPStr)] ref StringBuilder ErrorMessage);
Пример #6
0
        public static LLVMBool TargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T, LLVMModuleRef M, LLVMCodeGenFileType codegen, out string ErrorMessage, out LLVMMemoryBufferRef OutMemBuf)
        {
            var retVal = TargetMachineEmitToMemoryBuffer(T, M, codegen, out IntPtr message, out OutMemBuf);

            ErrorMessage = message != IntPtr.Zero && retVal.Value != 0 ? Marshal.PtrToStringAnsi(message) : null;
            DisposeMessage(message);
            return(retVal);
        }
Пример #7
0
        public static LLVMBool TargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M, IntPtr Filename, LLVMCodeGenFileType codegen, out string ErrorMessage)
        {
            var retVal = TargetMachineEmitToFile(T, M, Filename, codegen, out IntPtr message);

            ErrorMessage = message != IntPtr.Zero && retVal.Value != 0 ? Marshal.PtrToStringAnsi(message) : null;
            DisposeMessage(message);
            return(retVal);
        }
Пример #8
0
 public static extern LLVMBool TargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef @T, LLVMModuleRef @M, LLVMCodeGenFileType @codegen, out IntPtr @ErrorMessage, out LLVMMemoryBufferRef @OutMemBuf);
Пример #9
0
 public static extern LLVMBool TargetMachineEmitToFile(LLVMTargetMachineRef @T, LLVMModuleRef @M, IntPtr @Filename, LLVMCodeGenFileType @codegen, out IntPtr @ErrorMessage);
Пример #10
0
 public bool EmitToFile(Module m, IntPtr filename, LLVMCodeGenFileType codegen, out IntPtr errorMessage) => LLVM.TargetMachineEmitToFile(this.Unwrap(), m.Unwrap(), filename, codegen, out errorMessage);
Пример #11
0
 public static extern LLVMBool TargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M, IntPtr Filename, LLVMCodeGenFileType codegen, out IntPtr ErrorMessage);
Пример #12
0
 public bool TryEmitToFile(LLVMModuleRef module, string fileName, LLVMCodeGenFileType codegen, out string message) => TryEmitToFile(module, fileName.AsSpan(), codegen, out message);
Пример #13
0
 public void EmitToFile(LLVMModuleRef module, string fileName, LLVMCodeGenFileType codegen) => EmitToFile(module, fileName.AsSpan(), codegen);