llvm.org GIT mirror llvm / ba0c7cd
[OCaml] Implement Llvm.string_of_llvalue git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194136 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Zotov 7 years ago
4 changed file(s) with 24 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
381381 external value_name : llvalue -> string = "llvm_value_name"
382382 external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
383383 external dump_value : llvalue -> unit = "llvm_dump_value"
384 external string_of_llvalue : llvalue -> string = "llvm_string_of_llvalue"
384385 external replace_all_uses_with : llvalue -> llvalue -> unit
385386 = "llvm_replace_all_uses_with"
386387
653653 error. See the method [llvm::Value::dump]. *)
654654 val dump_value : llvalue -> unit
655655
656 (** [string_of_llvalue v] returns a string describing the value [v]. *)
657 val string_of_llvalue : llvalue -> string
658
656659 (** [replace_all_uses_with old new] replaces all uses of the value [old]
657660 with the value [new]. See the method [llvm::Value::replaceAllUsesWith]. *)
658661 val replace_all_uses_with : llvalue -> llvalue -> unit
526526 return Val_unit;
527527 }
528528
529 /* llvalue -> string */
530 CAMLprim value llvm_string_of_llvalue(LLVMTypeRef M) {
531 char* TypeCStr;
532 TypeCStr = LLVMPrintValueToString(M);
533
534 value TypeStr = caml_copy_string(TypeCStr);
535 LLVMDisposeMessage(TypeCStr);
536
537 return TypeStr;
538 }
539
529540 /* llvalue -> llvalue -> unit */
530541 CAMLprim value llvm_replace_all_uses_with(LLVMValueRef OldVal,
531542 LLVMValueRef NewVal) {
6464
6565 let filename = Sys.argv.(1)
6666 let m = create_module context filename
67
68
69 (*===-- Conversion --------------------------------------------------------===*)
70
71 let test_conversion () =
72 insist ("i32" = (string_of_lltype i32_type));
73 let c = const_int i32_type 42 in
74 insist ("i32 42" = (string_of_llvalue c))
6775
6876
6977 (*===-- Target ------------------------------------------------------------===*)
13911399 (*===-- Driver ------------------------------------------------------------===*)
13921400
13931401 let _ =
1402 suite "conversion" test_conversion;
13941403 suite "target" test_target;
13951404 suite "constants" test_constants;
13961405 suite "global values" test_global_values;