/* 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.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; }
/* TargetMachine.t -> DataLayout.t */ CAMLprim value llvm_targetmachine_data_layout(value Machine) { CAMLparam1(Machine); CAMLlocal1(DataLayout); /* LLVMGetTargetMachineData returns a pointer owned by the TargetMachine, so it is impossible to wrap it with llvm_alloc_target_data, which assumes that OCaml owns the pointer. */ LLVMTargetDataRef OrigDataLayout; OrigDataLayout = LLVMGetTargetMachineData(TargetMachine_val(Machine)); char* TargetDataCStr; TargetDataCStr = LLVMCopyStringRepOfTargetData(OrigDataLayout); DataLayout = llvm_alloc_data_layout(LLVMCreateTargetData(TargetDataCStr)); LLVMDisposeMessage(TargetDataCStr); CAMLreturn(DataLayout); }
/* TargetMachine.t -> Llvm.PassManager.t -> unit */ CAMLprim value llvm_targetmachine_add_analysis_passes(LLVMPassManagerRef PM, value Machine) { LLVMAddAnalysisPasses(TargetMachine_val(Machine), PM); return Val_unit; }
/* bool -> TargetMachine.t -> unit */ CAMLprim value llvm_targetmachine_set_verbose_asm(value Verb, value Machine) { LLVMSetTargetMachineAsmVerbosity(TargetMachine_val(Machine), Bool_val(Verb)); return Val_unit; }
/* TargetMachine.t -> string */ CAMLprim value llvm_targetmachine_features(value Machine) { return llvm_string_of_message(LLVMGetTargetMachineFeatureString( TargetMachine_val(Machine))); }
/* TargetMachine.t -> string */ CAMLprim value llvm_targetmachine_cpu(value Machine) { return llvm_string_of_message(LLVMGetTargetMachineCPU( TargetMachine_val(Machine))); }
/* TargetMachine.t -> Target.t */ CAMLprim LLVMTargetRef llvm_targetmachine_target(value Machine) { return LLVMGetTargetMachineTarget(TargetMachine_val(Machine)); }
static value llvm_alloc_targetmachine(LLVMTargetMachineRef Machine) { value V = alloc_custom(&llvm_target_machine_ops, sizeof(LLVMTargetMachineRef), 0, 1); TargetMachine_val(V) = Machine; return V; }
static void llvm_finalize_target_machine(value Machine) { LLVMDisposeTargetMachine(TargetMachine_val(Machine)); }
/* TargetMachine.t -> DataLayout.t */ CAMLprim value llvm_targetmachine_data_layout(value Machine) { return llvm_alloc_data_layout(LLVMCreateTargetDataLayout( TargetMachine_val(Machine))); }