Source

ocaml-llvm-phantom / lib / wrap.ml

(* We require [initialize_native_target] to make the engine real JIT.
   Otherwise it fails to create a JIT and fall back to an interpreter,
   which fails to find external symbols
*)
let _bool = Llvm_executionengine.initialize_native_target ()
(* CR jfuruse: check the returned bool *)

module Create(A : sig 
  val context : Context.t
end) = struct

  include A

  module Value = Value_ctxt.Make(struct let context = context end)
  module Type = struct
    include Type_ctxt.Make(struct let context = context end)
    (* Copy size_of functions in Type *)
    let size_i64_of = Value.size_i64_of
    let size_of = Value.size_of
  end

  module CreateModule(A : sig
    val opt : bool
    val name : string
  end) = struct
    module M = Module.Make(struct
      include A
      let context = context
    end)
    include M
    module B = Build.Make(M)
    include B
    include B.Monad.Open
  end
end