[llvm-commits] [PATCH] Expose Pass and PassManager classes to c and ocaml bindings.
Gordon Henriksen
gordonhenriksen at mac.com
Mon Mar 10 09:33:20 PDT 2008
On Mar 10, 2008, at 04:18, Erick Tryzelaar wrote:
> This is groundwork to exposing the llvm transformations to the
> bindings. It only partially implements the pass api.
Nice. A few comments.
> diff --git bindings/ocaml/llvm/llvm.mli bindings/ocaml/llvm/llvm.mli
> index 838c518..f318383 100644
> --- bindings/ocaml/llvm/llvm.mli
> +++ bindings/ocaml/llvm/llvm.mli
> @@ -1362,3 +1378,35 @@ module MemoryBuffer : sig
> (** Disposes of a memory buffer. *)
> external dispose : llmemorybuffer -> unit =
> "llvm_memorybuffer_dispose"
> end
> +
> +
> +(** {6 Pass} *)
> +
> +external pass_of_functionpass : llpass -> llfunctionpass
> + = "LLVMPassFunctionPass"
> +
> +external pass_name : llpass -> string = "llvm_pass_name"
> +
> +module PassManager : sig
> + external create : unit -> llpassmanager = "llvm_passmanager_create"
> + external dispose : llpassmanager -> unit =
> "llvm_passmanager_dispose"
> + external add_pass : llpassmanager -> llpass -> unit
> + = "llvm_passmanager_add_pass"
> + external run_module : llpassmanager -> llmodule -> unit
> + = "llvm_passmanager_run_module"
> +end
> +
> +module FunctionPassManager : sig
> + external create : llmoduleprovider -> llfunctionpassmanager
> + = "llvm_function_passmanager_create"
> + external dispose : llfunctionpassmanager -> unit
> + = "llvm_functionpassmanager_dispose"
> + external add_pass : llfunctionpassmanager -> llpass -> unit
> + = "llvm_functionpassmanager_add_pass"
> + external run_function : llfunctionpassmanager -> llvalue -> unit
> + = "llvm_functionpassmanager_run_function"
> + external do_initialization : llfunctionpassmanager -> unit
> + =
> "llvm_functionpassmanager_do_initialization"
> + external do_finalization : llfunctionpassmanager -> unit
> + =
> "llvm_functionpassmanager_do_finalization"
> +end
No docucomments?
> diff --git bindings/ocaml/llvm/llvm_ocaml.c bindings/ocaml/llvm/
> llvm_ocaml.c
> index 0c7ee84..d795efd 100644
> --- bindings/ocaml/llvm/llvm_ocaml.c
> +++ bindings/ocaml/llvm/llvm_ocaml.c
> @@ -16,6 +16,8 @@
>
> \*=
> =
> =
> ----------------------------------------------------------------------=
> ==*/
>
> #include "llvm-c/Core.h"
> +#include "llvm-c/Pass.h"
> +#include "llvm-c/PassManager.h"
> #include "caml/alloc.h"
> #include "caml/custom.h"
> #include "caml/memory.h"
> +/*===-- Pass.h - Pass C Iface -----------------------------------*-
> C++ -*-===*\
> +/*===-- PassManager.h - Pass Manager C Iface --------------------*-
> C++ -*-===*\
I'd rather stick to one C header per library (or at least area of
functionality) if you don't mind.
> +//===-- PassBindings.cpp - C bindings for Passes
> --------------------------===//
>>
> +//===-- PassManagerBindings.cpp - C bindings for Pass Managers
> ------------===//
Likewise the glue. Bindings simply aren't significant enough to double
the number of source files in the tree. :) As another approach, we can
dump the C bindings at the bottom of the .cpp defining the methods
they expose.
Thanks Erick! I'll look at the other two later.
— Gordon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20080310/fee44d56/attachment.html>
More information about the llvm-commits
mailing list