llvm.org GIT mirror llvm / 1a70735
[OCaml] Add OCaml API for LLVMGetIndices Summary: This patch adds a thin wrapper around LLVMGetNumIndices and LLVMGetIndices to return the indices of ExtractValue or InsertValue instructions as an OCaml array. It has not seemed to be necessary to expose LLVMGetNumIndices separately. Reviewers: whitequark Reviewed By: whitequark Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D52207 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342474 91177308-0d34-0410-b5e6-96231b3b80d8 whitequark 1 year, 1 month ago
3 changed file(s) with 19 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
537537 external operand_use : llvalue -> int -> lluse = "llvm_operand_use"
538538 external set_operand : llvalue -> int -> llvalue -> unit = "llvm_set_operand"
539539 external num_operands : llvalue -> int = "llvm_num_operands"
540 external indices : llvalue -> int array = "llvm_indices"
540541
541542 (*--... Operations on constants of (mostly) any type .......................--*)
542543 external is_constant : llvalue -> bool = "llvm_is_constant"
813813 val num_operands : llvalue -> int
814814
815815
816 (** [indices i] returns the indices for the ExtractValue or InsertValue
817 instruction [i].
818 See the [llvm::getIndices] methods. *)
819 val indices : llvalue -> int array
820
816821 (** {7 Operations on constants of (mostly) any type} *)
817822
818823 (** [is_constant v] returns [true] if the value [v] is a constant, [false]
731731 return Val_int(LLVMGetNumOperands(V));
732732 }
733733
734 /* llvalue -> int array */
735 CAMLprim value llvm_indices(LLVMValueRef Instr) {
736 CAMLparam0();
737 CAMLlocal1(indices);
738 unsigned n = LLVMGetNumIndices(Instr);
739 const unsigned *Indices = LLVMGetIndices(Instr);
740 indices = caml_alloc(n, 0);
741 for (unsigned i = 0; i < n; i++) {
742 Op_val(indices)[i] = Val_int(Indices[i]);
743 }
744 CAMLreturn(indices);
745 }
746
734747 /*--... Operations on constants of (mostly) any type .......................--*/
735748
736749 /* llvalue -> bool */