diff options
Diffstat (limited to 'llvm/bindings/ocaml/bitwriter')
| -rw-r--r-- | llvm/bindings/ocaml/bitwriter/Makefile | 23 | ||||
| -rw-r--r-- | llvm/bindings/ocaml/bitwriter/bitwriter_ocaml.c | 31 | ||||
| -rw-r--r-- | llvm/bindings/ocaml/bitwriter/llvm_bitwriter.ml | 18 | ||||
| -rw-r--r-- | llvm/bindings/ocaml/bitwriter/llvm_bitwriter.mli | 18 |
4 files changed, 90 insertions, 0 deletions
diff --git a/llvm/bindings/ocaml/bitwriter/Makefile b/llvm/bindings/ocaml/bitwriter/Makefile new file mode 100644 index 00000000000..aef41f50092 --- /dev/null +++ b/llvm/bindings/ocaml/bitwriter/Makefile @@ -0,0 +1,23 @@ +##===- bindings/ocaml/llvm/Makefile ------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file was developed by the LLVM research group and is distributed under +# the University of Illinois Open Source License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +# +# This is the makefile for the llvm-ml interface. Reference materials on +# installing ocaml libraries: +# +# https://fedoraproject.org/wiki/Packaging/OCaml +# http://pkg-ocaml-maint.alioth.debian.org/ocaml_packaging_policy.txt +# +##===----------------------------------------------------------------------===## + +LEVEL := ../../.. +LIBRARYNAME := llvm_bitwriter +DONT_BUILD_RELINKED := 1 +UsedComponents := bitwriter + +include ../Makefile.ocaml diff --git a/llvm/bindings/ocaml/bitwriter/bitwriter_ocaml.c b/llvm/bindings/ocaml/bitwriter/bitwriter_ocaml.c new file mode 100644 index 00000000000..4abfa9f7b90 --- /dev/null +++ b/llvm/bindings/ocaml/bitwriter/bitwriter_ocaml.c @@ -0,0 +1,31 @@ +/*===-- bitwriter_ocaml.c - LLVM Ocaml Glue ---------------------*- C++ -*-===*\ +|* *| +|* The LLVM Compiler Infrastructure *| +|* *| +|* This file was developed by Gordon Henriksen and is distributed under the *| +|* University of Illinois Open Source License. See LICENSE.TXT for details. *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This file glues LLVM's ocaml interface to its C interface. These functions *| +|* are by and large transparent wrappers to the corresponding C functions. *| +|* *| +|* Note that these functions intentionally take liberties with the CAMLparamX *| +|* macros, since most of the parameters are not GC heap objects. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#include "llvm-c/BitWriter.h" +#include "llvm-c/Core.h" +#include "caml/alloc.h" +#include "caml/mlvalues.h" +#include "caml/memory.h" + +/*===-- Modules -----------------------------------------------------------===*/ + +/* Llvm.llmodule -> string -> bool */ +CAMLprim value llvm_write_bitcode_file(value M, value Path) { + CAMLparam1(Path); + int res = LLVMWriteBitcodeToFile((LLVMModuleRef) M, String_val(Path)); + CAMLreturn(Val_bool(res == 0)); +} diff --git a/llvm/bindings/ocaml/bitwriter/llvm_bitwriter.ml b/llvm/bindings/ocaml/bitwriter/llvm_bitwriter.ml new file mode 100644 index 00000000000..c9264b16c13 --- /dev/null +++ b/llvm/bindings/ocaml/bitwriter/llvm_bitwriter.ml @@ -0,0 +1,18 @@ +(*===-- llvm_bitwriter.ml - LLVM Ocaml Interface ----------------*- C++ -*-===* + * + * The LLVM Compiler Infrastructure + * + * This file was developed by Gordon Henriksen and is distributed under the + * University of Illinois Open Source License. See LICENSE.TXT for details. + * + *===----------------------------------------------------------------------=== + * + * This interface provides an ocaml API for the LLVM intermediate + * representation, the classes in the VMCore library. + * + *===----------------------------------------------------------------------===*) + + +(* Writes the bitcode for module the given path. Returns true if successful. *) +external write_bitcode_file : Llvm.llmodule -> string -> bool + = "llvm_write_bitcode_file" diff --git a/llvm/bindings/ocaml/bitwriter/llvm_bitwriter.mli b/llvm/bindings/ocaml/bitwriter/llvm_bitwriter.mli new file mode 100644 index 00000000000..3b7c6d49589 --- /dev/null +++ b/llvm/bindings/ocaml/bitwriter/llvm_bitwriter.mli @@ -0,0 +1,18 @@ +(*===-- llvm_bitwriter.mli - LLVM Ocaml Interface ---------------*- C++ -*-===* + * + * The LLVM Compiler Infrastructure + * + * This file was developed by Gordon Henriksen and is distributed under the + * University of Illinois Open Source License. See LICENSE.TXT for details. + * + *===----------------------------------------------------------------------=== + * + * This interface provides an ocaml API for the LLVM bitcode writer, the + * classes in the classes in the Bitwriter library. + * + *===----------------------------------------------------------------------===*) + + +(* Writes the bitcode for module the given path. Returns true if successful. *) +external write_bitcode_file : Llvm.llmodule -> string -> bool + = "llvm_write_bitcode_file" |

