diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2018-12-12 14:11:04 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-12 14:11:04 -0800 |
commit | 75b693434b5af75d105af4900b5d0c6048155421 (patch) | |
tree | 233cf1c142d7695c1239fe84135cbfd0d463350f | |
parent | 7edaebedb0f7185fae0f3fbf146a1c6b44842f5c (diff) | |
download | binaryen-75b693434b5af75d105af4900b5d0c6048155421.tar.gz binaryen-75b693434b5af75d105af4900b5d0c6048155421.tar.bz2 binaryen-75b693434b5af75d105af4900b5d0c6048155421.zip |
Update wrap and demote literal op names (#1817)
* Update literal op names
* Remove `demoteToF32` in favor of `demote`
-rw-r--r-- | src/literal.h | 11 | ||||
-rw-r--r-- | src/wasm-interpreter.h | 10 | ||||
-rw-r--r-- | src/wasm/literal.cpp | 17 |
3 files changed, 16 insertions, 22 deletions
diff --git a/src/literal.h b/src/literal.h index 1bc09c360..4ed23b80d 100644 --- a/src/literal.h +++ b/src/literal.h @@ -97,13 +97,12 @@ public: Literal extendS8() const; Literal extendS16() const; Literal extendS32() const; - Literal truncateToI32() const; - Literal truncateToF32() const; + Literal wrapToI32() const; - Literal truncSIToF32() const; - Literal truncUIToF32() const; - Literal truncSIToF64() const; - Literal truncUIToF64() const; + Literal convertSIToF32() const; + Literal convertUIToF32() const; + Literal convertSIToF64() const; + Literal convertUIToF64() const; Literal truncSatToSI32() const; Literal truncSatToSI64() const; diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index fed74282d..8554daded 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -254,15 +254,15 @@ public: case ReinterpretInt64: return value.castToF64(); case ExtendSInt32: return value.extendToSI64(); case ExtendUInt32: return value.extendToUI64(); - case WrapInt64: return value.truncateToI32(); + case WrapInt64: return value.wrapToI32(); case ConvertUInt32ToFloat32: - case ConvertUInt64ToFloat32: return value.truncUIToF32(); + case ConvertUInt64ToFloat32: return value.convertUIToF32(); case ConvertUInt32ToFloat64: - case ConvertUInt64ToFloat64: return value.truncUIToF64(); + case ConvertUInt64ToFloat64: return value.convertUIToF64(); case ConvertSInt32ToFloat32: - case ConvertSInt64ToFloat32: return value.truncSIToF32(); + case ConvertSInt64ToFloat32: return value.convertSIToF32(); case ConvertSInt32ToFloat64: - case ConvertSInt64ToFloat64: return value.truncSIToF64(); + case ConvertSInt64ToFloat64: return value.convertSIToF64(); case ExtendS8Int32: case ExtendS8Int64: return value.extendS8(); case ExtendS16Int32: diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index ece92c6ee..7b9e64e43 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -223,35 +223,30 @@ Literal Literal::extendS32() const { WASM_UNREACHABLE(); } -Literal Literal::truncateToI32() const { +Literal Literal::wrapToI32() const { assert(type == Type::i64); return Literal((int32_t)i64); } -Literal Literal::truncateToF32() const { - assert(type == Type::f64); - return Literal(float(getf64())); -} - -Literal Literal::truncSIToF32() const { +Literal Literal::convertSIToF32() const { if (type == Type::i32) return Literal(float(i32)); if (type == Type::i64) return Literal(float(i64)); WASM_UNREACHABLE(); } -Literal Literal::truncUIToF32() const { +Literal Literal::convertUIToF32() const { if (type == Type::i32) return Literal(float(uint32_t(i32))); if (type == Type::i64) return Literal(float(uint64_t(i64))); WASM_UNREACHABLE(); } -Literal Literal::truncSIToF64() const { +Literal Literal::convertSIToF64() const { if (type == Type::i32) return Literal(double(i32)); if (type == Type::i64) return Literal(double(i64)); WASM_UNREACHABLE(); } -Literal Literal::truncUIToF64() const { +Literal Literal::convertUIToF64() const { if (type == Type::i32) return Literal(double(uint32_t(i32))); if (type == Type::i64) return Literal(double(uint64_t(i64))); WASM_UNREACHABLE(); @@ -426,7 +421,7 @@ Literal Literal::demote() const { // when we must convert to infinity, do that if (f64 < -std::numeric_limits<float>::max()) return Literal(-std::numeric_limits<float>::infinity()); if (f64 > std::numeric_limits<float>::max()) return Literal(std::numeric_limits<float>::infinity()); - return truncateToF32(); + return Literal(float(getf64())); } Literal Literal::add(const Literal& other) const { |