summaryrefslogtreecommitdiff
path: root/bindings
diff options
context:
space:
mode:
authorPeter Zotov <whitequark@whitequark.org>2013-11-06 09:21:08 +0000
committerPeter Zotov <whitequark@whitequark.org>2013-11-06 09:21:08 +0000
commitba0c7cd012b064e2d8009480f9ae6f7d75e00e13 (patch)
tree97f2b78d23db4f2a21fad1de359bc79e6bcdb00b /bindings
parent14bbb1d9b083c7935185e7c11ddf059f352aa3fc (diff)
downloadllvm-ba0c7cd012b064e2d8009480f9ae6f7d75e00e13.tar.gz
llvm-ba0c7cd012b064e2d8009480f9ae6f7d75e00e13.tar.bz2
llvm-ba0c7cd012b064e2d8009480f9ae6f7d75e00e13.tar.xz
[OCaml] Implement Llvm.string_of_llvalue
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194136 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r--bindings/ocaml/llvm/llvm.ml1
-rw-r--r--bindings/ocaml/llvm/llvm.mli3
-rw-r--r--bindings/ocaml/llvm/llvm_ocaml.c11
3 files changed, 15 insertions, 0 deletions
diff --git a/bindings/ocaml/llvm/llvm.ml b/bindings/ocaml/llvm/llvm.ml
index 7096c169b4..780e305e2f 100644
--- a/bindings/ocaml/llvm/llvm.ml
+++ b/bindings/ocaml/llvm/llvm.ml
@@ -382,6 +382,7 @@ external type_of : llvalue -> lltype = "llvm_type_of"
external value_name : llvalue -> string = "llvm_value_name"
external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
external dump_value : llvalue -> unit = "llvm_dump_value"
+external string_of_llvalue : llvalue -> string = "llvm_string_of_llvalue"
external replace_all_uses_with : llvalue -> llvalue -> unit
= "llvm_replace_all_uses_with"
diff --git a/bindings/ocaml/llvm/llvm.mli b/bindings/ocaml/llvm/llvm.mli
index 8ad21f20c4..e965b7ee7e 100644
--- a/bindings/ocaml/llvm/llvm.mli
+++ b/bindings/ocaml/llvm/llvm.mli
@@ -654,6 +654,9 @@ val set_value_name : string -> llvalue -> unit
error. See the method [llvm::Value::dump]. *)
val dump_value : llvalue -> unit
+(** [string_of_llvalue v] returns a string describing the value [v]. *)
+val string_of_llvalue : llvalue -> string
+
(** [replace_all_uses_with old new] replaces all uses of the value [old]
with the value [new]. See the method [llvm::Value::replaceAllUsesWith]. *)
val replace_all_uses_with : llvalue -> llvalue -> unit
diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c
index ad4b36cc2b..6134bfa6d3 100644
--- a/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/bindings/ocaml/llvm/llvm_ocaml.c
@@ -527,6 +527,17 @@ CAMLprim value llvm_dump_value(LLVMValueRef Val) {
return Val_unit;
}
+/* llvalue -> string */
+CAMLprim value llvm_string_of_llvalue(LLVMTypeRef M) {
+ char* TypeCStr;
+ TypeCStr = LLVMPrintValueToString(M);
+
+ value TypeStr = caml_copy_string(TypeCStr);
+ LLVMDisposeMessage(TypeCStr);
+
+ return TypeStr;
+}
+
/* llvalue -> llvalue -> unit */
CAMLprim value llvm_replace_all_uses_with(LLVMValueRef OldVal,
LLVMValueRef NewVal) {