Skip to content

Commit f0a8286

Browse files
authored
Refactor fast-interpreter SIMD compilation flags (#4261)
- enable SIMD flag by default unless hardware limitation - use SIMDE flag to control fast-interpreter behavior
1 parent 26aa483 commit f0a8286

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

build-scripts/config_common.cmake

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,7 @@ else ()
377377
message (" Wakeup of blocking operations enabled")
378378
endif ()
379379
if (WAMR_BUILD_SIMD EQUAL 1)
380-
if (WAMR_BUILD_FAST_INTERP EQUAL 1 AND WAMR_BUILD_SIMDE EQUAL 0)
381-
set(SIMD_ENABLED 0)
382-
message(" SIMD disabled for fast-interp as simde is not being built")
383-
elseif (WAMR_BUILD_TARGET MATCHES "RISCV64.*")
380+
if (WAMR_BUILD_TARGET MATCHES "RISCV64.*")
384381
set(SIMD_ENABLED 0)
385382
message (" SIMD disabled due to not supported on target RISCV64")
386383
else()

build-scripts/runtime_lib.cmake

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,6 @@ if (WAMR_BUILD_LIB_RATS EQUAL 1)
155155
include (${IWASM_DIR}/libraries/lib-rats/lib_rats.cmake)
156156
endif ()
157157

158-
if (WAMR_BUILD_SIMD EQUAL 1 AND WAMR_BUILD_FAST_INTERP EQUAL 1)
159-
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
160-
message(STATUS "SIMDe doesnt support platform " ${WAMR_BUILD_PLATFORM})
161-
set(WAMR_BUILD_SIMDE 0)
162-
else()
163-
include (${IWASM_DIR}/libraries/simde/simde.cmake)
164-
set (WAMR_BUILD_SIMDE 1)
165-
endif()
166-
endif ()
167-
168158
if (WAMR_BUILD_WASM_CACHE EQUAL 1)
169159
include (${WAMR_ROOT_DIR}/build-scripts/involve_boringssl.cmake)
170160
endif ()
@@ -178,6 +168,18 @@ endif ()
178168
# include the build config template file
179169
include (${CMAKE_CURRENT_LIST_DIR}/config_common.cmake)
180170

171+
if (WAMR_BUILD_SIMD EQUAL 1 AND WAMR_BUILD_FAST_INTERP EQUAL 1)
172+
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
173+
message(STATUS "SIMDe doesnt support platform " ${WAMR_BUILD_PLATFORM})
174+
set(WAMR_BUILD_SIMDE 0)
175+
else()
176+
include (${IWASM_DIR}/libraries/simde/simde.cmake)
177+
set (WAMR_BUILD_SIMDE 1)
178+
endif()
179+
else()
180+
set(WAMR_BUILD_SIMDE 0)
181+
endif ()
182+
181183
include_directories (${IWASM_DIR}/include)
182184

183185
file (GLOB header

core/iwasm/common/wasm_loader_common.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,12 @@ bool
152152
is_valid_value_type_for_interpreter(uint8 value_type)
153153
{
154154
#if (WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_JIT == 0) \
155-
&& (WASM_ENABLE_FAST_INTERP == 0)
155+
&& (WASM_ENABLE_SIMDE == 0)
156156
/*
157-
* Note: regardless of WASM_ENABLE_SIMD, our interpreters don't have
158-
* SIMD implemented. It's safer to reject v128, especially for the
159-
* fast interpreter.
157+
* Note: regardless of WASM_ENABLE_SIMD, our classic interpreters don't
158+
* have SIMD implemented.
159+
*
160+
* WASM_ENABLE_SIMDE is used to control SIMD feaure in fast interpreter
160161
*/
161162
if (value_type == VALUE_TYPE_V128)
162163
return false;

core/iwasm/interpreter/wasm_interp_fast.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3565,7 +3565,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
35653565
HANDLE_OP_END();
35663566
}
35673567

3568-
#if WASM_ENABLE_SIMD != 0
3568+
#if WASM_ENABLE_SIMDE != 0
35693569
HANDLE_OP(EXT_OP_SET_LOCAL_FAST_V128)
35703570
HANDLE_OP(EXT_OP_TEE_LOCAL_FAST_V128)
35713571
{
@@ -3619,7 +3619,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
36193619
GET_I64_FROM_ADDR((uint32 *)global_addr));
36203620
HANDLE_OP_END();
36213621
}
3622-
#if WASM_ENABLE_SIMD != 0
3622+
#if WASM_ENABLE_SIMDE != 0
36233623
HANDLE_OP(WASM_OP_GET_GLOBAL_V128)
36243624
{
36253625
global_idx = read_uint32(frame_ip);
@@ -4956,7 +4956,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
49564956

49574957
HANDLE_OP_END();
49584958
}
4959-
#if WASM_ENABLE_SIMD != 0
4959+
#if WASM_ENABLE_SIMDE != 0
49604960
HANDLE_OP(EXT_OP_COPY_STACK_TOP_V128)
49614961
{
49624962
addr1 = GET_OFFSET();

0 commit comments

Comments
 (0)