Ejemplo n.º 1
0
 public LLVMBasicBlockRef InsertBasicBlock(string Name)
 {
     using (var marshaledName = new MarshaledString(Name))
     {
         return(LLVM.InsertBasicBlock(this, marshaledName));
     }
 }
Ejemplo n.º 2
0
 public bool TryFindFunction(string Name, out LLVMValueRef OutFn)
 {
     using (var marshaledName = new MarshaledString(Name))
         fixed(LLVMValueRef *pOutFn = &OutFn)
         {
             return(LLVM.FindFunction(this, marshaledName, (LLVMOpaqueValue **)pOutFn) == 0);
         }
 }
Ejemplo n.º 3
0
 public LLVMTargetMachineRef CreateTargetMachine(string triple, string cpu, string features, LLVMCodeGenOptLevel level, LLVMRelocMode reloc, LLVMCodeModel codeModel)
 {
     using (var marshaledTriple = new MarshaledString(triple))
         using (var marshaledCPU = new MarshaledString(cpu))
             using (var marshaledFeatures = new MarshaledString(features))
             {
                 return(LLVM.CreateTargetMachine(this, marshaledTriple, marshaledCPU, marshaledFeatures, level, reloc, codeModel));
             }
 }
Ejemplo n.º 4
0
        public LLVMValueRef[] GetNamedMetadataOperands(string Name)
        {
            using (var marshaledName = new MarshaledString(Name))
            {
                var Dest = new LLVMValueRef[LLVM.GetNamedMetadataNumOperands(this, marshaledName)];

                fixed(LLVMValueRef *pDest = Dest)
                {
                    LLVM.GetNamedMetadataOperands(this, marshaledName, (LLVMOpaqueValue **)pDest);
                }

                return(Dest);
            }
        }
Ejemplo n.º 5
0
        public MarshaledStringArray(ReadOnlySpan <string> inputs)
        {
            if (inputs.IsEmpty)
            {
                Count  = 0;
                Values = null;
            }
            else
            {
                Count  = inputs.Length;
                Values = new MarshaledString[Count];

                for (int i = 0; i < Count; i++)
                {
                    Values[i] = new MarshaledString(inputs[i].AsSpan());
                }
            }
        }
Ejemplo n.º 6
0
        public bool TryPrintToFile(string Filename, out string ErrorMessage)
        {
            using (var marshaledFilename = new MarshaledString(Filename))
            {
                sbyte *pErrorMessage;
                var    result = LLVM.PrintModuleToFile(this, marshaledFilename, &pErrorMessage);


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

                return(result == 0);
            }
        }
Ejemplo n.º 7
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);
            }
        }