Skip to content

Commit

Permalink
[OCaml] Synchronize transformations with LLVM-C.
Browse files Browse the repository at this point in the history
Also, rearrange the functions in a way that allows to quickly
compare C headers and .mli/glue files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220842 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
whitequark committed Oct 29, 2014
1 parent 68a70cd commit 360c7ed
Show file tree
Hide file tree
Showing 12 changed files with 507 additions and 408 deletions.
10 changes: 2 additions & 8 deletions bindings/ocaml/transforms/ipo/ipo_ocaml.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ CAMLprim value llvm_add_always_inliner(LLVMPassManagerRef PM) {
return Val_unit;
}

/* [`Module] Llvm.PassManager.t -> unit */
CAMLprim value llvm_add_always_inliner_pass(LLVMPassManagerRef PM) {
LLVMAddAlwaysInlinerPass(PM);
return Val_unit;
}

/* [`Module] Llvm.PassManager.t -> unit */
CAMLprim value llvm_add_global_dce(LLVMPassManagerRef PM) {
LLVMAddGlobalDCEPass(PM);
Expand All @@ -74,7 +68,7 @@ CAMLprim value llvm_add_global_optimizer(LLVMPassManagerRef PM) {
}

/* [`Module] Llvm.PassManager.t -> unit */
CAMLprim value llvm_add_ipc_propagation(LLVMPassManagerRef PM) {
CAMLprim value llvm_add_ip_constant_propagation(LLVMPassManagerRef PM) {
LLVMAddIPConstantPropagationPass(PM);
return Val_unit;
}
Expand All @@ -91,7 +85,7 @@ CAMLprim value llvm_add_ipsccp(LLVMPassManagerRef PM) {
return Val_unit;
}

/* [`Module] Llvm.PassManager.t -> bool -> unit */
/* [`Module] Llvm.PassManager.t -> all_but_main:bool -> unit */
CAMLprim value llvm_add_internalize(LLVMPassManagerRef PM, value AllButMain) {
LLVMAddInternalizePass(PM, Bool_val(AllButMain));
return Val_unit;
Expand Down
70 changes: 42 additions & 28 deletions bindings/ocaml/transforms/ipo/llvm_ipo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,45 @@
*
*===----------------------------------------------------------------------===*)

external add_argument_promotion : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_argument_promotion"
external add_constant_merge : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_constant_merge"
external add_dead_arg_elimination :
[ | `Module ] Llvm.PassManager.t -> unit = "llvm_add_dead_arg_elimination"
external add_function_attrs : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_function_attrs"
external add_function_inlining : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_function_inlining"
external add_always_inliner : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_always_inliner"
external add_global_dce : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_global_dce"
external add_global_optimizer : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_global_optimizer"
external add_ipc_propagation : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_ipc_propagation"
external add_prune_eh : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_prune_eh"
external add_ipsccp : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_ipsccp"
external add_internalize : [ | `Module ] Llvm.PassManager.t -> bool -> unit =
"llvm_add_internalize"
external add_strip_dead_prototypes :
[ | `Module ] Llvm.PassManager.t -> unit = "llvm_add_strip_dead_prototypes"
external add_strip_symbols : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_strip_symbols"
external add_argument_promotion
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_argument_promotion"
external add_constant_merge
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_constant_merge"
external add_dead_arg_elimination
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_dead_arg_elimination"
external add_function_attrs
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_function_attrs"
external add_function_inlining
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_function_inlining"
external add_always_inliner
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_always_inliner"
external add_global_dce
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_global_dce"
external add_global_optimizer
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_global_optimizer"
external add_ipc_propagation
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_ip_constant_propagation"
external add_prune_eh
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_prune_eh"
external add_ipsccp
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_ipsccp"
external add_internalize
: [ `Module ] Llvm.PassManager.t -> all_but_main:bool -> unit
= "llvm_add_internalize"
external add_strip_dead_prototypes
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_strip_dead_prototypes"
external add_strip_symbols
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_strip_symbols"
124 changes: 69 additions & 55 deletions bindings/ocaml/transforms/ipo/llvm_ipo.mli
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,72 @@
This interface provides an OCaml API for LLVM interprocedural optimizations, the
classes in the [LLVMIPO] library. *)

(** See llvm::createAddArgumentPromotionPass *)
external add_argument_promotion : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_argument_promotion"

(** See llvm::createConstantMergePass function. *)
external add_constant_merge : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_constant_merge"

(** See llvm::createDeadArgEliminationPass function. *)
external add_dead_arg_elimination :
[ | `Module ] Llvm.PassManager.t -> unit = "llvm_add_dead_arg_elimination"

(** See llvm::createFunctionAttrsPass function. *)
external add_function_attrs : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_function_attrs"

(** See llvm::createFunctionInliningPass function. *)
external add_function_inlining : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_function_inlining"

(** See llvm::createAlwaysInlinerPass function. *)
external add_always_inliner : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_always_inliner"

(** See llvm::createGlobalDCEPass function. *)
external add_global_dce : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_global_dce"

(** See llvm::createGlobalOptimizerPass function. *)
external add_global_optimizer : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_global_optimizer"

(** See llvm::createIPConstantPropagationPass function. *)
external add_ipc_propagation : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_ipc_propagation"

(** See llvm::createPruneEHPass function. *)
external add_prune_eh : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_prune_eh"

(** See llvm::createIPSCCPPass function. *)
external add_ipsccp : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_ipsccp"

(** See llvm::createInternalizePass function. *)
external add_internalize : [ | `Module ] Llvm.PassManager.t -> bool -> unit =
"llvm_add_internalize"

(** See llvm::createStripDeadPrototypesPass function. *)
external add_strip_dead_prototypes :
[ | `Module ] Llvm.PassManager.t -> unit = "llvm_add_strip_dead_prototypes"

(** See llvm::createStripSymbolsPass function. *)
external add_strip_symbols : [ | `Module ] Llvm.PassManager.t -> unit =
"llvm_add_strip_symbols"
(** See the [llvm::createAddArgumentPromotionPass] function. *)
external add_argument_promotion
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_argument_promotion"

(** See the [llvm::createConstantMergePass] function. *)
external add_constant_merge
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_constant_merge"

(** See the [llvm::createDeadArgEliminationPass] function. *)
external add_dead_arg_elimination
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_dead_arg_elimination"

(** See the [llvm::createFunctionAttrsPass] function. *)
external add_function_attrs
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_function_attrs"

(** See the [llvm::createFunctionInliningPass] function. *)
external add_function_inlining
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_function_inlining"

(** See the [llvm::createAlwaysInlinerPass] function. *)
external add_always_inliner
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_always_inliner"

(** See the [llvm::createGlobalDCEPass] function. *)
external add_global_dce
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_global_dce"

(** See the [llvm::createGlobalOptimizerPass] function. *)
external add_global_optimizer
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_global_optimizer"

(** See the [llvm::createIPConstantPropagationPass] function. *)
external add_ipc_propagation
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_ip_constant_propagation"

(** See the [llvm::createPruneEHPass] function. *)
external add_prune_eh
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_prune_eh"

(** See the [llvm::createIPSCCPPass] function. *)
external add_ipsccp
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_ipsccp"

(** See the [llvm::createInternalizePass] function. *)
external add_internalize
: [ `Module ] Llvm.PassManager.t -> all_but_main:bool -> unit
= "llvm_add_internalize"

(** See the [llvm::createStripDeadPrototypesPass] function. *)
external add_strip_dead_prototypes
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_strip_dead_prototypes"

(** See the [llvm::createStripSymbolsPass] function. *)
external add_strip_symbols
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_strip_symbols"
20 changes: 10 additions & 10 deletions bindings/ocaml/transforms/passmgr_builder/llvm_passmgr_builder.mli
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,41 @@

type t

(** See [llvm::PassManagerBuilder]. *)
(** See the [llvm::PassManagerBuilder] function. *)
external create : unit -> t
= "llvm_pmbuilder_create"

(** See [llvm::PassManagerBuilder::OptLevel]. *)
(** See the [llvm::PassManagerBuilder::OptLevel] function. *)
external set_opt_level : int -> t -> unit
= "llvm_pmbuilder_set_opt_level"

(** See [llvm::PassManagerBuilder::SizeLevel]. *)
(** See the [llvm::PassManagerBuilder::SizeLevel] function. *)
external set_size_level : int -> t -> unit
= "llvm_pmbuilder_set_size_level"

(** See [llvm::PassManagerBuilder::DisableUnitAtATime]. *)
(** See the [llvm::PassManagerBuilder::DisableUnitAtATime] function. *)
external set_disable_unit_at_a_time : bool -> t -> unit
= "llvm_pmbuilder_set_disable_unit_at_a_time"

(** See [llvm::PassManagerBuilder::DisableUnrollLoops]. *)
(** See the [llvm::PassManagerBuilder::DisableUnrollLoops] function. *)
external set_disable_unroll_loops : bool -> t -> unit
= "llvm_pmbuilder_set_disable_unroll_loops"

(** See [llvm::PassManagerBuilder::Inliner]. *)
(** See the [llvm::PassManagerBuilder::Inliner] function. *)
external use_inliner_with_threshold : int -> t -> unit
= "llvm_pmbuilder_use_inliner_with_threshold"

(** See [llvm::PassManagerBuilder::populateFunctionPassManager]. *)
(** See the [llvm::PassManagerBuilder::populateFunctionPassManager] function. *)
external populate_function_pass_manager
: [ `Function ] Llvm.PassManager.t -> t -> unit
= "llvm_pmbuilder_populate_function_pass_manager"

(** See [llvm::PassManagerBuilder::populateModulePassManager]. *)
(** See the [llvm::PassManagerBuilder::populateModulePassManager] function. *)
external populate_module_pass_manager
: [ `Module ] Llvm.PassManager.t -> t -> unit
= "llvm_pmbuilder_populate_module_pass_manager"

(** See [llvm::PassManagerBuilder::populateLTOPassManager]. *)
(** See the [llvm::PassManagerBuilder::populateLTOPassManager] function. *)
external populate_lto_pass_manager
: [ `Module ] Llvm.PassManager.t -> internalize:bool -> run_inliner:bool -> t -> unit
= "llvm_pmbuilder_populate_lto_pass_manager"
= "llvm_pmbuilder_populate_lto_pass_manager"
Loading

0 comments on commit 360c7ed

Please sign in to comment.