2009-09-03 23:27:31 +00:00
|
|
|
(* RUN: %ocamlopt -warn-error A llvm.cmxa llvm_target.cmxa %s -o %t
|
2010-08-20 14:51:26 +00:00
|
|
|
* RUN: %t %t.bc
|
2010-09-09 15:50:19 +00:00
|
|
|
* XFAIL: vg_leak
|
2008-03-16 20:08:03 +00:00
|
|
|
*)
|
|
|
|
|
2009-09-03 23:27:31 +00:00
|
|
|
(* Note: It takes several seconds for ocamlopt to link an executable with
|
2008-03-16 20:08:03 +00:00
|
|
|
libLLVMCore.a, so it's better to write a big test than a bunch of
|
|
|
|
little ones. *)
|
|
|
|
|
|
|
|
open Llvm
|
|
|
|
open Llvm_target
|
|
|
|
|
2010-08-20 14:51:26 +00:00
|
|
|
|
2009-08-19 17:32:24 +00:00
|
|
|
let context = global_context ()
|
|
|
|
let i32_type = Llvm.i32_type context
|
|
|
|
let i64_type = Llvm.i64_type context
|
|
|
|
|
2008-03-16 20:08:03 +00:00
|
|
|
(* Tiny unit test framework - really just to help find which line is busted *)
|
2010-08-20 14:51:26 +00:00
|
|
|
let print_checkpoints = false
|
|
|
|
|
2008-03-16 20:08:03 +00:00
|
|
|
let suite name f =
|
2010-08-20 14:51:26 +00:00
|
|
|
if print_checkpoints then
|
|
|
|
prerr_endline (name ^ ":");
|
2008-03-16 20:08:03 +00:00
|
|
|
f ()
|
|
|
|
|
|
|
|
|
|
|
|
(*===-- Fixture -----------------------------------------------------------===*)
|
|
|
|
|
|
|
|
let filename = Sys.argv.(1)
|
2009-08-19 17:32:24 +00:00
|
|
|
let m = create_module context filename
|
2008-03-16 20:08:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
(*===-- Target Data -------------------------------------------------------===*)
|
|
|
|
|
|
|
|
let test_target_data () =
|
|
|
|
let td = TargetData.create (target_triple m) in
|
2009-08-19 17:32:24 +00:00
|
|
|
let sty = struct_type context [| i32_type; i64_type |] in
|
2008-03-16 20:08:03 +00:00
|
|
|
|
|
|
|
ignore (TargetData.as_string td);
|
|
|
|
ignore (TargetData.invalidate_struct_layout td sty);
|
|
|
|
ignore (byte_order td);
|
|
|
|
ignore (pointer_size td);
|
|
|
|
ignore (intptr_type td);
|
|
|
|
ignore (size_in_bits td sty);
|
|
|
|
ignore (store_size td sty);
|
|
|
|
ignore (abi_size td sty);
|
|
|
|
ignore (stack_align td sty);
|
|
|
|
ignore (preferred_align td sty);
|
|
|
|
ignore (preferred_align_of_global td (declare_global sty "g" m));
|
|
|
|
ignore (element_at_offset td sty (Int64.of_int 1));
|
|
|
|
ignore (offset_of_element td sty 1);
|
|
|
|
|
|
|
|
TargetData.dispose td
|
|
|
|
|
|
|
|
|
|
|
|
(*===-- Driver ------------------------------------------------------------===*)
|
|
|
|
|
|
|
|
let _ =
|
|
|
|
suite "target data" test_target_data;
|
|
|
|
dispose_module m
|