From ab8dbae1d1a27e4de24fd9ee09d45785a414922d Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Fri, 21 Jul 2017 08:46:23 -0700 Subject: Optimizer support for atomic instructions (#1094) * Teach EffectAnalyzer not to reorder atomics wrt other memory operations. * Teach EffectAnalyzer not to reorder host operations with memory operations * Teach various passes about the operands of AtomicRMW and AtomicCmpxchg * Factor out some functions in DeadCodeElimination and MergeBlocks --- src/wasm-builder.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/wasm-builder.h') diff --git a/src/wasm-builder.h b/src/wasm-builder.h index f702342d2..a1f2ec9b3 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -193,6 +193,11 @@ public: ret->type = type; return ret; } + Load* makeAtomicLoad(unsigned bytes, bool signed_, uint32_t offset, Expression* ptr, WasmType type) { + Load* load = makeLoad(bytes, signed_, offset, getWasmTypeSize(type), ptr, type); + load->isAtomic = true; + return load; + } Store* makeStore(unsigned bytes, uint32_t offset, unsigned align, Expression *ptr, Expression *value, WasmType type) { auto* ret = allocator.alloc(); ret->isAtomic = false; @@ -201,6 +206,36 @@ public: assert(isConcreteWasmType(ret->value->type) ? ret->value->type == type : true); return ret; } + Store* makeAtomicStore(unsigned bytes, uint32_t offset, Expression* ptr, Expression* value, WasmType type) { + Store* store = makeStore(bytes, offset, getWasmTypeSize(type), ptr, value, type); + store->isAtomic = true; + return store; + } + AtomicRMW* makeAtomicRMW(AtomicRMWOp op, unsigned bytes, uint32_t offset, + Expression* ptr, Expression* value, WasmType type) { + auto* ret = allocator.alloc(); + ret->op = op; + ret->bytes = bytes; + ret->offset = offset; + ret->ptr = ptr; + ret->value = value; + ret->type = type; + ret->finalize(); + return ret; + } + AtomicCmpxchg* makeAtomicCmpxchg(unsigned bytes, uint32_t offset, + Expression* ptr, Expression* expected, Expression* replacement, + WasmType type) { + auto* ret = allocator.alloc(); + ret->bytes = bytes; + ret->offset = offset; + ret->ptr = ptr; + ret->expected = expected; + ret->replacement = replacement; + ret->type = type; + ret->finalize(); + return ret; + } Const* makeConst(Literal value) { assert(isConcreteWasmType(value.type)); auto* ret = allocator.alloc(); -- cgit v1.2.3