Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Update README and copy overview from threads repo
  • Loading branch information
binji committed Jan 16, 2018
1 parent 9d789ca commit 93ec2c1
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
13 changes: 12 additions & 1 deletion 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

Expand Down
50 changes: 50 additions & 0 deletions 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

0 comments on commit 93ec2c1

Please sign in to comment.