From e0efe46b33068f2e651e850cdc3ede0306f1853c Mon Sep 17 00:00:00 2001 From: Alan Hu Date: Fri, 24 Feb 2023 13:14:11 -0800 Subject: [PATCH] [OCaml] Remove all PassManager-related functions Reviewed By: aeubanks, nikic Differential Revision: https://reviews.llvm.org/D144751 --- llvm/bindings/ocaml/llvm/llvm.ml | 18 -- llvm/bindings/ocaml/llvm/llvm.mli | 51 ----- llvm/bindings/ocaml/llvm/llvm_ocaml.c | 33 --- llvm/bindings/ocaml/target/llvm_target.ml | 2 - llvm/bindings/ocaml/target/llvm_target.mli | 4 - llvm/bindings/ocaml/target/target_ocaml.c | 7 - llvm/bindings/ocaml/transforms/CMakeLists.txt | 5 +- llvm/bindings/ocaml/transforms/ipo/CMakeLists.txt | 5 - llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c | 50 ----- llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml | 23 -- llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli | 38 ---- .../transforms/passmgr_builder/CMakeLists.txt | 5 - .../passmgr_builder/llvm_passmgr_builder.ml | 28 --- .../passmgr_builder/llvm_passmgr_builder.mli | 48 ----- .../passmgr_builder/passmgr_builder_ocaml.c | 92 -------- .../ocaml/transforms/scalar_opts/CMakeLists.txt | 5 - .../transforms/scalar_opts/llvm_scalar_opts.ml | 116 ----------- .../transforms/scalar_opts/llvm_scalar_opts.mli | 187 ----------------- .../transforms/scalar_opts/scalar_opts_ocaml.c | 231 --------------------- .../ocaml/transforms/vectorize/CMakeLists.txt | 5 - .../ocaml/transforms/vectorize/llvm_vectorize.ml | 14 -- .../ocaml/transforms/vectorize/llvm_vectorize.mli | 22 -- .../ocaml/transforms/vectorize/vectorize_ocaml.c | 32 --- llvm/docs/CMakeLists.txt | 4 - llvm/test/Bindings/OCaml/core.ml | 24 --- llvm/test/Bindings/OCaml/ipo.ml | 63 ------ llvm/test/Bindings/OCaml/passmgr_builder.ml | 60 ------ llvm/test/Bindings/OCaml/scalar_opts.ml | 87 -------- llvm/test/Bindings/OCaml/target.ml | 4 +- llvm/test/Bindings/OCaml/vectorize.ml | 55 ----- llvm/test/CMakeLists.txt | 4 - 31 files changed, 2 insertions(+), 1320 deletions(-) delete mode 100644 llvm/bindings/ocaml/transforms/ipo/CMakeLists.txt delete mode 100644 llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c delete mode 100644 llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml delete mode 100644 llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli delete mode 100644 llvm/bindings/ocaml/transforms/passmgr_builder/CMakeLists.txt delete mode 100644 llvm/bindings/ocaml/transforms/passmgr_builder/llvm_passmgr_builder.ml delete mode 100644 llvm/bindings/ocaml/transforms/passmgr_builder/llvm_passmgr_builder.mli delete mode 100644 llvm/bindings/ocaml/transforms/passmgr_builder/passmgr_builder_ocaml.c delete mode 100644 llvm/bindings/ocaml/transforms/scalar_opts/CMakeLists.txt delete mode 100644 llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml delete mode 100644 llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli delete mode 100644 llvm/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c delete mode 100644 llvm/bindings/ocaml/transforms/vectorize/CMakeLists.txt delete mode 100644 llvm/bindings/ocaml/transforms/vectorize/llvm_vectorize.ml delete mode 100644 llvm/bindings/ocaml/transforms/vectorize/llvm_vectorize.mli delete mode 100644 llvm/bindings/ocaml/transforms/vectorize/vectorize_ocaml.c delete mode 100644 llvm/test/Bindings/OCaml/ipo.ml delete mode 100644 llvm/test/Bindings/OCaml/passmgr_builder.ml delete mode 100644 llvm/test/Bindings/OCaml/scalar_opts.ml delete mode 100644 llvm/test/Bindings/OCaml/vectorize.ml diff --git a/llvm/bindings/ocaml/llvm/llvm.ml b/llvm/bindings/ocaml/llvm/llvm.ml index 10d44a6..4487866 100644 --- a/llvm/bindings/ocaml/llvm/llvm.ml +++ b/llvm/bindings/ocaml/llvm/llvm.ml @@ -1392,21 +1392,3 @@ module MemoryBuffer = struct external as_string : llmemorybuffer -> string = "llvm_memorybuffer_as_string" external dispose : llmemorybuffer -> unit = "llvm_memorybuffer_dispose" end - - -(*===-- Pass Manager ------------------------------------------------------===*) - -module PassManager = struct - type 'a t - type any = [ `Module | `Function ] - external create : unit -> [ `Module ] t = "llvm_passmanager_create" - external create_function : llmodule -> [ `Function ] t - = "LLVMCreateFunctionPassManager" - external run_module : llmodule -> [ `Module ] t -> bool - = "llvm_passmanager_run_module" - external initialize : [ `Function ] t -> bool = "llvm_passmanager_initialize" - external run_function : llvalue -> [ `Function ] t -> bool - = "llvm_passmanager_run_function" - external finalize : [ `Function ] t -> bool = "llvm_passmanager_finalize" - external dispose : [< any ] t -> unit = "llvm_passmanager_dispose" -end diff --git a/llvm/bindings/ocaml/llvm/llvm.mli b/llvm/bindings/ocaml/llvm/llvm.mli index 38bf555..59ac5b8 100644 --- a/llvm/bindings/ocaml/llvm/llvm.mli +++ b/llvm/bindings/ocaml/llvm/llvm.mli @@ -2622,54 +2622,3 @@ module MemoryBuffer : sig (** Disposes of a memory buffer. *) val dispose : llmemorybuffer -> unit end - - -(** {6 Pass Managers} *) - -module PassManager : sig - (** *) - type 'a t - type any = [ `Module | `Function ] - - (** [PassManager.create ()] constructs a new whole-module pass pipeline. This - type of pipeline is suitable for link-time optimization and whole-module - transformations. - See the constructor of [llvm::PassManager]. *) - val create : unit -> [ `Module ] t - - (** [PassManager.create_function m] constructs a new function-by-function - pass pipeline over the module [m]. It does not take ownership of [m]. - This type of pipeline is suitable for code generation and JIT compilation - tasks. - See the constructor of [llvm::FunctionPassManager]. *) - val create_function : llmodule -> [ `Function ] t - - (** [run_module m pm] initializes, executes on the module [m], and finalizes - all of the passes scheduled in the pass manager [pm]. Returns [true] if - any of the passes modified the module, [false] otherwise. - See the [llvm::PassManager::run] method. *) - val run_module : llmodule -> [ `Module ] t -> bool - - (** [initialize fpm] initializes all of the function passes scheduled in the - function pass manager [fpm]. Returns [true] if any of the passes modified - the module, [false] otherwise. - See the [llvm::FunctionPassManager::doInitialization] method. *) - val initialize : [ `Function ] t -> bool - - (** [run_function f fpm] executes all of the function passes scheduled in the - function pass manager [fpm] over the function [f]. Returns [true] if any - of the passes modified [f], [false] otherwise. - See the [llvm::FunctionPassManager::run] method. *) - val run_function : llvalue -> [ `Function ] t -> bool - - (** [finalize fpm] finalizes all of the function passes scheduled in the - function pass manager [fpm]. Returns [true] if any of the passes - modified the module, [false] otherwise. - See the [llvm::FunctionPassManager::doFinalization] method. *) - val finalize : [ `Function ] t -> bool - - (** Frees the memory of a pass pipeline. For function pipelines, does not free - the module. - See the destructor of [llvm::BasePassManager]. *) - val dispose : [< any ] t -> unit -end diff --git a/llvm/bindings/ocaml/llvm/llvm_ocaml.c b/llvm/bindings/ocaml/llvm/llvm_ocaml.c index 0762ebe..dff14cf 100644 --- a/llvm/bindings/ocaml/llvm/llvm_ocaml.c +++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.c @@ -2339,36 +2339,3 @@ value llvm_memorybuffer_dispose(LLVMMemoryBufferRef MemBuf) { LLVMDisposeMemoryBuffer(MemBuf); return Val_unit; } - -/*===-- Pass Managers -----------------------------------------------------===*/ - -/* unit -> [ `Module ] PassManager.t */ -LLVMPassManagerRef llvm_passmanager_create(value Unit) { - return LLVMCreatePassManager(); -} - -/* llmodule -> [ `Function ] PassManager.t -> bool */ -value llvm_passmanager_run_module(LLVMModuleRef M, LLVMPassManagerRef PM) { - return Val_bool(LLVMRunPassManager(PM, M)); -} - -/* [ `Function ] PassManager.t -> bool */ -value llvm_passmanager_initialize(LLVMPassManagerRef FPM) { - return Val_bool(LLVMInitializeFunctionPassManager(FPM)); -} - -/* llvalue -> [ `Function ] PassManager.t -> bool */ -value llvm_passmanager_run_function(LLVMValueRef F, LLVMPassManagerRef FPM) { - return Val_bool(LLVMRunFunctionPassManager(FPM, F)); -} - -/* [ `Function ] PassManager.t -> bool */ -value llvm_passmanager_finalize(LLVMPassManagerRef FPM) { - return Val_bool(LLVMFinalizeFunctionPassManager(FPM)); -} - -/* PassManager.any PassManager.t -> unit */ -value llvm_passmanager_dispose(LLVMPassManagerRef PM) { - LLVMDisposePassManager(PM); - return Val_unit; -} diff --git a/llvm/bindings/ocaml/target/llvm_target.ml b/llvm/bindings/ocaml/target/llvm_target.ml index 0922ebe..29af018 100644 --- a/llvm/bindings/ocaml/target/llvm_target.ml +++ b/llvm/bindings/ocaml/target/llvm_target.ml @@ -122,8 +122,6 @@ module TargetMachine = struct = "llvm_targetmachine_features" external data_layout : t -> DataLayout.t = "llvm_targetmachine_data_layout" - external add_analysis_passes : [< Llvm.PassManager.any ] Llvm.PassManager.t -> t -> unit - = "llvm_targetmachine_add_analysis_passes" external set_verbose_asm : bool -> t -> unit = "llvm_targetmachine_set_verbose_asm" external emit_to_file : Llvm.llmodule -> CodeGenFileType.t -> string -> diff --git a/llvm/bindings/ocaml/target/llvm_target.mli b/llvm/bindings/ocaml/target/llvm_target.mli index 8d31079..56ecb2d 100644 --- a/llvm/bindings/ocaml/target/llvm_target.mli +++ b/llvm/bindings/ocaml/target/llvm_target.mli @@ -200,10 +200,6 @@ module TargetMachine : sig [llvm::TargetMachine::getFeatureString]. *) val features : t -> string - (** Adds the target-specific analysis passes to the pass manager. - See [llvm::TargetMachine::addAnalysisPasses]. *) - val add_analysis_passes : [< Llvm.PassManager.any ] Llvm.PassManager.t -> t -> unit - (** Sets the assembly verbosity of this target machine. See [llvm::TargetMachine::setAsmVerbosity]. *) val set_verbose_asm : bool -> t -> unit diff --git a/llvm/bindings/ocaml/target/target_ocaml.c b/llvm/bindings/ocaml/target/target_ocaml.c index 2b7259b..d0bc6f1 100644 --- a/llvm/bindings/ocaml/target/target_ocaml.c +++ b/llvm/bindings/ocaml/target/target_ocaml.c @@ -327,10 +327,3 @@ llvm_targetmachine_emit_to_memory_buffer(LLVMModuleRef Module, value FileType, return Buffer; } - -/* TargetMachine.t -> Llvm.PassManager.t -> unit */ -value llvm_targetmachine_add_analysis_passes(LLVMPassManagerRef PM, - value Machine) { - LLVMAddAnalysisPasses(TargetMachine_val(Machine), PM); - return Val_unit; -} diff --git a/llvm/bindings/ocaml/transforms/CMakeLists.txt b/llvm/bindings/ocaml/transforms/CMakeLists.txt index beb8694..0628d67 100644 --- a/llvm/bindings/ocaml/transforms/CMakeLists.txt +++ b/llvm/bindings/ocaml/transforms/CMakeLists.txt @@ -1,5 +1,2 @@ -add_subdirectory(ipo) -add_subdirectory(passmgr_builder) -add_subdirectory(scalar_opts) add_subdirectory(utils) -add_subdirectory(vectorize) + diff --git a/llvm/bindings/ocaml/transforms/ipo/CMakeLists.txt b/llvm/bindings/ocaml/transforms/ipo/CMakeLists.txt deleted file mode 100644 index 4b8784f..0000000 --- a/llvm/bindings/ocaml/transforms/ipo/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_ocaml_library(llvm_ipo - OCAML llvm_ipo - OCAMLDEP llvm - C ipo_ocaml - LLVM ipo) diff --git a/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c b/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c deleted file mode 100644 index 008d18e..0000000 --- a/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c +++ /dev/null @@ -1,50 +0,0 @@ -/*===-- ipo_ocaml.c - LLVM OCaml Glue ---------------------------*- C++ -*-===*\ -|* *| -|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| -|* Exceptions. *| -|* See https://llvm.org/LICENSE.txt for license information. *| -|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| -|* *| -|*===----------------------------------------------------------------------===*| -|* *| -|* This file glues LLVM's OCaml interface to its C interface. These functions *| -|* are by and large transparent wrappers to the corresponding C functions. *| -|* *| -|* Note that these functions intentionally take liberties with the CAMLparamX *| -|* macros, since most of the parameters are not GC heap objects. *| -|* *| -\*===----------------------------------------------------------------------===*/ - -#include "llvm-c/Transforms/IPO.h" -#include "caml/mlvalues.h" -#include "caml/misc.h" - -/* [`Module] Llvm.PassManager.t -> unit */ -value llvm_add_constant_merge(LLVMPassManagerRef PM) { - LLVMAddConstantMergePass(PM); - return Val_unit; -} - -/* [`Module] Llvm.PassManager.t -> unit */ -value llvm_add_dead_arg_elimination(LLVMPassManagerRef PM) { - LLVMAddDeadArgEliminationPass(PM); - return Val_unit; -} - -/* [`Module] Llvm.PassManager.t -> unit */ -value llvm_add_function_attrs(LLVMPassManagerRef PM) { - LLVMAddFunctionAttrsPass(PM); - return Val_unit; -} - -/* [`Module] Llvm.PassManager.t -> unit */ -value llvm_add_always_inliner(LLVMPassManagerRef PM) { - LLVMAddAlwaysInlinerPass(PM); - return Val_unit; -} - -/* [`Module] Llvm.PassManager.t -> unit */ -value llvm_add_global_dce(LLVMPassManagerRef PM) { - LLVMAddGlobalDCEPass(PM); - return Val_unit; -} diff --git a/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml b/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml deleted file mode 100644 index e54ee49..0000000 --- a/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml +++ /dev/null @@ -1,23 +0,0 @@ -(*===-- llvm_ipo.ml - LLVM OCaml Interface --------------------*- OCaml -*-===* - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===----------------------------------------------------------------------===*) - -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_always_inliner - : [ `Module ] Llvm.PassManager.t -> unit - = "llvm_add_always_inliner" -external add_global_dce - : [ `Module ] Llvm.PassManager.t -> unit - = "llvm_add_global_dce" diff --git a/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli b/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli deleted file mode 100644 index baa0984..0000000 --- a/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli +++ /dev/null @@ -1,38 +0,0 @@ -(*===-- llvm_ipo.mli - LLVM OCaml Interface -------------------*- OCaml -*-===* - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===----------------------------------------------------------------------===*) - -(** IPO Transforms. - - This interface provides an OCaml API for LLVM interprocedural optimizations, the - classes in the [LLVMIPO] library. *) - -(** 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::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" - \ No newline at end of file diff --git a/llvm/bindings/ocaml/transforms/passmgr_builder/CMakeLists.txt b/llvm/bindings/ocaml/transforms/passmgr_builder/CMakeLists.txt deleted file mode 100644 index b012863..0000000 --- a/llvm/bindings/ocaml/transforms/passmgr_builder/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_ocaml_library(llvm_passmgr_builder - OCAML llvm_passmgr_builder - OCAMLDEP llvm - C passmgr_builder_ocaml - LLVM ipo) diff --git a/llvm/bindings/ocaml/transforms/passmgr_builder/llvm_passmgr_builder.ml b/llvm/bindings/ocaml/transforms/passmgr_builder/llvm_passmgr_builder.ml deleted file mode 100644 index c39a592..0000000 --- a/llvm/bindings/ocaml/transforms/passmgr_builder/llvm_passmgr_builder.ml +++ /dev/null @@ -1,28 +0,0 @@ -(*===-- llvm_passmgr_builder.ml - LLVM OCaml Interface --------*- OCaml -*-===* - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===----------------------------------------------------------------------===*) - -type t - -external create : unit -> t - = "llvm_pmbuilder_create" -external set_opt_level : int -> t -> unit - = "llvm_pmbuilder_set_opt_level" -external set_size_level : int -> t -> unit - = "llvm_pmbuilder_set_size_level" -external set_disable_unit_at_a_time : bool -> t -> unit - = "llvm_pmbuilder_set_disable_unit_at_a_time" -external set_disable_unroll_loops : bool -> t -> unit - = "llvm_pmbuilder_set_disable_unroll_loops" -external use_inliner_with_threshold : int -> t -> unit - = "llvm_pmbuilder_use_inliner_with_threshold" -external populate_function_pass_manager - : [ `Function ] Llvm.PassManager.t -> t -> unit - = "llvm_pmbuilder_populate_function_pass_manager" -external populate_module_pass_manager - : [ `Module ] Llvm.PassManager.t -> t -> unit - = "llvm_pmbuilder_populate_module_pass_manager" \ No newline at end of file diff --git a/llvm/bindings/ocaml/transforms/passmgr_builder/llvm_passmgr_builder.mli b/llvm/bindings/ocaml/transforms/passmgr_builder/llvm_passmgr_builder.mli deleted file mode 100644 index d2861ea..0000000 --- a/llvm/bindings/ocaml/transforms/passmgr_builder/llvm_passmgr_builder.mli +++ /dev/null @@ -1,48 +0,0 @@ -(*===-- llvm_passmgr_builder.mli - LLVM OCaml Interface -------*- OCaml -*-===* - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===----------------------------------------------------------------------===*) - -(** Pass Manager Builder. - - This interface provides an OCaml API for LLVM pass manager builder - from the [LLVMCore] library. *) - -type t - -(** See the [llvm::PassManagerBuilder] function. *) -external create : unit -> t - = "llvm_pmbuilder_create" - -(** See the [llvm::PassManagerBuilder::OptLevel] function. *) -external set_opt_level : int -> t -> unit - = "llvm_pmbuilder_set_opt_level" - -(** See the [llvm::PassManagerBuilder::SizeLevel] function. *) -external set_size_level : int -> t -> unit - = "llvm_pmbuilder_set_size_level" - -(** 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 the [llvm::PassManagerBuilder::DisableUnrollLoops] function. *) -external set_disable_unroll_loops : bool -> t -> unit - = "llvm_pmbuilder_set_disable_unroll_loops" - -(** See the [llvm::PassManagerBuilder::Inliner] function. *) -external use_inliner_with_threshold : int -> t -> unit - = "llvm_pmbuilder_use_inliner_with_threshold" - -(** See the [llvm::PassManagerBuilder::populateFunctionPassManager] function. *) -external populate_function_pass_manager - : [ `Function ] Llvm.PassManager.t -> t -> unit - = "llvm_pmbuilder_populate_function_pass_manager" - -(** See the [llvm::PassManagerBuilder::populateModulePassManager] function. *) -external populate_module_pass_manager - : [ `Module ] Llvm.PassManager.t -> t -> unit - = "llvm_pmbuilder_populate_module_pass_manager" diff --git a/llvm/bindings/ocaml/transforms/passmgr_builder/passmgr_builder_ocaml.c b/llvm/bindings/ocaml/transforms/passmgr_builder/passmgr_builder_ocaml.c deleted file mode 100644 index de0a762..0000000 --- a/llvm/bindings/ocaml/transforms/passmgr_builder/passmgr_builder_ocaml.c +++ /dev/null @@ -1,92 +0,0 @@ -/*===-- passmgr_builder_ocaml.c - LLVM OCaml Glue ---------------*- C++ -*-===*\ -|* *| -|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| -|* Exceptions. *| -|* See https://llvm.org/LICENSE.txt for license information. *| -|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| -|* *| -|*===----------------------------------------------------------------------===*| -|* *| -|* This file glues LLVM's OCaml interface to its C interface. These functions *| -|* are by and large transparent wrappers to the corresponding C functions. *| -|* *| -|* Note that these functions intentionally take liberties with the CAMLparamX *| -|* 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/misc.h" - -#define PMBuilder_val(v) (*(LLVMPassManagerBuilderRef *)(Data_custom_val(v))) - -static void llvm_finalize_pmbuilder(value PMB) { - LLVMPassManagerBuilderDispose(PMBuilder_val(PMB)); -} - -static struct custom_operations pmbuilder_ops = { - (char *)"Llvm_passmgr_builder.t", llvm_finalize_pmbuilder, - custom_compare_default, custom_hash_default, - custom_serialize_default, custom_deserialize_default, - custom_compare_ext_default}; - -static value alloc_pmbuilder(LLVMPassManagerBuilderRef Ref) { - value Val = - alloc_custom(&pmbuilder_ops, sizeof(LLVMPassManagerBuilderRef), 0, 1); - PMBuilder_val(Val) = Ref; - return Val; -} - -/* t -> unit */ -value llvm_pmbuilder_create(value Unit) { - return alloc_pmbuilder(LLVMPassManagerBuilderCreate()); -} - -/* int -> t -> unit */ -value llvm_pmbuilder_set_opt_level(value OptLevel, value PMB) { - LLVMPassManagerBuilderSetOptLevel(PMBuilder_val(PMB), Int_val(OptLevel)); - return Val_unit; -} - -/* int -> t -> unit */ -value llvm_pmbuilder_set_size_level(value SizeLevel, value PMB) { - LLVMPassManagerBuilderSetSizeLevel(PMBuilder_val(PMB), Int_val(SizeLevel)); - return Val_unit; -} - -/* int -> t -> unit */ -value llvm_pmbuilder_use_inliner_with_threshold(value Threshold, value PMB) { - LLVMPassManagerBuilderSetOptLevel(PMBuilder_val(PMB), Int_val(Threshold)); - return Val_unit; -} - -/* bool -> t -> unit */ -value llvm_pmbuilder_set_disable_unit_at_a_time(value DisableUnitAtATime, - value PMB) { - LLVMPassManagerBuilderSetDisableUnitAtATime(PMBuilder_val(PMB), - Bool_val(DisableUnitAtATime)); - return Val_unit; -} - -/* bool -> t -> unit */ -value llvm_pmbuilder_set_disable_unroll_loops(value DisableUnroll, value PMB) { - LLVMPassManagerBuilderSetDisableUnrollLoops(PMBuilder_val(PMB), - Bool_val(DisableUnroll)); - return Val_unit; -} - -/* [ `Function ] Llvm.PassManager.t -> t -> unit */ -value llvm_pmbuilder_populate_function_pass_manager(LLVMPassManagerRef PM, - value PMB) { - LLVMPassManagerBuilderPopulateFunctionPassManager(PMBuilder_val(PMB), PM); - return Val_unit; -} - -/* [ `Module ] Llvm.PassManager.t -> t -> unit */ -value llvm_pmbuilder_populate_module_pass_manager(LLVMPassManagerRef PM, - value PMB) { - LLVMPassManagerBuilderPopulateModulePassManager(PMBuilder_val(PMB), PM); - return Val_unit; -} diff --git a/llvm/bindings/ocaml/transforms/scalar_opts/CMakeLists.txt b/llvm/bindings/ocaml/transforms/scalar_opts/CMakeLists.txt deleted file mode 100644 index d680b02..0000000 --- a/llvm/bindings/ocaml/transforms/scalar_opts/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_ocaml_library(llvm_scalar_opts - OCAML llvm_scalar_opts - OCAMLDEP llvm - C scalar_opts_ocaml - LLVM Scalar) diff --git a/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml b/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml deleted file mode 100644 index cf212b9..0000000 --- a/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml +++ /dev/null @@ -1,116 +0,0 @@ -(*===-- llvm_scalar_opts.ml - LLVM OCaml Interface ------------*- OCaml -*-===* - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===----------------------------------------------------------------------===*) - -external add_aggressive_dce - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_aggressive_dce" -external add_dce - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_dce" -external add_alignment_from_assumptions - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_alignment_from_assumptions" -external add_cfg_simplification - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_cfg_simplification" -external add_dead_store_elimination - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_dead_store_elimination" -external add_scalarizer - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_scalarizer" -external add_merged_load_store_motion - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_merged_load_store_motion" -external add_gvn - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_gvn" -external add_ind_var_simplification - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_ind_var_simplify" -external add_instruction_combination - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_instruction_combining" -external add_jump_threading - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_jump_threading" -external add_licm - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_licm" -external add_loop_rotation - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_loop_rotate" -external add_loop_unroll - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_loop_unroll" -external add_memcpy_opt - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_memcpy_opt" -external add_partially_inline_lib_calls - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_partially_inline_lib_calls" -external add_lower_atomic - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_lower_atomic" -external add_lower_switch - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_lower_switch" -external add_memory_to_register_promotion - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_promote_memory_to_register" -external add_reassociation - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_reassociation" -external add_sccp - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_sccp" -external add_scalar_repl_aggregation - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_scalar_repl_aggregates" -external add_scalar_repl_aggregation_ssa - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_scalar_repl_aggregates_ssa" -external add_scalar_repl_aggregation_with_threshold - : int -> [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_scalar_repl_aggregates_with_threshold" -external add_lib_call_simplification - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_simplify_lib_calls" -external add_tail_call_elimination - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_tail_call_elimination" -external add_memory_to_register_demotion - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_demote_memory_to_register" -external add_verifier - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_verifier" -external add_correlated_value_propagation - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_correlated_value_propagation" -external add_early_cse - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_early_cse" -external add_lower_expect_intrinsic - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_lower_expect_intrinsic" -external add_lower_constant_intrinsics - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_lower_constant_intrinsics" -external add_type_based_alias_analysis - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_type_based_alias_analysis" -external add_scoped_no_alias_alias_analysis - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_scoped_no_alias_aa" -external add_basic_alias_analysis - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_basic_alias_analysis" -external add_unify_function_exit_nodes - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_unify_function_exit_nodes" diff --git a/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli b/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli deleted file mode 100644 index ff21c35..0000000 --- a/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli +++ /dev/null @@ -1,187 +0,0 @@ -(*===-- llvm_scalar_opts.mli - LLVM OCaml Interface -----------*- OCaml -*-===* - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===----------------------------------------------------------------------===*) - -(** Scalar Transforms. - - This interface provides an OCaml API for LLVM scalar transforms, the - classes in the [LLVMScalarOpts] library. *) - -(** See the [llvm::createAggressiveDCEPass] function. *) -external add_aggressive_dce - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_aggressive_dce" - -(** See the [llvm::createDCEPass] function. *) -external add_dce - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_dce" - -(** See the [llvm::createAlignmentFromAssumptionsPass] function. *) -external add_alignment_from_assumptions - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_alignment_from_assumptions" - -(** See the [llvm::createCFGSimplificationPass] function. *) -external add_cfg_simplification - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_cfg_simplification" - -(** See [llvm::createDeadStoreEliminationPass] function. *) -external add_dead_store_elimination - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_dead_store_elimination" - -(** See [llvm::createScalarizerPass] function. *) -external add_scalarizer - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_scalarizer" - -(** See [llvm::createMergedLoadStoreMotionPass] function. *) -external add_merged_load_store_motion - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_merged_load_store_motion" - -(** See the [llvm::createGVNPass] function. *) -external add_gvn - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_gvn" - -(** See the [llvm::createIndVarSimplifyPass] function. *) -external add_ind_var_simplification - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_ind_var_simplify" - -(** See the [llvm::createInstructionCombiningPass] function. *) -external add_instruction_combination - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_instruction_combining" - -(** See the [llvm::createJumpThreadingPass] function. *) -external add_jump_threading - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_jump_threading" - -(** See the [llvm::createLICMPass] function. *) -external add_licm - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_licm" - -(** See the [llvm::createLoopRotatePass] function. *) -external add_loop_rotation - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_loop_rotate" - -(** See the [llvm::createLoopUnrollPass] function. *) -external add_loop_unroll - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_loop_unroll" - -(** See the [llvm::createMemCpyOptPass] function. *) -external add_memcpy_opt - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_memcpy_opt" - -(** See the [llvm::createPartiallyInlineLibCallsPass] function. *) -external add_partially_inline_lib_calls - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_partially_inline_lib_calls" - -(** See the [llvm::createLowerAtomicPass] function. *) -external add_lower_atomic - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_lower_atomic" - -(** See the [llvm::createLowerSwitchPass] function. *) -external add_lower_switch - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_lower_switch" - -(** See the [llvm::createPromoteMemoryToRegisterPass] function. *) -external add_memory_to_register_promotion - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_promote_memory_to_register" - -(** See the [llvm::createReassociatePass] function. *) -external add_reassociation - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_reassociation" - -(** See the [llvm::createSROAPass] function. *) -external add_scalar_repl_aggregation - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_scalar_repl_aggregates" - -(** See the [llvm::createSROAPass] function. *) -external add_scalar_repl_aggregation_ssa - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_scalar_repl_aggregates_ssa" - -(** See the [llvm::createSROAPass] function. *) -external add_scalar_repl_aggregation_with_threshold - : int -> [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_scalar_repl_aggregates_with_threshold" - -(** See the [llvm::createSimplifyLibCallsPass] function. *) -external add_lib_call_simplification - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_simplify_lib_calls" - -(** See the [llvm::createTailCallEliminationPass] function. *) -external add_tail_call_elimination - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_tail_call_elimination" - -(** See the [llvm::createDemoteMemoryToRegisterPass] function. *) -external add_memory_to_register_demotion - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_demote_memory_to_register" - -(** See the [llvm::createVerifierPass] function. *) -external add_verifier - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_verifier" - -(** See the [llvm::createCorrelatedValuePropagationPass] function. *) -external add_correlated_value_propagation - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_correlated_value_propagation" - -(** See the [llvm::createEarlyCSE] function. *) -external add_early_cse - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_early_cse" - -(** See the [llvm::createLowerExpectIntrinsicPass] function. *) -external add_lower_expect_intrinsic - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_lower_expect_intrinsic" - -(** See the [llvm::createLowerConstantIntrinsicsPass] function. *) -external add_lower_constant_intrinsics - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_lower_constant_intrinsics" - -(** See the [llvm::createTypeBasedAliasAnalysisPass] function. *) -external add_type_based_alias_analysis - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_type_based_alias_analysis" - -(** See the [llvm::createScopedNoAliasAAPass] function. *) -external add_scoped_no_alias_alias_analysis - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_scoped_no_alias_aa" - -(** See the [llvm::createBasicAliasAnalysisPass] function. *) -external add_basic_alias_analysis - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_basic_alias_analysis" - -(** See the [llvm::createUnifyFunctionExitNodesPass] function. *) -external add_unify_function_exit_nodes - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_unify_function_exit_nodes" diff --git a/llvm/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c b/llvm/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c deleted file mode 100644 index a804169..0000000 --- a/llvm/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c +++ /dev/null @@ -1,231 +0,0 @@ -/*===-- scalar_opts_ocaml.c - LLVM OCaml Glue -------------------*- C++ -*-===*\ -|* *| -|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| -|* Exceptions. *| -|* See https://llvm.org/LICENSE.txt for license information. *| -|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| -|* *| -|*===----------------------------------------------------------------------===*| -|* *| -|* This file glues LLVM's OCaml interface to its C interface. These functions *| -|* are by and large transparent wrappers to the corresponding C functions. *| -|* *| -|* Note that these functions intentionally take liberties with the CAMLparamX *| -|* macros, since most of the parameters are not GC heap objects. *| -|* *| -\*===----------------------------------------------------------------------===*/ - -#include "llvm-c/Transforms/Scalar.h" -#include "llvm-c/Transforms/Utils.h" -#include "caml/mlvalues.h" -#include "caml/misc.h" - -/* [ unit */ -value llvm_add_aggressive_dce(LLVMPassManagerRef PM) { - LLVMAddAggressiveDCEPass(PM); - return Val_unit; -} - -value llvm_add_dce(LLVMPassManagerRef PM) { - LLVMAddDCEPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_alignment_from_assumptions(LLVMPassManagerRef PM) { - LLVMAddAlignmentFromAssumptionsPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_cfg_simplification(LLVMPassManagerRef PM) { - LLVMAddCFGSimplificationPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_dead_store_elimination(LLVMPassManagerRef PM) { - LLVMAddDeadStoreEliminationPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_scalarizer(LLVMPassManagerRef PM) { - LLVMAddScalarizerPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_merged_load_store_motion(LLVMPassManagerRef PM) { - LLVMAddMergedLoadStoreMotionPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_gvn(LLVMPassManagerRef PM) { - LLVMAddGVNPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_ind_var_simplify(LLVMPassManagerRef PM) { - LLVMAddIndVarSimplifyPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_instruction_combining(LLVMPassManagerRef PM) { - LLVMAddInstructionCombiningPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_jump_threading(LLVMPassManagerRef PM) { - LLVMAddJumpThreadingPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_licm(LLVMPassManagerRef PM) { - LLVMAddLICMPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_loop_rotate(LLVMPassManagerRef PM) { - LLVMAddLoopRotatePass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_loop_unroll(LLVMPassManagerRef PM) { - LLVMAddLoopUnrollPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_memcpy_opt(LLVMPassManagerRef PM) { - LLVMAddMemCpyOptPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_partially_inline_lib_calls(LLVMPassManagerRef PM) { - LLVMAddPartiallyInlineLibCallsPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_lower_atomic(LLVMPassManagerRef PM) { - LLVMAddLowerAtomicPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_lower_switch(LLVMPassManagerRef PM) { - LLVMAddLowerSwitchPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_promote_memory_to_register(LLVMPassManagerRef PM) { - LLVMAddPromoteMemoryToRegisterPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_reassociation(LLVMPassManagerRef PM) { - LLVMAddReassociatePass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_scalar_repl_aggregates(LLVMPassManagerRef PM) { - LLVMAddScalarReplAggregatesPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_scalar_repl_aggregates_ssa(LLVMPassManagerRef PM) { - LLVMAddScalarReplAggregatesPassSSA(PM); - return Val_unit; -} - -/* int -> [ unit */ -value llvm_add_scalar_repl_aggregates_with_threshold(value threshold, - LLVMPassManagerRef PM) { - LLVMAddScalarReplAggregatesPassWithThreshold(PM, Int_val(threshold)); - return Val_unit; -} - -/* [ unit */ -value llvm_add_simplify_lib_calls(LLVMPassManagerRef PM) { - LLVMAddSimplifyLibCallsPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_tail_call_elimination(LLVMPassManagerRef PM) { - LLVMAddTailCallEliminationPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_demote_memory_to_register(LLVMPassManagerRef PM) { - LLVMAddDemoteMemoryToRegisterPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_verifier(LLVMPassManagerRef PM) { - LLVMAddVerifierPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_correlated_value_propagation(LLVMPassManagerRef PM) { - LLVMAddCorrelatedValuePropagationPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_early_cse(LLVMPassManagerRef PM) { - LLVMAddEarlyCSEPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_lower_expect_intrinsic(LLVMPassManagerRef PM) { - LLVMAddLowerExpectIntrinsicPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_lower_constant_intrinsics(LLVMPassManagerRef PM) { - LLVMAddLowerConstantIntrinsicsPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_type_based_alias_analysis(LLVMPassManagerRef PM) { - LLVMAddTypeBasedAliasAnalysisPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_scoped_no_alias_aa(LLVMPassManagerRef PM) { - LLVMAddScopedNoAliasAAPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_basic_alias_analysis(LLVMPassManagerRef PM) { - LLVMAddBasicAliasAnalysisPass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_unify_function_exit_nodes(LLVMPassManagerRef PM) { - LLVMAddUnifyFunctionExitNodesPass(PM); - return Val_unit; -} diff --git a/llvm/bindings/ocaml/transforms/vectorize/CMakeLists.txt b/llvm/bindings/ocaml/transforms/vectorize/CMakeLists.txt deleted file mode 100644 index 47af239..0000000 --- a/llvm/bindings/ocaml/transforms/vectorize/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_ocaml_library(llvm_vectorize - OCAML llvm_vectorize - OCAMLDEP llvm - C vectorize_ocaml - LLVM Vectorize) diff --git a/llvm/bindings/ocaml/transforms/vectorize/llvm_vectorize.ml b/llvm/bindings/ocaml/transforms/vectorize/llvm_vectorize.ml deleted file mode 100644 index a2e280e..0000000 --- a/llvm/bindings/ocaml/transforms/vectorize/llvm_vectorize.ml +++ /dev/null @@ -1,14 +0,0 @@ -(*===-- llvm_vectorize.ml - LLVM OCaml Interface --------------*- OCaml -*-===* - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===----------------------------------------------------------------------===*) - -external add_loop_vectorize - : [ unit - = "llvm_add_loop_vectorize" -external add_slp_vectorize - : [ unit - = "llvm_add_slp_vectorize" diff --git a/llvm/bindings/ocaml/transforms/vectorize/llvm_vectorize.mli b/llvm/bindings/ocaml/transforms/vectorize/llvm_vectorize.mli deleted file mode 100644 index 7376d9e6..0000000 --- a/llvm/bindings/ocaml/transforms/vectorize/llvm_vectorize.mli +++ /dev/null @@ -1,22 +0,0 @@ -(*===-- llvm_vectorize.mli - LLVM OCaml Interface -------------*- OCaml -*-===* - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===----------------------------------------------------------------------===*) - -(** Vectorize Transforms. - - This interface provides an OCaml API for LLVM vectorize transforms, the - classes in the [LLVMVectorize] library. *) - -(** See the [llvm::createLoopVectorizePass] function. *) -external add_loop_vectorize - : [ unit - = "llvm_add_loop_vectorize" - -(** See the [llvm::createSLPVectorizerPass] function. *) -external add_slp_vectorize - : [ unit - = "llvm_add_slp_vectorize" diff --git a/llvm/bindings/ocaml/transforms/vectorize/vectorize_ocaml.c b/llvm/bindings/ocaml/transforms/vectorize/vectorize_ocaml.c deleted file mode 100644 index d9b15bf..0000000 --- a/llvm/bindings/ocaml/transforms/vectorize/vectorize_ocaml.c +++ /dev/null @@ -1,32 +0,0 @@ -/*===-- vectorize_ocaml.c - LLVM OCaml Glue ---------------------*- C++ -*-===*\ -|* *| -|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| -|* Exceptions. *| -|* See https://llvm.org/LICENSE.txt for license information. *| -|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| -|* *| -|*===----------------------------------------------------------------------===*| -|* *| -|* This file glues LLVM's OCaml interface to its C interface. These functions *| -|* are by and large transparent wrappers to the corresponding C functions. *| -|* *| -|* Note that these functions intentionally take liberties with the CAMLparamX *| -|* macros, since most of the parameters are not GC heap objects. *| -|* *| -\*===----------------------------------------------------------------------===*/ - -#include "llvm-c/Transforms/Vectorize.h" -#include "caml/mlvalues.h" -#include "caml/misc.h" - -/* [ unit */ -value llvm_add_loop_vectorize(LLVMPassManagerRef PM) { - LLVMAddLoopVectorizePass(PM); - return Val_unit; -} - -/* [ unit */ -value llvm_add_slp_vectorize(LLVMPassManagerRef PM) { - LLVMAddSLPVectorizePass(PM); - return Val_unit; -} diff --git a/llvm/docs/CMakeLists.txt b/llvm/docs/CMakeLists.txt index 0f2681e..5e420a2 100644 --- a/llvm/docs/CMakeLists.txt +++ b/llvm/docs/CMakeLists.txt @@ -131,11 +131,7 @@ if( NOT uses_ocaml LESS 0 AND LLVM_ENABLE_OCAMLDOC ) ocaml_llvm_irreader ocaml_llvm_linker ocaml_llvm_target - ocaml_llvm_ipo - ocaml_llvm_passmgr_builder - ocaml_llvm_scalar_opts ocaml_llvm_transform_utils - ocaml_llvm_vectorize ) foreach(llvm_target ${LLVM_TARGETS_TO_BUILD}) diff --git a/llvm/test/Bindings/OCaml/core.ml b/llvm/test/Bindings/OCaml/core.ml index f8ed685..86a5a11 100644 --- a/llvm/test/Bindings/OCaml/core.ml +++ b/llvm/test/Bindings/OCaml/core.ml @@ -1458,29 +1458,6 @@ let test_builder () = * CHECK: !1 = !{i32 1, !"metadata test"} *) -(*===-- Pass Managers -----------------------------------------------------===*) - -let test_pass_manager () = - let (++) x f = ignore (f x); x in - - begin group "module pass manager"; - ignore (PassManager.create () - ++ PassManager.run_module m - ++ PassManager.dispose) - end; - - begin group "function pass manager"; - let fty = function_type void_type [| |] in - let fn = define_function "FunctionPassManager" fty m in - ignore (build_ret_void (builder_at_end context (entry_block fn))); - - ignore (PassManager.create_function m - ++ PassManager.initialize - ++ PassManager.run_function fn - ++ PassManager.finalize - ++ PassManager.dispose) - end - (*===-- Memory Buffer -----------------------------------------------------===*) @@ -1523,7 +1500,6 @@ let _ = suite "basic blocks" test_basic_blocks; suite "instructions" test_instructions; suite "builder" test_builder; - suite "pass manager" test_pass_manager; suite "memory buffer" test_memory_buffer; suite "writer" test_writer; (* Keep this last; it disposes m. *) exit !exit_status diff --git a/llvm/test/Bindings/OCaml/ipo.ml b/llvm/test/Bindings/OCaml/ipo.ml deleted file mode 100644 index 9866de4..0000000 --- a/llvm/test/Bindings/OCaml/ipo.ml +++ /dev/null @@ -1,63 +0,0 @@ -(* RUN: rm -rf %t && mkdir -p %t && cp %s %t/ipo_opts.ml - * RUN: %ocamlc -g -w +A -package llvm.ipo -linkpkg %t/ipo_opts.ml -o %t/executable - * RUN: %t/executable %t/bitcode.bc - * RUN: %ocamlopt -g -w +A -package llvm.ipo -linkpkg %t/ipo_opts.ml -o %t/executable - * RUN: %t/executable %t/bitcode.bc - * XFAIL: vg_leak - *) - -(* Note: It takes several seconds for ocamlopt to link an executable with - libLLVMCore.a, so it's better to write a big test than a bunch of - little ones. *) - -open Llvm -open Llvm_ipo -open Llvm_target - -let context = global_context () -let void_type = Llvm.void_type context -let i8_type = Llvm.i8_type context - -(* Tiny unit test framework - really just to help find which line is busted *) -let print_checkpoints = false - -let suite name f = - if print_checkpoints then - prerr_endline (name ^ ":"); - f () - - -(*===-- Fixture -----------------------------------------------------------===*) - -let filename = Sys.argv.(1) -let m = create_module context filename - - -(*===-- Transforms --------------------------------------------------------===*) - -let test_transforms () = - let (++) x f = f x; x in - - let fty = function_type i8_type [| |] in - let fn = define_function "fn" fty m in - let fn2 = define_function "fn2" fty m in begin - ignore (build_ret (const_int i8_type 4) (builder_at_end context (entry_block fn))); - let b = builder_at_end context (entry_block fn2) in - ignore (build_ret (build_call fty fn [| |] "" b) b); - end; - - ignore (PassManager.create () - ++ add_constant_merge - ++ add_dead_arg_elimination - ++ add_function_attrs - ++ add_always_inliner - ++ add_global_dce - ++ PassManager.run_module m - ++ PassManager.dispose) - - -(*===-- Driver ------------------------------------------------------------===*) - -let _ = - suite "transforms" test_transforms; - dispose_module m diff --git a/llvm/test/Bindings/OCaml/passmgr_builder.ml b/llvm/test/Bindings/OCaml/passmgr_builder.ml deleted file mode 100644 index f761b2a..0000000 --- a/llvm/test/Bindings/OCaml/passmgr_builder.ml +++ /dev/null @@ -1,60 +0,0 @@ -(* RUN: rm -rf %t && mkdir -p %t && cp %s %t/passmgr_builder.ml - * RUN: %ocamlc -g -w +A -package llvm.passmgr_builder -linkpkg %t/passmgr_builder.ml -o %t/executable - * RUN: %t/executable %t/bitcode.bc - * RUN: %ocamlopt -g -w +A -package llvm.passmgr_builder -linkpkg %t/passmgr_builder.ml -o %t/executable - * RUN: %t/executable %t/bitcode.bc - * XFAIL: vg_leak - *) - -(* Note: It takes several seconds for ocamlopt to link an executable with - libLLVMCore.a, so it's better to write a big test than a bunch of - little ones. *) - -open Llvm -open Llvm_passmgr_builder - -let context = global_context () -let void_type = Llvm.void_type context - -(* Tiny unit test framework - really just to help find which line is busted *) -let print_checkpoints = false - -let suite name f = - if print_checkpoints then - prerr_endline (name ^ ":"); - f () - - -(*===-- Fixture -----------------------------------------------------------===*) - -let filename = Sys.argv.(1) -let m = create_module context filename - - -(*===-- Pass Manager Builder ----------------------------------------------===*) - -let test_pmbuilder () = - let (++) x f = ignore (f x); x in - - let module_passmgr = PassManager.create () in - let func_passmgr = PassManager.create_function m in - - ignore (Llvm_passmgr_builder.create () - ++ set_opt_level 3 - ++ set_size_level 1 - ++ set_disable_unit_at_a_time false - ++ set_disable_unroll_loops false - ++ use_inliner_with_threshold 10 - ++ populate_function_pass_manager func_passmgr - ++ populate_module_pass_manager module_passmgr); - Gc.compact (); - - PassManager.dispose module_passmgr; - PassManager.dispose func_passmgr - - -(*===-- Driver ------------------------------------------------------------===*) - -let _ = - suite "pass manager builder" test_pmbuilder; - dispose_module m diff --git a/llvm/test/Bindings/OCaml/scalar_opts.ml b/llvm/test/Bindings/OCaml/scalar_opts.ml deleted file mode 100644 index 861e38c..0000000 --- a/llvm/test/Bindings/OCaml/scalar_opts.ml +++ /dev/null @@ -1,87 +0,0 @@ -(* RUN: rm -rf %t && mkdir -p %t && cp %s %t/scalar_opts.ml - * RUN: %ocamlc -g -w +A -package llvm.scalar_opts -linkpkg %t/scalar_opts.ml -o %t/executable - * RUN: %t/executable %t/bitcode.bc - * RUN: %ocamlopt -g -w +A -package llvm.scalar_opts -linkpkg %t/scalar_opts.ml -o %t/executable - * RUN: %t/executable %t/bitcode.bc - * XFAIL: vg_leak - *) - -(* Note: It takes several seconds for ocamlopt to link an executable with - libLLVMCore.a, so it's better to write a big test than a bunch of - little ones. *) - -open Llvm -open Llvm_scalar_opts -open Llvm_target - -let context = global_context () -let void_type = Llvm.void_type context - -(* Tiny unit test framework - really just to help find which line is busted *) -let print_checkpoints = false - -let suite name f = - if print_checkpoints then - prerr_endline (name ^ ":"); - f () - - -(*===-- Fixture -----------------------------------------------------------===*) - -let filename = Sys.argv.(1) -let m = create_module context filename - - -(*===-- Transforms --------------------------------------------------------===*) - -let test_transforms () = - let (++) x f = f x; x in - - let fty = function_type void_type [| |] in - let fn = define_function "fn" fty m in - ignore (build_ret_void (builder_at_end context (entry_block fn))); - - ignore (PassManager.create_function m - ++ add_aggressive_dce - ++ add_alignment_from_assumptions - ++ add_cfg_simplification - ++ add_dead_store_elimination - ++ add_scalarizer - ++ add_merged_load_store_motion - ++ add_gvn - ++ add_ind_var_simplification - ++ add_instruction_combination - ++ add_jump_threading - ++ add_licm - ++ add_loop_rotation - ++ add_loop_unroll - ++ add_memcpy_opt - ++ add_partially_inline_lib_calls - ++ add_lower_switch - ++ add_memory_to_register_promotion - ++ add_reassociation - ++ add_sccp - ++ add_scalar_repl_aggregation - ++ add_scalar_repl_aggregation_ssa - ++ add_scalar_repl_aggregation_with_threshold 4 - ++ add_lib_call_simplification - ++ add_tail_call_elimination - ++ add_memory_to_register_demotion - ++ add_verifier - ++ add_correlated_value_propagation - ++ add_early_cse - ++ add_lower_expect_intrinsic - ++ add_type_based_alias_analysis - ++ add_scoped_no_alias_alias_analysis - ++ add_basic_alias_analysis - ++ PassManager.initialize - ++ PassManager.run_function fn - ++ PassManager.finalize - ++ PassManager.dispose) - - -(*===-- Driver ------------------------------------------------------------===*) - -let _ = - suite "transforms" test_transforms; - dispose_module m diff --git a/llvm/test/Bindings/OCaml/target.ml b/llvm/test/Bindings/OCaml/target.ml index 9006681..e9465fd 100644 --- a/llvm/test/Bindings/OCaml/target.ml +++ b/llvm/test/Bindings/OCaml/target.ml @@ -82,9 +82,7 @@ let test_target_machine () = assert_equal (TM.cpu machine) ""; assert_equal (TM.features machine) ""; ignore (TM.data_layout machine); - TM.set_verbose_asm true machine; - let pm = PassManager.create () in - TM.add_analysis_passes pm machine + TM.set_verbose_asm true machine (*===-- Code Emission -----------------------------------------------------===*) diff --git a/llvm/test/Bindings/OCaml/vectorize.ml b/llvm/test/Bindings/OCaml/vectorize.ml deleted file mode 100644 index 72cd191..0000000 --- a/llvm/test/Bindings/OCaml/vectorize.ml +++ /dev/null @@ -1,55 +0,0 @@ -(* RUN: rm -rf %t && mkdir -p %t && cp %s %t/vectorize_opts.ml - * RUN: %ocamlc -g -w +A -package llvm.vectorize -linkpkg %t/vectorize_opts.ml -o %t/executable - * RUN: %t/executable %t/bitcode.bc - * RUN: %ocamlopt -g -w +A -package llvm.vectorize -linkpkg %t/vectorize_opts.ml -o %t/executable - * RUN: %t/executable %t/bitcode.bc - * XFAIL: vg_leak - *) - -(* Note: It takes several seconds for ocamlopt to link an executable with - libLLVMCore.a, so it's better to write a big test than a bunch of - little ones. *) - -open Llvm -open Llvm_vectorize -open Llvm_target - -let context = global_context () -let void_type = Llvm.void_type context - -(* Tiny unit test framework - really just to help find which line is busted *) -let print_checkpoints = false - -let suite name f = - if print_checkpoints then - prerr_endline (name ^ ":"); - f () - - -(*===-- Fixture -----------------------------------------------------------===*) - -let filename = Sys.argv.(1) -let m = create_module context filename - - -(*===-- Transforms --------------------------------------------------------===*) - -let test_transforms () = - let (++) x f = f x; x in - - let fty = function_type void_type [| |] in - let fn = define_function "fn" fty m in - ignore (build_ret_void (builder_at_end context (entry_block fn))); - - ignore (PassManager.create () - ++ add_loop_vectorize - ++ add_slp_vectorize - ++ PassManager.run_module m - ++ PassManager.dispose) - - -(*===-- Driver ------------------------------------------------------------===*) - -let _ = - suite "transforms" test_transforms; - dispose_module m diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt index 5f52ce7..9339940 100644 --- a/llvm/test/CMakeLists.txt +++ b/llvm/test/CMakeLists.txt @@ -212,11 +212,7 @@ if(TARGET ocaml_llvm) ocaml_llvm_irreader ocaml_llvm_linker ocaml_llvm_target - ocaml_llvm_ipo - ocaml_llvm_passmgr_builder - ocaml_llvm_scalar_opts ocaml_llvm_transform_utils - ocaml_llvm_vectorize ) endif() -- 2.7.4