summaryrefslogtreecommitdiff
path: root/src/prebuilt/wasm2c_atomicops_source_declarations.cc
diff options
context:
space:
mode:
authorSoni L <EnderMoneyMod@gmail.com>2023-11-14 22:25:41 -0300
committerGitHub <noreply@github.com>2023-11-14 17:25:41 -0800
commit21e73b7e6eee4addbc84ae265ee2f5ca88178934 (patch)
treea6ea97dbf70a173e7f5667487ca0e4a64a8b97f5 /src/prebuilt/wasm2c_atomicops_source_declarations.cc
parenta0bc02eacae79763d35360673620ab38d527f68a (diff)
downloadwabt-21e73b7e6eee4addbc84ae265ee2f5ca88178934.tar.gz
wabt-21e73b7e6eee4addbc84ae265ee2f5ca88178934.tar.bz2
wabt-21e73b7e6eee4addbc84ae265ee2f5ca88178934.zip
wasm2c: Improve address abstraction for BE support (#2328)
Diffstat (limited to 'src/prebuilt/wasm2c_atomicops_source_declarations.cc')
-rw-r--r--src/prebuilt/wasm2c_atomicops_source_declarations.cc56
1 files changed, 29 insertions, 27 deletions
diff --git a/src/prebuilt/wasm2c_atomicops_source_declarations.cc b/src/prebuilt/wasm2c_atomicops_source_declarations.cc
index 91b6929e..5e82c15b 100644
--- a/src/prebuilt/wasm2c_atomicops_source_declarations.cc
+++ b/src/prebuilt/wasm2c_atomicops_source_declarations.cc
@@ -225,23 +225,23 @@ R"w2c_template( TRAP(UNALIGNED); \
R"w2c_template( }
)w2c_template"
R"w2c_template(
-#define DEFINE_ATOMIC_LOAD(name, t1, t2, t3, force_read) \
+#define DEFINE_ATOMIC_LOAD(name, t1, t2, t3, force_read) \
)w2c_template"
-R"w2c_template( static inline t3 name(wasm_rt_memory_t* mem, u64 addr) { \
+R"w2c_template( static inline t3 name(wasm_rt_memory_t* mem, u64 addr) { \
)w2c_template"
-R"w2c_template( MEMCHECK(mem, addr, t1); \
+R"w2c_template( MEMCHECK(mem, addr, t1); \
)w2c_template"
-R"w2c_template( ATOMIC_ALIGNMENT_CHECK(addr, t1); \
+R"w2c_template( ATOMIC_ALIGNMENT_CHECK(addr, t1); \
)w2c_template"
-R"w2c_template( t1 result; \
+R"w2c_template( t1 result; \
)w2c_template"
-R"w2c_template( wasm_rt_memcpy(&result, &mem->data[addr], sizeof(t1)); \
+R"w2c_template( wasm_rt_memcpy(&result, MEM_ADDR(mem, addr, sizeof(t1)), sizeof(t1)); \
)w2c_template"
-R"w2c_template( result = atomic_load_##t1(&mem->data[addr]); \
+R"w2c_template( result = atomic_load_##t1(MEM_ADDR(mem, addr, sizeof(t1))); \
)w2c_template"
-R"w2c_template( force_read(result); \
+R"w2c_template( force_read(result); \
)w2c_template"
-R"w2c_template( return (t3)(t2)result; \
+R"w2c_template( return (t3)(t2)result; \
)w2c_template"
R"w2c_template( }
)w2c_template"
@@ -271,7 +271,7 @@ R"w2c_template( ATOMIC_ALIGNMENT_CHECK(addr, t1);
)w2c_template"
R"w2c_template( t1 wrapped = (t1)value; \
)w2c_template"
-R"w2c_template( atomic_store_##t1(&mem->data[addr], wrapped); \
+R"w2c_template( atomic_store_##t1(MEM_ADDR(mem, addr, sizeof(t1)), wrapped); \
)w2c_template"
R"w2c_template( }
)w2c_template"
@@ -291,19 +291,19 @@ R"w2c_template(DEFINE_ATOMIC_STORE(i64_atomic_store16, u16, u64)
R"w2c_template(DEFINE_ATOMIC_STORE(i64_atomic_store32, u32, u64)
)w2c_template"
R"w2c_template(
-#define DEFINE_ATOMIC_RMW(name, op, t1, t2) \
+#define DEFINE_ATOMIC_RMW(name, op, t1, t2) \
)w2c_template"
-R"w2c_template( static inline t2 name(wasm_rt_memory_t* mem, u64 addr, t2 value) { \
+R"w2c_template( static inline t2 name(wasm_rt_memory_t* mem, u64 addr, t2 value) { \
)w2c_template"
-R"w2c_template( MEMCHECK(mem, addr, t1); \
+R"w2c_template( MEMCHECK(mem, addr, t1); \
)w2c_template"
-R"w2c_template( ATOMIC_ALIGNMENT_CHECK(addr, t1); \
+R"w2c_template( ATOMIC_ALIGNMENT_CHECK(addr, t1); \
)w2c_template"
-R"w2c_template( t1 wrapped = (t1)value; \
+R"w2c_template( t1 wrapped = (t1)value; \
)w2c_template"
-R"w2c_template( t1 ret = atomic_##op##_##t1(&mem->data[addr], wrapped); \
+R"w2c_template( t1 ret = atomic_##op##_##t1(MEM_ADDR(mem, addr, sizeof(t1)), wrapped); \
)w2c_template"
-R"w2c_template( return (t2)ret; \
+R"w2c_template( return (t2)ret; \
)w2c_template"
R"w2c_template( }
)w2c_template"
@@ -398,25 +398,27 @@ R"w2c_template(DEFINE_ATOMIC_RMW(i64_atomic_rmw32_xchg_u, exchange, u32, u64)
R"w2c_template(DEFINE_ATOMIC_RMW(i64_atomic_rmw_xchg, exchange, u64, u64)
)w2c_template"
R"w2c_template(
-#define DEFINE_ATOMIC_CMP_XCHG(name, t1, t2) \
+#define DEFINE_ATOMIC_CMP_XCHG(name, t1, t2) \
)w2c_template"
-R"w2c_template( static inline t1 name(wasm_rt_memory_t* mem, u64 addr, t1 expected, \
+R"w2c_template( static inline t1 name(wasm_rt_memory_t* mem, u64 addr, t1 expected, \
)w2c_template"
-R"w2c_template( t1 replacement) { \
+R"w2c_template( t1 replacement) { \
)w2c_template"
-R"w2c_template( MEMCHECK(mem, addr, t2); \
+R"w2c_template( MEMCHECK(mem, addr, t2); \
)w2c_template"
-R"w2c_template( ATOMIC_ALIGNMENT_CHECK(addr, t2); \
+R"w2c_template( ATOMIC_ALIGNMENT_CHECK(addr, t2); \
)w2c_template"
-R"w2c_template( t2 expected_wrapped = (t2)expected; \
+R"w2c_template( t2 expected_wrapped = (t2)expected; \
)w2c_template"
-R"w2c_template( t2 replacement_wrapped = (t2)replacement; \
+R"w2c_template( t2 replacement_wrapped = (t2)replacement; \
)w2c_template"
-R"w2c_template( t2 old = atomic_compare_exchange_##t2(&mem->data[addr], &expected_wrapped, \
+R"w2c_template( t2 old = \
)w2c_template"
-R"w2c_template( replacement_wrapped); \
+R"w2c_template( atomic_compare_exchange_##t2(MEM_ADDR(mem, addr, sizeof(t2)), \
)w2c_template"
-R"w2c_template( return (t1)old; \
+R"w2c_template( &expected_wrapped, replacement_wrapped); \
+)w2c_template"
+R"w2c_template( return (t1)old; \
)w2c_template"
R"w2c_template( }
)w2c_template"