LIBRARYNAME := llvm_executionengine
DONT_BUILD_RELINKED := 1
UsedComponents := executionengine jit interpreter native
-UsedOcamlInterfaces := llvm
+UsedOcamlInterfaces := llvm llvm_target
include ../Makefile.ocaml
= "llvm_ee_run_function_as_main"
external free_machine_code: Llvm.llvalue -> t -> unit
= "llvm_ee_free_machine_code"
+
+ external target_data: t -> Llvm_target.TargetData.t
+ = "LLVMGetExecutionEngineTargetData"
(* The following are not bound. Patches are welcome.
(** [free_machine_code f ee] releases the memory in the execution engine [ee]
used to store the machine code for the function [f]. *)
val free_machine_code: Llvm.llvalue -> t -> unit
+
+ (** [target_data ee] is the target data owned by the execution engine
+ [ee]. *)
+ val target_data: t -> Llvm_target.TargetData.t
end
#define LLVM_C_EXECUTIONENGINE_H
#include "llvm-c/Core.h"
+#include "llvm-c/Target.h"
#ifdef __cplusplus
extern "C" {
int LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
LLVMValueRef *OutFn);
+LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE);
+
#ifdef __cplusplus
}
}
return 1;
}
+
+LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE) {
+ return wrap(unwrap(EE)->getTargetData());
+}
-(* RUN: %ocamlc -warn-error A llvm.cma llvm_executionengine.cma %s -o %t
+(* RUN: %ocamlc -warn-error A llvm.cma llvm_target.cma llvm_executionengine.cma %s -o %t
* RUN: ./%t %t.bc
*)
open Llvm
open Llvm_executionengine
+open Llvm_target
(* Note that this takes a moment to link, so it's best to keep the number of
individual tests low. *)
(* run_static_dtors *)
ExecutionEngine.run_static_dtors ee;
+
+ (* Show that the target data binding links and runs.*)
+ let td = ExecutionEngine.target_data ee in
+
+ (* Demonstrate that a garbage pointer wasn't returned. *)
+ let ty = intptr_type td in
+ if ty != i32_type && ty != i64_type then bomb "target_data did not work";
(* dispose *)
ExecutionEngine.dispose ee