llvm.org GIT mirror llvm / b65c5f2
Add support getting the operands of a User to ocaml. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97414 91177308-0d34-0410-b5e6-96231b3b80d8 Erick Tryzelaar 10 years ago
4 changed file(s) with 36 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
240240 external dump_value : llvalue -> unit = "llvm_dump_value"
241241 external replace_all_uses_with : llvalue -> llvalue -> unit
242242 = "LLVMReplaceAllUsesWith"
243
244 (*--... Operations on users ................................................--*)
245 external operand : llvalue -> int -> llvalue = "llvm_operand"
243246
244247 (*--... Operations on constants of (mostly) any type .......................--*)
245248 external is_constant : llvalue -> bool = "llvm_is_constant"
510510 * with the value [new]. See the method [llvm::Value::replaceAllUsesWith]. *)
511511 external replace_all_uses_with : llvalue -> llvalue -> unit
512512 = "LLVMReplaceAllUsesWith"
513
514
515 (* {6 Users} *)
516
517 (** [operand v i] returns the operand at index [i] for the value [v]. See the
518 method [llvm::User::getOperand]. *)
519 external operand : llvalue -> int -> llvalue = "llvm_operand"
513520
514521
515522 (** {7 Operations on constants of (mostly) any type} *)
439439 return Val_unit;
440440 }
441441
442 /*--... Operations on users ................................................--*/
443
444 /* llvalue -> int -> llvalue */
445 CAMLprim LLVMValueRef llvm_operand(LLVMValueRef V, value I) {
446 return LLVMGetOperand(V, Int_val(I));
447 }
448
442449 /*--... Operations on constants of (mostly) any type .......................--*/
443450
444451 /* llvalue -> bool */
605605 dispose_module m
606606 end
607607
608
609 (*===-- Users -------------------------------------------------------------===*)
610
611 let test_users () =
612 let ty = function_type i32_type [| i32_type; i32_type |] in
613 let fn = define_function "user_function" ty m in
614 let b = builder_at_end context (entry_block fn) in
615
616 let p1 = param fn 0 in
617 let p2 = param fn 1 in
618 let i = build_add p1 p2 "sum" b in
619
620 insist ((operand i 0) = p1);
621 insist ((operand i 1) = p2);
622
623 ignore (build_unreachable b)
624
625
608626 (*===-- Aliases -----------------------------------------------------------===*)
609627
610628 let test_aliases () =
12721290 suite "constants" test_constants;
12731291 suite "global values" test_global_values;
12741292 suite "global variables" test_global_variables;
1293 suite "users" test_users;
12751294 suite "aliases" test_aliases;
12761295 suite "functions" test_functions;
12771296 suite "params" test_params;