Implement SIMD latest opcodes and update LLVM to 13.0 (#758)

Implement the latest SIMD opcodes and update LLVM 13.0,
update the llvm build scripts, update the sample workloads‘ build scripts,
and build customized wasi-sdk to build some workloads.
Also refine the CI rules.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
Wenyong Huang
2021-09-17 19:12:57 +08:00
committed by GitHub
parent 7e60a5db8d
commit 7be0d385a6
82 changed files with 5266 additions and 4698 deletions

View File

@ -44,4 +44,119 @@ simd_bitcast_and_push_v128(const AOTCompContext *comp_ctx,
return true;
fail:
return false;
}
}
LLVMValueRef
simd_lane_id_to_llvm_value(AOTCompContext *comp_ctx, uint8 lane_id)
{
LLVMValueRef lane_indexes[] = {
LLVM_CONST(i32_zero), LLVM_CONST(i32_one),
LLVM_CONST(i32_two), LLVM_CONST(i32_three),
LLVM_CONST(i32_four), LLVM_CONST(i32_five),
LLVM_CONST(i32_six), LLVM_CONST(i32_seven),
LLVM_CONST(i32_eight), LLVM_CONST(i32_nine),
LLVM_CONST(i32_ten), LLVM_CONST(i32_eleven),
LLVM_CONST(i32_twelve), LLVM_CONST(i32_thirteen),
LLVM_CONST(i32_fourteen), LLVM_CONST(i32_fifteen),
};
return lane_id < 16 ? lane_indexes[lane_id] : NULL;
}
LLVMValueRef
simd_build_const_integer_vector(const AOTCompContext *comp_ctx,
const LLVMTypeRef element_type,
const int *element_value,
uint32 length)
{
LLVMValueRef vector = NULL;
LLVMValueRef *elements;
unsigned i;
if (!(elements = wasm_runtime_malloc(sizeof(LLVMValueRef) * length))) {
return NULL;
}
for (i = 0; i < length; i++) {
if (!(elements[i] =
LLVMConstInt(element_type, element_value[i], true))) {
HANDLE_FAILURE("LLVMConstInst");
goto fail;
}
}
if (!(vector = LLVMConstVector(elements, length))) {
HANDLE_FAILURE("LLVMConstVector");
goto fail;
}
fail:
wasm_runtime_free(elements);
return vector;
}
LLVMValueRef
simd_build_splat_const_integer_vector(const AOTCompContext *comp_ctx,
const LLVMTypeRef element_type,
const int64 element_value,
uint32 length)
{
LLVMValueRef vector = NULL, element;
LLVMValueRef *elements;
unsigned i;
if (!(elements = wasm_runtime_malloc(sizeof(LLVMValueRef) * length))) {
return NULL;
}
if (!(element = LLVMConstInt(element_type, element_value, true))) {
HANDLE_FAILURE("LLVMConstInt");
goto fail;
}
for (i = 0; i < length; i++) {
elements[i] = element;
}
if (!(vector = LLVMConstVector(elements, length))) {
HANDLE_FAILURE("LLVMConstVector");
goto fail;
}
fail:
wasm_runtime_free(elements);
return vector;
}
LLVMValueRef
simd_build_splat_const_float_vector(const AOTCompContext *comp_ctx,
const LLVMTypeRef element_type,
const float element_value,
uint32 length)
{
LLVMValueRef vector = NULL, element;
LLVMValueRef *elements;
unsigned i;
if (!(elements = wasm_runtime_malloc(sizeof(LLVMValueRef) * length))) {
return NULL;
}
if (!(element = LLVMConstReal(element_type, element_value))) {
HANDLE_FAILURE("LLVMConstReal");
goto fail;
}
for (i = 0; i < length; i++) {
elements[i] = element;
}
if (!(vector = LLVMConstVector(elements, length))) {
HANDLE_FAILURE("LLVMConstVector");
goto fail;
}
fail:
wasm_runtime_free(elements);
return vector;
}