llvm.org GIT mirror llvm / 98c9164
[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 Peter Zotov 3 years ago
4 changed file(s) with 18 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
482482 external mdnode : llcontext -> llvalue array -> llvalue = "llvm_mdnode"
483483 external mdnull : llcontext -> llvalue = "llvm_mdnull"
484484 external get_mdstring : llvalue -> string option = "llvm_get_mdstring"
485 external get_mdnode_operands : llvalue -> llvalue array
486 = "llvm_get_mdnode_operands"
485487 external get_named_metadata : llmodule -> string -> llvalue array
486488 = "llvm_get_namedmd"
487489 external add_named_metadata_operand : llmodule -> string -> llvalue -> unit
851851 See the method [llvm::MDString::getString] *)
852852 val get_mdstring : llvalue -> string option
853853
854 (** [get_mdnode_operands v] returns the operands in the MDNode. *)
855 (* See the method [llvm::MDNode::getOperand] *)
856 val get_mdnode_operands : llvalue -> llvalue array
857
854858 (** [get_named_metadata m name] returns all the MDNodes belonging to the named
855859 metadata (if any).
856860 See the method [llvm::NamedMDNode::getOperand]. *)
733733 CAMLreturn(Val_int(0));
734734 }
735735
736 CAMLprim value llvm_get_mdnode_operands(LLVMValueRef V) {
737 CAMLparam0();
738 CAMLlocal1(Operands);
739 unsigned int n;
740
741 n = LLVMGetMDNodeNumOperands(V);
742 Operands = alloc(n, 0);
743 LLVMGetMDNodeOperands(V, (LLVMValueRef *) Operands);
744 CAMLreturn(Operands);
745 }
746
736747 /* llmodule -> string -> llvalue array */
737748 CAMLprim value llvm_get_namedmd(LLVMModuleRef M, value Name)
738749 {
11211121
11221122 insist ((has_metadata i) = true);
11231123 insist ((metadata i kind) = Some md);
1124 insist ((get_mdnode_operands md) = [| m1; m2 |]);
11241125
11251126 clear_metadata i kind;
11261127