2009-09-04 01:27:31 +02:00
|
|
|
(* RUN: %ocamlopt -warn-error A llvm.cmxa llvm_target.cmxa %s -o %t
|
2010-08-20 16:51:26 +02:00
|
|
|
* RUN: %t %t.bc
|
2010-09-09 17:50:19 +02:00
|
|
|
* XFAIL: vg_leak
|
2008-03-16 21:08:03 +01:00
|
|
|
*)
|
|
|
|
|
2009-09-04 01:27:31 +02:00
|
|
|
(* Note: It takes several seconds for ocamlopt to link an executable with
|
2008-03-16 21:08:03 +01: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 16:51:26 +02:00
|
|
|
|
2009-08-19 19:32:24 +02:00
|
|
|
let context = global_context ()
|
|
|
|
let i32_type = Llvm.i32_type context
|
|
|
|
let i64_type = Llvm.i64_type context
|
|
|
|
|
2008-03-16 21:08:03 +01:00
|
|
|
(* Tiny unit test framework - really just to help find which line is busted *)
|
2010-08-20 16:51:26 +02:00
|
|
|
let print_checkpoints = false
|
|
|
|
|
2008-03-16 21:08:03 +01:00
|
|
|
let suite name f =
|
2010-08-20 16:51:26 +02:00
|
|
|
if print_checkpoints then
|
|
|
|
prerr_endline (name ^ ":");
|
2008-03-16 21:08:03 +01:00
|
|
|
f ()
|
|
|
|
|
|
|
|
|
|
|
|
(*===-- Fixture -----------------------------------------------------------===*)
|
|
|
|
|
|
|
|
let filename = Sys.argv.(1)
|
2009-08-19 19:32:24 +02:00
|
|
|
let m = create_module context filename
|
2008-03-16 21:08:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
(*===-- Target Data -------------------------------------------------------===*)
|
|
|
|
|
|
|
|
let test_target_data () =
|
2012-10-08 18:39:34 +02:00
|
|
|
let td = DataLayout.create (target_triple m) in
|
2009-08-19 19:32:24 +02:00
|
|
|
let sty = struct_type context [| i32_type; i64_type |] in
|
2008-03-16 21:08:03 +01:00
|
|
|
|
2012-10-08 18:39:34 +02:00
|
|
|
ignore (DataLayout.as_string td);
|
2008-03-16 21:08:03 +01:00
|
|
|
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);
|
|
|
|
|
2012-10-08 18:39:34 +02:00
|
|
|
DataLayout.dispose td
|
2008-03-16 21:08:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
(*===-- Driver ------------------------------------------------------------===*)
|
|
|
|
|
|
|
|
let _ =
|
|
|
|
suite "target data" test_target_data;
|
|
|
|
dispose_module m
|