diff options
author | Jay Phelps <hello@jayphelps.com> | 2019-08-20 15:27:58 -0500 |
---|---|---|
committer | Heejin Ahn <aheejin@gmail.com> | 2019-08-20 13:27:58 -0700 |
commit | dce1fe8c16559437cae05c0dd782237474ca6082 (patch) | |
tree | 811e57a34951ad316072d7da8838461c25fbf465 /src/wasm/literal.cpp | |
parent | 86b8cf6c299d0189d7819cf5eabb1ea03d34ff3a (diff) | |
download | binaryen-dce1fe8c16559437cae05c0dd782237474ca6082.tar.gz binaryen-dce1fe8c16559437cae05c0dd782237474ca6082.tar.bz2 binaryen-dce1fe8c16559437cae05c0dd782237474ca6082.zip |
Add initial support for anyref as an opaque type (#2294)
Another round of trying to push upstream things from my fork.
This PR only adds support for anyref itself as an opaque type. It does NOT implement the full [reference types proposal](https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/Overview.md)--so no table.get/set/grow/etc or ref.null, ref.func, etc.
Figured it was easier to review and merge as we go, especially if I did something fundamentally wrong.
***
I did put it under the `--enable-reference-types` flag as I imagine that even though this PR doesn't complete the full feature set, it probably is the right home. Lmk if not.
I'll also be adding a few github comments to places I want to point out/question.
Diffstat (limited to 'src/wasm/literal.cpp')
-rw-r--r-- | src/wasm/literal.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index 68268d366..43adec6f6 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -137,6 +137,7 @@ void Literal::getBits(uint8_t (&buf)[16]) const { case Type::v128: memcpy(buf, &v128, sizeof(v128)); break; + case Type::anyref: // anyref type is opaque case Type::exnref: // exnref type is opaque case Type::none: case Type::unreachable: @@ -272,6 +273,7 @@ std::ostream& operator<<(std::ostream& o, Literal literal) { o << "i32x4 "; literal.printVec128(o, literal.getv128()); break; + case Type::anyref: // anyref type is opaque case Type::exnref: // exnref type is opaque case Type::unreachable: WASM_UNREACHABLE(); @@ -475,6 +477,7 @@ Literal Literal::eqz() const { case Type::f64: return eq(Literal(double(0))); case Type::v128: + case Type::anyref: case Type::exnref: case Type::none: case Type::unreachable: @@ -494,6 +497,7 @@ Literal Literal::neg() const { case Type::f64: return Literal(int64_t(i64 ^ 0x8000000000000000ULL)).castToF64(); case Type::v128: + case Type::anyref: case Type::exnref: case Type::none: case Type::unreachable: @@ -513,6 +517,7 @@ Literal Literal::abs() const { case Type::f64: return Literal(int64_t(i64 & 0x7fffffffffffffffULL)).castToF64(); case Type::v128: + case Type::anyref: case Type::exnref: case Type::none: case Type::unreachable: @@ -615,6 +620,7 @@ Literal Literal::add(const Literal& other) const { case Type::f64: return Literal(getf64() + other.getf64()); case Type::v128: + case Type::anyref: case Type::exnref: case Type::none: case Type::unreachable: @@ -634,6 +640,7 @@ Literal Literal::sub(const Literal& other) const { case Type::f64: return Literal(getf64() - other.getf64()); case Type::v128: + case Type::anyref: case Type::exnref: case Type::none: case Type::unreachable: @@ -724,6 +731,7 @@ Literal Literal::mul(const Literal& other) const { case Type::f64: return Literal(getf64() * other.getf64()); case Type::v128: + case Type::anyref: case Type::exnref: case Type::none: case Type::unreachable: @@ -942,6 +950,7 @@ Literal Literal::eq(const Literal& other) const { case Type::f64: return Literal(getf64() == other.getf64()); case Type::v128: + case Type::anyref: case Type::exnref: case Type::none: case Type::unreachable: @@ -961,6 +970,7 @@ Literal Literal::ne(const Literal& other) const { case Type::f64: return Literal(getf64() != other.getf64()); case Type::v128: + case Type::anyref: case Type::exnref: case Type::none: case Type::unreachable: |