Skip to content

Commit b39a178

Browse files
committed
fixup! Introduce WASM_CPU_SUPPORTS_UNALIGNED_SIMD_ACCESS for V128 load/store
fixup! Introduce WASM_CPU_SUPPORTS_UNALIGNED_SIMD_ACCESS for V128 load/store Remove duplicate STORE_V128/LOAD_V128 definitions from the WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS==0 branch. These are now defined exclusively in the SIMD access block below, which handles all three cases (unaligned addr, unaligned SIMD only, neither). Fixes redefinition errors on MSVC (C2084) and GCC/ARC (Zephyr).
1 parent 29ff55e commit b39a178

1 file changed

Lines changed: 2 additions & 85 deletions

File tree

core/iwasm/common/wasm_runtime_common.h

Lines changed: 2 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -272,93 +272,10 @@ STORE_U16(void *addr, uint16_t value)
272272
((uint8_t *)(addr))[1] = u.u8[1];
273273
}
274274

275-
static inline void
276-
STORE_V128(void *addr, V128 value)
277-
{
278-
uintptr_t addr_ = (uintptr_t)(addr);
279-
union {
280-
V128 val;
281-
uint64 u64[2];
282-
uint32 u32[4];
283-
uint16 u16[8];
284-
uint8 u8[16];
285-
} u;
286-
287-
if ((addr_ & (uintptr_t)15) == 0) {
288-
*(V128 *)addr = value;
289-
}
290-
else if ((addr_ & (uintptr_t)7) == 0) {
291-
u.val = value;
292-
((uint64 *)(addr))[0] = u.u64[0];
293-
((uint64 *)(addr))[1] = u.u64[1];
294-
}
295-
else if ((addr_ & (uintptr_t)3) == 0) {
296-
u.val = value;
297-
((uint32 *)addr)[0] = u.u32[0];
298-
((uint32 *)addr)[1] = u.u32[1];
299-
((uint32 *)addr)[2] = u.u32[2];
300-
((uint32 *)addr)[3] = u.u32[3];
301-
}
302-
else if ((addr_ & (uintptr_t)1) == 0) {
303-
u.val = value;
304-
((uint16 *)addr)[0] = u.u16[0];
305-
((uint16 *)addr)[1] = u.u16[1];
306-
((uint16 *)addr)[2] = u.u16[2];
307-
((uint16 *)addr)[3] = u.u16[3];
308-
((uint16 *)addr)[4] = u.u16[4];
309-
((uint16 *)addr)[5] = u.u16[5];
310-
((uint16 *)addr)[6] = u.u16[6];
311-
((uint16 *)addr)[7] = u.u16[7];
312-
}
313-
else {
314-
u.val = value;
315-
for (int i = 0; i < 16; i++)
316-
((uint8 *)addr)[i] = u.u8[i];
317-
}
318-
}
275+
/* STORE_V128 / LOAD_V128 are defined separately below, guarded by
276+
* WASM_CPU_SUPPORTS_UNALIGNED_SIMD_ACCESS (see Block after line 474). */
319277

320278
/* For LOAD opcodes */
321-
static inline V128
322-
LOAD_V128(void *addr)
323-
{
324-
uintptr_t addr1 = (uintptr_t)addr;
325-
union {
326-
V128 val;
327-
uint64 u64[2];
328-
uint32 u32[4];
329-
uint16 u16[8];
330-
uint8 u8[16];
331-
} u;
332-
if ((addr1 & (uintptr_t)15) == 0)
333-
return *(V128 *)addr;
334-
335-
if ((addr1 & (uintptr_t)7) == 0) {
336-
u.u64[0] = ((uint64 *)addr)[0];
337-
u.u64[1] = ((uint64 *)addr)[1];
338-
}
339-
else if ((addr1 & (uintptr_t)3) == 0) {
340-
u.u32[0] = ((uint32 *)addr)[0];
341-
u.u32[1] = ((uint32 *)addr)[1];
342-
u.u32[2] = ((uint32 *)addr)[2];
343-
u.u32[3] = ((uint32 *)addr)[3];
344-
}
345-
else if ((addr1 & (uintptr_t)1) == 0) {
346-
u.u16[0] = ((uint16 *)addr)[0];
347-
u.u16[1] = ((uint16 *)addr)[1];
348-
u.u16[2] = ((uint16 *)addr)[2];
349-
u.u16[3] = ((uint16 *)addr)[3];
350-
u.u16[4] = ((uint16 *)addr)[4];
351-
u.u16[5] = ((uint16 *)addr)[5];
352-
u.u16[6] = ((uint16 *)addr)[6];
353-
u.u16[7] = ((uint16 *)addr)[7];
354-
}
355-
else {
356-
for (int i = 0; i < 16; i++)
357-
u.u8[i] = ((uint8 *)addr)[i];
358-
}
359-
return u.val;
360-
}
361-
362279
static inline int64
363280
LOAD_I64(void *addr)
364281
{

0 commit comments

Comments
 (0)