[llvm-commits] [llvm] r111625 - in /llvm/trunk: bindings/ocaml/llvm/llvm.ml bindings/ocaml/llvm/llvm.mli bindings/ocaml/llvm/llvm_ocaml.c include/llvm-c/Core.h lib/VMCore/Core.cpp test/Bindings/Ocaml/vmcore.ml
Erick Tryzelaar
idadesub at users.sourceforge.net
Fri Aug 20 07:51:22 PDT 2010
Author: erickt
Date: Fri Aug 20 09:51:22 2010
New Revision: 111625
URL: http://llvm.org/viewvc/llvm-project?rev=111625&view=rev
Log:
Expose LLVMSetOperand and LLVMGetNumOperands to llvm-c and ocaml.
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/include/llvm-c/Core.h
llvm/trunk/lib/VMCore/Core.cpp
llvm/trunk/test/Bindings/Ocaml/vmcore.ml
Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.ml?rev=111625&r1=111624&r2=111625&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm.ml (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm.ml Fri Aug 20 09:51:22 2010
@@ -280,6 +280,8 @@
(*--... Operations on users ................................................--*)
external operand : llvalue -> int -> llvalue = "llvm_operand"
+external set_operand : llvalue -> int -> llvalue -> unit = "llvm_set_operand"
+external num_operands : llvalue -> int = "llvm_num_operands"
(*--... Operations on constants of (mostly) any type .......................--*)
external is_constant : llvalue -> bool = "llvm_is_constant"
Modified: llvm/trunk/bindings/ocaml/llvm/llvm.mli
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.mli?rev=111625&r1=111624&r2=111625&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm.mli (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm.mli Fri Aug 20 09:51:22 2010
@@ -557,6 +557,14 @@
method [llvm::User::getOperand]. *)
external operand : llvalue -> int -> llvalue = "llvm_operand"
+(** [set_operand v i o] sets the operand of the value [v] at the index [i] to
+ the value [o].
+ See the method [llvm::User::setOperand]. *)
+external set_operand : llvalue -> int -> llvalue -> unit = "llvm_set_operand"
+
+(** [num_operands v] returns the number of operands for the value [v].
+ See the method [llvm::User::getNumOperands]. *)
+external num_operands : llvalue -> int = "llvm_num_operands"
(** {7 Operations on constants of (mostly) any type} *)
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=111625&r1=111624&r2=111625&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Fri Aug 20 09:51:22 2010
@@ -452,6 +452,17 @@
return LLVMGetOperand(V, Int_val(I));
}
+/* llvalue -> int -> llvalue -> unit */
+CAMLprim value llvm_set_operand(LLVMValueRef U, value I, LLVMValueRef V) {
+ LLVMSetOperand(U, Int_val(I), V);
+ return Val_unit;
+}
+
+/* llvalue -> int */
+CAMLprim value llvm_num_operands(LLVMValueRef V) {
+ return Val_int(LLVMGetNumOperands(V));
+}
+
/*--... Operations on constants of (mostly) any type .......................--*/
/* llvalue -> bool */
Modified: llvm/trunk/include/llvm-c/Core.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=111625&r1=111624&r2=111625&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Core.h (original)
+++ llvm/trunk/include/llvm-c/Core.h Fri Aug 20 09:51:22 2010
@@ -523,6 +523,8 @@
/* Operations on Users */
LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
+void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
+int LLVMGetNumOperands(LLVMValueRef Val);
/* Operations on constants of any type */
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
Modified: llvm/trunk/lib/VMCore/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=111625&r1=111624&r2=111625&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Core.cpp (original)
+++ llvm/trunk/lib/VMCore/Core.cpp Fri Aug 20 09:51:22 2010
@@ -489,6 +489,14 @@
return wrap(unwrap<User>(Val)->getOperand(Index));
}
+void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op) {
+ unwrap<User>(Val)->setOperand(Index, unwrap(Op));
+}
+
+int LLVMGetNumOperands(LLVMValueRef Val) {
+ return unwrap<User>(Val)->getNumOperands();
+}
+
/*--.. Operations on constants of any type .................................--*/
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty) {
Modified: llvm/trunk/test/Bindings/Ocaml/vmcore.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/vmcore.ml?rev=111625&r1=111624&r2=111625&view=diff
==============================================================================
--- llvm/trunk/test/Bindings/Ocaml/vmcore.ml (original)
+++ llvm/trunk/test/Bindings/Ocaml/vmcore.ml Fri Aug 20 09:51:22 2010
@@ -642,11 +642,18 @@
let p1 = param fn 0 in
let p2 = param fn 1 in
+ let a3 = build_alloca i32_type "user_alloca" b in
+ let p3 = build_load a3 "user_load" b in
let i = build_add p1 p2 "sum" b in
+ insist ((num_operands i) = 2);
insist ((operand i 0) = p1);
insist ((operand i 1) = p2);
+ set_operand i 1 p3;
+ insist ((operand i 1) != p2);
+ insist ((operand i 1) = p3);
+
ignore (build_unreachable b)
More information about the llvm-commits
mailing list