[OCaml] [autoconf] Migrate to ocamlfind.
[oota-llvm.git] / test / Bindings / Ocaml / vectorize_opts.ml
1 (* RUN: cp %s %T/vectorize_opts.ml
2  * RUN: %ocamlcomp -warn-error A -package llvm.vectorize -linkpkg %T/vectorize_opts.ml -o %t
3  * RUN: %t %t.bc
4  * XFAIL: vg_leak
5  *)
6
7 (* Note: It takes several seconds for ocamlopt to link an executable with
8          libLLVMCore.a, so it's better to write a big test than a bunch of
9          little ones. *)
10
11 open Llvm
12 open Llvm_vectorize
13 open Llvm_target
14
15 let context = global_context ()
16 let void_type = Llvm.void_type context
17
18 (* Tiny unit test framework - really just to help find which line is busted *)
19 let print_checkpoints = false
20
21 let suite name f =
22   if print_checkpoints then
23     prerr_endline (name ^ ":");
24   f ()
25
26
27 (*===-- Fixture -----------------------------------------------------------===*)
28
29 let filename = Sys.argv.(1)
30 let m = create_module context filename
31
32
33 (*===-- Transforms --------------------------------------------------------===*)
34
35 let test_transforms () =
36   let (++) x f = f x; x in
37
38   let fty = function_type void_type [| |] in
39   let fn = define_function "fn" fty m in
40   ignore (build_ret_void (builder_at_end context (entry_block fn)));
41
42   ignore (PassManager.create ()
43            ++ add_bb_vectorize
44            ++ add_loop_vectorize
45            ++ add_slp_vectorize
46            ++ PassManager.run_module m
47            ++ PassManager.dispose)
48
49
50 (*===-- Driver ------------------------------------------------------------===*)
51
52 let _ =
53   suite "transforms" test_transforms;
54   dispose_module m