2013-11-01 08:26:01 +08:00
|
|
|
/*===-- executionengine_ocaml.c - LLVM OCaml Glue ---------------*- C++ -*-===*\
|
2007-12-24 00:59:28 +08:00
|
|
|
|* *|
|
|
|
|
|* The LLVM Compiler Infrastructure *|
|
|
|
|
|* *|
|
2007-12-30 06:59:10 +08:00
|
|
|
|* This file is distributed under the University of Illinois Open Source *|
|
|
|
|
|* License. See LICENSE.TXT for details. *|
|
2007-12-24 00:59:28 +08:00
|
|
|
|* *|
|
|
|
|
|*===----------------------------------------------------------------------===*|
|
|
|
|
|* *|
|
2013-11-01 08:26:01 +08:00
|
|
|
|* This file glues LLVM's OCaml interface to its C interface. These functions *|
|
2007-12-24 00:59:28 +08:00
|
|
|
|* are by and large transparent wrappers to the corresponding C functions. *|
|
|
|
|
|* *|
|
|
|
|
|* Note that these functions intentionally take liberties with the CAMLparamX *|
|
|
|
|
|* macros, since most of the parameters are not GC heap objects. *|
|
|
|
|
|* *|
|
|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
|
2014-10-29 16:15:54 +08:00
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
2007-12-24 00:59:28 +08:00
|
|
|
#include "llvm-c/ExecutionEngine.h"
|
2009-06-25 05:09:18 +08:00
|
|
|
#include "llvm-c/Target.h"
|
2007-12-24 00:59:28 +08:00
|
|
|
#include "caml/alloc.h"
|
|
|
|
#include "caml/custom.h"
|
|
|
|
#include "caml/fail.h"
|
|
|
|
#include "caml/memory.h"
|
2014-10-29 16:15:54 +08:00
|
|
|
#include "caml/callback.h"
|
2007-12-24 00:59:28 +08:00
|
|
|
|
|
|
|
static void llvm_raise(value Prototype, char *Message) {
|
|
|
|
CAMLparam1(Prototype);
|
|
|
|
CAMLlocal1(CamlMessage);
|
2014-10-26 02:50:02 +08:00
|
|
|
|
2007-12-24 00:59:28 +08:00
|
|
|
CamlMessage = copy_string(Message);
|
|
|
|
LLVMDisposeMessage(Message);
|
2014-10-26 02:50:02 +08:00
|
|
|
|
2007-12-24 00:59:28 +08:00
|
|
|
raise_with_arg(Prototype, CamlMessage);
|
2014-10-29 16:15:54 +08:00
|
|
|
CAMLnoreturn;
|
2007-12-24 00:59:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*--... Operations on generic values .......................................--*/
|
|
|
|
|
|
|
|
#define Genericvalue_val(v) (*(LLVMGenericValueRef *)(Data_custom_val(v)))
|
|
|
|
|
|
|
|
static void llvm_finalize_generic_value(value GenVal) {
|
|
|
|
LLVMDisposeGenericValue(Genericvalue_val(GenVal));
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct custom_operations generic_value_ops = {
|
2014-10-29 16:15:54 +08:00
|
|
|
(char *) "Llvm_executionengine.GenericValue.t",
|
2007-12-24 00:59:28 +08:00
|
|
|
llvm_finalize_generic_value,
|
|
|
|
custom_compare_default,
|
|
|
|
custom_hash_default,
|
|
|
|
custom_serialize_default,
|
2014-10-29 16:15:54 +08:00
|
|
|
custom_deserialize_default,
|
|
|
|
custom_compare_ext_default
|
2007-12-24 00:59:28 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static value alloc_generic_value(LLVMGenericValueRef Ref) {
|
|
|
|
value Val = alloc_custom(&generic_value_ops, sizeof(LLVMGenericValueRef), 0, 1);
|
|
|
|
Genericvalue_val(Val) = Ref;
|
|
|
|
return Val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Llvm.lltype -> float -> t */
|
|
|
|
CAMLprim value llvm_genericvalue_of_float(LLVMTypeRef Ty, value N) {
|
2007-12-24 01:10:23 +08:00
|
|
|
CAMLparam1(N);
|
|
|
|
CAMLreturn(alloc_generic_value(
|
|
|
|
LLVMCreateGenericValueOfFloat(Ty, Double_val(N))));
|
2007-12-24 00:59:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 'a -> t */
|
2010-03-04 07:51:30 +08:00
|
|
|
CAMLprim value llvm_genericvalue_of_pointer(value V) {
|
2007-12-24 01:10:23 +08:00
|
|
|
CAMLparam1(V);
|
|
|
|
CAMLreturn(alloc_generic_value(LLVMCreateGenericValueOfPointer(Op_val(V))));
|
2007-12-24 00:59:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Llvm.lltype -> int -> t */
|
|
|
|
CAMLprim value llvm_genericvalue_of_int(LLVMTypeRef Ty, value Int) {
|
|
|
|
return alloc_generic_value(LLVMCreateGenericValueOfInt(Ty, Int_val(Int), 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Llvm.lltype -> int32 -> t */
|
|
|
|
CAMLprim value llvm_genericvalue_of_int32(LLVMTypeRef Ty, value Int32) {
|
2007-12-24 01:10:23 +08:00
|
|
|
CAMLparam1(Int32);
|
|
|
|
CAMLreturn(alloc_generic_value(
|
|
|
|
LLVMCreateGenericValueOfInt(Ty, Int32_val(Int32), 1)));
|
2007-12-24 00:59:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Llvm.lltype -> nativeint -> t */
|
|
|
|
CAMLprim value llvm_genericvalue_of_nativeint(LLVMTypeRef Ty, value NatInt) {
|
2007-12-24 01:10:23 +08:00
|
|
|
CAMLparam1(NatInt);
|
|
|
|
CAMLreturn(alloc_generic_value(
|
|
|
|
LLVMCreateGenericValueOfInt(Ty, Nativeint_val(NatInt), 1)));
|
2007-12-24 00:59:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Llvm.lltype -> int64 -> t */
|
|
|
|
CAMLprim value llvm_genericvalue_of_int64(LLVMTypeRef Ty, value Int64) {
|
2007-12-24 01:10:23 +08:00
|
|
|
CAMLparam1(Int64);
|
|
|
|
CAMLreturn(alloc_generic_value(
|
|
|
|
LLVMCreateGenericValueOfInt(Ty, Int64_val(Int64), 1)));
|
2007-12-24 00:59:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Llvm.lltype -> t -> float */
|
|
|
|
CAMLprim value llvm_genericvalue_as_float(LLVMTypeRef Ty, value GenVal) {
|
2007-12-24 01:10:23 +08:00
|
|
|
CAMLparam1(GenVal);
|
|
|
|
CAMLreturn(copy_double(
|
|
|
|
LLVMGenericValueToFloat(Ty, Genericvalue_val(GenVal))));
|
2007-12-24 00:59:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* t -> 'a */
|
2010-03-04 07:51:30 +08:00
|
|
|
CAMLprim value llvm_genericvalue_as_pointer(value GenVal) {
|
2007-12-24 00:59:28 +08:00
|
|
|
return Val_op(LLVMGenericValueToPointer(Genericvalue_val(GenVal)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* t -> int */
|
|
|
|
CAMLprim value llvm_genericvalue_as_int(value GenVal) {
|
|
|
|
assert(LLVMGenericValueIntWidth(Genericvalue_val(GenVal)) <= 8 * sizeof(value)
|
|
|
|
&& "Generic value too wide to treat as an int!");
|
|
|
|
return Val_int(LLVMGenericValueToInt(Genericvalue_val(GenVal), 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* t -> int32 */
|
|
|
|
CAMLprim value llvm_genericvalue_as_int32(value GenVal) {
|
2007-12-24 01:10:23 +08:00
|
|
|
CAMLparam1(GenVal);
|
2007-12-24 00:59:28 +08:00
|
|
|
assert(LLVMGenericValueIntWidth(Genericvalue_val(GenVal)) <= 32
|
|
|
|
&& "Generic value too wide to treat as an int32!");
|
2007-12-24 01:10:23 +08:00
|
|
|
CAMLreturn(copy_int32(LLVMGenericValueToInt(Genericvalue_val(GenVal), 1)));
|
2007-12-24 00:59:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* t -> int64 */
|
|
|
|
CAMLprim value llvm_genericvalue_as_int64(value GenVal) {
|
2007-12-24 01:10:23 +08:00
|
|
|
CAMLparam1(GenVal);
|
2007-12-24 00:59:28 +08:00
|
|
|
assert(LLVMGenericValueIntWidth(Genericvalue_val(GenVal)) <= 64
|
|
|
|
&& "Generic value too wide to treat as an int64!");
|
2007-12-24 01:10:23 +08:00
|
|
|
CAMLreturn(copy_int64(LLVMGenericValueToInt(Genericvalue_val(GenVal), 1)));
|
2007-12-24 00:59:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* t -> nativeint */
|
|
|
|
CAMLprim value llvm_genericvalue_as_nativeint(value GenVal) {
|
2007-12-24 01:10:23 +08:00
|
|
|
CAMLparam1(GenVal);
|
2007-12-24 00:59:28 +08:00
|
|
|
assert(LLVMGenericValueIntWidth(Genericvalue_val(GenVal)) <= 8 * sizeof(value)
|
|
|
|
&& "Generic value too wide to treat as a nativeint!");
|
2007-12-24 01:10:23 +08:00
|
|
|
CAMLreturn(copy_nativeint(LLVMGenericValueToInt(Genericvalue_val(GenVal),1)));
|
2007-12-24 00:59:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*--... Operations on execution engines ....................................--*/
|
|
|
|
|
2014-10-29 16:15:54 +08:00
|
|
|
/* unit -> bool */
|
|
|
|
CAMLprim value llvm_initialize_native_target(value Unit) {
|
|
|
|
LLVMLinkInInterpreter();
|
|
|
|
LLVMLinkInMCJIT();
|
|
|
|
|
|
|
|
return Val_bool(!LLVMInitializeNativeTarget() &&
|
|
|
|
!LLVMInitializeNativeAsmParser() &&
|
|
|
|
!LLVMInitializeNativeAsmPrinter());
|
|
|
|
}
|
|
|
|
|
2010-03-03 07:59:00 +08:00
|
|
|
/* llmodule -> ExecutionEngine.t */
|
|
|
|
CAMLprim LLVMExecutionEngineRef llvm_ee_create(LLVMModuleRef M) {
|
2007-12-24 00:59:28 +08:00
|
|
|
LLVMExecutionEngineRef Interp;
|
|
|
|
char *Error;
|
2010-03-03 07:59:00 +08:00
|
|
|
if (LLVMCreateExecutionEngineForModule(&Interp, M, &Error))
|
2014-10-29 16:15:54 +08:00
|
|
|
llvm_raise(*caml_named_value("Llvm_executionengine.Error"), Error);
|
2007-12-24 00:59:28 +08:00
|
|
|
return Interp;
|
|
|
|
}
|
|
|
|
|
2010-03-03 07:59:00 +08:00
|
|
|
/* llmodule -> ExecutionEngine.t */
|
2007-12-24 00:59:28 +08:00
|
|
|
CAMLprim LLVMExecutionEngineRef
|
2010-03-03 07:59:00 +08:00
|
|
|
llvm_ee_create_interpreter(LLVMModuleRef M) {
|
2007-12-24 00:59:28 +08:00
|
|
|
LLVMExecutionEngineRef Interp;
|
|
|
|
char *Error;
|
2010-03-03 07:59:00 +08:00
|
|
|
if (LLVMCreateInterpreterForModule(&Interp, M, &Error))
|
2014-10-29 16:15:54 +08:00
|
|
|
llvm_raise(*caml_named_value("Llvm_executionengine.Error"), Error);
|
2007-12-24 00:59:28 +08:00
|
|
|
return Interp;
|
|
|
|
}
|
|
|
|
|
2010-03-03 07:59:03 +08:00
|
|
|
/* llmodule -> int -> ExecutionEngine.t */
|
2008-08-09 04:49:28 +08:00
|
|
|
CAMLprim LLVMExecutionEngineRef
|
2010-03-03 07:59:03 +08:00
|
|
|
llvm_ee_create_jit(LLVMModuleRef M, value OptLevel) {
|
2008-08-09 04:49:28 +08:00
|
|
|
LLVMExecutionEngineRef JIT;
|
|
|
|
char *Error;
|
2010-03-03 07:59:03 +08:00
|
|
|
if (LLVMCreateJITCompilerForModule(&JIT, M, Int_val(OptLevel), &Error))
|
2014-10-29 16:15:54 +08:00
|
|
|
llvm_raise(*caml_named_value("Llvm_executionengine.Error"), Error);
|
2007-12-24 00:59:28 +08:00
|
|
|
return JIT;
|
|
|
|
}
|
|
|
|
|
2014-10-26 02:49:56 +08:00
|
|
|
/* llmodule -> llcompileroption -> ExecutionEngine.t */
|
|
|
|
CAMLprim LLVMExecutionEngineRef
|
|
|
|
llvm_ee_create_mcjit(LLVMModuleRef M, value OptRecord) {
|
|
|
|
LLVMExecutionEngineRef MCJIT;
|
|
|
|
char *Error;
|
2014-10-29 16:15:54 +08:00
|
|
|
struct LLVMMCJITCompilerOptions Options;
|
|
|
|
|
|
|
|
LLVMInitializeMCJITCompilerOptions(&Options, sizeof(Options));
|
|
|
|
Options.OptLevel = Int_val(Field(OptRecord, 0));
|
|
|
|
Options.CodeModel = Int_val(Field(OptRecord, 1));
|
|
|
|
Options.NoFramePointerElim = Int_val(Field(OptRecord, 2));
|
|
|
|
Options.EnableFastISel = Int_val(Field(OptRecord, 3));
|
|
|
|
Options.MCJMM = NULL;
|
|
|
|
|
2014-10-26 02:49:56 +08:00
|
|
|
if (LLVMCreateMCJITCompilerForModule(&MCJIT, M, &Options,
|
|
|
|
sizeof(Options), &Error))
|
2014-10-29 16:15:54 +08:00
|
|
|
llvm_raise(*caml_named_value("Llvm_executionengine.Error"), Error);
|
2014-10-26 02:49:56 +08:00
|
|
|
return MCJIT;
|
|
|
|
}
|
|
|
|
|
2007-12-24 00:59:28 +08:00
|
|
|
/* ExecutionEngine.t -> unit */
|
|
|
|
CAMLprim value llvm_ee_dispose(LLVMExecutionEngineRef EE) {
|
|
|
|
LLVMDisposeExecutionEngine(EE);
|
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
2010-03-03 07:59:00 +08:00
|
|
|
/* llmodule -> ExecutionEngine.t -> unit */
|
2010-03-04 07:51:30 +08:00
|
|
|
CAMLprim value llvm_ee_add_module(LLVMModuleRef M, LLVMExecutionEngineRef EE) {
|
2010-03-03 07:59:00 +08:00
|
|
|
LLVMAddModule(EE, M);
|
2007-12-24 00:59:28 +08:00
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
2010-03-03 07:59:00 +08:00
|
|
|
/* llmodule -> ExecutionEngine.t -> llmodule */
|
2010-03-04 07:51:30 +08:00
|
|
|
CAMLprim LLVMModuleRef llvm_ee_remove_module(LLVMModuleRef M,
|
|
|
|
LLVMExecutionEngineRef EE) {
|
2007-12-24 00:59:28 +08:00
|
|
|
LLVMModuleRef RemovedModule;
|
|
|
|
char *Error;
|
2010-03-03 07:59:00 +08:00
|
|
|
if (LLVMRemoveModule(EE, M, &RemovedModule, &Error))
|
2014-10-29 16:15:54 +08:00
|
|
|
llvm_raise(*caml_named_value("Llvm_executionengine.Error"), Error);
|
2007-12-24 00:59:28 +08:00
|
|
|
return RemovedModule;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* string -> ExecutionEngine.t -> llvalue option */
|
|
|
|
CAMLprim value llvm_ee_find_function(value Name, LLVMExecutionEngineRef EE) {
|
|
|
|
CAMLparam1(Name);
|
|
|
|
CAMLlocal1(Option);
|
|
|
|
LLVMValueRef Found;
|
|
|
|
if (LLVMFindFunction(EE, String_val(Name), &Found))
|
|
|
|
CAMLreturn(Val_unit);
|
2010-03-03 07:59:08 +08:00
|
|
|
Option = alloc(1, 0);
|
2007-12-24 00:59:28 +08:00
|
|
|
Field(Option, 0) = Val_op(Found);
|
|
|
|
CAMLreturn(Option);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* llvalue -> GenericValue.t array -> ExecutionEngine.t -> GenericValue.t */
|
|
|
|
CAMLprim value llvm_ee_run_function(LLVMValueRef F, value Args,
|
|
|
|
LLVMExecutionEngineRef EE) {
|
|
|
|
unsigned NumArgs;
|
|
|
|
LLVMGenericValueRef Result, *GVArgs;
|
|
|
|
unsigned I;
|
2014-10-26 02:50:02 +08:00
|
|
|
|
2007-12-24 00:59:28 +08:00
|
|
|
NumArgs = Wosize_val(Args);
|
|
|
|
GVArgs = (LLVMGenericValueRef*) malloc(NumArgs * sizeof(LLVMGenericValueRef));
|
|
|
|
for (I = 0; I != NumArgs; ++I)
|
|
|
|
GVArgs[I] = Genericvalue_val(Field(Args, I));
|
2014-10-26 02:50:02 +08:00
|
|
|
|
2007-12-24 00:59:28 +08:00
|
|
|
Result = LLVMRunFunction(EE, F, NumArgs, GVArgs);
|
2014-10-26 02:50:02 +08:00
|
|
|
|
2007-12-24 00:59:28 +08:00
|
|
|
free(GVArgs);
|
|
|
|
return alloc_generic_value(Result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ExecutionEngine.t -> unit */
|
|
|
|
CAMLprim value llvm_ee_run_static_ctors(LLVMExecutionEngineRef EE) {
|
|
|
|
LLVMRunStaticConstructors(EE);
|
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ExecutionEngine.t -> unit */
|
|
|
|
CAMLprim value llvm_ee_run_static_dtors(LLVMExecutionEngineRef EE) {
|
|
|
|
LLVMRunStaticDestructors(EE);
|
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* llvalue -> string array -> (string * string) array -> ExecutionEngine.t ->
|
|
|
|
int */
|
|
|
|
CAMLprim value llvm_ee_run_function_as_main(LLVMValueRef F,
|
|
|
|
value Args, value Env,
|
|
|
|
LLVMExecutionEngineRef EE) {
|
|
|
|
CAMLparam2(Args, Env);
|
|
|
|
int I, NumArgs, NumEnv, EnvSize, Result;
|
|
|
|
const char **CArgs, **CEnv;
|
|
|
|
char *CEnvBuf, *Pos;
|
2014-10-26 02:50:02 +08:00
|
|
|
|
2007-12-24 00:59:28 +08:00
|
|
|
NumArgs = Wosize_val(Args);
|
|
|
|
NumEnv = Wosize_val(Env);
|
2014-10-26 02:50:02 +08:00
|
|
|
|
2007-12-24 00:59:28 +08:00
|
|
|
/* Build the environment. */
|
|
|
|
CArgs = (const char **) malloc(NumArgs * sizeof(char*));
|
|
|
|
for (I = 0; I != NumArgs; ++I)
|
|
|
|
CArgs[I] = String_val(Field(Args, I));
|
2014-10-26 02:50:02 +08:00
|
|
|
|
2007-12-24 00:59:28 +08:00
|
|
|
/* Compute the size of the environment string buffer. */
|
|
|
|
for (I = 0, EnvSize = 0; I != NumEnv; ++I) {
|
|
|
|
EnvSize += strlen(String_val(Field(Field(Env, I), 0))) + 1;
|
|
|
|
EnvSize += strlen(String_val(Field(Field(Env, I), 1))) + 1;
|
|
|
|
}
|
2014-10-26 02:50:02 +08:00
|
|
|
|
2007-12-24 00:59:28 +08:00
|
|
|
/* Build the environment. */
|
|
|
|
CEnv = (const char **) malloc((NumEnv + 1) * sizeof(char*));
|
|
|
|
CEnvBuf = (char*) malloc(EnvSize);
|
|
|
|
Pos = CEnvBuf;
|
|
|
|
for (I = 0; I != NumEnv; ++I) {
|
|
|
|
char *Name = String_val(Field(Field(Env, I), 0)),
|
|
|
|
*Value = String_val(Field(Field(Env, I), 1));
|
|
|
|
int NameLen = strlen(Name),
|
|
|
|
ValueLen = strlen(Value);
|
2014-10-26 02:50:02 +08:00
|
|
|
|
2007-12-24 00:59:28 +08:00
|
|
|
CEnv[I] = Pos;
|
|
|
|
memcpy(Pos, Name, NameLen);
|
|
|
|
Pos += NameLen;
|
|
|
|
*Pos++ = '=';
|
|
|
|
memcpy(Pos, Value, ValueLen);
|
|
|
|
Pos += ValueLen;
|
|
|
|
*Pos++ = '\0';
|
|
|
|
}
|
|
|
|
CEnv[NumEnv] = NULL;
|
2014-10-26 02:50:02 +08:00
|
|
|
|
2007-12-24 00:59:28 +08:00
|
|
|
Result = LLVMRunFunctionAsMain(EE, F, NumArgs, CArgs, CEnv);
|
2014-10-26 02:50:02 +08:00
|
|
|
|
2007-12-24 00:59:28 +08:00
|
|
|
free(CArgs);
|
|
|
|
free(CEnv);
|
|
|
|
free(CEnvBuf);
|
2014-10-26 02:50:02 +08:00
|
|
|
|
2007-12-24 00:59:28 +08:00
|
|
|
CAMLreturn(Val_int(Result));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* llvalue -> ExecutionEngine.t -> unit */
|
|
|
|
CAMLprim value llvm_ee_free_machine_code(LLVMValueRef F,
|
|
|
|
LLVMExecutionEngineRef EE) {
|
|
|
|
LLVMFreeMachineCodeForFunction(EE, F);
|
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
2013-11-15 10:51:44 +08:00
|
|
|
extern value llvm_alloc_data_layout(LLVMTargetDataRef TargetData);
|
2013-11-11 22:47:11 +08:00
|
|
|
|
2013-11-15 10:51:44 +08:00
|
|
|
/* ExecutionEngine.t -> Llvm_target.DataLayout.t */
|
|
|
|
CAMLprim value llvm_ee_get_data_layout(LLVMExecutionEngineRef EE) {
|
|
|
|
value DataLayout;
|
|
|
|
LLVMTargetDataRef OrigDataLayout;
|
|
|
|
char* TargetDataCStr;
|
2014-10-29 16:15:54 +08:00
|
|
|
|
|
|
|
OrigDataLayout = LLVMGetExecutionEngineTargetData(EE);
|
2013-11-15 10:51:44 +08:00
|
|
|
TargetDataCStr = LLVMCopyStringRepOfTargetData(OrigDataLayout);
|
|
|
|
DataLayout = llvm_alloc_data_layout(LLVMCreateTargetData(TargetDataCStr));
|
|
|
|
LLVMDisposeMessage(TargetDataCStr);
|
|
|
|
|
|
|
|
return DataLayout;
|
2013-11-11 22:47:11 +08:00
|
|
|
}
|