aboutsummaryrefslogtreecommitdiff
path: root/Semantics.md
diff options
context:
space:
mode:
authorDan Gohman <sunfish@mozilla.com>2020-02-26 18:30:43 -0800
committerGitHub <noreply@github.com>2020-02-26 18:30:43 -0800
commitccbac15a287fa2af4a3db882d950db442011a7b1 (patch)
tree65a9bf05926713284bc5c6ee313f52b56d76bebc /Semantics.md
parentd4e7f960c5e3f3788531147e4ea4ed23eb507c02 (diff)
downloadnanowasm-design-ccbac15a287fa2af4a3db882d950db442011a7b1.tar.gz
Define non-trapping float-to-int conversions. (#1089)
* Define non-trapping float-to-int conversions. This also introduces the concept of prefix bytes, and defines the "numeric" prefix byte, used for encodin the new conversion instructions. * Add feature markers. * Add the feature marker in more places. * Rename "numeric" to "misc". See https://github.com/WebAssembly/nontrapping-float-to-int-conversions/issues/5. * Rename opcodes. See https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329.
Diffstat (limited to 'Semantics.md')
-rw-r--r--Semantics.md23
1 files changed, 22 insertions, 1 deletions
diff --git a/Semantics.md b/Semantics.md
index aa0ed9f..ae6db70 100644
--- a/Semantics.md
+++ b/Semantics.md
@@ -35,6 +35,14 @@ detailed in this document.
[:unicorn:][future general] = Planned [future][future general] feature
+## Post-MVP Features
+
+Some features were added post-MVP. These are indicated with the following symbols:
+
+| Symbol | Feature |
+| ---------- | ------- |
+| :bowling: | Saturating float to int conversions |
+
## Traps
Some operators may *trap* under some conditions, as noted below. In the MVP,
@@ -640,6 +648,14 @@ is NaN, and *ordered* otherwise.
* `f64.convert_u/i32`: convert an unsigned 32-bit integer to a 64-bit float
* `f64.convert_u/i64`: convert an unsigned 64-bit integer to a 64-bit float
* `f64.reinterpret/i64`: reinterpret the bits of a 64-bit integer as a 64-bit float
+ * `i32.trunc_sat_f32_s`: :bowling: truncate a 32-bit float to a signed 32-bit integer with saturation
+ * `i32.trunc_sat_f64_s`: :bowling: truncate a 64-bit float to a signed 32-bit integer with saturation
+ * `i32.trunc_sat_f32_u`: :bowling: truncate a 32-bit float to an unsigned 32-bit integer with saturation
+ * `i32.trunc_sat_f64_u`: :bowling: truncate a 64-bit float to an unsigned 32-bit integer with saturation
+ * `i64.trunc_sat_f32_s`: :bowling: truncate a 32-bit float to a signed 64-bit integer with saturation
+ * `i64.trunc_sat_f64_s`: :bowling: truncate a 64-bit float to a signed 64-bit integer with saturation
+ * `i64.trunc_sat_f32_u`: :bowling: truncate a 32-bit float to an unsigned 64-bit integer with saturation
+ * `i64.trunc_sat_f64_u`: :bowling: truncate a 64-bit float to an unsigned 64-bit integer with saturation
Wrapping and extension of integer values always succeed.
Promotion and demotion of floating point values always succeed.
@@ -665,7 +681,12 @@ round-to-nearest ties-to-even rounding.
Truncation from floating point to integer where IEEE 754-2008 would specify an
invalid operator exception (e.g. when the floating point value is NaN or
-outside the range which rounds to an integer in range) traps.
+outside the range which rounds to an integer in range) is handled as follows:
+ - For instructions with no exceptional behavior specified, a trap is produced.
+ - :bowling: For instructions containing `_sat`, no trap is produced, and:
+ - If the floating-point value is positive, the maximum integer value is returned.
+ - If the floating-point value is negative, the minimum integer value is returned.
+ - If the floating-point value is NaN, zero is returned.
## Type-parametric operators