[PATCH] D52207: [OCaml] Add OCaml API for LLVMGetIndices
whitequark via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 18 06:37:12 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342474: [OCaml] Add OCaml API for LLVMGetIndices (authored by whitequark, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D52207
Files:
llvm/trunk/bindings/ocaml/llvm/llvm.ml
llvm/trunk/bindings/ocaml/llvm/llvm.mli
llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
Index: llvm/trunk/bindings/ocaml/llvm/llvm.mli
===================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm.mli
+++ llvm/trunk/bindings/ocaml/llvm/llvm.mli
@@ -814,6 +814,11 @@
val num_operands : llvalue -> int
+(** [indices i] returns the indices for the ExtractValue or InsertValue
+ instruction [i].
+ See the [llvm::getIndices] methods. *)
+val indices : llvalue -> int array
+
(** {7 Operations on constants of (mostly) any type} *)
(** [is_constant v] returns [true] if the value [v] is a constant, [false]
Index: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
===================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
+++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
@@ -732,6 +732,19 @@
return Val_int(LLVMGetNumOperands(V));
}
+/* llvalue -> int array */
+CAMLprim value llvm_indices(LLVMValueRef Instr) {
+ CAMLparam0();
+ CAMLlocal1(indices);
+ unsigned n = LLVMGetNumIndices(Instr);
+ const unsigned *Indices = LLVMGetIndices(Instr);
+ indices = caml_alloc(n, 0);
+ for (unsigned i = 0; i < n; i++) {
+ Op_val(indices)[i] = Val_int(Indices[i]);
+ }
+ CAMLreturn(indices);
+}
+
/*--... Operations on constants of (mostly) any type .......................--*/
/* llvalue -> bool */
Index: llvm/trunk/bindings/ocaml/llvm/llvm.ml
===================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm.ml
+++ llvm/trunk/bindings/ocaml/llvm/llvm.ml
@@ -538,6 +538,7 @@
external operand_use : llvalue -> int -> lluse = "llvm_operand_use"
external set_operand : llvalue -> int -> llvalue -> unit = "llvm_set_operand"
external num_operands : llvalue -> int = "llvm_num_operands"
+external indices : llvalue -> int array = "llvm_indices"
(*--... Operations on constants of (mostly) any type .......................--*)
external is_constant : llvalue -> bool = "llvm_is_constant"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52207.165953.patch
Type: text/x-patch
Size: 1962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180918/74a945bd/attachment.bin>
More information about the llvm-commits
mailing list