summaryrefslogtreecommitdiff
path: root/bindings
diff options
context:
space:
mode:
authorPeter Zotov <whitequark@whitequark.org>2016-06-22 03:30:24 +0000
committerPeter Zotov <whitequark@whitequark.org>2016-06-22 03:30:24 +0000
commit98c9164467275be5a4f63dd7a1acecde39b27162 (patch)
treeb9937240598d5de1447c35c2d4517d0583341bbf /bindings
parent06dbef967776357611094d5abdebf18de0030cf8 (diff)
[OCaml] Add functions for accessing metadata nodes.
Patch by Xinyu Zhuang. Differential Revision: http://reviews.llvm.org/D19309 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273370 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r--bindings/ocaml/llvm/llvm.ml2
-rw-r--r--bindings/ocaml/llvm/llvm.mli4
-rw-r--r--bindings/ocaml/llvm/llvm_ocaml.c11
3 files changed, 17 insertions, 0 deletions
diff --git a/bindings/ocaml/llvm/llvm.ml b/bindings/ocaml/llvm/llvm.ml
index 5e149d44c41..513fe0c9687 100644
--- a/bindings/ocaml/llvm/llvm.ml
+++ b/bindings/ocaml/llvm/llvm.ml
@@ -483,6 +483,8 @@ external mdstring : llcontext -> string -> llvalue = "llvm_mdstring"
external mdnode : llcontext -> llvalue array -> llvalue = "llvm_mdnode"
external mdnull : llcontext -> llvalue = "llvm_mdnull"
external get_mdstring : llvalue -> string option = "llvm_get_mdstring"
+external get_mdnode_operands : llvalue -> llvalue array
+ = "llvm_get_mdnode_operands"
external get_named_metadata : llmodule -> string -> llvalue array
= "llvm_get_namedmd"
external add_named_metadata_operand : llmodule -> string -> llvalue -> unit
diff --git a/bindings/ocaml/llvm/llvm.mli b/bindings/ocaml/llvm/llvm.mli
index 8c068619838..0f973000f75 100644
--- a/bindings/ocaml/llvm/llvm.mli
+++ b/bindings/ocaml/llvm/llvm.mli
@@ -852,6 +852,10 @@ val mdnull : llcontext -> llvalue
See the method [llvm::MDString::getString] *)
val get_mdstring : llvalue -> string option
+(** [get_mdnode_operands v] returns the operands in the MDNode. *)
+(* See the method [llvm::MDNode::getOperand] *)
+val get_mdnode_operands : llvalue -> llvalue array
+
(** [get_named_metadata m name] returns all the MDNodes belonging to the named
metadata (if any).
See the method [llvm::NamedMDNode::getOperand]. *)
diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c
index 665842d0b6c..f968db8efd0 100644
--- a/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/bindings/ocaml/llvm/llvm_ocaml.c
@@ -734,6 +734,17 @@ CAMLprim value llvm_get_mdstring(LLVMValueRef V) {
CAMLreturn(Val_int(0));
}
+CAMLprim value llvm_get_mdnode_operands(LLVMValueRef V) {
+ CAMLparam0();
+ CAMLlocal1(Operands);
+ unsigned int n;
+
+ n = LLVMGetMDNodeNumOperands(V);
+ Operands = alloc(n, 0);
+ LLVMGetMDNodeOperands(V, (LLVMValueRef *) Operands);
+ CAMLreturn(Operands);
+}
+
/* llmodule -> string -> llvalue array */
CAMLprim value llvm_get_namedmd(LLVMModuleRef M, value Name)
{