llvm.org GIT mirror llvm / 7c1483b
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 Erick Tryzelaar 12 years ago
6 changed file(s) with 24 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
1414 LIBRARYNAME := llvm_executionengine
1515 DONT_BUILD_RELINKED := 1
1616 UsedComponents := executionengine jit interpreter native
17 UsedOcamlInterfaces := llvm
17 UsedOcamlInterfaces := llvm llvm_target
1818
1919 include ../Makefile.ocaml
8181 = "llvm_ee_run_function_as_main"
8282 external free_machine_code: Llvm.llvalue -> t -> unit
8383 = "llvm_ee_free_machine_code"
84
85 external target_data: t -> Llvm_target.TargetData.t
86 = "LLVMGetExecutionEngineTargetData"
8487
8588 (* The following are not bound. Patches are welcome.
8689
146146 (** [free_machine_code f ee] releases the memory in the execution engine [ee]
147147 used to store the machine code for the function [f]. *)
148148 val free_machine_code: Llvm.llvalue -> t -> unit
149
150 (** [target_data ee] is the target data owned by the execution engine
151 [ee]. *)
152 val target_data: t -> Llvm_target.TargetData.t
149153 end
1919 #define LLVM_C_EXECUTIONENGINE_H
2020
2121 #include "llvm-c/Core.h"
22 #include "llvm-c/Target.h"
2223
2324 #ifdef __cplusplus
2425 extern "C" {
8788 int LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
8889 LLVMValueRef *OutFn);
8990
91 LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE);
92
9093 #ifdef __cplusplus
9194 }
9295
186186 }
187187 return 1;
188188 }
189
190 LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE) {
191 return wrap(unwrap(EE)->getTargetData());
192 }
None (* RUN: %ocamlc -warn-error A llvm.cma llvm_executionengine.cma %s -o %t
0 (* RUN: %ocamlc -warn-error A llvm.cma llvm_target.cma llvm_executionengine.cma %s -o %t
11 * RUN: ./%t %t.bc
22 *)
33
44 open Llvm
55 open Llvm_executionengine
6 open Llvm_target
67
78 (* Note that this takes a moment to link, so it's best to keep the number of
89 individual tests low. *)
9192
9293 (* run_static_dtors *)
9394 ExecutionEngine.run_static_dtors ee;
95
96 (* Show that the target data binding links and runs.*)
97 let td = ExecutionEngine.target_data ee in
98
99 (* Demonstrate that a garbage pointer wasn't returned. *)
100 let ty = intptr_type td in
101 if ty != i32_type && ty != i64_type then bomb "target_data did not work";
94102
95103 (* dispose *)
96104 ExecutionEngine.dispose ee