diff options
author | Gordon Henriksen <gordonhenriksen@mac.com> | 2008-03-16 16:32:40 +0000 |
---|---|---|
committer | Gordon Henriksen <gordonhenriksen@mac.com> | 2008-03-16 16:32:40 +0000 |
commit | 41ba1546eb46030e9994ee14f8052a1981ae2c54 (patch) | |
tree | 74d0748a279884133b551f3658acc0c9879b0cbe /test/Bindings | |
parent | 395b4149061ba7a280b628a23bcfdce94ddbfdf5 (diff) | |
download | external_llvm-41ba1546eb46030e9994ee14f8052a1981ae2c54.zip external_llvm-41ba1546eb46030e9994ee14f8052a1981ae2c54.tar.gz external_llvm-41ba1546eb46030e9994ee14f8052a1981ae2c54.tar.bz2 |
C and Objective Caml bindings for several scalar transforms.
Patch originally by Erick Tryzelaar, but has been modified somewhat.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48419 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Bindings')
-rw-r--r-- | test/Bindings/Ocaml/scalar_opts.ml | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/Bindings/Ocaml/scalar_opts.ml b/test/Bindings/Ocaml/scalar_opts.ml new file mode 100644 index 0000000..2f520b1 --- /dev/null +++ b/test/Bindings/Ocaml/scalar_opts.ml @@ -0,0 +1,50 @@ +(* RUN: %ocamlc -warn-error A llvm.cma llvm_scalar_opts.cma %s -o %t + *) + +(* Note: It takes several seconds for ocamlc to link an executable with + libLLVMCore.a, so it's better to write a big test than a bunch of + little ones. *) + +open Llvm +open Llvm_scalar_opts + + +(* Tiny unit test framework - really just to help find which line is busted *) +let suite name f = + prerr_endline (name ^ ":"); + f () + + +(*===-- Fixture -----------------------------------------------------------===*) + +let filename = Sys.argv.(1) +let m = create_module filename +let mp = ModuleProvider.create m + + +(*===-- Transforms --------------------------------------------------------===*) + +let test_transforms () = + let (++) x f = ignore (f x); x in + + let fty = function_type void_type [| |] in + let fn = define_function "fn" fty m in + ignore (build_ret_void (builder_at_end (entry_block fn))); + + ignore (PassManager.create_function mp + (* ++ add_instruction_combining Requires target data. *) + ++ add_reassociation + ++ add_gvn + ++ add_cfg_simplification + ++ add_constant_propagation + ++ PassManager.initialize + ++ PassManager.run_function fn + ++ PassManager.finalize + ++ PassManager.dispose) + + +(*===-- Driver ------------------------------------------------------------===*) + +let _ = + suite "transforms" test_transforms; + ModuleProvider.dispose mp |