Refine wasm loader and interpreter, enhance wamrc to support SGX (#167)

Former-commit-id: 76f4a121d3c2a67114414fc60e80eba4bf49aa8e [formerly b1ab47945a40e6b249c9aa205d61281301585ea6]
Former-commit-id: 8e5c6e895eae22051a79a8d337a87cd2f431b6bc
This commit is contained in:
wenyongh
2020-02-18 15:15:24 +08:00
committed by GitHub
parent 20cf199ce4
commit e62bbeb9e8
16 changed files with 306 additions and 344 deletions

View File

@ -837,7 +837,8 @@ aot_create_comp_context(AOTCompData *comp_data,
char *triple_norm_new = NULL, *cpu_new = NULL;
char *err = NULL, *fp_round= "round.tonearest", *fp_exce = "fpexcept.strict";
char triple_buf[32] = {0};
uint32 opt_level;
uint32 opt_level, size_level;
LLVMCodeModel code_model;
/* Initialize LLVM environment */
LLVMInitializeAllTargetInfos();
@ -896,6 +897,7 @@ aot_create_comp_context(AOTCompData *comp_data,
cpu = option->target_cpu;
features = option->cpu_features;
opt_level = option->opt_level;
size_level = option->size_level;
if (arch) {
/* Add default sub-arch if not specified */
@ -1001,6 +1003,7 @@ aot_create_comp_context(AOTCompData *comp_data,
bh_printf(" target cpu: %s\n", cpu);
bh_printf(" cpu features: %s\n", features);
bh_printf(" opt level: %d\n", opt_level);
bh_printf(" size level: %d\n", size_level);
switch (option->output_format) {
case AOT_LLVMIR_UNOPT_FILE:
bh_printf(" output format: unoptimized LLVM IR\n");
@ -1030,11 +1033,21 @@ aot_create_comp_context(AOTCompData *comp_data,
goto fail;
}
/* Set code model */
if (size_level == 0)
code_model = LLVMCodeModelLarge;
else if (size_level == 1)
code_model = LLVMCodeModelMedium;
else if (size_level == 2)
code_model = LLVMCodeModelKernel;
else
code_model = LLVMCodeModelSmall;
/* Create the target machine */
if (!(comp_ctx->target_machine =
LLVMCreateTargetMachine(target, triple_norm, cpu, features,
opt_level, LLVMRelocStatic,
LLVMCodeModelSmall))) {
code_model))) {
aot_set_last_error("create LLVM target machine failed.");
goto fail;
}