diff --git a/bindings/ocaml/transforms/scalar/llvm_scalar_opts.ml b/bindings/ocaml/transforms/scalar/llvm_scalar_opts.ml index b4563b716a8..5699152b5a9 100644 --- a/bindings/ocaml/transforms/scalar/llvm_scalar_opts.ml +++ b/bindings/ocaml/transforms/scalar/llvm_scalar_opts.ml @@ -10,9 +10,38 @@ external add_constant_propagation : [ unit = "llvm_add_constant_propagation" -external add_instruction_combining : [ unit - = "llvm_add_instruction_combining" +external add_sccp : [ unit + = "llvm_add_sccp" +external add_dead_store_elimination : [ unit + = "llvm_add_dead_store_elimination" +external add_aggressive_dce : [ unit + = "llvm_add_aggressive_dce" +external +add_scalar_repl_aggregation : [ unit + = "llvm_add_scalar_repl_aggregation" +external add_ind_var_simplification : [ unit + = "llvm_add_ind_var_simplification" +external +add_instruction_combination : [ unit + = "llvm_add_instruction_combination" +external add_licm : [ unit + = "llvm_add_licm" +external add_loop_unswitch : [ unit + = "llvm_add_loop_unswitch" +external add_loop_unroll : [ unit + = "llvm_add_loop_unroll" +external add_loop_rotation : [ unit + = "llvm_add_loop_rotation" +external add_loop_index_split : [ unit + = "llvm_add_loop_index_split" external add_memory_to_register_promotion : [ unit @@ -21,12 +50,26 @@ external add_memory_to_register_demotion : [ unit = "llvm_add_memory_to_register_demotion" -external add_reassociation : [ unit +external add_reassociation : [ unit = "llvm_add_reassociation" -external add_gvn : [ unit - = "llvm_add_gvn" +external add_jump_threading : [ unit + = "llvm_add_jump_threading" external add_cfg_simplification : [ unit = "llvm_add_cfg_simplification" +external +add_tail_call_elimination : [ unit + = "llvm_add_tail_call_elimination" +external add_gvn : [ unit + = "llvm_add_gvn" +external add_memcpy_opt : [ unit + = "llvm_add_memcpy_opt" +external add_loop_deletion : [ unit + = "llvm_add_loop_deletion" +external +add_lib_call_simplification : [ unit + = "llvm_add_lib_call_simplification" diff --git a/bindings/ocaml/transforms/scalar/llvm_scalar_opts.mli b/bindings/ocaml/transforms/scalar/llvm_scalar_opts.mli index 6fcce0432d7..9f95fbce9f8 100644 --- a/bindings/ocaml/transforms/scalar/llvm_scalar_opts.mli +++ b/bindings/ocaml/transforms/scalar/llvm_scalar_opts.mli @@ -17,10 +17,59 @@ external add_constant_propagation : [ unit = "llvm_add_constant_propagation" +(** See the [llvm::createSCCPPass] function. *) +external add_sccp : [ unit + = "llvm_add_sccp" + +(** See [llvm::createDeadStoreEliminationPass] function. *) +external add_dead_store_elimination : [ unit + = "llvm_add_dead_store_elimination" + +(** See The [llvm::createAggressiveDCEPass] function. *) +external add_aggressive_dce : [ unit + = "llvm_add_aggressive_dce" + +(** See the [llvm::createScalarReplAggregatesPass] function. *) +external +add_scalar_repl_aggregation : [ unit + = "llvm_add_scalar_repl_aggregation" + +(** See the [llvm::createIndVarSimplifyPass] function. *) +external add_ind_var_simplification : [ unit + = "llvm_add_ind_var_simplification" + (** See the [llvm::createInstructionCombiningPass] function. *) -external add_instruction_combining : [ unit - = "llvm_add_instruction_combining" +external +add_instruction_combination : [ unit + = "llvm_add_instruction_combination" + +(** See the [llvm::createLICMPass] function. *) +external add_licm : [ unit + = "llvm_add_licm" + +(** See the [llvm::createLoopUnswitchPass] function. *) +external add_loop_unswitch : [ unit + = "llvm_add_loop_unswitch" + +(** See the [llvm::createLoopUnrollPass] function. *) +external add_loop_unroll : [ unit + = "llvm_add_loop_unroll" + +(** See the [llvm::createLoopRotatePass] function. *) +external add_loop_rotation : [ unit + = "llvm_add_loop_rotation" + +(** See the [llvm::createLoopIndexSplitPass] function. *) +external add_loop_index_split : [ unit + = "llvm_add_loop_index_split" (** See the [llvm::createPromoteMemoryToRegisterPass] function. *) external @@ -35,16 +84,40 @@ add_memory_to_register_demotion : [ unit +external add_reassociation : [ unit = "llvm_add_reassociation" +(** See the [llvm::createJumpThreadingPass] function. *) +external add_jump_threading : [ unit + = "llvm_add_jump_threading" + +(** See the [llvm::createCFGSimplificationPass] function. *) +external add_cfg_simplification : [ unit + = "llvm_add_cfg_simplification" + +(** See the [llvm::createTailCallEliminationPass] function. *) +external +add_tail_call_elimination : [ unit + = "llvm_add_tail_call_elimination" + (** See the [llvm::createGVNPass] function. *) external add_gvn : [ unit = "llvm_add_gvn" -(** See the [llvm::createCFGSimplificationPass] function. *) -external add_cfg_simplification : [ unit - = "llvm_add_cfg_simplification" +(** See the [llvm::createMemCpyOptPass] function. *) +external add_memcpy_opt : [ unit + = "llvm_add_memcpy_opt" + +(** See the [llvm::createLoopDeletionPass] function. *) +external add_loop_deletion : [ unit + = "llvm_add_loop_deletion" + +(** See the [llvm::createSimplifyLibCallsPass] function. *) +external +add_lib_call_simplification : [ unit + = "llvm_add_lib_call_simplification" diff --git a/bindings/ocaml/transforms/scalar/scalar_opts_ocaml.c b/bindings/ocaml/transforms/scalar/scalar_opts_ocaml.c index 87c10609843..c20bdde5753 100644 --- a/bindings/ocaml/transforms/scalar/scalar_opts_ocaml.c +++ b/bindings/ocaml/transforms/scalar/scalar_opts_ocaml.c @@ -26,11 +26,71 @@ CAMLprim value llvm_add_constant_propagation(LLVMPassManagerRef PM) { } /* [ unit */ -CAMLprim value llvm_add_instruction_combining(LLVMPassManagerRef PM) { +CAMLprim value llvm_add_sccp(LLVMPassManagerRef PM) { + LLVMAddSCCPPass(PM); + return Val_unit; +} + +/* [ unit */ +CAMLprim value llvm_add_dead_store_elimination(LLVMPassManagerRef PM) { + LLVMAddDeadStoreEliminationPass(PM); + return Val_unit; +} + +/* [ unit */ +CAMLprim value llvm_add_aggressive_dce(LLVMPassManagerRef PM) { + LLVMAddAggressiveDCEPass(PM); + return Val_unit; +} + +/* [ unit */ +CAMLprim value llvm_add_scalar_repl_aggregation(LLVMPassManagerRef PM) { + LLVMAddScalarReplAggregatesPass(PM); + return Val_unit; +} + +/* [ unit */ +CAMLprim value llvm_add_ind_var_simplification(LLVMPassManagerRef PM) { + LLVMAddIndVarSimplifyPass(PM); + return Val_unit; +} + +/* [ unit */ +CAMLprim value llvm_add_instruction_combination(LLVMPassManagerRef PM) { LLVMAddInstructionCombiningPass(PM); return Val_unit; } +/* [ unit */ +CAMLprim value llvm_add_licm(LLVMPassManagerRef PM) { + LLVMAddLICMPass(PM); + return Val_unit; +} + +/* [ unit */ +CAMLprim value llvm_add_loop_unswitch(LLVMPassManagerRef PM) { + LLVMAddLoopUnrollPass(PM); + return Val_unit; +} + +/* [ unit */ +CAMLprim value llvm_add_loop_unroll(LLVMPassManagerRef PM) { + LLVMAddLoopUnrollPass(PM); + return Val_unit; +} + +/* [ unit */ +CAMLprim value llvm_add_loop_rotation(LLVMPassManagerRef PM) { + LLVMAddLoopRotatePass(PM); + return Val_unit; +} + +/* [ unit */ +CAMLprim value llvm_add_loop_index_split(LLVMPassManagerRef PM) { + LLVMAddLoopIndexSplitPass(PM); + return Val_unit; +} + /* [ unit */ CAMLprim value llvm_add_memory_to_register_promotion(LLVMPassManagerRef PM) { LLVMAddPromoteMemoryToRegisterPass(PM); @@ -50,8 +110,8 @@ CAMLprim value llvm_add_reassociation(LLVMPassManagerRef PM) { } /* [ unit */ -CAMLprim value llvm_add_gvn(LLVMPassManagerRef PM) { - LLVMAddGVNPass(PM); +CAMLprim value llvm_add_jump_threading(LLVMPassManagerRef PM) { + LLVMAddJumpThreadingPass(PM); return Val_unit; } @@ -60,3 +120,33 @@ CAMLprim value llvm_add_cfg_simplification(LLVMPassManagerRef PM) { LLVMAddCFGSimplificationPass(PM); return Val_unit; } + +/* [ unit */ +CAMLprim value llvm_add_tail_call_elimination(LLVMPassManagerRef PM) { + LLVMAddTailCallEliminationPass(PM); + return Val_unit; +} + +/* [ unit */ +CAMLprim value llvm_add_gvn(LLVMPassManagerRef PM) { + LLVMAddGVNPass(PM); + return Val_unit; +} + +/* [ unit */ +CAMLprim value llvm_add_memcpy_opt(LLVMPassManagerRef PM) { + LLVMAddMemCpyOptPass(PM); + return Val_unit; +} + +/* [ unit */ +CAMLprim value llvm_add_loop_deletion(LLVMPassManagerRef PM) { + LLVMAddLoopDeletionPass(PM); + return Val_unit; +} + +/* [ unit */ +CAMLprim value llvm_add_lib_call_simplification(LLVMPassManagerRef PM) { + LLVMAddSimplifyLibCallsPass(PM); + return Val_unit; +} diff --git a/test/Bindings/Ocaml/scalar_opts.ml b/test/Bindings/Ocaml/scalar_opts.ml index 1b488c5b021..f28eff28da7 100644 --- a/test/Bindings/Ocaml/scalar_opts.ml +++ b/test/Bindings/Ocaml/scalar_opts.ml @@ -37,11 +37,28 @@ let test_transforms () = ignore (PassManager.create_function m ++ TargetData.add td - ++ add_instruction_combining - ++ add_reassociation - ++ add_gvn - ++ add_cfg_simplification ++ add_constant_propagation + ++ add_sccp + ++ add_dead_store_elimination + ++ add_aggressive_dce + ++ add_scalar_repl_aggregation + ++ add_ind_var_simplification + ++ add_instruction_combination + ++ add_licm + ++ add_loop_unswitch + ++ add_loop_unroll + ++ add_loop_rotation + ++ add_loop_index_split + ++ add_memory_to_register_promotion + ++ add_memory_to_register_demotion + ++ add_reassociation + ++ add_jump_threading + ++ add_cfg_simplification + ++ add_tail_call_elimination + ++ add_gvn + ++ add_memcpy_opt + ++ add_loop_deletion + ++ add_lib_call_simplification ++ PassManager.initialize ++ PassManager.run_function fn ++ PassManager.finalize