1. camlspotter
  2. ocaml-llvm-phantom

Source

ocaml-llvm-phantom / lib / module_intf.ml

open Llvm

open Type
open Value

open Phantom

module type S = sig

  (** {6 Modules}

      Module is another state like builder, but rarely created. We here uses ML Functor
      instead of monad to avoid typing module argument everywhere.

      (We can use monads instead but probably we are fed up with too many binds.)
  *)

  val context : Context.t
  val name : string
  val opt : bool

  val module_ : llmodule
  (** Created module *)

  (** {6 Functions from Llvm.ml with shorter names} *)

  val dispose : unit -> unit
  (** Calls Llvm.dispose_module. Use with care *)
  val target_triple : unit -> string
  val set_target_triple : string -> unit
  val data_layout : unit -> string
  val set_data_layout : string -> unit
(* not in 3.2
  val define_type_name : string -> 'a typ -> 'a typ
*)
  (* delete_type_name : really you need it ? *)
  val type_by_name : string -> unknown typ option
  val dump : unit -> unit
    (** Calls dump_module *)
  val set_inline_asm : string -> unit
    (** Calls set_module_inline_asm *)

  module ExecutionEngine : sig
    val run_function : ('args -> 'ret) pointer v -> 'args Genvalue.vs -> 'ret Genvalue.v

    (** run_function<i> : (tpl<i> -> 'a) pointer v -> tpl<i>[0] Genvalue.v -> ... -> tpl<i>[i-1] Genvalue.v -> 'a Genvalue.v *)

    val run_function0 : (tpl0 -> 'a) pointer v -> unit -> 'a Genvalue.v
    val run_function1 : ('a tpl1 -> 'b) pointer v -> 'a Genvalue.v -> 'b Genvalue.v
    val run_function2 : (('a, 'b) tpl2 -> 'c) pointer v ->
      'a Genvalue.v -> 'b Genvalue.v -> 'c Genvalue.v
    val run_function3 :
      (('a, 'b, 'c) tpl3 -> 'd) pointer v ->
      'a Genvalue.v ->
      'b Genvalue.v ->
      'c Genvalue.v -> 'd Genvalue.v
    val run_function4 :
      (('a, 'b, 'c, 'd) tpl4 -> 'e) pointer v ->
      'a Genvalue.v ->
      'b Genvalue.v ->
      'c Genvalue.v ->
      'd Genvalue.v -> 'e Genvalue.v
    val run_function5 :
      (('a, 'b, 'c, 'd, 'e) tpl5 -> 'f) pointer v ->
      'a Genvalue.v ->
      'b Genvalue.v ->
      'c Genvalue.v ->
      'd Genvalue.v ->
      'e Genvalue.v -> 'f Genvalue.v
    val run_function6 :
      (('a, 'b, 'c, 'd, 'e, 'f) tpl6 -> 'g) pointer v ->
      'a Genvalue.v ->
      'b Genvalue.v ->
      'c Genvalue.v ->
      'd Genvalue.v ->
      'e Genvalue.v ->
      'f Genvalue.v -> 'g Genvalue.v
    val run_function7 :
      (('a, 'b, 'c, 'd, 'e, 'f, 'g) tpl7 -> 'h) pointer v ->
      'a Genvalue.v ->
      'b Genvalue.v ->
      'c Genvalue.v ->
      'd Genvalue.v ->
      'e Genvalue.v ->
      'f Genvalue.v ->
      'g Genvalue.v -> 'h Genvalue.v
    val run_function8 :
      (('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h) tpl8 -> 'i) pointer v ->
      'a Genvalue.v ->
      'b Genvalue.v ->
      'c Genvalue.v ->
      'd Genvalue.v ->
      'e Genvalue.v ->
      'f Genvalue.v ->
      'g Genvalue.v ->
      'h Genvalue.v -> 'i Genvalue.v
    val run_function9 :
      (('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i) tpl9 -> 'j) pointer v ->
      'a Genvalue.v ->
      'b Genvalue.v ->
      'c Genvalue.v ->
      'd Genvalue.v ->
      'e Genvalue.v ->
      'f Genvalue.v ->
      'g Genvalue.v ->
      'h Genvalue.v ->
      'i Genvalue.v -> 'j Genvalue.v
    val run_function10 :
      (('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j) tpl10 -> 'k) pointer v ->
      'a Genvalue.v ->
      'b Genvalue.v ->
      'c Genvalue.v ->
      'd Genvalue.v ->
      'e Genvalue.v ->
      'f Genvalue.v ->
      'g Genvalue.v ->
      'h Genvalue.v ->
      'i Genvalue.v ->
      'j Genvalue.v -> 'k Genvalue.v
  end

  module Function : sig
    val lookup : string -> (unknown -> unknown) pointer v option
    val declare : string -> ('a -> 'b) typ -> ('a -> 'b) pointer v
  end
  
  module External : sig
    val declare : string -> 'a typ -> 'b typs -> ('b -> 'a) pointer v
    val declare_var_arg : string -> 'a typ -> 'b typs -> ('b -> dots -> 'a) pointer v

    (** functions from libc *)  

    val malloc : (i32 tpl1 -> void_pointer) pointer v
    val free : (void_pointer tpl1 -> void) pointer v
    val memcpy : ((void_pointer, void_pointer, i32) tpl3 -> void_pointer) pointer v
    val printf : (i8 pointer tpl1 -> dots -> i32) pointer v
    val bzero : ((void_pointer, i32) tpl2 -> void) pointer v
  end

  module PassManager : sig 
    val run_function_if_opt : ('a -> 'b) pointer v -> unit 
  end
end