Add (very basic) bindings for ModuleProvider.
[oota-llvm.git] / bindings / ocaml / llvm / llvm_ocaml.c
index dd37e3e978afb5d318f6948ec0e4756660babb91..f9d7e6f4780f5e6c8201c05dace0e8af26fd2d05 100644 (file)
@@ -536,6 +536,29 @@ CAMLprim value llvm_set_function_call_conv(value Id, LLVMValueRef Fn) {
   return Val_unit;
 }
 
+/* llvalue -> string option */
+CAMLprim value llvm_collector(LLVMValueRef Fn) {
+  const char *Collector;
+  CAMLparam0();
+  CAMLlocal2(Name, Option);
+  
+  if ((Collector = LLVMGetCollector(Fn))) {
+    Name = copy_string(Collector);
+    
+    Option = alloc(1, 0);
+    Field(Option, 0) = Name;
+    CAMLreturn(Option);
+  } else {
+    CAMLreturn(Val_int(0));
+  }
+}
+
+/* string option -> llvalue -> unit */
+CAMLprim value llvm_set_collector(value GC, LLVMValueRef Fn) {
+  LLVMSetCollector(Fn, GC == Val_int(0)? 0 : String_val(Field(GC, 0)));
+  return Val_unit;
+}
+
 /*--... Operations on basic blocks .........................................--*/
 
 /* llvalue -> llbasicblock array */
@@ -1024,3 +1047,11 @@ CAMLprim LLVMValueRef llvm_build_shufflevector(LLVMValueRef V1, LLVMValueRef V2,
   return LLVMBuildShuffleVector(Builder_val(B), V1, V2, Mask, String_val(Name));
 }
 
+
+/*===-- Module Providers --------------------------------------------------===*/
+
+/* llmoduleprovider -> unit */
+CAMLprim value llvm_dispose_module_provider(LLVMModuleProviderRef MP) {
+  LLVMDisposeModuleProvider(MP);
+  return Val_unit;
+}