Indentation change.
[llvm/avr.git] / test / Bindings / Ocaml / scalar_opts.ml
blob0a65db996bb4424e52895a994e881d5e8ff4eca9
1 (* RUN: %ocamlc -warn-error A llvm.cma llvm_scalar_opts.cma llvm_target.cma %s -o %t 2> /dev/null
2 *)
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. *)
8 open Llvm
9 open Llvm_scalar_opts
10 open Llvm_target
13 (* Tiny unit test framework - really just to help find which line is busted *)
14 let suite name f =
15 prerr_endline (name ^ ":");
16 f ()
19 (*===-- Fixture -----------------------------------------------------------===*)
21 let filename = Sys.argv.(1)
22 let m = create_module filename
23 let mp = ModuleProvider.create m
26 (*===-- Transforms --------------------------------------------------------===*)
28 let test_transforms () =
29 let (++) x f = ignore (f x); x in
31 let fty = function_type void_type [| |] in
32 let fn = define_function "fn" fty m in
33 ignore (build_ret_void (builder_at_end (entry_block fn)));
35 let td = TargetData.create (target_triple m) in
37 ignore (PassManager.create_function mp
38 ++ TargetData.add td
39 ++ add_instruction_combining
40 ++ add_reassociation
41 ++ add_gvn
42 ++ add_cfg_simplification
43 ++ add_constant_propagation
44 ++ PassManager.initialize
45 ++ PassManager.run_function fn
46 ++ PassManager.finalize
47 ++ PassManager.dispose);
49 TargetData.dispose td
52 (*===-- Driver ------------------------------------------------------------===*)
54 let _ =
55 suite "transforms" test_transforms;
56 ModuleProvider.dispose mp