summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bindings/ocaml/target/llvm_target.ml2
-rw-r--r--bindings/ocaml/target/llvm_target.mli4
-rw-r--r--bindings/ocaml/target/target_ocaml.c7
-rw-r--r--test/Bindings/Ocaml/target.ml4
4 files changed, 16 insertions, 1 deletions
diff --git a/bindings/ocaml/target/llvm_target.ml b/bindings/ocaml/target/llvm_target.ml
index aadd90f5518..bd7388e29fa 100644
--- a/bindings/ocaml/target/llvm_target.ml
+++ b/bindings/ocaml/target/llvm_target.ml
@@ -126,6 +126,8 @@ 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/bindings/ocaml/target/llvm_target.mli b/bindings/ocaml/target/llvm_target.mli
index ca91e0d9105..676bc613c64 100644
--- a/bindings/ocaml/target/llvm_target.mli
+++ b/bindings/ocaml/target/llvm_target.mli
@@ -207,6 +207,10 @@ module TargetMachine : sig
(** Returns the data layout of this target machine. *)
val data_layout : t -> DataLayout.t
+ (** 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/bindings/ocaml/target/target_ocaml.c b/bindings/ocaml/target/target_ocaml.c
index fea3eff174a..efb5d9bd51e 100644
--- a/bindings/ocaml/target/target_ocaml.c
+++ b/bindings/ocaml/target/target_ocaml.c
@@ -374,3 +374,10 @@ CAMLprim LLVMMemoryBufferRef llvm_targetmachine_emit_to_memory_buffer(
return Buffer;
}
+
+/* TargetMachine.t -> Llvm.PassManager.t -> unit */
+CAMLprim value llvm_targetmachine_add_analysis_passes(LLVMPassManagerRef PM,
+ value Machine) {
+ LLVMAddAnalysisPasses(TargetMachine_val(Machine), PM);
+ return Val_unit;
+}
diff --git a/test/Bindings/Ocaml/target.ml b/test/Bindings/Ocaml/target.ml
index 35135880e29..e431fa4a254 100644
--- a/test/Bindings/Ocaml/target.ml
+++ b/test/Bindings/Ocaml/target.ml
@@ -87,7 +87,9 @@ 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
+ TM.set_verbose_asm true machine;
+ let pm = PassManager.create () in
+ TM.add_analysis_passes pm machine
(*===-- Code Emission -----------------------------------------------------===*)