Skip to content

Commit 8cae7cc

Browse files
committed
Fixes
1 parent 632f662 commit 8cae7cc

File tree

6 files changed

+43
-37
lines changed

6 files changed

+43
-37
lines changed

build-scripts/config_common.cmake

+10-4
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,18 @@ else ()
320320
message (" Wakeup of blocking operations enabled")
321321
endif ()
322322
if (WAMR_BUILD_SIMD EQUAL 1)
323-
if (NOT WAMR_BUILD_TARGET MATCHES "RISCV64.*")
324-
add_definitions (-DWASM_ENABLE_SIMD=1)
325-
message (" SIMD enabled")
326-
else ()
323+
set(SIMD_ENABLED 0)
324+
if (WAMR_BUILD_TARGET MATCHES "RISCV64.*")
325+
set(WAMR_BUILD_SIMD 0)
327326
message (" SIMD disabled due to not supported on target RISCV64")
327+
elseif (WAMR_BUILD_FAST_INTERP EQUAL 1 AND WAMR_BUILD_SIMDE EQUAL 0)
328+
set(WAMR_BUILD_SIMD 0)
329+
message(" SIMD disabled as the simde is not built in fast interpreter mode")
330+
else()
331+
set(SIMD_ENABLED 1)
332+
message (" SIMD enabled")
328333
endif ()
334+
add_definitions(-DWASM_ENABLE_SIMD=${SIMD_ENABLED})
329335
endif ()
330336
if (WAMR_BUILD_AOT_STACK_FRAME EQUAL 1)
331337
add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)

build-scripts/runtime_lib.cmake

+8-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,14 @@ if (WAMR_BUILD_LIB_RATS EQUAL 1)
155155
include (${IWASM_DIR}/libraries/lib-rats/lib_rats.cmake)
156156
endif ()
157157

158-
if (WAMR_BUILD_LIB_SIMDE EQUAL 1)
159-
include (${IWASM_DIR}/libraries/simde/simde.cmake)
158+
if (WAMR_BUILD_SIMD EQUAL 1 AND WAMR_BUILD_FAST_INTERP EQUAL 1)
159+
if (NOT (WAMR_BUILD_TARGET MATCHES "AARCH64.*" OR WAMR_BUILD_TARGET MATCHES "ARM.*"))
160+
message(STATUS "SIMDe doesnt support platform " ${WAMR_BUILD_TARGET})
161+
set(WAMR_BUILD_SIMDE 0)
162+
else()
163+
include (${IWASM_DIR}/libraries/simde/simde.cmake)
164+
set (WAMR_BUILD_SIMDE 1)
165+
endif()
160166
endif ()
161167

162168
if (WAMR_BUILD_WASM_CACHE EQUAL 1)

core/iwasm/interpreter/wasm_interp_fast.c

+8-10
Original file line numberDiff line numberDiff line change
@@ -3541,7 +3541,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
35413541
HANDLE_OP_END();
35423542
}
35433543

3544-
#if WASM_ENABLE_SIMDE != 0
3544+
#if WASM_ENABLE_SIMD != 0
35453545
HANDLE_OP(EXT_OP_SET_LOCAL_FAST_V128)
35463546
HANDLE_OP(EXT_OP_TEE_LOCAL_FAST_V128)
35473547
{
@@ -3595,8 +3595,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
35953595
GET_I64_FROM_ADDR((uint32 *)global_addr));
35963596
HANDLE_OP_END();
35973597
}
3598-
#if WASM_ENABLE_SIMDE != 0
3599-
HANDLE_OP(WASM_OP_GET_GLOBAL_128)
3598+
#if WASM_ENABLE_SIMD != 0
3599+
HANDLE_OP(WASM_OP_GET_GLOBAL_V128)
36003600
{
36013601
global_idx = read_uint32(frame_ip);
36023602
bh_assert(global_idx < module->e->global_count);
@@ -3675,7 +3675,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
36753675
HANDLE_OP_END();
36763676
}
36773677
#if WASM_ENABLE_SIMDE != 0
3678-
HANDLE_OP(WASM_OP_SET_GLOBAL_128)
3678+
HANDLE_OP(WASM_OP_SET_GLOBAL_V128)
36793679
{
36803680
global_idx = read_uint32(frame_ip);
36813681
bh_assert(global_idx < module->e->global_count);
@@ -4932,7 +4932,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
49324932

49334933
HANDLE_OP_END();
49344934
}
4935-
#if WASM_ENABLE_SIMDE != 0
4935+
#if WASM_ENABLE_SIMD != 0
49364936
HANDLE_OP(EXT_OP_COPY_STACK_TOP_V128)
49374937
{
49384938
addr1 = GET_OFFSET();
@@ -5836,8 +5836,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
58365836
case SIMD_v128_load:
58375837
{
58385838
uint32 offset, addr;
5839-
offset = read_uint32(
5840-
frame_ip); // TODO: Check with an offset!
5839+
offset = read_uint32(frame_ip);
58415840
addr = GET_OPERAND(uint32, I32, 0);
58425841
frame_ip += 2;
58435842
addr_ret = GET_OFFSET();
@@ -5852,15 +5851,14 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
58525851
addr = GET_OPERAND(uint32, I32, 0); \
58535852
frame_ip += 2; \
58545853
addr_ret = GET_OFFSET(); \
5855-
CHECK_MEMORY_OVERFLOW(4); \
5854+
CHECK_MEMORY_OVERFLOW(16); \
58565855
\
58575856
simde_v128_t simde_result = simde_func(maddr); \
58585857
\
58595858
V128 result; \
58605859
SIMDE_V128_TO_SIMD_V128(simde_result, result); \
58615860
PUT_V128_TO_ADDR(frame_lp + addr_ret, result); \
58625861
\
5863-
break; \
58645862
} while (0)
58655863
case SIMD_v128_load8x8_s:
58665864
{
@@ -5938,7 +5936,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
59385936
offset += base;
59395937
addr = GET_OPERAND(uint32, I32, 0);
59405938

5941-
CHECK_MEMORY_OVERFLOW(4);
5939+
CHECK_MEMORY_OVERFLOW(16);
59425940
STORE_V128(maddr, data);
59435941
break;
59445942
}

core/iwasm/interpreter/wasm_loader.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -7301,8 +7301,8 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
73017301
case WASM_OP_GET_GLOBAL_64:
73027302
case WASM_OP_SET_GLOBAL_64:
73037303
#if WASM_ENABLE_SIMDE != 0
7304-
case WASM_OP_GET_GLOBAL_128:
7305-
case WASM_OP_SET_GLOBAL_128:
7304+
case WASM_OP_GET_GLOBAL_V128:
7305+
case WASM_OP_SET_GLOBAL_V128:
73067306
#endif
73077307
case WASM_OP_SET_GLOBAL_AUX_STACK:
73087308
skip_leb_uint32(p, p_end); /* local index */
@@ -9588,6 +9588,7 @@ wasm_loader_get_const_offset(WASMLoaderContext *ctx, uint8 type, void *value,
95889588
bh_memcpy_s(&(c->value.v128), sizeof(WASMValue), value,
95899589
sizeof(V128));
95909590
ctx->const_cell_num++;
9591+
break;
95919592
#if WASM_ENABLE_REF_TYPES != 0 && WASM_ENABLE_GC == 0
95929593
case VALUE_TYPE_EXTERNREF:
95939594
case VALUE_TYPE_FUNCREF:
@@ -13226,7 +13227,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
1322613227
#if WASM_ENABLE_SIMDE != 0
1322713228
if (global_type == VALUE_TYPE_V128) {
1322813229
skip_label();
13229-
emit_label(WASM_OP_GET_GLOBAL_128);
13230+
emit_label(WASM_OP_GET_GLOBAL_V128);
1323013231
}
1323113232
#endif /* end of WASM_ENABLE_SIMDE */
1323213233
emit_uint32(loader_ctx, global_idx);
@@ -13326,7 +13327,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
1332613327
#if WASM_ENABLE_SIMDE != 0
1332713328
else if (global_type == VALUE_TYPE_V128) {
1332813329
skip_label();
13329-
emit_label(WASM_OP_SET_GLOBAL_128);
13330+
emit_label(WASM_OP_SET_GLOBAL_V128);
1333013331
}
1333113332
#endif /* end of WASM_ENABLE_SIMDE */
1333213333
emit_uint32(loader_ctx, global_idx);

core/iwasm/interpreter/wasm_opcode.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,13 @@ typedef enum WASMOpcode {
278278
DEBUG_OP_BREAK = 0xdc, /* debug break point */
279279
#endif
280280

281-
#if WASM_ENABLE_JIT != 0 || WASM_ENABLE_FAST_INTERP != 0 \
282-
&& WASM_ENABLE_SIMD != 0
281+
#if WASM_ENABLE_JIT != 0 \
282+
|| WASM_ENABLE_FAST_INTERP != 0 && WASM_ENABLE_SIMD != 0
283283
EXT_OP_SET_LOCAL_FAST_V128 = 0xdd,
284284
EXT_OP_TEE_LOCAL_FAST_V128 = 0xde,
285285
EXT_OP_COPY_STACK_TOP_V128 = 0xdf,
286-
WASM_OP_GET_GLOBAL_128 = 0xe0,
287-
WASM_OP_SET_GLOBAL_128 = 0xe1,
286+
WASM_OP_GET_GLOBAL_V128 = 0xe0,
287+
WASM_OP_SET_GLOBAL_V128 = 0xe1,
288288
#endif
289289

290290
/* Post-MVP extend op prefix */
@@ -798,13 +798,13 @@ typedef enum WASMAtomicEXTOpcode {
798798
#define SET_GOTO_TABLE_SIMD_PREFIX_ELEM()
799799
#endif
800800

801-
#if WASM_ENABLE_FAST_INTERP != 0 && WASM_ENABLE_SIMD != 0
802-
#define DEF_EXT_V128_HANDLE() \
803-
SET_GOTO_TABLE_ELEM(EXT_OP_SET_LOCAL_FAST_V128), \
804-
SET_GOTO_TABLE_ELEM(EXT_OP_TEE_LOCAL_FAST_V128), \
805-
SET_GOTO_TABLE_ELEM(EXT_OP_COPY_STACK_TOP_V128), \
806-
SET_GOTO_TABLE_ELEM(WASM_OP_GET_GLOBAL_V128), \
807-
SET_GOTO_TABLE_ELEM(WASM_OP_SET_GLOBAL_V128),
801+
#if (WASM_ENABLE_FAST_INTERP != 0) && WASM_ENABLE_SIMD != 0
802+
#define DEF_EXT_V128_HANDLE() \
803+
SET_GOTO_TABLE_ELEM(EXT_OP_SET_LOCAL_FAST_V128), /* 0xdd */ \
804+
SET_GOTO_TABLE_ELEM(EXT_OP_TEE_LOCAL_FAST_V128), /* 0xde */ \
805+
SET_GOTO_TABLE_ELEM(EXT_OP_COPY_STACK_TOP_V128), /* 0xdf */ \
806+
SET_GOTO_TABLE_ELEM(WASM_OP_GET_GLOBAL_V128), /* 0xe0 */ \
807+
SET_GOTO_TABLE_ELEM(WASM_OP_SET_GLOBAL_V128), /* 0xe1 */
808808

809809
#else
810810
#define DEF_EXT_V128_HANDLE()

core/iwasm/libraries/simde/simde.cmake

+1-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44

55
set (LIB_SIMDE_DIR ${CMAKE_CURRENT_LIST_DIR})
66

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

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

0 commit comments

Comments
 (0)