/ocaml_of_llvm

LLVM to OCaml transpiler

Primary LanguageOCamlOtherNOASSERTION

This project is a transpiler from LLVM bitcode to OCaml source code (not from OCaml to LLVM). This is largely useless, but pretty amusing.

It exists because I wanted to try to use js_of_ocaml on an project with a non-trivial dependency on a C library. By 'compiling' the C library to OCaml and modifying the project to use that, I'd be able to turn the project into a 'pure' OCaml project. This currently should work for small-ish C libraries.

The included scripts "build" an example binary from Intel's XED in this manner.

There's still missing llvm opcodes, and I/O is mostly unimplemented, and there's probably lots of bugs. But, the XED example binary works (at least for me; if your clang generates different bitcode, then it may contain an unimplemented/buggy opcode).

Requirements

Works with LLVM 8; will almost certainly have minor issues with other versions of the IR.

Works with OCaml 4.08.0; it should work with older versions if you deal with the renamed standard library functions.