aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErick Tryzelaar <idadesub@users.sourceforge.net>2008-03-27 00:27:14 +0000
committerErick Tryzelaar <idadesub@users.sourceforge.net>2008-03-27 00:27:14 +0000
commit7c1483bc6f009318ce66c4d37d1ba930e01a6d13 (patch)
tree8aa88262df0f503ca36854ba1150deb772dcf048
parent5b0c85588a5cdb90e975257f53291bb08e461b81 (diff)
Expose ExecutionEngine::getTargetData() to c and ocaml bindings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48851 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--bindings/ocaml/executionengine/Makefile2
-rw-r--r--bindings/ocaml/executionengine/llvm_executionengine.ml3
-rw-r--r--bindings/ocaml/executionengine/llvm_executionengine.mli4
-rw-r--r--include/llvm-c/ExecutionEngine.h3
-rw-r--r--lib/ExecutionEngine/ExecutionEngineBindings.cpp4
-rw-r--r--test/Bindings/Ocaml/executionengine.ml10
6 files changed, 24 insertions, 2 deletions
diff --git a/bindings/ocaml/executionengine/Makefile b/bindings/ocaml/executionengine/Makefile
index 445e0ea401..40fb98e191 100644
--- a/bindings/ocaml/executionengine/Makefile
+++ b/bindings/ocaml/executionengine/Makefile
@@ -15,6 +15,6 @@ LEVEL := ../../..
LIBRARYNAME := llvm_executionengine
DONT_BUILD_RELINKED := 1
UsedComponents := executionengine jit interpreter native
-UsedOcamlInterfaces := llvm
+UsedOcamlInterfaces := llvm llvm_target
include ../Makefile.ocaml
diff --git a/bindings/ocaml/executionengine/llvm_executionengine.ml b/bindings/ocaml/executionengine/llvm_executionengine.ml
index a73fc1e4ba..4b9132df05 100644
--- a/bindings/ocaml/executionengine/llvm_executionengine.ml
+++ b/bindings/ocaml/executionengine/llvm_executionengine.ml
@@ -82,6 +82,9 @@ module ExecutionEngine = struct
= "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.
diff --git a/bindings/ocaml/executionengine/llvm_executionengine.mli b/bindings/ocaml/executionengine/llvm_executionengine.mli
index d3037fe856..9794f358ff 100644
--- a/bindings/ocaml/executionengine/llvm_executionengine.mli
+++ b/bindings/ocaml/executionengine/llvm_executionengine.mli
@@ -147,4 +147,8 @@ module ExecutionEngine: sig
(** [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
diff --git a/include/llvm-c/ExecutionEngine.h b/include/llvm-c/ExecutionEngine.h
index cfa6f521bf..b1d130c20f 100644
--- a/include/llvm-c/ExecutionEngine.h
+++ b/include/llvm-c/ExecutionEngine.h
@@ -20,6 +20,7 @@
#define LLVM_C_EXECUTIONENGINE_H
#include "llvm-c/Core.h"
+#include "llvm-c/Target.h"
#ifdef __cplusplus
extern "C" {
@@ -88,6 +89,8 @@ int LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE,
int LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
LLVMValueRef *OutFn);
+LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE);
+
#ifdef __cplusplus
}
diff --git a/lib/ExecutionEngine/ExecutionEngineBindings.cpp b/lib/ExecutionEngine/ExecutionEngineBindings.cpp
index 20ee78044c..4dc0add069 100644
--- a/lib/ExecutionEngine/ExecutionEngineBindings.cpp
+++ b/lib/ExecutionEngine/ExecutionEngineBindings.cpp
@@ -187,3 +187,7 @@ int LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
}
return 1;
}
+
+LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE) {
+ return wrap(unwrap(EE)->getTargetData());
+}
diff --git a/test/Bindings/Ocaml/executionengine.ml b/test/Bindings/Ocaml/executionengine.ml
index a091098b5b..d238076a06 100644
--- a/test/Bindings/Ocaml/executionengine.ml
+++ b/test/Bindings/Ocaml/executionengine.ml
@@ -1,9 +1,10 @@
-(* 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. *)
@@ -92,6 +93,13 @@ let test_executionengine () =
(* 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