diff options
author | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-12-11 00:20:48 +0000 |
---|---|---|
committer | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-12-11 00:20:48 +0000 |
commit | bbc6597f02d108f32b5bdc7711cc67386196017b (patch) | |
tree | c0a9de6590c68d7d5cbd907da5ec03c723201e56 /test/Bindings | |
parent | 7eb587779e1c19768b98ba633c6dd0bbd306a323 (diff) | |
download | external_llvm-bbc6597f02d108f32b5bdc7711cc67386196017b.zip external_llvm-bbc6597f02d108f32b5bdc7711cc67386196017b.tar.gz external_llvm-bbc6597f02d108f32b5bdc7711cc67386196017b.tar.bz2 |
Adding Ocaml bindings for the bitreader as requested by Sarah
Thompson. Usage should be something like this:
open Llvm
open Llvm_bitreader
match read_bitcode_file fn with
| Bitreader_failure msg ->
prerr_endline msg
| Bitreader_success m ->
...;
dispose_module m
Compile with: ocamlc llvm.cma llvm_bitreader.cma
ocamlopt llvm.cmxa llvm_bitreader.cmxa
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44824 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Bindings')
-rw-r--r-- | test/Bindings/Ocaml/bitreader.ml | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/Bindings/Ocaml/bitreader.ml b/test/Bindings/Ocaml/bitreader.ml new file mode 100644 index 0000000..0bf8c00 --- /dev/null +++ b/test/Bindings/Ocaml/bitreader.ml @@ -0,0 +1,23 @@ +(* RUN: %ocamlc llvm.cma llvm_bitreader.cma llvm_bitwriter.cma %s -o %t + * RUN: ./%t %t.bc + * RUN: llvm-dis < %t.bc | grep caml_int_ty + *) + +(* Note that this takes a moment to link, so it's best to keep the number of + individual tests low. *) + +let test x = if not x then exit 1 else () + +let _ = + let fn = Sys.argv.(1) in + let m = Llvm.create_module "ocaml_test_module" in + + ignore (Llvm.define_type_name "caml_int_ty" Llvm.i32_type m); + + test (Llvm_bitwriter.write_bitcode_file m fn); + + Llvm.dispose_module m; + + test (match Llvm_bitreader.read_bitcode_file fn with + | Llvm_bitreader.Bitreader_success m -> Llvm.dispose_module m; true + | Llvm_bitreader.Bitreader_failure _ -> false) |