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