summaryrefslogtreecommitdiff
path: root/bindings/ocaml/llvm/llvm_ocaml.c
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/ocaml/llvm/llvm_ocaml.c')
-rw-r--r--bindings/ocaml/llvm/llvm_ocaml.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c
index 6bccd28aea..4d721822f1 100644
--- a/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/bindings/ocaml/llvm/llvm_ocaml.c
@@ -195,6 +195,38 @@ CAMLprim LLVMTypeRef llvm_opaque_type(value Unit) {
return LLVMOpaqueType();
}
+/*--... Operations on type handles .........................................--*/
+
+#define Typehandle_val(v) (*(LLVMTypeHandleRef *)(Data_custom_val(v)))
+
+void llvm_finalize_handle(value TH) {
+ LLVMDisposeTypeHandle(Typehandle_val(TH));
+}
+
+static struct custom_operations typehandle_ops = {
+ (char *) "LLVMTypeHandle",
+ llvm_finalize_handle,
+ custom_compare_default,
+ custom_hash_default,
+ custom_serialize_default,
+ custom_deserialize_default
+};
+
+CAMLprim value llvm_handle_to_type(LLVMTypeRef PATy) {
+ value TH = alloc_custom(&typehandle_ops, sizeof(LLVMBuilderRef), 0, 1);
+ Typehandle_val(TH) = LLVMCreateTypeHandle(PATy);
+ return TH;
+}
+
+CAMLprim LLVMTypeRef llvm_type_of_handle(value TH) {
+ return LLVMResolveTypeHandle(Typehandle_val(TH));
+}
+
+CAMLprim value llvm_refine_type(LLVMTypeRef AbstractTy, LLVMTypeRef ConcreteTy){
+ LLVMRefineAbstractType(AbstractTy, ConcreteTy);
+ return Val_unit;
+}
+
/*===-- VALUES ------------------------------------------------------------===*/