Skip to content

Commit 5cb017e

Browse files
committed
Merge pull request #121 from WebAssembly/categorize-ops
Categorize ops previously "under consideration"
2 parents ea85e91 + b2c9664 commit 5cb017e

File tree

2 files changed

+106
-74
lines changed

2 files changed

+106
-74
lines changed

AstSemantics.md

Lines changed: 12 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ and 0 representing false.
306306
* Int32Sle - signed less than or equal
307307
* Int32Ult - unsigned less than
308308
* Int32Ule - unsigned less than or equal
309+
* Int32Clz - count leading zeroes (defined for all values, including 0)
310+
* Int32Ctz - count trailing zeroes (defined for all values, including 0)
311+
* Int32Popcnt - count number of ones
309312

310313
Division or remainder by zero traps.
311314
Signed division overflow (`INT32_MIN / -1`) traps. Signed remainder with a
@@ -320,22 +323,6 @@ Note that greater-than and greater-than-or-equal operations are not required,
320323
since "a < b" == "b > a" and "a <= b" == "b >= a". Such equalities also hold for
321324
floating point comparisons, even considering NaN.
322325

323-
Additional 32-bit integer Operations under consideration:
324-
325-
* Int32SMulHigh - signed multiplication (upper 32-bits)
326-
* Int32UMulHigh - unsigned multiplication (upper 32-bits)
327-
* Int32Clz - count leading zeroes (defined for all values, including 0)
328-
* Int32Ctz - count trailing zeroes (defined for all values, including 0)
329-
* Int32Popcnt - count number of ones
330-
* Int32BSwap - reverse bytes (endian conversion)
331-
* Int32Rotr - bitwise rotate right
332-
* Int32Rotl - bitwise rotate left
333-
* Int32Not - signed-less one's complement
334-
* Int32SMin - signed minimum
335-
* Int32SMax - signed maximum
336-
* Int32UMin - unsigned minimum
337-
* Int32UMax - unsigned maximum
338-
339326
## Floating point operations
340327

341328
Floating point arithmetic follows the IEEE-754 standard, except that:
@@ -369,10 +356,14 @@ Floating point arithmetic follows the IEEE-754 standard, except that:
369356
* Float32Copysign - copysign
370357
* Float32Ceil - ceiling operation
371358
* Float32Floor - floor operation
359+
* Float32Trunc - round to nearest integer towards zero
360+
* Float32NearestInt - round to nearest integer, ties to even
372361
* Float32Eq - compare equal
373362
* Float32Lt - less than
374363
* Float32Le - less than or equal
375364
* Float32Sqrt - square root
365+
* Float32Min - minimum (binary operator); if either operand is NaN, returns NaN
366+
* Float32Max - maximum (binary operator); if either operand is NaN, returns NaN
376367

377368
* Float64Add - addition
378369
* Float64Sub - subtraction
@@ -383,28 +374,16 @@ Floating point arithmetic follows the IEEE-754 standard, except that:
383374
* Float64Copysign - copysign
384375
* Float64Ceil - ceiling operation
385376
* Float64Floor - floor operation
377+
* Float64Trunc - round to nearest integer towards zero
378+
* Float64NearestInt - round to nearest integer, ties to even
386379
* Float64Eq - compare equal
387380
* Float64Lt - less than
388381
* Float64Le - less than or equal
389382
* Float64Sqrt - square root
383+
* Float64Min - minimum (binary operator); if either operand is NaN, returns NaN
384+
* Float64Max - maximum (binary operator); if either operand is NaN, returns NaN
390385

391-
Operations under consideration:
392-
393-
* Float32Min - minimum; if either operand is NaN, returns NaN
394-
* Float32Max - maximum; if either operand is NaN, returns NaN
395-
* Float32MinNum - minimum; if exactly one operand is NaN, returns the other operand
396-
* Float32MaxNum - maximum; if exactly one operand is NaN, returns the other operand
397-
* Float32Trunc - round to nearest integer towards zero
398-
* Float32NearestInt - round to nearest integer, ties to even
399-
400-
* Float64Min - minimum; if either operand is NaN, returns NaN
401-
* Float64Max - maximum; if either operand is NaN, returns NaN
402-
* Float64MinNum - minimum; if exactly one operand is NaN, returns the other operand
403-
* Float64MaxNum - maximum; if exactly one operand is NaN, returns the other operand
404-
* Float64Trunc - round to nearest integer towards zero
405-
* Float64NearestInt - round to nearest integer, ties to even
406-
407-
Min, Max, MinNum, and MaxNum operations would treat -0 as being effectively less than 0.
386+
Min and Max operations treat -0 as being effectively less than 0.
408387

409388
## Datatype conversions, truncations, reinterpretations, promotions, and demotions
410389

@@ -436,37 +415,3 @@ overflow to infinity or negative infinity as specified by IEEE-754.
436415
Conversion from floating point to integer where IEEE-754 would specify an
437416
invalid operation exception (e.g. when the floating point value is NaN or
438417
outside the range which rounds to an integer in range) traps.
439-
440-
## Post-MVP intrinsics
441-
442-
The following list of intrinsics is being considered for addition after the MVP. The
443-
rationale is that, for the MVP, these operations can be statically linked into the
444-
WebAssembly module by the code generator at small size cost and this avoids a
445-
non-trivial specification burden of their semantics/precision. Adding these
446-
intrinsics post-MVP would allow for better high-level backend optimization of
447-
these intrinsics that require builtin knowledge of their semantics. On the other
448-
hand, a code generator may continue to statically link in its own implementation
449-
since this provides greater control over precision/performance tradeoffs.
450-
451-
* Float64Sin - trigonometric sine
452-
* Float64Cos - trigonometric cosine
453-
* Float64Tan - trigonometric tangent
454-
* Float64ASin - trigonometric arcsine
455-
* Float64ACos - trigonometric arccosine
456-
* Float64ATan - trigonometric arctangent
457-
* Float64ATan2 - trigonometric arctangent with two arguments
458-
* Float64Exp - exponentiate e
459-
* Float64Ln - natural logarithm
460-
* Float64Pow - exponentiate
461-
* Float32Sin - trigonometric sine
462-
* Float32Cos - trigonometric cosine
463-
* Float32Tan - trigonometric tangent
464-
* Float32ASin - trigonometric arcsine
465-
* Float32ACos - trigonometric arccosine
466-
* Float32ATan - trigonometric arctangent
467-
* Float32ATan2 - trigonometric arctangent with two arguments
468-
* Float32Exp - exponentiate e
469-
* Float32Ln - natural logarithm
470-
* Float32Pow - exponentiate
471-
472-
The rounding behavior of these operations would need clarification.

FutureFeatures.md

Lines changed: 94 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,6 @@ include:
152152

153153
[a proposal in the SIMD.js repository]: https://github.com/johnmccutchan/ecmascript_simd/issues/180
154154

155-
## Operations which may not be available or may not perform well on all platforms
156-
157-
* Fused multiply-add.
158-
* Reciprocal square root approximate.
159-
* 16-bit floating point.
160-
* and more!
161-
162155
## Platform-independent Just-in-Time compilation
163156

164157
WebAssembly is a new virtual ISA, and as such applications won't be able to
@@ -213,3 +206,97 @@ use cases:
213206
things possible. Possibly this could involve throwing or possibly by
214207
resuming execution at the trapping instruction with the execution state
215208
altered, if there can be a reasonable way to specify how that should work.
209+
210+
## Additional integer operations
211+
212+
* The following operations can be built from other operators already present,
213+
however in doing so they read at least one non-constant input multiple times,
214+
breaking single-use expression tree formation.
215+
* Int32Rotr - bitwise rotate right
216+
* Int32Rotl - bitwise rotate left
217+
* Int32SMin - signed minimum
218+
* Int32SMax - signed maximum
219+
* Int32UMin - unsigned minimum
220+
* Int32UMax - unsigned maximum
221+
* Int32SExt - `sext(x, y)` is `x<<y>>y`
222+
* Int32Abs - absolute value (is `abs(INT32_MIN)` `INT32_MIN` or should it trap?)
223+
* Int32BSwap - reverse bytes (endian conversion)
224+
* Int32BSwap16 - `bswap16(x)` is `((x>>8)&255)|((x&255)<<8)`
225+
226+
* The following operations are just potentially interesting.
227+
* Int32Clrs - count leading redundant sign bits (defined for all values, including 0)
228+
229+
## Additional floating point operations
230+
231+
* Float32MinNum - minimum; if exactly one operand is NaN, returns the other operand
232+
* Float32MaxNum - maximum; if exactly one operand is NaN, returns the other operand
233+
* Float32FMA - fused multiply-add (results always conforming to IEEE-754)
234+
* Float64MinNum - minimum; if exactly one operand is NaN, returns the other operand
235+
* Float64MaxNum - maximum; if exactly one operand is NaN, returns the other operand
236+
* Float64FMA - fused multiply-add (results always conforming to IEEE-754)
237+
238+
MinNum, and MaxNum operations would treat -0 as being effectively less than 0.
239+
240+
Note that some operations, like FMA, may not be available or may not perform
241+
well on all platforms. These should be guarded by
242+
[feature tests](FeatureTest.md) so that if available, they behave consistently.
243+
244+
## Floating point approximation operations
245+
246+
* Float32ReciprocalApproximation - reciprocal approximation
247+
* Float64ReciprocalApproximation - reciprocal approximation
248+
* Float32ReciprocalSqrtApproximation - reciprocal sqrt approximation
249+
* Float64ReciprocalSqrtApproximation - reciprocal sqrt approximation
250+
251+
These operations would not required to be fully precise, but the specifics
252+
would need clarification.
253+
254+
## 16-bit and 128-bit floating-point support
255+
256+
For 16-bit floating-point support, it may make sense to split the feature
257+
into two parts: support for just converting between 16-bit and 32-bit or
258+
64-bit formats possibly folded into load and store operations, and full
259+
support for actual 16-bit arithmetic.
260+
261+
128-bit is an interesting question because hardware support for it is very
262+
rare, so it's usually going to be implemented with software emulation anyway,
263+
so there's nothing preventing WebAssembly applications from linking to an
264+
appropriate emulation library and getting similarly performant results.
265+
Emulation libraries would have more flexibility to offer approximation
266+
techniques such as double-double arithmetic. If we standardize 128-bit
267+
floating point in WebAssembly, it will probably be standard IEEE-754
268+
quadruple precision.
269+
270+
## Floating-point library intrinsics
271+
272+
These operations aren't needed because they can be implemented in WebAssembly
273+
code and linked into WebAssembly modules as at small size cost, and this avoids
274+
a non-trivial specification burden of their semantics/precision. Adding these
275+
intrinsics would allow for better high-level backend optimization of these
276+
intrinsics that require builtin knowledge of their semantics. On the other
277+
hand, a code generator may continue to statically link in its own
278+
implementation since this provides greater control over precision/performance
279+
tradeoffs.
280+
281+
* Float64Sin - trigonometric sine
282+
* Float64Cos - trigonometric cosine
283+
* Float64Tan - trigonometric tangent
284+
* Float64ASin - trigonometric arcsine
285+
* Float64ACos - trigonometric arccosine
286+
* Float64ATan - trigonometric arctangent
287+
* Float64ATan2 - trigonometric arctangent with two arguments
288+
* Float64Exp - exponentiate e
289+
* Float64Ln - natural logarithm
290+
* Float64Pow - exponentiate
291+
* Float32Sin - trigonometric sine
292+
* Float32Cos - trigonometric cosine
293+
* Float32Tan - trigonometric tangent
294+
* Float32ASin - trigonometric arcsine
295+
* Float32ACos - trigonometric arccosine
296+
* Float32ATan - trigonometric arctangent
297+
* Float32ATan2 - trigonometric arctangent with two arguments
298+
* Float32Exp - exponentiate e
299+
* Float32Ln - natural logarithm
300+
* Float32Pow - exponentiate
301+
302+
The rounding behavior of these operations would need clarification.

0 commit comments

Comments
 (0)