/* llmodule -> ExecutionEngine.t */ CAMLprim LLVMExecutionEngineRef llvm_ee_create(LLVMModuleRef M) { LLVMExecutionEngineRef Interp; char *Error; if (LLVMCreateExecutionEngineForModule(&Interp, M, &Error)) llvm_raise(llvm_ee_error_exn, Error); return Interp; }
/* llmodule -> ExecutionEngine.t -> llmodule */ CAMLprim value llvm_ee_remove_module(LLVMModuleRef M, LLVMExecutionEngineRef EE) { LLVMModuleRef RemovedModule; char *Error; if (LLVMRemoveModule(EE, M, &RemovedModule, &Error)) llvm_raise(*caml_named_value("Llvm_executionengine.Error"), Error); return Val_unit; }
/* llmodule -> ExecutionEngine.t */ CAMLprim LLVMExecutionEngineRef llvm_ee_create(LLVMModuleRef M) { LLVMExecutionEngineRef Interp; char *Error; if (LLVMCreateExecutionEngineForModule(&Interp, M, &Error)) llvm_raise(*caml_named_value("Llvm_executionengine.Error"), Error); return Interp; }
/* llmodule -> ExecutionEngine.t -> llmodule */ CAMLprim LLVMModuleRef llvm_ee_remove_module(LLVMModuleRef M, LLVMExecutionEngineRef EE) { LLVMModuleRef RemovedModule; char *Error; if (LLVMRemoveModule(EE, M, &RemovedModule, &Error)) llvm_raise(llvm_ee_error_exn, Error); return RemovedModule; }
/* llmodule -> int -> ExecutionEngine.t */ CAMLprim LLVMExecutionEngineRef llvm_ee_create_jit(LLVMModuleRef M, value OptLevel) { LLVMExecutionEngineRef JIT; char *Error; if (LLVMCreateJITCompilerForModule(&JIT, M, Int_val(OptLevel), &Error)) llvm_raise(llvm_ee_error_exn, Error); return JIT; }
/* llmodule -> llmodule -> Mode.t -> unit */ CAMLprim value llvm_link_modules(LLVMModuleRef Dst, LLVMModuleRef Src, value Mode) { char* Message; if (LLVMLinkModules(Dst, Src, Int_val(Mode), &Message)) llvm_raise(*caml_named_value("Llvm_linker.Error"), Message); return Val_unit; }
/* llmodule -> int -> ExecutionEngine.t */ CAMLprim LLVMExecutionEngineRef llvm_ee_create_jit(LLVMModuleRef M, value OptLevel) { LLVMExecutionEngineRef JIT; char *Error; if (LLVMCreateJITCompilerForModule(&JIT, M, Int_val(OptLevel), &Error)) llvm_raise(*caml_named_value("Llvm_executionengine.Error"), Error); return JIT; }
/* llmoduleprovider -> ExecutionEngine.t */ CAMLprim LLVMExecutionEngineRef llvm_ee_create_fast_jit(LLVMModuleProviderRef MP) { LLVMExecutionEngineRef JIT; char *Error; if (LLVMCreateJITCompiler(&JIT, MP, 1, &Error)) llvm_raise(llvm_ee_error_exn, Error); return JIT; }
/* llmoduleprovider -> ExecutionEngine.t */ CAMLprim LLVMExecutionEngineRef llvm_ee_create_interpreter(LLVMModuleProviderRef MP) { LLVMExecutionEngineRef Interp; char *Error; if (LLVMCreateInterpreter(&Interp, MP, &Error)) llvm_raise(llvm_ee_error_exn, Error); return Interp; }
/* llmodule -> llmodule -> Mode.t -> unit raises Error msg on error */ CAMLprim value llvm_link_modules(LLVMModuleRef Dst, LLVMModuleRef Src, value Mode) { char* Message; if (LLVMLinkModules(Dst, Src, Int_val(Mode), &Message)) llvm_raise(llvm_linker_error_exn, Message); return Val_unit; }
/* string -> Target.t */ CAMLprim LLVMTargetRef llvm_target_by_triple(value Triple) { LLVMTargetRef T; char *Error; if(LLVMGetTargetFromTriple(String_val(Triple), &T, &Error)) llvm_raise(*caml_named_value("Llvm_target.Error"), Error); return T; }
/* string -> Target.t */ CAMLprim LLVMTargetRef llvm_target_by_triple(value Triple) { LLVMTargetRef T; char *Error; if(LLVMGetTargetFromTriple(String_val(Triple), &T, &Error)) llvm_raise(llvm_target_error_exn, Error); return T; }
/* Llvm.llmodule -> CodeGenFileType.t -> string -> TargetMachine.t -> unit */ CAMLprim value llvm_targetmachine_emit_to_file(LLVMModuleRef Module, value FileType, value FileName, value Machine) { char *ErrorMessage; if(LLVMTargetMachineEmitToFile(TargetMachine_val(Machine), Module, String_val(FileName), Int_val(FileType), &ErrorMessage)) { llvm_raise(*caml_named_value("Llvm_target.Error"), ErrorMessage); } return Val_unit; }
/* Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule */ CAMLprim value llvm_get_module_provider(LLVMContextRef C, LLVMMemoryBufferRef MemBuf) { CAMLparam0(); CAMLlocal2(Variant, MessageVal); char *Message; LLVMModuleProviderRef MP; if (LLVMGetBitcodeModuleProviderInContext(C, MemBuf, &MP, &Message)) llvm_raise(llvm_bitreader_error_exn, Message); CAMLreturn((value) MP); }
/* Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule */ CAMLprim value llvm_parse_bitcode(LLVMContextRef C, LLVMMemoryBufferRef MemBuf) { CAMLparam0(); CAMLlocal2(Variant, MessageVal); LLVMModuleRef M; char *Message; if (LLVMParseBitcodeInContext(C, MemBuf, &M, &Message)) llvm_raise(llvm_bitreader_error_exn, Message); CAMLreturn((value) M); }
/* Llvm.llmodule -> CodeGenFileType.t -> TargetMachine.t -> Llvm.llmemorybuffer */ CAMLprim LLVMMemoryBufferRef llvm_targetmachine_emit_to_memory_buffer( LLVMModuleRef Module, value FileType, value Machine) { char *ErrorMessage; LLVMMemoryBufferRef Buffer; if(LLVMTargetMachineEmitToMemoryBuffer(TargetMachine_val(Machine), Module, Int_val(FileType), &ErrorMessage, &Buffer)) { llvm_raise(*caml_named_value("Llvm_target.Error"), ErrorMessage); } return Buffer; }
/* llmodule -> llcompileroption -> ExecutionEngine.t */ CAMLprim LLVMExecutionEngineRef llvm_ee_create_mcjit(LLVMModuleRef M, value OptRecord) { LLVMExecutionEngineRef MCJIT; char *Error; struct LLVMMCJITCompilerOptions Options; LLVMInitializeMCJITCompilerOptions(&Options, sizeof(Options)); Options.OptLevel = Int_val(Field(OptRecord, 0)); Options.CodeModel = Int_val(Field(OptRecord, 1)); Options.NoFramePointerElim = Int_val(Field(OptRecord, 2)); Options.EnableFastISel = Int_val(Field(OptRecord, 3)); Options.MCJMM = NULL; if (LLVMCreateMCJITCompilerForModule(&MCJIT, M, &Options, sizeof(Options), &Error)) llvm_raise(*caml_named_value("Llvm_executionengine.Error"), Error); return MCJIT; }