summaryrefslogtreecommitdiff
path: root/src/binary-reader-ir.cc
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2017-09-20 09:49:58 -0700
committerGitHub <noreply@github.com>2017-09-20 09:49:58 -0700
commit447e6f752b157d0a9951525a045d862e62d9b88c (patch)
tree2484ab5841f35fa50127f6dd83460f943a202fb6 /src/binary-reader-ir.cc
parentc71918746e06d2afffc46b3da5e3f2c024cc4b92 (diff)
downloadwabt-447e6f752b157d0a9951525a045d862e62d9b88c.tar.gz
wabt-447e6f752b157d0a9951525a045d862e62d9b88c.tar.bz2
wabt-447e6f752b157d0a9951525a045d862e62d9b88c.zip
Add Atomic instructions (#633)
This adds support for all atomic instructions, enabled via the `--enable-threads` flag. It supports all tools: parsing text, decoding binary, validation, and interpreting. It does not currently ensure that the memory is marked as shared; that flag is not supported in wabt yet.
Diffstat (limited to 'src/binary-reader-ir.cc')
-rw-r--r--src/binary-reader-ir.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/binary-reader-ir.cc b/src/binary-reader-ir.cc
index 70dc4fbf..f37b4ddb 100644
--- a/src/binary-reader-ir.cc
+++ b/src/binary-reader-ir.cc
@@ -116,6 +116,18 @@ class BinaryReaderIR : public BinaryReaderNop {
Result BeginFunctionBody(Index index) override;
Result OnLocalDecl(Index decl_index, Index count, Type type) override;
+ Result OnAtomicLoadExpr(Opcode opcode,
+ uint32_t alignment_log2,
+ Address offset) override;
+ Result OnAtomicStoreExpr(Opcode opcode,
+ uint32_t alignment_log2,
+ Address offset) override;
+ Result OnAtomicRmwExpr(Opcode opcode,
+ uint32_t alignment_log2,
+ Address offset) override;
+ Result OnAtomicRmwCmpxchgExpr(Opcode opcode,
+ uint32_t alignment_log2,
+ Address offset) override;
Result OnBinaryExpr(Opcode opcode) override;
Result OnBlockExpr(Index num_types, Type* sig_types) override;
Result OnBrExpr(Index depth) override;
@@ -509,6 +521,34 @@ Result BinaryReaderIR::OnLocalDecl(Index decl_index, Index count, Type type) {
return Result::Ok;
}
+Result BinaryReaderIR::OnAtomicLoadExpr(Opcode opcode,
+ uint32_t alignment_log2,
+ Address offset) {
+ return AppendExpr(
+ MakeUnique<AtomicLoadExpr>(opcode, 1 << alignment_log2, offset));
+}
+
+Result BinaryReaderIR::OnAtomicStoreExpr(Opcode opcode,
+ uint32_t alignment_log2,
+ Address offset) {
+ return AppendExpr(
+ MakeUnique<AtomicStoreExpr>(opcode, 1 << alignment_log2, offset));
+}
+
+Result BinaryReaderIR::OnAtomicRmwExpr(Opcode opcode,
+ uint32_t alignment_log2,
+ Address offset) {
+ return AppendExpr(
+ MakeUnique<AtomicRmwExpr>(opcode, 1 << alignment_log2, offset));
+}
+
+Result BinaryReaderIR::OnAtomicRmwCmpxchgExpr(Opcode opcode,
+ uint32_t alignment_log2,
+ Address offset) {
+ return AppendExpr(
+ MakeUnique<AtomicRmwCmpxchgExpr>(opcode, 1 << alignment_log2, offset));
+}
+
Result BinaryReaderIR::OnBinaryExpr(Opcode opcode) {
return AppendExpr(MakeUnique<BinaryExpr>(opcode, GetLocation()));
}