diff options
Diffstat (limited to 'src/support')
-rw-r--r-- | src/support/safe_integer.cpp | 10 | ||||
-rw-r--r-- | src/support/safe_integer.h | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/support/safe_integer.cpp b/src/support/safe_integer.cpp index 3a50b50ea..86ba2547a 100644 --- a/src/support/safe_integer.cpp +++ b/src/support/safe_integer.cpp @@ -98,6 +98,11 @@ int64_t wasm::toSInteger64(double x) { * 1 11111111 111...11 => 0xffffffff => -nan(0x7fffff) */ +bool wasm::isInRangeI16TruncS(int32_t i) { + uint32_t u = i; + return (u < 0x47000000U) || (u >= 0x80000000U && u <= 0xc7000000U); +} + bool wasm::isInRangeI32TruncS(int32_t i) { uint32_t u = i; return (u < 0x4f000000U) || (u >= 0x80000000U && u <= 0xcf000000U); @@ -108,6 +113,11 @@ bool wasm::isInRangeI64TruncS(int32_t i) { return (u < 0x5f000000U) || (u >= 0x80000000U && u <= 0xdf000000U); } +bool wasm::isInRangeI16TruncU(int32_t i) { + uint32_t u = i; + return (u < 0x47800000) || (u >= 0x80000000U && u < 0xbf800000U); +} + bool wasm::isInRangeI32TruncU(int32_t i) { uint32_t u = i; return (u < 0x4f800000U) || (u >= 0x80000000U && u < 0xbf800000U); diff --git a/src/support/safe_integer.h b/src/support/safe_integer.h index 031c6c323..6888ab25f 100644 --- a/src/support/safe_integer.h +++ b/src/support/safe_integer.h @@ -32,8 +32,10 @@ uint64_t toUInteger64(double x); int64_t toSInteger64(double x); // The isInRange* functions all expect to be passed the binary representation // of a float or double. +bool isInRangeI16TruncS(int32_t i); bool isInRangeI32TruncS(int32_t i); bool isInRangeI64TruncS(int32_t i); +bool isInRangeI16TruncU(int32_t i); bool isInRangeI32TruncU(int32_t i); bool isInRangeI64TruncU(int32_t i); bool isInRangeI32TruncS(int64_t i); |