(* RUN: rm -rf %t && mkdir -p %t && cp %s %t/target.ml
* RUN: %ocamlc -g -w +A -package llvm.target -package llvm.all_backends -linkpkg %t/target.ml -o %t/executable
* RUN: %ocamlopt -g -w +A -package llvm.target -package llvm.all_backends -linkpkg %t/target.ml -o %t/executable
* RUN: %t/executable %t/bitcode.bc
* XFAIL: vg_leak
*)
(* Note: It takes several seconds for ocamlopt to link an executable with
libLLVMCore.a, so it's better to write a big test than a bunch of
little ones. *)
let ( = initialize (
let context = global_context (
let i32_type = i32_type context
let i64_type = i64_type context
(* Tiny unit test framework - really just to help find which line is busted *)
let print_checkpoints = false
let _ =
record_backtrace true
if a <> b then failwith "assert_equal"
(*===-- Fixture -----------------------------------------------------------===*)
let filename = argv.
let m = create_module context filename
let target = by_triple
let machine = create target
(*===-- Data Layout -------------------------------------------------------===*)
DataLayout in
let layout = "e-p:32:32-f64:32:64-v64:32:64-v128:32:128-n32-S32" in
let dl = of_string layout in
let sty = struct_type context in
assert_equal layout;
assert_equal Little;
assert_equal 4;
assert_equal i32_type;
assert_equal 4;
assert_equal i32_type;
assert_equal ;
assert_equal ;
assert_equal ;
assert_equal 4;
assert_equal 8;
assert_equal 8;
assert_equal 0;
assert_equal
(*===-- Target ------------------------------------------------------------===*)
Target in
ignore ;
ignore ;
ignore ;
ignore ;
ignore ;
ignore
(*===-- Target Machine ----------------------------------------------------===*)
TargetMachine in
assert_equal target;
assert_equal ;
assert_equal "";
assert_equal "";
ignore ;
set_verbose_asm true machine;
let pm = create ( in
add_analysis_passes pm machine
(*===-- Code Emission -----------------------------------------------------===*)
emit_to_file m ObjectFile filename machine;
try
emit_to_file m ObjectFile
"/nonexistent/file" machine;
failwith "must raise"
(;
let buf = emit_to_memory_buffer m ObjectFile
machine in
dispose buf
(*===-- Driver ------------------------------------------------------------===*)
let _ =
test_target_data (;
test_target (;
test_target_machine (;
test_code_emission (;
dispose_module m