summaryrefslogtreecommitdiff
path: root/src/wasm/literal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/literal.cpp')
-rw-r--r--src/wasm/literal.cpp17
1 files changed, 6 insertions, 11 deletions
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 {