[llvm] r273370 - [OCaml] Add functions for accessing metadata nodes.
Peter Zotov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 21 20:30:24 PDT 2016
Author: whitequark
Date: Tue Jun 21 22:30:24 2016
New Revision: 273370
URL: http://llvm.org/viewvc/llvm-project?rev=273370&view=rev
Log:
[OCaml] Add functions for accessing metadata nodes.
Patch by Xinyu Zhuang.
Differential Revision: http://reviews.llvm.org/D19309
Modified:
llvm/trunk/bindings/ocaml/llvm/llvm.ml
llvm/trunk/bindings/ocaml/llvm/llvm.mli
llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
llvm/trunk/test/Bindings/OCaml/core.ml
Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.ml?rev=273370&r1=273369&r2=273370&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm.ml (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm.ml Tue Jun 21 22:30:24 2016
@@ -483,6 +483,8 @@ external mdstring : llcontext -> string
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
Modified: llvm/trunk/bindings/ocaml/llvm/llvm.mli
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.mli?rev=273370&r1=273369&r2=273370&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm.mli (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm.mli Tue Jun 21 22:30:24 2016
@@ -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]. *)
Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c?rev=273370&r1=273369&r2=273370&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Tue Jun 21 22:30:24 2016
@@ -734,6 +734,17 @@ CAMLprim value llvm_get_mdstring(LLVMVal
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)
{
Modified: llvm/trunk/test/Bindings/OCaml/core.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/OCaml/core.ml?rev=273370&r1=273369&r2=273370&view=diff
==============================================================================
--- llvm/trunk/test/Bindings/OCaml/core.ml (original)
+++ llvm/trunk/test/Bindings/OCaml/core.ml Tue Jun 21 22:30:24 2016
@@ -1122,6 +1122,7 @@ let test_builder () =
insist ((has_metadata i) = true);
insist ((metadata i kind) = Some md);
+ insist ((get_mdnode_operands md) = [| m1; m2 |]);
clear_metadata i kind;
More information about the llvm-commits
mailing list