From d92cfd9d7f7e397b77d55f9b4cef5f45354c55b4 Mon Sep 17 00:00:00 2001 From: James Marsh Date: Thu, 31 Oct 2024 14:24:04 +0000 Subject: [PATCH] Addressing PR comments --- build-scripts/config_common.cmake | 4 +- core/iwasm/common/wasm_runtime_common.h | 57 ++++++++++--------- core/iwasm/interpreter/wasm_interp_fast.c | 4 +- core/iwasm/interpreter/wasm_opcode.h | 2 +- core/iwasm/libraries/simde/simde.cmake | 2 + .../platforms/linux-sgx/CMakeLists.txt | 5 -- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index eaf06d7f32..de9afd3f8e 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -324,8 +324,8 @@ if (WAMR_BUILD_SIMD EQUAL 1) else () message (" SIMD disabled due to not supported on target RISCV64") endif () - if(WAMR_BUILD_TARGET MATCHES "AARCH64.*" OR "ARM.*") - add_definitions (-DWAMR_BUILD_SIMDE=1) + if(WAMR_BUILD_SIMDE EQUAL 1 AND WAMR_BUILD_TARGET MATCHES "AARCH64.*" OR "ARM.*") + add_definitions (-DWASM_ENABLE_SIMDE=1) endif() endif () if (WAMR_BUILD_AOT_STACK_FRAME EQUAL 1) diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h index e4675d15a3..0fe7bd4010 100644 --- a/core/iwasm/common/wasm_runtime_common.h +++ b/core/iwasm/common/wasm_runtime_common.h @@ -272,33 +272,36 @@ STORE_U16(void *addr, uint16_t value) ((uint8_t *)(addr))[1] = u.u8[1]; } -#define STORE_V128(addr, value) \ - do { \ - uintptr_t addr_ = (uintptr_t)(addr); \ - union { \ - V128 val; \ - uint64 u64[2]; \ - uint32 u32[4]; \ - uint16 u16[8]; \ - uint8 u8[16]; \ - } u; \ - if ((addr_ & (uintptr_t)15) == 0) \ - *(V128 *)(addr) = (V128)(value); \ - else { \ - u.val = (V128)(value); \ - if ((addr_ & (uintptr_t)7) == 0) { \ - ((uint64 *)(addr))[0] = u.u64[0]; \ - ((uint64 *)(addr))[1] = u.u64[1]; \ - } \ - else { \ - bh_assert((addr_ & (uintptr_t)3) == 0); \ - ((uint32 *)(addr))[0] = u.u32[0]; \ - ((uint32 *)(addr))[1] = u.u32[1]; \ - ((uint32 *)(addr))[2] = u.u32[2]; \ - ((uint32 *)(addr))[3] = u.u32[3]; \ - } \ - } \ - } while (0) +static inline void +STORE_V128(void *addr, V128 value) +{ + uintptr_t addr_ = (uintptr_t)(addr); + union { + V128 val; + uint64 u64[2]; + uint32 u32[4]; + uint16 u16[8]; + uint8 u8[16]; + } u; + + if ((addr_ & (uintptr_t)15) == 0) { + *(V128 *)addr = value; + } + else { + u.val = value; + if ((addr_ & (uintptr_t)7) == 0) { + ((uint64 *)(addr))[0] = u.u64[0]; + ((uint64 *)(addr))[1] = u.u64[1]; + } + else { + bh_assert((addr_ & (uintptr_t)3) == 0); + ((uint32 *)addr)[0] = u.u32[0]; + ((uint32 *)addr)[1] = u.u32[1]; + ((uint32 *)addr)[2] = u.u32[2]; + ((uint32 *)addr)[3] = u.u32[3]; + } + } +} /* For LOAD opcodes */ static inline V128 diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index 76767bfa15..9bbc0e395e 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -21,7 +21,7 @@ #include "../common/wasm_shared_memory.h" #endif -#if WASM_ENABLE_SIMD != 0 && WAMR_BUILD_SIMDE != 0 +#if WASM_ENABLE_SIMDE != 0 #include "simde/wasm/simd128.h" #endif @@ -5650,7 +5650,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, #endif goto call_func_from_entry; } -#if WASM_ENABLE_SIMD != 0 && WAMR_BUILD_SIMDE != 0 +#if WASM_ENABLE_SIMDE != 0 #define SIMD_V128_TO_SIMDE_V128(v) \ ({ \ bh_assert(sizeof(V128) == sizeof(simde_v128_t)); \ diff --git a/core/iwasm/interpreter/wasm_opcode.h b/core/iwasm/interpreter/wasm_opcode.h index 55347316da..065ea226e0 100644 --- a/core/iwasm/interpreter/wasm_opcode.h +++ b/core/iwasm/interpreter/wasm_opcode.h @@ -783,7 +783,7 @@ typedef enum WASMAtomicEXTOpcode { #define SET_GOTO_TABLE_ELEM(opcode) [opcode] = HANDLE_OPCODE(opcode) #if (WASM_ENABLE_JIT != 0 || WASM_ENABLE_FAST_INTERP != 0) \ - && WASM_ENABLE_SIMD != 0 && WAMR_BUILD_SIMDE != 0 + && WASM_ENABLE_SIMD != 0 && WASM_ENABLE_SIMDE != 0 #define SET_GOTO_TABLE_SIMD_PREFIX_ELEM() \ SET_GOTO_TABLE_ELEM(WASM_OP_SIMD_PREFIX), #else diff --git a/core/iwasm/libraries/simde/simde.cmake b/core/iwasm/libraries/simde/simde.cmake index 98ffbedad9..d869553954 100644 --- a/core/iwasm/libraries/simde/simde.cmake +++ b/core/iwasm/libraries/simde/simde.cmake @@ -1,3 +1,5 @@ +# Copyright (C) 2024 Amazon Inc. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # simde is a header only library set (LIB_SIMDE_DIR ${CMAKE_CURRENT_LIST_DIR}) diff --git a/product-mini/platforms/linux-sgx/CMakeLists.txt b/product-mini/platforms/linux-sgx/CMakeLists.txt index e7bdbb40ce..20b3fdfac1 100644 --- a/product-mini/platforms/linux-sgx/CMakeLists.txt +++ b/product-mini/platforms/linux-sgx/CMakeLists.txt @@ -68,11 +68,6 @@ if (NOT DEFINED WAMR_BUILD_LIB_RATS) set (WAMR_BUILD_LIB_RATS 0) endif() -if (NOT DEFINED WAMR_BUILD_SIMDE) - # Disable lib simde by default - set (WAMR_BUILD_SIMDE 0) -endif() - if (NOT DEFINED WAMR_BUILD_FAST_INTERP) # Enable fast interpreter set (WAMR_BUILD_FAST_INTERP 1)