Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Differential D136400 Diff 498897 llvm/bindings/ocaml/transforms/passmgr_builder/passmgr_builder_ocaml.c
Changeset View
Changeset View
Standalone View
Standalone View
llvm/bindings/ocaml/transforms/passmgr_builder/passmgr_builder_ocaml.c
Show All 9 Lines | |||||
|* This file glues LLVM's OCaml interface to its C interface. These functions *| | |* This file glues LLVM's OCaml interface to its C interface. These functions *| | ||||
|* are by and large transparent wrappers to the corresponding C functions. *| | |* are by and large transparent wrappers to the corresponding C functions. *| | ||||
|* *| | |* *| | ||||
|* Note that these functions intentionally take liberties with the CAMLparamX *| | |* Note that these functions intentionally take liberties with the CAMLparamX *| | ||||
|* macros, since most of the parameters are not GC heap objects. *| | |* macros, since most of the parameters are not GC heap objects. *| | ||||
|* *| | |* *| | ||||
\*===----------------------------------------------------------------------===*/ | \*===----------------------------------------------------------------------===*/ | ||||
#include "llvm-c/Transforms/PassManagerBuilder.h" | |||||
#include "caml/mlvalues.h" | |||||
#include "caml/custom.h" | #include "caml/custom.h" | ||||
#include "caml/memory.h" | |||||
#include "caml/misc.h" | #include "caml/misc.h" | ||||
#include "caml/mlvalues.h" | |||||
#include "llvm_ocaml.h" | |||||
#include "llvm-c/Transforms/PassManagerBuilder.h" | |||||
#define PMBuilder_val(v) (*(LLVMPassManagerBuilderRef *)(Data_custom_val(v))) | #define PMBuilder_val(v) (*(LLVMPassManagerBuilderRef *)(Data_custom_val(v))) | ||||
static void llvm_finalize_pmbuilder(value PMB) { | static void llvm_finalize_pmbuilder(value PMB) { | ||||
LLVMPassManagerBuilderDispose(PMBuilder_val(PMB)); | LLVMPassManagerBuilderDispose(PMBuilder_val(PMB)); | ||||
} | } | ||||
static struct custom_operations pmbuilder_ops = { | static struct custom_operations pmbuilder_ops = { | ||||
(char *)"Llvm_passmgr_builder.t", llvm_finalize_pmbuilder, | (char *)"Llvm_passmgr_builder.t", llvm_finalize_pmbuilder, | ||||
custom_compare_default, custom_hash_default, | custom_compare_default, custom_hash_default, | ||||
custom_serialize_default, custom_deserialize_default, | custom_serialize_default, custom_deserialize_default, | ||||
custom_compare_ext_default}; | custom_compare_ext_default}; | ||||
static value alloc_pmbuilder(LLVMPassManagerBuilderRef Ref) { | static value alloc_pmbuilder(LLVMPassManagerBuilderRef Ref) { | ||||
value Val = | value Val = caml_alloc_custom(&pmbuilder_ops, | ||||
alloc_custom(&pmbuilder_ops, sizeof(LLVMPassManagerBuilderRef), 0, 1); | sizeof(LLVMPassManagerBuilderRef), 0, 1); | ||||
PMBuilder_val(Val) = Ref; | PMBuilder_val(Val) = Ref; | ||||
return Val; | return Val; | ||||
} | } | ||||
/* t -> unit */ | /* t -> unit */ | ||||
value llvm_pmbuilder_create(value Unit) { | value llvm_pmbuilder_create(value Unit) { | ||||
return alloc_pmbuilder(LLVMPassManagerBuilderCreate()); | return alloc_pmbuilder(LLVMPassManagerBuilderCreate()); | ||||
} | } | ||||
Show All 27 Lines | |||||
/* bool -> t -> unit */ | /* bool -> t -> unit */ | ||||
value llvm_pmbuilder_set_disable_unroll_loops(value DisableUnroll, value PMB) { | value llvm_pmbuilder_set_disable_unroll_loops(value DisableUnroll, value PMB) { | ||||
LLVMPassManagerBuilderSetDisableUnrollLoops(PMBuilder_val(PMB), | LLVMPassManagerBuilderSetDisableUnrollLoops(PMBuilder_val(PMB), | ||||
Bool_val(DisableUnroll)); | Bool_val(DisableUnroll)); | ||||
return Val_unit; | return Val_unit; | ||||
} | } | ||||
/* [ `Function ] Llvm.PassManager.t -> t -> unit */ | /* [ `Function ] Llvm.PassManager.t -> t -> unit */ | ||||
value llvm_pmbuilder_populate_function_pass_manager(LLVMPassManagerRef PM, | value llvm_pmbuilder_populate_function_pass_manager(value PM, value PMB) { | ||||
value PMB) { | LLVMPassManagerBuilderPopulateFunctionPassManager(PMBuilder_val(PMB), | ||||
LLVMPassManagerBuilderPopulateFunctionPassManager(PMBuilder_val(PMB), PM); | PassManager_val(PM)); | ||||
return Val_unit; | return Val_unit; | ||||
} | } | ||||
/* [ `Module ] Llvm.PassManager.t -> t -> unit */ | /* [ `Module ] Llvm.PassManager.t -> t -> unit */ | ||||
value llvm_pmbuilder_populate_module_pass_manager(LLVMPassManagerRef PM, | value llvm_pmbuilder_populate_module_pass_manager(value PM, value PMB) { | ||||
value PMB) { | LLVMPassManagerBuilderPopulateModulePassManager(PMBuilder_val(PMB), | ||||
LLVMPassManagerBuilderPopulateModulePassManager(PMBuilder_val(PMB), PM); | PassManager_val(PM)); | ||||
return Val_unit; | return Val_unit; | ||||
} | } |