From 93ec2c1ce9deddcf9956f825ad6b3222ead6ff2a Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Tue, 16 Jan 2018 14:20:02 -0800 Subject: [PATCH] Update README and copy overview from threads repo --- README.md | 13 +++++- proposals/sign-extension-ops/Overview.md | 50 ++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 proposals/sign-extension-ops/Overview.md diff --git a/README.md b/README.md index 26d58a3..8bad7b5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,15 @@ -[![Build Status](https://travis-ci.org/WebAssembly/spec.svg?branch=master)](https://travis-ci.org/WebAssembly/spec) +[![Build Status](https://travis-ci.org/WebAssembly/sign-extension-ops.svg?branch=master)](https://travis-ci.org/WebAssembly/sign-extension-ops) + +# Sign Extension Operators Proposal for WebAssembly + +This repository is a clone of github.com/WebAssembly/spec/. It is meant for +discussion, prototype specification and implementation of a proposal to add +sign-extension operators to WebAssembly. + +See the [overview](proposals/sign-extension-ops/Overview.md) for a summary of +the proposal. + +Original README from upstream repository follows... # spec diff --git a/proposals/sign-extension-ops/Overview.md b/proposals/sign-extension-ops/Overview.md new file mode 100644 index 0000000..bb0fe0d --- /dev/null +++ b/proposals/sign-extension-ops/Overview.md @@ -0,0 +1,50 @@ +# Sign-extension operators proposal for WebAssembly + +This page describes a proposal for the post-MVP +[sign-extension operator feature][future sext]. + +This proposal adds five new integer instructions for sign-extending 8-bit, +16-bit, and 32-bit values. + +## New Sign-extending Operators + +To support sign-extending, five new sign-extension operators are added: + + * `i32.extend8_s`: extend a signed 8-bit integer to a 32-bit integer + * `i32.extend16_s`: extend a signed 16-bit integer to a 32-bit integer + * `i64.extend8_s`: extend a signed 8-bit integer to a 64-bit integer + * `i64.extend16_s`: extend a signed 16-bit integer to a 64-bit integer + * `i64.extend32_s`: extend a signed 32-bit integer to a 64-bit integer + +Note that `i64.extend32_s` was not originally included when this proposal was +discussed in the May 2017 CG meeting. The reason given was that +the behavior matches `i64.extend_s/i32`. It was later discovered that this is +not correct, as `i64.extend_s/i32` sign-extends an `i32` value to `i64`, +whereas `i64.extend32_s` sign-extends an `i64` value to `i64`. The behavior +of `i64.extend32_s` can be emulated with `i32.wrap/i64` followed by +`i64.extend_s/i32`, but the same can be said of the sign-extending load +operations. Therefore, `i64.extend32_s` has been added for consistency. + +## [Spec Changes][spec] + +The [instruction syntax][] is modified as follows: + +``` +instr ::= ... | + inn.extend8_s | inn.extend16_s | i64.extend32_s +``` + +The [instruction binary format][] is modified as follows: + +``` +instr ::= ... + | 0xC0 => i32.extend8_s + | 0xC1 => i32.extend16_s + | 0xC2 => i64.extend8_s + | 0xC3 => i64.extend16_s + | 0xC4 => i64.extend32_s +``` + +[future sext]: https://github.com/WebAssembly/design/blob/master/FutureFeatures.md#additional-integer-operators +[instruction syntax]: https://webassembly.github.io/spec/syntax/instructions.html +[instruction binary format]: https://webassembly.github.io/spec/binary/instructions.html