Index: bindings/ocaml/llvm/llvm.ml =================================================================== --- bindings/ocaml/llvm/llvm.ml +++ bindings/ocaml/llvm/llvm.ml @@ -483,6 +483,9 @@ 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_count : llvalue -> int = "llvm_get_mdnode_count" +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 Index: bindings/ocaml/llvm/llvm.mli =================================================================== --- bindings/ocaml/llvm/llvm.mli +++ bindings/ocaml/llvm/llvm.mli @@ -852,6 +852,14 @@ See the method [llvm::MDString::getString] *) val get_mdstring : llvalue -> string option +(** [get_mdnode_count v] returns the number of operands in the MDNode. + See the method [llvm::MDNode::getNumOperands] *) +val get_mdnode_count : llvalue -> int + +(** [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]. *) Index: bindings/ocaml/llvm/llvm_ocaml.c =================================================================== --- bindings/ocaml/llvm/llvm_ocaml.c +++ bindings/ocaml/llvm/llvm_ocaml.c @@ -734,6 +734,26 @@ CAMLreturn(Val_int(0)); } +CAMLprim value llvm_get_mdnode_count(LLVMValueRef V) { + CAMLparam0(); + unsigned int n; + + n = LLVMGetMDNodeNumOperands(V); + CAMLreturn(Val_int(n)); + +} + +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) {