385bc8131e28579be0277f8e6914b1c9b4addd5c
[oota-llvm.git] / test / Bindings / Ocaml / target.ml
1 (* RUN: %ocamlc -warn-error A llvm.cma llvm_target.cma %s -o %t 2> /dev/null
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 (* Tiny unit test framework - really just to help find which line is busted *)
12 let suite name f =
13   prerr_endline (name ^ ":");
14   f ()
15
16
17 (*===-- Fixture -----------------------------------------------------------===*)
18
19 let filename = Sys.argv.(1)
20 let m = create_module (global_context ()) filename
21
22
23 (*===-- Target Data -------------------------------------------------------===*)
24
25 let test_target_data () =
26   let td = TargetData.create (target_triple m) in
27   let sty = struct_type (global_context ()) [| i32_type; i64_type |] in
28   
29   ignore (TargetData.as_string td);
30   ignore (TargetData.invalidate_struct_layout td sty);
31   ignore (byte_order td);
32   ignore (pointer_size td);
33   ignore (intptr_type td);
34   ignore (size_in_bits td sty);
35   ignore (store_size td sty);
36   ignore (abi_size td sty);
37   ignore (stack_align td sty);
38   ignore (preferred_align td sty);
39   ignore (preferred_align_of_global td (declare_global sty "g" m));
40   ignore (element_at_offset td sty (Int64.of_int 1));
41   ignore (offset_of_element td sty 1);
42   
43   TargetData.dispose td
44
45
46 (*===-- Driver ------------------------------------------------------------===*)
47
48 let _ =
49   suite "target data" test_target_data;
50   dispose_module m