1 (* RUN: rm -rf %t.builddir
2 * RUN: mkdir -p %t.builddir
3 * RUN: cp %s %t.builddir
4 * RUN: %ocamlopt -warn-error A llvm.cmxa llvm_target.cmxa %t.builddir/target.ml -o %t
9 (* Note: It takes several seconds for ocamlopt to link an executable with
10 libLLVMCore.a, so it's better to write a big test than a bunch of
17 let context = global_context ()
18 let i32_type = Llvm.i32_type context
19 let i64_type = Llvm.i64_type context
21 (* Tiny unit test framework - really just to help find which line is busted *)
22 let print_checkpoints = false
25 if print_checkpoints then
26 prerr_endline (name ^ ":");
30 (*===-- Fixture -----------------------------------------------------------===*)
32 let filename = Sys.argv.(1)
33 let m = create_module context filename
36 (*===-- Target Data -------------------------------------------------------===*)
38 let test_target_data () =
39 let td = DataLayout.create (target_triple m) in
40 let sty = struct_type context [| i32_type; i64_type |] in
42 ignore (DataLayout.as_string td);
43 ignore (byte_order td);
44 ignore (pointer_size td);
45 ignore (intptr_type td);
46 ignore (size_in_bits td sty);
47 ignore (store_size td sty);
48 ignore (abi_size td sty);
49 ignore (stack_align td sty);
50 ignore (preferred_align td sty);
51 ignore (preferred_align_of_global td (declare_global sty "g" m));
52 ignore (element_at_offset td sty (Int64.of_int 1));
53 ignore (offset_of_element td sty 1);
58 (*===-- Driver ------------------------------------------------------------===*)
61 suite "target data" test_target_data;