diff --git a/AstSemantics.md b/AstSemantics.md index 548eb9d5..edd2f93f 100644 --- a/AstSemantics.md +++ b/AstSemantics.md @@ -270,6 +270,21 @@ nested. This guarantees that all resulting control flow graphs are well-structur feature would allow efficient compilation of arbitrary irreducible control flow. +## Floating Point Subnormal Handling + + * `subnormal_mode`: Like [`block`](AstSemantics.md#control-flow-structures), + but with a mode attribute specifying special semantics for the handling of + subnormal values in all lexically contained [floating point operations][] + except `neg`, `abs`, and `copysign`, and [conversions][], except those in + contained `subnormal_mode` blocks. The mode may be one of: + * `standard`: standard semantics are followed + * `dont_care`: Subnormal values may or may not be interpreted as zero of the + same sign. Subnormal result values may or may not be replaced by any + subnormal value of the same sign, or zero of the same sign. + + [floating point operations]: AstSemantics.md#floating-point-operations + [conversions]: AstSemantics.md#datatype-conversions-truncations-reinterpretations-promotions-and-demotions + ## Calls Direct calls to a function specify the callee by index into a function table. @@ -400,8 +415,8 @@ Floating point arithmetic follows the IEEE-754 standard, except that: - WebAssembly uses the round-to-nearest ties-to-even rounding attribute, except where otherwise specified. Non-default directed rounding attributes are not supported. - - The strategy for gradual underflow (subnormals) is - [under discussion](https://github.com/WebAssembly/design/issues/148). + - Inside the lexical extent of a `subnormal_mode` block, operators may follow + [alternate semantics](AstSemantics.md#floating-point-subnormal-handling). In the future, these limitations may be lifted, enabling [full IEEE-754 support](FutureFeatures.md#full-ieee-754-conformance). @@ -485,8 +500,7 @@ Promotion and demotion of floating point values always succeed. Demotion of floating point values uses round-to-nearest ties-to-even rounding, and may overflow to infinity or negative infinity as specified by IEEE-754. If the operand of promotion or demotion is NaN, the sign bit and significand -of the result are computed from an unspecified function of the implementation, -the opcode, and the operand. +of the result are not specified. Reinterpretations always succeed. diff --git a/Nondeterminism.md b/Nondeterminism.md index afec0883..73294767 100644 --- a/Nondeterminism.md +++ b/Nondeterminism.md @@ -31,12 +31,16 @@ currently admits nondeterminism: nondeterministic. * Out of bounds heap accesses *may* want [some flexibility](AstSemantics.md#out-of-bounds) - * [NaN bit patterns](AstSemantics.md#floating-point-operations) - * [Fixed-width SIMD may want some flexibility](PostMVP.md#fixed-width-simd) - - In SIMD.js, floating point values may or may not have subnormals flushed to - zero. - - In SIMD.js, operations ending in "Approximation" return approximations that - may vary between platforms. + * NaN bit patterns in floating point + [operations](AstSemantics.md#floating-point-operations) and + [conversions](AstSemantics.md#datatype-conversions-truncations-reinterpretations-promotions-and-demotions) + * Within the lexical extent of a + `dont_care` [`subnormal_mode`](AstSemantics.md#floating-point-subnormal-handling) + block, the interpretation and production of subnormal values is + nondeterministically relaxed. + * [Fixed-width SIMD](PostMVP.md#fixed-width-simd) may define operations with + names ending in "approximation" which return approximations that may vary + nondeterministically. * Environment-dependent resource limits may be exhausted. A few examples: - Memory allocation may fail. - Program stack may get exhausted.