From 34c4d450071635abdf045482cd0a17267718a6d2 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 8 Jun 2015 15:14:41 -0700 Subject: [PATCH] Convert operator and type names to lowercase with underscores. --- AstSemantics.md | 246 +++++++++++++++++++++++----------------------- FutureFeatures.md | 84 ++++++++-------- 2 files changed, 165 insertions(+), 165 deletions(-) diff --git a/AstSemantics.md b/AstSemantics.md index b8f85d04..49b275a7 100644 --- a/AstSemantics.md +++ b/AstSemantics.md @@ -35,48 +35,48 @@ variables, local variables, and parameters. The heap itself is not typed, but all accesses to the heap are annotated with a type. The legal types for global variables and heap accesses are called *Memory types*. - * Int8 - signed 8-bit integer - * Int16 - signed 16-bit integer - * Int32 - signed 32-bit integer - * Uint8 - unsigned 8-bit integer - * Uint16 - unsigned 16-bit integer - * Uint32 - unsigned 32-bit integer - * Float32 - 32-bit floating point - * Float64 - 64-bit floating point + * sint8 - signed 8-bit integer + * sint16 - signed 16-bit integer + * sint32 - signed 32-bit integer + * uint8 - unsigned 8-bit integer + * uint16 - unsigned 16-bit integer + * uint32 - unsigned 32-bit integer + * float32 - 32-bit floating point + * float64 - 64-bit floating point The legal types for parameters and local variables, called *Local types* are a subset of the Memory types: - * Int32 - 32-bit integer - * Float32 - 32-bit floating point - * Float64 - 64-bit floating point + * int32 - 32-bit integer + * float32 - 32-bit floating point + * float64 - 64-bit floating point All IR operations except loads and stores deal with local types. Loads implicitly convert Memory types to Local types according to the follow rules: - * Load[Int8] - sign-extend to Int32 - * Load[Int16] - sign-extend to Int32 - * Load[Int32] - (no conversion) - * Load[Uint8] - zero-extend to Int32 - * Load[Uint16] - zero-extend to Int32 - * Load[Uint32] - reinterpret as Int32 - * Load[Float32] - (no conversion) - * Load[Float64] - (no conversion) + * load[sint8] - sign-extend to int32 + * load[sint16] - sign-extend to int32 + * load[sint32] - (no conversion) + * load[uint8] - zero-extend to int32 + * load[uint16] - zero-extend to int32 + * load[uint32] - reinterpret as int32 + * load[float32] - (no conversion) + * load[float64] - (no conversion) -Note that the local type Int32 does not technically have a sign; the sign bit +Note that the local type int32 does not technically have a sign; the sign bit is interpreted differently by the operations below. Similar to loads, stores implicitly truncate Local types to Memory types according to the following rules: - * Store[Int8] - truncate Int32 to Int8 - * Store[Int16] - truncate Int32 to Int16 - * Store[Int32] - (no truncation) - * Store[Uint8] - truncate Int32 to Uint8 - * Store[Uint16] - truncate Int32 to Uint16 - * Store[Uint32] - reinterpret Int32 as Uint32 - * Store[Float32] - (no truncation) - * Store[Float64] - (no truncation) + * store[sint8] - truncate int32 to sint8 + * store[sint16] - truncate int32 to sint16 + * store[sint32] - (no truncation) + * store[uint8] - truncate int32 to uint8 + * store[uint16] - truncate int32 to uint16 + * store[uint32] - reinterpret int32 as uint32 + * store[float32] - (no truncation) + * store[float64] - (no truncation) Truncation of integers simply discards any upper bits; i.e. truncation does not perform saturation, trap on overflow, etc. @@ -92,8 +92,8 @@ Local variables have *Local types* and are initialized to the appropriate zero v their type at the beginning of the function, except parameters which are initialized to the values of the arguments passed to the function. - * GetLocal - read the current value of a local variable - * SetLocal - set the current value of a local variable + * get_local - read the current value of a local variable + * set_local - set the current value of a local variable The details of index space for local variables and their types needs clarification, e.g. whether locals with type int32 must be contiguous and separate from others, @@ -104,16 +104,16 @@ etc. WebAssembly offers basic structured control flow. All control flow structures are statements. - * **Block**: a fixed-length sequence of statements - * **If**: if statement - * **Do-While**: do while statement, basically a loop with a conditional branch + * **block**: a fixed-length sequence of statements + * **if**: if statement + * **do_while**: do while statement, basically a loop with a conditional branch (back to the top of the loop) - * **Forever**: infinite loop statement (like `while (1)`), basically an + * **forever**: infinite loop statement (like `while (1)`), basically an unconditional branch (back to the top of the loop) - * **Continue**: continue to start of nested loop - * **Break**: break to end from nested loop or block - * **Return**: return zero or more values from this function - * **Switch**: switch statement with fallthrough + * **continue**: continue to start of nested loop + * **break**: break to end from nested loop or block + * **return**: return zero or more values from this function + * **switch**: switch statement with fallthrough Break and continue statements can only target blocks or loops in which they are nested. This guarantees that all resulting control flow graphs are reducible, @@ -142,14 +142,14 @@ include implicit zero- or sign-extension and stores may include implicit truncat Indexes into the heap are always byte indexes. - * LoadHeap - load a value from the heap at a given index with given alignment - * StoreHeap - store a given value to the heap at a given index with given alignment + * load_heap - load a value from the heap at a given index with given alignment + * store_heap - store a given value to the heap at a given index with given alignment To enable more aggressive hoisting of bounds checks, heap accesses may also include an offset: - * LoadHeapWithOffset - load a value from the heap at a given index plus a given immediate offset - * StoreHeapWithOffset - store a given value to the heap at a given index plus a given immediate offset + * load_heap_with_offset - load a value from the heap at a given index plus a given immediate offset + * store_heap_with_offset - store a given value to the heap at a given index plus a given immediate offset The addition of the offset and index is specified to use infinite precision such that an out-of-bounds access never wraps around to an in-bounds access. @@ -164,7 +164,7 @@ accept 64-bit unsigned integers. In the MVP, heaps are not shared between threads. When [threads](PostMVP.md#threads) are added as a feature, the basic -`LoadHeap`/`StoreHeap` nodes will have the most relaxed semantics specified in +`load_heap`/`store_heap` nodes will have the most relaxed semantics specified in the memory model and new heap-access nodes will be added with atomic and ordering guarantees. @@ -218,8 +218,8 @@ opportunities provided by each. Global accesses always specify a single global variable with a constant index. Every global has exactly one type. Global variables are not aliased to the heap. - * LoadGlobal - load the value of a given global variable - * StoreGlobal - store a given value to a given global variable + * load_global - load the value of a given global variable + * store_global - store a given value to a given global variable The specification will add atomicity annotations in the future. Currently all global accesses can be considered "non-atomic". @@ -228,21 +228,21 @@ all global accesses can be considered "non-atomic". Direct calls to a function specify the callee by index into a function table. - * CallDirect - call function directly + * call_direct - call function directly Each function has a signature in terms of local types, and calls must match the function signature exactly. [Imported functions](MVP.md#code-loading-and-imports) also have signatures and are added to the same function table and are thus also -callable via `CallDirect`. +callable via `call_direct`. Indirect calls may be made to a value of function-pointer type. A function- pointer value may be obtained for a given function as specified by its index in the function table. - * CallIndirect - call function indirectly - * AddressOf - obtain a function pointer value for a given function + * call_indirect - call function indirectly + * addressof - obtain a function pointer value for a given function -Function-pointer values are comparable for equality and the `AddressOf` operator +Function-pointer values are comparable for equality and the `addressof` operator is monomorphic. Function-pointer values can be explicitly coerced to and from integers (which, in particular, is necessary when loading/storing to the heap since the heap only provides integer types). For security and safety reasons, @@ -266,16 +266,16 @@ All basic data types allow literal values of that data type. See the ## Expressions with control flow Expression trees offer significant size reduction by avoiding the need for -`SetLocal`/`GetLocal` pairs in the common case of an expression with only one, +`set_local`/`get_local` pairs in the common case of an expression with only one, immediate use. The following primitives provide AST nodes that express control flow and thus allow more opportunities to build bigger expression trees -and further reduce `SetLocal`/`GetLocal` usage (which constitute 30-40% of total +and further reduce `set_local`/`get_local` usage (which constitute 30-40% of total bytes in the [polyfill prototype](https://github.com/WebAssembly/polyfill-prototype-1)). Additionally, these primitives are useful building blocks for WebAssembly-generators (including the JavaScript polyfill). - * Comma - evaluate and ignore the result of the first operand, evaluate and return the second operand - * Conditional - basically ternary ?: operator + * comma - evaluate and ignore the result of the first operand, evaluate and return the second operand + * conditional - basically ternary ?: operator New operands should be considered which allow measurably greater expression-tree-building opportunities. @@ -288,27 +288,27 @@ that overflows conforms to the standard wrap-around semantics. All comparison operations yield 32-bit integer results with 1 representing true and 0 representing false. - * Int32Add - signed-less addition - * Int32Sub - signed-less subtraction - * Int32Mul - signed-less multiplication (lower 32-bits) - * Int32SDiv - signed division - * Int32UDiv - unsigned division - * Int32SRem - signed remainder - * Int32URem - unsigned remainder - * Int32And - signed-less logical and - * Int32Ior - signed-less inclusive or - * Int32Xor - signed-less exclusive or - * Int32Shl - signed-less shift left - * Int32Shr - unsigned shift right - * Int32Sar - signed arithmetic shift right - * Int32Eq - signed-less compare equal - * Int32Slt - signed less than - * Int32Sle - signed less than or equal - * Int32Ult - unsigned less than - * Int32Ule - unsigned less than or equal - * Int32Clz - count leading zeroes (defined for all values, including 0) - * Int32Ctz - count trailing zeroes (defined for all values, including 0) - * Int32Popcnt - count number of ones + * int32.add - signed-less addition + * int32.sub - signed-less subtraction + * int32.mul - signed-less multiplication (lower 32-bits) + * int32.sdiv - signed division + * int32.udiv - unsigned division + * int32.srem - signed remainder + * int32.urem - unsigned remainder + * int32.and - signed-less logical and + * int32.ior - signed-less inclusive or + * int32.xor - signed-less exclusive or + * int32.shl - signed-less shift left + * int32.shr - unsigned shift right + * int32.sar - signed arithmetic shift right + * int32.eq - signed-less compare equal + * int32.slt - signed less than + * int32.sle - signed less than or equal + * int32.ult - unsigned less than + * int32.ule - unsigned less than or equal + * int32.clz - count leading zeroes (defined for all values, including 0) + * int32.ctz - count trailing zeroes (defined for all values, including 0) + * int32.popcnt - count number of ones Division or remainder by zero traps. Signed division overflow (`INT32_MIN / -1`) traps. Signed remainder with a @@ -316,7 +316,7 @@ non-zero denominator always returns the correct value, even when the corresponding division would trap. Shifts interpret their shift count operand as an unsigned value. When the -shift count is at least the bitwidth of the shift, Shl and Shr return 0, +shift count is at least the bitwidth of the shift, shl and shr return 0, and Sar returns 0 if the value being shifted is non-negative, and -1 otherwise. Note that greater-than and greater-than-or-equal operations are not required, @@ -347,58 +347,58 @@ Floating point arithmetic follows the IEEE-754 standard, except that: WebAssembly includes enough functionality to support reasonable library implementations of the remaining required operations. - * Float32Add - addition - * Float32Sub - subtraction - * Float32Mul - multiplication - * Float32Div - division - * Float32Abs - absolute value - * Float32Neg - negation - * Float32Copysign - copysign - * Float32Ceil - ceiling operation - * Float32Floor - floor operation - * Float32Trunc - round to nearest integer towards zero - * Float32NearestInt - round to nearest integer, ties to even - * Float32Eq - compare equal - * Float32Lt - less than - * Float32Le - less than or equal - * Float32Sqrt - square root - * Float32Min - minimum (binary operator); if either operand is NaN, returns NaN - * Float32Max - maximum (binary operator); if either operand is NaN, returns NaN - - * Float64Add - addition - * Float64Sub - subtraction - * Float64Mul - multiplication - * Float64Div - division - * Float64Abs - absolute value - * Float64Neg - negation - * Float64Copysign - copysign - * Float64Ceil - ceiling operation - * Float64Floor - floor operation - * Float64Trunc - round to nearest integer towards zero - * Float64NearestInt - round to nearest integer, ties to even - * Float64Eq - compare equal - * Float64Lt - less than - * Float64Le - less than or equal - * Float64Sqrt - square root - * Float64Min - minimum (binary operator); if either operand is NaN, returns NaN - * Float64Max - maximum (binary operator); if either operand is NaN, returns NaN + * float32.add - addition + * float32.sub - subtraction + * float32.mul - multiplication + * float32.div - division + * float32.abs - absolute value + * float32.neg - negation + * float32.copysign - copysign + * float32.ceil - ceiling operation + * float32.floor - floor operation + * float32.trunc - round to nearest integer towards zero + * float32.nearestint - round to nearest integer, ties to even + * float32.eq - compare equal + * float32.lt - less than + * float32.le - less than or equal + * float32.sqrt - square root + * float32.min - minimum (binary operator); if either operand is NaN, returns NaN + * float32.max - maximum (binary operator); if either operand is NaN, returns NaN + + * float64.add - addition + * float64.sub - subtraction + * float64.mul - multiplication + * float64.div - division + * float64.abs - absolute value + * float64.neg - negation + * float64.copysign - copysign + * float64.ceil - ceiling operation + * float64.floor - floor operation + * float64.trunc - round to nearest integer towards zero + * float64.nearestint - round to nearest integer, ties to even + * float64.eq - compare equal + * float64.lt - less than + * float64.le - less than or equal + * float64.sqrt - square root + * float64.min - minimum (binary operator); if either operand is NaN, returns NaN + * float64.max - maximum (binary operator); if either operand is NaN, returns NaN Min and Max operations treat -0 as being effectively less than 0. ## Datatype conversions, truncations, reinterpretations, promotions, and demotions - * Int32FromFloat64 - truncate a 64-bit float to a signed integer - * Int32FromFloat32 - truncate a 32-bit float to a signed integer - * Uint32FromFloat64 - truncate a 64-bit float to an unsigned integer - * Uint32FromFloat32 - truncate a 32-bit float to an unsigned integer - * Int32FromFloat32Bits - reinterpret the bits of a 32-bit float as a 32-bit integer - * Float64FromFloat32 - promote a 32-bit float to a 64-bit float - * Float64FromInt32 - convert a signed integer to a 64-bit float - * Float64FromUInt32 - convert an unsigned integer to a 64-bit float - * Float32FromFloat64 - demote a 64-bit float to a 32-bit float - * Float32FromInt32 - convert a signed integer to a 32-bit float - * Float32FromUInt32 - convert an unsigned integer to a 32-bit float - * Float32FromInt32Bits - reinterpret the bits of a 32-bit integer as a 32-bit float + * sint32_from_float64 - truncate a 64-bit float to a signed integer + * sint32_from_float32 - truncate a 32-bit float to a signed integer + * uint32_from_float64 - truncate a 64-bit float to an unsigned integer + * uint32_from_float32 - truncate a 32-bit float to an unsigned integer + * int32_from_float32_bits - reinterpret the bits of a 32-bit float as a 32-bit integer + * float64_from_float32 - promote a 32-bit float to a 64-bit float + * float64_from_sint32 - convert a signed integer to a 64-bit float + * float64_from_uint32 - convert an unsigned integer to a 64-bit float + * float32_from_float64 - demote a 64-bit float to a 32-bit float + * float32_from_sint32 - convert a signed integer to a 32-bit float + * float32_from_uint32 - convert an unsigned integer to a 32-bit float + * float32_from_int32_bits - reinterpret the bits of a 32-bit integer as a 32-bit float Promotion and demotion of floating point values always succeeds. Demotion of floating point values uses round-to-nearest ties-to-even rounding, diff --git a/FutureFeatures.md b/FutureFeatures.md index 21b35242..d0e79d19 100644 --- a/FutureFeatures.md +++ b/FutureFeatures.md @@ -212,41 +212,41 @@ use cases: * The following operations can be built from other operators already present, however in doing so they read at least one non-constant input multiple times, breaking single-use expression tree formation. - * Int32Rotr - bitwise rotate right - * Int32Rotl - bitwise rotate left - * Int32SMin - signed minimum - * Int32SMax - signed maximum - * Int32UMin - unsigned minimum - * Int32UMax - unsigned maximum - * Int32SExt - `sext(x, y)` is `x<>y` - * Int32Abs - absolute value (is `abs(INT32_MIN)` `INT32_MIN` or should it trap?) - * Int32BSwap - reverse bytes (endian conversion) - * Int32BSwap16 - `bswap16(x)` is `((x>>8)&255)|((x&255)<<8)` + * int32.rotr - bitwise rotate right + * int32.rotl - bitwise rotate left + * int32.smin - signed minimum + * int32.smax - signed maximum + * int32.umin - unsigned minimum + * int32.umax - unsigned maximum + * int32.sext - `sext(x, y)` is `x<>y` + * int32.abs - absolute value (is `abs(INT32_MIN)` `INT32_MIN` or should it trap?) + * int32.bswap - reverse bytes (endian conversion) + * int32.bswap16 - `bswap16(x)` is `((x>>8)&255)|((x&255)<<8)` * The following operations are just potentially interesting. - * Int32Clrs - count leading redundant sign bits (defined for all values, including 0) + * int32.clrs - count leading redundant sign bits (defined for all values, including 0) ## Additional floating point operations - * Float32MinNum - minimum; if exactly one operand is NaN, returns the other operand - * Float32MaxNum - maximum; if exactly one operand is NaN, returns the other operand - * Float32FMA - fused multiply-add (results always conforming to IEEE-754) - * Float64MinNum - minimum; if exactly one operand is NaN, returns the other operand - * Float64MaxNum - maximum; if exactly one operand is NaN, returns the other operand - * Float64FMA - fused multiply-add (results always conforming to IEEE-754) + * float32.minnum - minimum; if exactly one operand is NaN, returns the other operand + * float32.maxnum - maximum; if exactly one operand is NaN, returns the other operand + * float32.fma - fused multiply-add (results always conforming to IEEE-754) + * float64.minnum - minimum; if exactly one operand is NaN, returns the other operand + * float64.maxnum - maximum; if exactly one operand is NaN, returns the other operand + * float64.fma - fused multiply-add (results always conforming to IEEE-754) MinNum, and MaxNum operations would treat -0 as being effectively less than 0. -Note that some operations, like FMA, may not be available or may not perform +Note that some operations, like fma, may not be available or may not perform well on all platforms. These should be guarded by [feature tests](FeatureTest.md) so that if available, they behave consistently. ## Floating point approximation operations - * Float32ReciprocalApproximation - reciprocal approximation - * Float64ReciprocalApproximation - reciprocal approximation - * Float32ReciprocalSqrtApproximation - reciprocal sqrt approximation - * Float64ReciprocalSqrtApproximation - reciprocal sqrt approximation + * float32.reciprocal_approximation - reciprocal approximation + * float64.reciprocal_approximation - reciprocal approximation + * float32.reciprocal_sqrt_approximation - reciprocal sqrt approximation + * float64.reciprocal_sqrt_approximation - reciprocal sqrt approximation These operations would not required to be fully precise, but the specifics would need clarification. @@ -278,25 +278,25 @@ hand, a code generator may continue to statically link in its own implementation since this provides greater control over precision/performance tradeoffs. - * Float64Sin - trigonometric sine - * Float64Cos - trigonometric cosine - * Float64Tan - trigonometric tangent - * Float64ASin - trigonometric arcsine - * Float64ACos - trigonometric arccosine - * Float64ATan - trigonometric arctangent - * Float64ATan2 - trigonometric arctangent with two arguments - * Float64Exp - exponentiate e - * Float64Ln - natural logarithm - * Float64Pow - exponentiate - * Float32Sin - trigonometric sine - * Float32Cos - trigonometric cosine - * Float32Tan - trigonometric tangent - * Float32ASin - trigonometric arcsine - * Float32ACos - trigonometric arccosine - * Float32ATan - trigonometric arctangent - * Float32ATan2 - trigonometric arctangent with two arguments - * Float32Exp - exponentiate e - * Float32Ln - natural logarithm - * Float32Pow - exponentiate + * float64.sin - trigonometric sine + * float64.cos - trigonometric cosine + * float64.tan - trigonometric tangent + * float64.asin - trigonometric arcsine + * float64.acos - trigonometric arccosine + * float64.atan - trigonometric arctangent + * float64.atan2 - trigonometric arctangent with two arguments + * float64.exp - exponentiate e + * float64.ln - natural logarithm + * float64.pow - exponentiate + * float32.sin - trigonometric sine + * float32.cos - trigonometric cosine + * float32.tan - trigonometric tangent + * float32.asin - trigonometric arcsine + * float32.acos - trigonometric arccosine + * float32.atan - trigonometric arctangent + * float32.atan2 - trigonometric arctangent with two arguments + * float32.exp - exponentiate e + * float32.ln - natural logarithm + * float32.pow - exponentiate The rounding behavior of these operations would need clarification.