1(* RUN: %ocamlopt -warn-error A llvm.cmxa llvm_target.cmxa %s -o %t 2 * RUN: %t %t.bc 3 * XFAIL: vg_leak 4 *) 5 6(* Note: It takes several seconds for ocamlopt to link an executable with 7 libLLVMCore.a, so it's better to write a big test than a bunch of 8 little ones. *) 9 10open Llvm 11open Llvm_target 12 13 14let context = global_context () 15let i32_type = Llvm.i32_type context 16let i64_type = Llvm.i64_type context 17 18(* Tiny unit test framework - really just to help find which line is busted *) 19let print_checkpoints = false 20 21let suite name f = 22 if print_checkpoints then 23 prerr_endline (name ^ ":"); 24 f () 25 26 27(*===-- Fixture -----------------------------------------------------------===*) 28 29let filename = Sys.argv.(1) 30let m = create_module context filename 31 32 33(*===-- Target Data -------------------------------------------------------===*) 34 35let test_target_data () = 36 let td = TargetData.create (target_triple m) in 37 let sty = struct_type context [| i32_type; i64_type |] in 38 39 ignore (TargetData.as_string td); 40 ignore (byte_order td); 41 ignore (pointer_size td); 42 ignore (intptr_type td); 43 ignore (size_in_bits td sty); 44 ignore (store_size td sty); 45 ignore (abi_size td sty); 46 ignore (stack_align td sty); 47 ignore (preferred_align td sty); 48 ignore (preferred_align_of_global td (declare_global sty "g" m)); 49 ignore (element_at_offset td sty (Int64.of_int 1)); 50 ignore (offset_of_element td sty 1); 51 52 TargetData.dispose td 53 54 55(*===-- Driver ------------------------------------------------------------===*) 56 57let _ = 58 suite "target data" test_target_data; 59 dispose_module m 60