##===- bindings/ocaml/Makefile -----------------------------*- Makefile -*-===##
-#
+#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
-#
+#
##===----------------------------------------------------------------------===##
LEVEL := ../..
##===- bindings/ocaml/Makefile.ocaml -----------------------*- Makefile -*-===##
-#
+#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
-#
+#
##===----------------------------------------------------------------------===##
-#
+#
# An OCaml library is a unique project type in the context of LLVM, so rules are
# here rather than in Makefile.rules.
-#
+#
# Reference materials on installing OCaml libraries:
-#
+#
# https://fedoraproject.org/wiki/Packaging/OCaml
# http://pkg-ocaml-maint.alioth.debian.org/ocaml_packaging_policy.txt
-#
+#
##===----------------------------------------------------------------------===##
include $(LEVEL)/Makefile.config
$(UsedLibs))
endif
endif
-
+
# -g was introduced in 3.10.0.
#ifneq ($(ENABLE_OPTIMIZED),1)
# OCAMLDEBUGFLAG := -g
$(Echo) "Installing $(BuildMode) $(DestA)"
$(Verb) $(MKDIR) $(PROJ_libocamldir)
$(Verb) $(INSTALL) $(LibraryA) $(DestA)
- $(Verb)
+ $(Verb)
uninstall-a::
$(Echo) "Uninstalling $(DestA)"
##===- bindings/ocaml/analysis/Makefile --------------------*- Makefile -*-===##
-#
+#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
-#
+#
##===----------------------------------------------------------------------===##
-#
+#
# This is the makefile for the Objective Caml Llvm_analysis interface.
-#
+#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
CAMLprim value llvm_verify_module(LLVMModuleRef M) {
CAMLparam0();
CAMLlocal2(String, Option);
-
+
char *Message;
int Result = LLVMVerifyModule(M, LLVMReturnStatusAction, &Message);
-
+
if (0 == Result) {
Option = Val_int(0);
} else {
String = copy_string(Message);
Store_field(Option, 0, String);
}
-
+
LLVMDisposeMessage(Message);
-
+
CAMLreturn(Option);
}
##===- bindings/ocaml/bitreader/Makefile -------------------*- Makefile -*-===##
-#
+#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
-#
+#
##===----------------------------------------------------------------------===##
-#
+#
# This is the makefile for the Objective Caml Llvm_bitreader interface.
-#
+#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
static void llvm_raise(value Prototype, char *Message) {
CAMLparam1(Prototype);
CAMLlocal1(CamlMessage);
-
+
CamlMessage = copy_string(Message);
LLVMDisposeMessage(Message);
-
+
raise_with_arg(Prototype, CamlMessage);
abort(); /* NOTREACHED */
#ifdef CAMLnoreturn
CAMLparam0();
CAMLlocal2(Variant, MessageVal);
char *Message;
-
+
LLVMModuleRef M;
if (LLVMGetBitcodeModuleInContext(C, MemBuf, &M, &Message))
llvm_raise(llvm_bitreader_error_exn, Message);
-
+
CAMLreturn((value) M);
}
CAMLlocal2(Variant, MessageVal);
LLVMModuleRef M;
char *Message;
-
+
if (LLVMParseBitcodeInContext(C, MemBuf, &M, &Message))
llvm_raise(llvm_bitreader_error_exn, Message);
-
+
CAMLreturn((value) M);
}
##===- bindings/ocaml/bitwriter/Makefile -------------------*- Makefile -*-===##
-#
+#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
-#
+#
##===----------------------------------------------------------------------===##
-#
+#
# This is the makefile for the Objective Caml Llvm_bitwriter interface.
-#
+#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
##===- bindings/ocaml/executionengine/Makefile --------------*- Makefile -*-===##
-#
+#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
-#
+#
##===----------------------------------------------------------------------===##
-#
+#
# This is the makefile for the Objective Caml Llvm_executionengine interface.
-#
+#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
##===- bindings/ocaml/llvm/Makefile ------------------------*- Makefile -*-===##
-#
+#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
-#
+#
##===----------------------------------------------------------------------===##
-#
+#
# This is the makefile for the Objective Caml Llvm interface.
-#
+#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
(** {7 Operations on composite constants} *)
(** [const_string c s] returns the constant [i8] array with the values of the
- characters in the string [s] in the context [c]. The array is not
+ characters in the string [s] in the context [c]. The array is not
null-terminated (but see {!const_stringz}). This value can in turn be used
as the initializer for a global variable. See the method
[llvm::ConstantArray::get]. *)
path [p]. If the file could not be read, then [IoError msg] is
raised. *)
val of_file : string -> llmemorybuffer
-
+
(** [of_stdin ()] is the memory buffer containing the contents of standard input.
If standard input is empty, then [IoError msg] is raised. *)
val of_stdin : unit -> llmemorybuffer
(** [as_string mb] is the string containing the contents of memory buffer [mb]. *)
val as_string : llmemorybuffer -> string
-
+
(** Disposes of a memory buffer. *)
val dispose : llmemorybuffer -> unit
end
(** *)
type 'a t
type any = [ `Module | `Function ]
-
+
(** [PassManager.create ()] constructs a new whole-module pass pipeline. This
type of pipeline is suitable for link-time optimization and whole-module
transformations.
See the constructor of [llvm::PassManager]. *)
val create : unit -> [ `Module ] t
-
+
(** [PassManager.create_function m] constructs a new function-by-function
pass pipeline over the module [m]. It does not take ownership of [m].
This type of pipeline is suitable for code generation and JIT compilation
the module, [false] otherwise.
See the [llvm::FunctionPassManager::doInitialization] method. *)
val initialize : [ `Function ] t -> bool
-
+
(** [run_function f fpm] executes all of the function passes scheduled in the
function pass manager [fpm] over the function [f]. Returns [true] if any
of the passes modified [f], [false] otherwise.
See the [llvm::FunctionPassManager::run] method. *)
val run_function : llvalue -> [ `Function ] t -> bool
-
+
(** [finalize fpm] finalizes all of the function passes scheduled in in the
function pass manager [fpm]. Returns [true] if any of the passes
modified the module, [false] otherwise.
See the [llvm::FunctionPassManager::doFinalization] method. *)
val finalize : [ `Function ] t -> bool
-
+
(** Frees the memory of a pass pipeline. For function pipelines, does not free
the module.
See the destructor of [llvm::BasePassManager]. *)
static void llvm_raise(value Prototype, char *Message) {
CAMLparam1(Prototype);
CAMLlocal1(CamlMessage);
-
+
CamlMessage = copy_string(Message);
LLVMDisposeMessage(Message);
-
+
raise_with_arg(Prototype, CamlMessage);
abort(); /* NOTREACHED */
#ifdef CAMLnoreturn
const char *GC;
CAMLparam0();
CAMLlocal2(Name, Option);
-
+
if ((GC = LLVMGetGC(Fn))) {
Name = copy_string(GC);
-
+
Option = alloc(1, 0);
Field(Option, 0) = Name;
CAMLreturn(Option);
unsigned I;
CAMLparam0();
CAMLlocal3(Hd, Tl, Tmp);
-
+
/* Build a tuple list of them. */
Tl = Val_int(0);
for (I = LLVMCountIncoming(PhiNode); I != 0; ) {
Hd = alloc(2, 0);
Store_field(Hd, 0, (value) LLVMGetIncomingValue(PhiNode, --I));
Store_field(Hd, 1, (value) LLVMGetIncomingBlock(PhiNode, I));
-
+
Tmp = alloc(2, 0);
Store_field(Tmp, 0, Hd);
Store_field(Tmp, 1, Tl);
Tl = Tmp;
}
-
+
CAMLreturn(Tl);
}
CAMLprim LLVMValueRef llvm_build_phi(value Incoming, value Name, value B) {
value Hd, Tl;
LLVMValueRef FirstValue, PhiNode;
-
+
assert(Incoming != Val_int(0) && "Empty list passed to Llvm.build_phi!");
-
+
Hd = Field(Incoming, 0);
FirstValue = (LLVMValueRef) Field(Hd, 0);
PhiNode = LLVMBuildPhi(Builder_val(B), LLVMTypeOf(FirstValue),
LLVMAddIncoming(PhiNode, (LLVMValueRef*) &Field(Hd, 0),
(LLVMBasicBlockRef*) &Field(Hd, 1), 1);
}
-
+
return PhiNode;
}
LLVMValueRef Element,
LLVMValueRef Idx,
value Name, value B) {
- return LLVMBuildInsertElement(Builder_val(B), Vec, Element, Idx,
+ return LLVMBuildInsertElement(Builder_val(B), Vec, Element, Idx,
String_val(Name));
}
CAMLparam1(Path);
char *Message;
LLVMMemoryBufferRef MemBuf;
-
+
if (LLVMCreateMemoryBufferWithContentsOfFile(String_val(Path),
&MemBuf, &Message))
llvm_raise(llvm_ioerror_exn, Message);
-
+
CAMLreturn((value) MemBuf);
}
CAMLprim LLVMMemoryBufferRef llvm_memorybuffer_of_stdin(value Unit) {
char *Message;
LLVMMemoryBufferRef MemBuf;
-
+
if (LLVMCreateMemoryBufferWithSTDIN(&MemBuf, &Message))
llvm_raise(llvm_ioerror_exn, Message);
-
+
return MemBuf;
}
= "llvm_add_cfg_simplification"
external
add_tail_call_elimination : [<Llvm.PassManager.any] Llvm.PassManager.t -> unit
- = "llvm_add_tail_call_elimination"
+ = "llvm_add_tail_call_elimination"
external add_gvn : [<Llvm.PassManager.any] Llvm.PassManager.t
-> unit
= "llvm_add_gvn"
(** See the [llvm::createTailCallEliminationPass] function. *)
external
add_tail_call_elimination : [<Llvm.PassManager.any] Llvm.PassManager.t -> unit
- = "llvm_add_tail_call_elimination"
+ = "llvm_add_tail_call_elimination"
(** See the [llvm::createGVNPass] function. *)
external add_gvn : [<Llvm.PassManager.any] Llvm.PassManager.t