Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzzabiyaka committed Jan 28, 2025
1 parent 632f662 commit 36833e4
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 31 deletions.
8 changes: 5 additions & 3 deletions build-scripts/config_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,13 @@ else ()
message (" Wakeup of blocking operations enabled")
endif ()
if (WAMR_BUILD_SIMD EQUAL 1)
if (NOT WAMR_BUILD_TARGET MATCHES "RISCV64.*")
if (WAMR_BUILD_TARGET MATCHES "RISCV64.*")
message (" SIMD disabled due to not supported on target RISCV64")
elseif (WAMR_BUILD_FAST_INTERP EQUAL 1 AND WAMR_BUILD_SIMDE EQUAL 0)
message(" SIMD disabled as the simde is not built in fast interpreter mode")
else()
add_definitions (-DWASM_ENABLE_SIMD=1)
message (" SIMD enabled")
else ()
message (" SIMD disabled due to not supported on target RISCV64")
endif ()
endif ()
if (WAMR_BUILD_AOT_STACK_FRAME EQUAL 1)
Expand Down
10 changes: 8 additions & 2 deletions build-scripts/runtime_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,14 @@ if (WAMR_BUILD_LIB_RATS EQUAL 1)
include (${IWASM_DIR}/libraries/lib-rats/lib_rats.cmake)
endif ()

if (WAMR_BUILD_LIB_SIMDE EQUAL 1)
include (${IWASM_DIR}/libraries/simde/simde.cmake)
if (WAMR_BUILD_SIMD EQUAL 1 AND WAMR_BUILD_FAST_INTERP EQUAL 1)
if (NOT (WAMR_BUILD_TARGET MATCHES "AARCH64.*" OR WAMR_BUILD_TARGET MATCHES "ARM.*"))
message(STATUS "SIMDe doesnt support platform " ${WAMR_BUILD_TARGET})
set(WAMR_BUILD_SIMDE 0)
else()
include (${IWASM_DIR}/libraries/simde/simde.cmake)
set (WAMR_BUILD_SIMDE 1)
endif()
endif ()

if (WAMR_BUILD_WASM_CACHE EQUAL 1)
Expand Down
14 changes: 6 additions & 8 deletions core/iwasm/interpreter/wasm_interp_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -3541,7 +3541,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
HANDLE_OP_END();
}

#if WASM_ENABLE_SIMDE != 0
#if WASM_ENABLE_SIMD != 0
HANDLE_OP(EXT_OP_SET_LOCAL_FAST_V128)
HANDLE_OP(EXT_OP_TEE_LOCAL_FAST_V128)
{
Expand Down Expand Up @@ -3595,8 +3595,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
GET_I64_FROM_ADDR((uint32 *)global_addr));
HANDLE_OP_END();
}
#if WASM_ENABLE_SIMDE != 0
HANDLE_OP(WASM_OP_GET_GLOBAL_128)
#if WASM_ENABLE_SIMD != 0
HANDLE_OP(WASM_OP_GET_GLOBAL_V128)
{
global_idx = read_uint32(frame_ip);
bh_assert(global_idx < module->e->global_count);
Expand Down Expand Up @@ -4932,7 +4932,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,

HANDLE_OP_END();
}
#if WASM_ENABLE_SIMDE != 0
#if WASM_ENABLE_SIMD != 0
HANDLE_OP(EXT_OP_COPY_STACK_TOP_V128)
{
addr1 = GET_OFFSET();
Expand Down Expand Up @@ -5836,8 +5836,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
case SIMD_v128_load:
{
uint32 offset, addr;
offset = read_uint32(
frame_ip); // TODO: Check with an offset!
offset = read_uint32(frame_ip);
addr = GET_OPERAND(uint32, I32, 0);
frame_ip += 2;
addr_ret = GET_OFFSET();
Expand All @@ -5852,15 +5851,14 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
addr = GET_OPERAND(uint32, I32, 0); \
frame_ip += 2; \
addr_ret = GET_OFFSET(); \
CHECK_MEMORY_OVERFLOW(4); \
CHECK_MEMORY_OVERFLOW(16); \
\
simde_v128_t simde_result = simde_func(maddr); \
\
V128 result; \
SIMDE_V128_TO_SIMD_V128(simde_result, result); \
PUT_V128_TO_ADDR(frame_lp + addr_ret, result); \
\
break; \
} while (0)
case SIMD_v128_load8x8_s:
{
Expand Down
4 changes: 2 additions & 2 deletions core/iwasm/interpreter/wasm_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -7301,7 +7301,7 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
case WASM_OP_GET_GLOBAL_64:
case WASM_OP_SET_GLOBAL_64:
#if WASM_ENABLE_SIMDE != 0
case WASM_OP_GET_GLOBAL_128:
case WASM_OP_GET_GLOBAL_V128:
case WASM_OP_SET_GLOBAL_128:
#endif
case WASM_OP_SET_GLOBAL_AUX_STACK:
Expand Down Expand Up @@ -13226,7 +13226,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
#if WASM_ENABLE_SIMDE != 0
if (global_type == VALUE_TYPE_V128) {
skip_label();
emit_label(WASM_OP_GET_GLOBAL_128);
emit_label(WASM_OP_GET_GLOBAL_V128);
}
#endif /* end of WASM_ENABLE_SIMDE */
emit_uint32(loader_ctx, global_idx);
Expand Down
20 changes: 10 additions & 10 deletions core/iwasm/interpreter/wasm_opcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,12 @@ typedef enum WASMOpcode {
DEBUG_OP_BREAK = 0xdc, /* debug break point */
#endif

#if WASM_ENABLE_JIT != 0 || WASM_ENABLE_FAST_INTERP != 0 \
&& WASM_ENABLE_SIMD != 0
#if WASM_ENABLE_JIT != 0 \
|| WASM_ENABLE_FAST_INTERP != 0 && WASM_ENABLE_SIMD != 0
EXT_OP_SET_LOCAL_FAST_V128 = 0xdd,
EXT_OP_TEE_LOCAL_FAST_V128 = 0xde,
EXT_OP_COPY_STACK_TOP_V128 = 0xdf,
WASM_OP_GET_GLOBAL_128 = 0xe0,
WASM_OP_GET_GLOBAL_V128 = 0xe0,
WASM_OP_SET_GLOBAL_128 = 0xe1,
#endif

Expand Down Expand Up @@ -798,13 +798,13 @@ typedef enum WASMAtomicEXTOpcode {
#define SET_GOTO_TABLE_SIMD_PREFIX_ELEM()
#endif

#if WASM_ENABLE_FAST_INTERP != 0 && WASM_ENABLE_SIMD != 0
#define DEF_EXT_V128_HANDLE() \
SET_GOTO_TABLE_ELEM(EXT_OP_SET_LOCAL_FAST_V128), \
SET_GOTO_TABLE_ELEM(EXT_OP_TEE_LOCAL_FAST_V128), \
SET_GOTO_TABLE_ELEM(EXT_OP_COPY_STACK_TOP_V128), \
SET_GOTO_TABLE_ELEM(WASM_OP_GET_GLOBAL_V128), \
SET_GOTO_TABLE_ELEM(WASM_OP_SET_GLOBAL_V128),
#if (WASM_ENABLE_FAST_INTERP != 0) && WASM_ENABLE_SIMD != 0
#define DEF_EXT_V128_HANDLE() \
SET_GOTO_TABLE_ELEM(EXT_OP_SET_LOCAL_FAST_V128), /* 0xdd */ \
SET_GOTO_TABLE_ELEM(EXT_OP_TEE_LOCAL_FAST_V128), /* 0xde */ \
SET_GOTO_TABLE_ELEM(EXT_OP_COPY_STACK_TOP_V128), /* 0xdf */ \
SET_GOTO_TABLE_ELEM(WASM_OP_GET_GLOBAL_V128), /* 0xe0 */ \
SET_GOTO_TABLE_ELEM(WASM_OP_SET_GLOBAL_128), /* 0xe1 */

#else
#define DEF_EXT_V128_HANDLE()
Expand Down
7 changes: 1 addition & 6 deletions core/iwasm/libraries/simde/simde.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@

set (LIB_SIMDE_DIR ${CMAKE_CURRENT_LIST_DIR})

if (WAMR_BUILD_TARGET MATCHES "AARCH64.*" OR WAMR_BUILD_TARGET MATCHES "ARM.*")
add_definitions (-DWASM_ENABLE_SIMDE=1)
else()
message(WARNING "Disabling SIMD for fast interpreter as the target is not supported")
set(WAMR_BUILD_SIMD 0)
endif()
add_definitions (-DWASM_ENABLE_SIMDE=1)

include_directories(${LIB_SIMDE_DIR} ${LIB_SIMDE_DIR}/simde)

Expand Down

0 comments on commit 36833e4

Please sign in to comment.