support app framework base library in assemblyscript (#164)

This commit is contained in:
Xu Jun
2020-02-13 15:51:22 +08:00
committed by GitHub
parent b5cbc02e90
commit 5a10651dd0
17 changed files with 1083 additions and 40 deletions

View File

@ -245,6 +245,7 @@ fail:
aot_set_last_error("llvm build load failed."); \
goto fail; \
} \
LLVMSetAlignment(value, 1); \
} while (0)
#define BUILD_TRUNC(data_type) do { \
@ -256,10 +257,12 @@ fail:
} while (0)
#define BUILD_STORE() do { \
if (!LLVMBuildStore(comp_ctx->builder, value, maddr)) { \
LLVMValueRef res; \
if (!(res = LLVMBuildStore(comp_ctx->builder, value, maddr))) { \
aot_set_last_error("llvm build store failed."); \
goto fail; \
} \
LLVMSetAlignment(res, 1); \
} while (0)
#define BUILD_SIGN_EXT(dst_type) do { \
@ -599,12 +602,7 @@ aot_compile_op_memory_grow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
return false;
}
/* convert call result from i8 to i1 */
if (!(ret_value = LLVMBuildIntCast(comp_ctx->builder, ret_value,
INT1_TYPE, "mem_grow_ret"))) {
aot_set_last_error("llvm build bit cast failed.");
return false;
}
BUILD_ICMP(LLVMIntUGT, ret_value, I8_ZERO, ret_value, "mem_grow_ret");
/* ret_value = ret_value == true ? delta : pre_page_count */
if (!(ret_value = LLVMBuildSelect(comp_ctx->builder, ret_value,

View File

@ -405,14 +405,23 @@ aot_compile_int_bit_count(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
CHECK_LLVM_CONST(zero_undef);
/* Call the LLVM intrinsic function */
DEF_INT_UNARY_OP(call_llvm_intrinsic(comp_ctx,
bit_cnt_llvm_intrinsic[type],
ret_type,
param_types,
2,
operand,
zero_undef),
NULL);
if (type < POP_CNT32)
DEF_INT_UNARY_OP(call_llvm_intrinsic(comp_ctx,
bit_cnt_llvm_intrinsic[type],
ret_type,
param_types,
2,
operand,
zero_undef),
NULL);
else
DEF_INT_UNARY_OP(call_llvm_intrinsic(comp_ctx,
bit_cnt_llvm_intrinsic[type],
ret_type,
param_types,
1,
operand),
NULL);
return true;