1/*===-- scalar_opts_ocaml.c - LLVM Ocaml Glue -------------------*- C++ -*-===*\ 2|* *| 3|* The LLVM Compiler Infrastructure *| 4|* *| 5|* This file is distributed under the University of Illinois Open Source *| 6|* License. See LICENSE.TXT for details. *| 7|* *| 8|*===----------------------------------------------------------------------===*| 9|* *| 10|* This file glues LLVM's ocaml interface to its C interface. These functions *| 11|* are by and large transparent wrappers to the corresponding C functions. *| 12|* *| 13|* Note that these functions intentionally take liberties with the CAMLparamX *| 14|* macros, since most of the parameters are not GC heap objects. *| 15|* *| 16\*===----------------------------------------------------------------------===*/ 17 18#include "llvm-c/Transforms/Scalar.h" 19#include "caml/mlvalues.h" 20#include "caml/misc.h" 21 22/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 23CAMLprim value llvm_add_constant_propagation(LLVMPassManagerRef PM) { 24 LLVMAddConstantPropagationPass(PM); 25 return Val_unit; 26} 27 28/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 29CAMLprim value llvm_add_sccp(LLVMPassManagerRef PM) { 30 LLVMAddSCCPPass(PM); 31 return Val_unit; 32} 33 34/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 35CAMLprim value llvm_add_dead_store_elimination(LLVMPassManagerRef PM) { 36 LLVMAddDeadStoreEliminationPass(PM); 37 return Val_unit; 38} 39 40/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 41CAMLprim value llvm_add_aggressive_dce(LLVMPassManagerRef PM) { 42 LLVMAddAggressiveDCEPass(PM); 43 return Val_unit; 44} 45 46/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 47CAMLprim value llvm_add_scalar_repl_aggregation(LLVMPassManagerRef PM) { 48 LLVMAddScalarReplAggregatesPass(PM); 49 return Val_unit; 50} 51 52/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 53CAMLprim value llvm_add_scalar_repl_aggregation_ssa(LLVMPassManagerRef PM) { 54 LLVMAddScalarReplAggregatesPassSSA(PM); 55 return Val_unit; 56} 57 58/* [<Llvm.PassManager.any] Llvm.PassManager.t -> int -> unit */ 59CAMLprim value llvm_add_scalar_repl_aggregation_with_threshold(value threshold, 60 LLVMPassManagerRef PM) { 61 LLVMAddScalarReplAggregatesPassWithThreshold(PM, Int_val(threshold)); 62 return Val_unit; 63} 64 65/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 66CAMLprim value llvm_add_ind_var_simplification(LLVMPassManagerRef PM) { 67 LLVMAddIndVarSimplifyPass(PM); 68 return Val_unit; 69} 70 71/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 72CAMLprim value llvm_add_instruction_combination(LLVMPassManagerRef PM) { 73 LLVMAddInstructionCombiningPass(PM); 74 return Val_unit; 75} 76 77/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 78CAMLprim value llvm_add_licm(LLVMPassManagerRef PM) { 79 LLVMAddLICMPass(PM); 80 return Val_unit; 81} 82 83/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 84CAMLprim value llvm_add_loop_unswitch(LLVMPassManagerRef PM) { 85 LLVMAddLoopUnswitchPass(PM); 86 return Val_unit; 87} 88 89/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 90CAMLprim value llvm_add_loop_unroll(LLVMPassManagerRef PM) { 91 LLVMAddLoopUnrollPass(PM); 92 return Val_unit; 93} 94 95/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 96CAMLprim value llvm_add_loop_rotation(LLVMPassManagerRef PM) { 97 LLVMAddLoopRotatePass(PM); 98 return Val_unit; 99} 100 101/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 102CAMLprim value llvm_add_memory_to_register_promotion(LLVMPassManagerRef PM) { 103 LLVMAddPromoteMemoryToRegisterPass(PM); 104 return Val_unit; 105} 106 107/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 108CAMLprim value llvm_add_memory_to_register_demotion(LLVMPassManagerRef PM) { 109 LLVMAddDemoteMemoryToRegisterPass(PM); 110 return Val_unit; 111} 112 113/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 114CAMLprim value llvm_add_reassociation(LLVMPassManagerRef PM) { 115 LLVMAddReassociatePass(PM); 116 return Val_unit; 117} 118 119/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 120CAMLprim value llvm_add_jump_threading(LLVMPassManagerRef PM) { 121 LLVMAddJumpThreadingPass(PM); 122 return Val_unit; 123} 124 125/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 126CAMLprim value llvm_add_cfg_simplification(LLVMPassManagerRef PM) { 127 LLVMAddCFGSimplificationPass(PM); 128 return Val_unit; 129} 130 131/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 132CAMLprim value llvm_add_tail_call_elimination(LLVMPassManagerRef PM) { 133 LLVMAddTailCallEliminationPass(PM); 134 return Val_unit; 135} 136 137/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 138CAMLprim value llvm_add_gvn(LLVMPassManagerRef PM) { 139 LLVMAddGVNPass(PM); 140 return Val_unit; 141} 142 143/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 144CAMLprim value llvm_add_memcpy_opt(LLVMPassManagerRef PM) { 145 LLVMAddMemCpyOptPass(PM); 146 return Val_unit; 147} 148 149/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 150CAMLprim value llvm_add_loop_deletion(LLVMPassManagerRef PM) { 151 LLVMAddLoopDeletionPass(PM); 152 return Val_unit; 153} 154 155/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 156CAMLprim value llvm_add_loop_idiom(LLVMPassManagerRef PM) { 157 LLVMAddLoopIdiomPass(PM); 158 return Val_unit; 159} 160 161/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 162CAMLprim value llvm_add_lib_call_simplification(LLVMPassManagerRef PM) { 163 LLVMAddSimplifyLibCallsPass(PM); 164 return Val_unit; 165} 166 167/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 168CAMLprim value llvm_add_verifier(LLVMPassManagerRef PM) { 169 LLVMAddVerifierPass(PM); 170 return Val_unit; 171} 172 173/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 174CAMLprim value llvm_add_correlated_value_propagation(LLVMPassManagerRef PM) { 175 LLVMAddCorrelatedValuePropagationPass(PM); 176 return Val_unit; 177} 178 179/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 180CAMLprim value llvm_add_early_cse(LLVMPassManagerRef PM) { 181 LLVMAddEarlyCSEPass(PM); 182 return Val_unit; 183} 184 185/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 186CAMLprim value llvm_add_lower_expect_intrinsic(LLVMPassManagerRef PM) { 187 LLVMAddLowerExpectIntrinsicPass(PM); 188 return Val_unit; 189} 190 191/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 192CAMLprim value llvm_add_type_based_alias_analysis(LLVMPassManagerRef PM) { 193 LLVMAddTypeBasedAliasAnalysisPass(PM); 194 return Val_unit; 195} 196 197/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */ 198CAMLprim value llvm_add_basic_alias_analysis(LLVMPassManagerRef PM) { 199 LLVMAddBasicAliasAnalysisPass(PM); 200 return Val_unit; 201} 202