1 /*===-- scalar_opts_ocaml.c - LLVM OCaml Glue -------------------*- C++ -*-===*\
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
5 |* See https://llvm.org/LICENSE.txt for license information. *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
8 |*===----------------------------------------------------------------------===*|
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. *|
13 |* Note that these functions intentionally take liberties with the CAMLparamX *|
14 |* macros, since most of the parameters are not GC heap objects. *|
16 \*===----------------------------------------------------------------------===*/
18 #include "llvm-c/Transforms/Scalar.h"
19 #include "llvm-c/Transforms/Utils.h"
20 #include "caml/mlvalues.h"
21 #include "caml/misc.h"
23 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
24 CAMLprim value
llvm_add_aggressive_dce(LLVMPassManagerRef PM
) {
25 LLVMAddAggressiveDCEPass(PM
);
29 CAMLprim value
llvm_add_dce(LLVMPassManagerRef PM
) {
34 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
35 CAMLprim value
llvm_add_alignment_from_assumptions(LLVMPassManagerRef PM
) {
36 LLVMAddAlignmentFromAssumptionsPass(PM
);
40 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
41 CAMLprim value
llvm_add_cfg_simplification(LLVMPassManagerRef PM
) {
42 LLVMAddCFGSimplificationPass(PM
);
46 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
47 CAMLprim value
llvm_add_dead_store_elimination(LLVMPassManagerRef PM
) {
48 LLVMAddDeadStoreEliminationPass(PM
);
52 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
53 CAMLprim value
llvm_add_scalarizer(LLVMPassManagerRef PM
) {
54 LLVMAddScalarizerPass(PM
);
58 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
59 CAMLprim value
llvm_add_merged_load_store_motion(LLVMPassManagerRef PM
) {
60 LLVMAddMergedLoadStoreMotionPass(PM
);
64 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
65 CAMLprim value
llvm_add_gvn(LLVMPassManagerRef PM
) {
70 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
71 CAMLprim value
llvm_add_ind_var_simplify(LLVMPassManagerRef PM
) {
72 LLVMAddIndVarSimplifyPass(PM
);
76 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
77 CAMLprim value
llvm_add_instruction_combining(LLVMPassManagerRef PM
) {
78 LLVMAddInstructionCombiningPass(PM
);
82 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
83 CAMLprim value
llvm_add_jump_threading(LLVMPassManagerRef PM
) {
84 LLVMAddJumpThreadingPass(PM
);
88 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
89 CAMLprim value
llvm_add_licm(LLVMPassManagerRef PM
) {
94 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
95 CAMLprim value
llvm_add_loop_deletion(LLVMPassManagerRef PM
) {
96 LLVMAddLoopDeletionPass(PM
);
100 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
101 CAMLprim value
llvm_add_loop_idiom(LLVMPassManagerRef PM
) {
102 LLVMAddLoopIdiomPass(PM
);
106 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
107 CAMLprim value
llvm_add_loop_rotate(LLVMPassManagerRef PM
) {
108 LLVMAddLoopRotatePass(PM
);
112 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
113 CAMLprim value
llvm_add_loop_reroll(LLVMPassManagerRef PM
) {
114 LLVMAddLoopRerollPass(PM
);
118 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
119 CAMLprim value
llvm_add_loop_unroll(LLVMPassManagerRef PM
) {
120 LLVMAddLoopUnrollPass(PM
);
124 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
125 CAMLprim value
llvm_add_loop_unswitch(LLVMPassManagerRef PM
) {
126 LLVMAddLoopUnswitchPass(PM
);
130 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
131 CAMLprim value
llvm_add_memcpy_opt(LLVMPassManagerRef PM
) {
132 LLVMAddMemCpyOptPass(PM
);
136 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
137 CAMLprim value
llvm_add_partially_inline_lib_calls(LLVMPassManagerRef PM
) {
138 LLVMAddPartiallyInlineLibCallsPass(PM
);
142 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
143 CAMLprim value
llvm_add_lower_atomic(LLVMPassManagerRef PM
) {
144 LLVMAddLowerAtomicPass(PM
);
148 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
149 CAMLprim value
llvm_add_lower_switch(LLVMPassManagerRef PM
) {
150 LLVMAddLowerSwitchPass(PM
);
154 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
155 CAMLprim value
llvm_add_promote_memory_to_register(LLVMPassManagerRef PM
) {
156 LLVMAddPromoteMemoryToRegisterPass(PM
);
160 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
161 CAMLprim value
llvm_add_reassociation(LLVMPassManagerRef PM
) {
162 LLVMAddReassociatePass(PM
);
166 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
167 CAMLprim value
llvm_add_sccp(LLVMPassManagerRef PM
) {
172 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
173 CAMLprim value
llvm_add_scalar_repl_aggregates(LLVMPassManagerRef PM
) {
174 LLVMAddScalarReplAggregatesPass(PM
);
178 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
179 CAMLprim value
llvm_add_scalar_repl_aggregates_ssa(LLVMPassManagerRef PM
) {
180 LLVMAddScalarReplAggregatesPassSSA(PM
);
184 /* int -> [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
185 CAMLprim value
llvm_add_scalar_repl_aggregates_with_threshold(value threshold
,
186 LLVMPassManagerRef PM
) {
187 LLVMAddScalarReplAggregatesPassWithThreshold(PM
, Int_val(threshold
));
191 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
192 CAMLprim value
llvm_add_simplify_lib_calls(LLVMPassManagerRef PM
) {
193 LLVMAddSimplifyLibCallsPass(PM
);
197 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
198 CAMLprim value
llvm_add_tail_call_elimination(LLVMPassManagerRef PM
) {
199 LLVMAddTailCallEliminationPass(PM
);
203 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
204 CAMLprim value
llvm_add_constant_propagation(LLVMPassManagerRef PM
) {
205 LLVMAddConstantPropagationPass(PM
);
209 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
210 CAMLprim value
llvm_add_demote_memory_to_register(LLVMPassManagerRef PM
) {
211 LLVMAddDemoteMemoryToRegisterPass(PM
);
215 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
216 CAMLprim value
llvm_add_verifier(LLVMPassManagerRef PM
) {
217 LLVMAddVerifierPass(PM
);
221 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
222 CAMLprim value
llvm_add_correlated_value_propagation(LLVMPassManagerRef PM
) {
223 LLVMAddCorrelatedValuePropagationPass(PM
);
227 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
228 CAMLprim value
llvm_add_early_cse(LLVMPassManagerRef PM
) {
229 LLVMAddEarlyCSEPass(PM
);
233 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
234 CAMLprim value
llvm_add_lower_expect_intrinsic(LLVMPassManagerRef PM
) {
235 LLVMAddLowerExpectIntrinsicPass(PM
);
239 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
240 CAMLprim value
llvm_add_lower_constant_intrinsics(LLVMPassManagerRef PM
) {
241 LLVMAddLowerConstantIntrinsicsPass(PM
);
245 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
246 CAMLprim value
llvm_add_type_based_alias_analysis(LLVMPassManagerRef PM
) {
247 LLVMAddTypeBasedAliasAnalysisPass(PM
);
251 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
252 CAMLprim value
llvm_add_scoped_no_alias_aa(LLVMPassManagerRef PM
) {
253 LLVMAddScopedNoAliasAAPass(PM
);
257 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
258 CAMLprim value
llvm_add_basic_alias_analysis(LLVMPassManagerRef PM
) {
259 LLVMAddBasicAliasAnalysisPass(PM
);
263 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
264 CAMLprim value
llvm_add_unify_function_exit_nodes(LLVMPassManagerRef PM
) {
265 LLVMAddUnifyFunctionExitNodesPass(PM
);