summaryrefslogtreecommitdiff
path: root/src/wasm-builder.h
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2017-07-21 08:46:23 -0700
committerGitHub <noreply@github.com>2017-07-21 08:46:23 -0700
commitab8dbae1d1a27e4de24fd9ee09d45785a414922d (patch)
treeac337117d973464a16d597fc7a5c29550a93a489 /src/wasm-builder.h
parentda680fdbcb7eaad1c692369c7c826fc02b00c877 (diff)
downloadbinaryen-ab8dbae1d1a27e4de24fd9ee09d45785a414922d.tar.gz
binaryen-ab8dbae1d1a27e4de24fd9ee09d45785a414922d.tar.bz2
binaryen-ab8dbae1d1a27e4de24fd9ee09d45785a414922d.zip
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
Diffstat (limited to 'src/wasm-builder.h')
-rw-r--r--src/wasm-builder.h35
1 files changed, 35 insertions, 0 deletions
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<Store>();
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<AtomicRMW>();
+ 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<AtomicCmpxchg>();
+ 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<Const>();