[OCaml] Fix ocamlc -custom builds when configured as --enable-shared.
[oota-llvm.git] / bindings / ocaml / target / target_ocaml.c
index fea3eff174ae62b8d58949793836ea023e87c7c6..8f77cb46f13234a50d7fc8a0fc8f8847e6548359 100644 (file)
 #include "caml/custom.h"
 #include "caml/callback.h"
 
-/*===---- Exceptions ------------------------------------------------------===*/
-
-static void llvm_raise(value Prototype, char *Message) {
-  CAMLparam1(Prototype);
-  CAMLlocal1(CamlMessage);
-
-  CamlMessage = copy_string(Message);
-  LLVMDisposeMessage(Message);
-
-  raise_with_arg(Prototype, CamlMessage);
-  CAMLnoreturn;
-}
-
-static value llvm_string_of_message(char* Message) {
-  value String = caml_copy_string(Message);
-  LLVMDisposeMessage(Message);
-
-  return String;
-}
+void llvm_raise(value Prototype, char *Message);
+value llvm_string_of_message(char* Message);
 
 /*===---- Data Layout -----------------------------------------------------===*/
 
@@ -374,3 +357,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;
+}