Fixed some bugs.
[llvm/zpu.git] / test / Bindings / Ocaml / target.ml
blob5e3ab4bf93547c8979f7894177fc3920b18f6f09
1 (* RUN: %ocamlopt -warn-error A llvm.cmxa llvm_target.cmxa %s -o %t
2 * RUN: %t %t.bc
3 * XFAIL: vg_leak
4 *)
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. *)
10 open Llvm
11 open Llvm_target
14 let context = global_context ()
15 let i32_type = Llvm.i32_type context
16 let i64_type = Llvm.i64_type context
18 (* Tiny unit test framework - really just to help find which line is busted *)
19 let print_checkpoints = false
21 let suite name f =
22 if print_checkpoints then
23 prerr_endline (name ^ ":");
24 f ()
27 (*===-- Fixture -----------------------------------------------------------===*)
29 let filename = Sys.argv.(1)
30 let m = create_module context filename
33 (*===-- Target Data -------------------------------------------------------===*)
35 let test_target_data () =
36 let td = TargetData.create (target_triple m) in
37 let sty = struct_type context [| i32_type; i64_type |] in
39 ignore (TargetData.as_string td);
40 ignore (TargetData.invalidate_struct_layout td sty);
41 ignore (byte_order td);
42 ignore (pointer_size td);
43 ignore (intptr_type td);
44 ignore (size_in_bits td sty);
45 ignore (store_size td sty);
46 ignore (abi_size td sty);
47 ignore (stack_align td sty);
48 ignore (preferred_align td sty);
49 ignore (preferred_align_of_global td (declare_global sty "g" m));
50 ignore (element_at_offset td sty (Int64.of_int 1));
51 ignore (offset_of_element td sty 1);
53 TargetData.dispose td
56 (*===-- Driver ------------------------------------------------------------===*)
58 let _ =
59 suite "target data" test_target_data;
60 dispose_module m