-
Notifications
You must be signed in to change notification settings - Fork 695
Update AstSemantics.md #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,38 +82,47 @@ only communicate through messaging, e.g. in browsers using `postMessage`. It | |
will be possible to share linear memory between threads of execution when | ||
[threads](PostMVP.md#threads) are added. | ||
|
||
### Linear Memory Operations | ||
|
||
Linear memory operations are annotated with a memory type and perform a | ||
conversion between that memory type and a local type. | ||
|
||
Loads read data from linear memory, convert from their memory type to a basic | ||
type, and return the result: | ||
|
||
* `i32.load8_s`: sign-extend i8 to i32 | ||
* `i32.load8_u`: zero-extend i8 to i32 | ||
* `i32.load16_s`: sign-extend i16 to i32 | ||
* `i32.load16_u`: zero-extend i16 to i32 | ||
* `i32.load`: (no conversion) | ||
* `i64.load`: (no conversion) | ||
* `f32.load`: (no conversion) | ||
* `f64.load`: (no conversion) | ||
|
||
Stores have an operand providing a value to store. They convert from the value's | ||
local type to their memory type, and write the resulting value to linear memory: | ||
|
||
* `i32.store8`: wrap i32 to i8 | ||
* `i32.store16`: wrap i32 to i16 | ||
* `i32.store`: (no conversion) | ||
* `i64.store`: (no conversion) | ||
* `f32.store`: (no conversion) | ||
* `f64.store`: (no conversion) | ||
|
||
Wrapping of integers simply discards any upper bits; i.e. wrapping does not | ||
perform saturation, trap on overflow, etc. | ||
|
||
In addition to storing a value to linear memory, store instructions also | ||
reproduce their value operand, with no conversion applied. | ||
### Linear Memory Accesses | ||
|
||
Linear memory access is accomplished with explicit `load` and `store` operations that | ||
accept as input an `index` operand that is interpreted as a unsigned byte offset into the | ||
linear memory. | ||
|
||
Integer loads can specify a size which is smaller than the result type as well as a | ||
signedness. Such integer loads perform an implicit sign- or zero-extension as specified below. | ||
|
||
* `i32.load8_s`: load 1 byte and sign-extend i8 to i32 | ||
* `i32.load8_u`: load 1 byte and zero-extend i8 to i32 | ||
* `i32.load16_s`: load 2 bytes and sign-extend i16 to i32 | ||
* `i32.load16_u`: load 2 bytes and zero-extend i16 to i32 | ||
* `i32.load`: load 4 bytes as i32 | ||
* `i64.load8_s`: load 1 byte and sign-extend i8 to i64 | ||
* `i64.load8_u`: load 1 byte and zero-extend i8 to i64 | ||
* `i64.load16_s`: load 2 bytes and sign-extend i16 to i64 | ||
* `i64.load16_u`: load 2 bytes and zero-extend i16 to i64 | ||
* `i64.load32_s`: load 4 bytes and sign-extend i32 to i64 | ||
* `i64.load32_u`: load 4 bytes and zero-extend i32 to i64 | ||
* `i64.load`: load 8 bytes as i64 | ||
* `f32.load`: load 4 bytes as f32 | ||
* `f64.load`: load 8 bytes as f64 | ||
|
||
In addition to an `index` operand, stores have an additional input operand which is the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
`value` to store to memory. Like loads, integer stores may specify a smaller size than the | ||
operand size and include an implicit integer wrap operation which discards the upper bits. | ||
Stores write only the bytes in the linear memory corresponding to their size. | ||
|
||
* `i32.store8`: wrap i32 to i8 and store 1 byte | ||
* `i32.store16`: wrap i32 to i16 and store 2 bytes | ||
* `i32.store`: (no conversion) store 4 bytes | ||
* `i64.store8`: wrap i64 to i8 and store 1 byte | ||
* `i64.store16`: wrap i64 to i16 and store 2 bytes | ||
* `i64.store32`: wrap i64 to i32 and store 4 bytes | ||
* `i64.store`: (no conversion) store 8 bytes | ||
* `f32.store`: (no conversion) store 4 bytes | ||
* `f64.store`: (no conversion) store 8 bytes | ||
|
||
In addition to storing to memory, store instructions produce a value which is their | ||
input operand without conversion. | ||
|
||
### Addressing | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They accept as input an
index
and anoffset
which are described in the Addressing section immediately following this section.