diff options
| author | titzer <titzer@google.com> | 2016-03-04 08:19:41 -0800 |
|---|---|---|
| committer | titzer <titzer@google.com> | 2016-03-04 08:19:41 -0800 |
| commit | 0b987cf8d04b563adbdb0822774c8eb972cdb83d (patch) | |
| tree | 2467b7844d25f8ef877d38f67572052eac83568a /BinaryEncoding.md | |
| parent | 4a4d492356864a77c63045d84eee2c23e3251992 (diff) | |
| download | nanowasm-design-0b987cf8d04b563adbdb0822774c8eb972cdb83d.tar.gz | |
Replace tableswitch with br_table.
Diffstat (limited to 'BinaryEncoding.md')
| -rw-r--r-- | BinaryEncoding.md | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/BinaryEncoding.md b/BinaryEncoding.md index a34e63c..e3604ef 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -289,19 +289,20 @@ It is legal to have several entries with the same type. | `select` | `0x05` | | select one of two values based on condition | | `br` | `0x06` | relative_depth = `uint8` | break that targets a outer nested block | | `br_if` | `0x07` | relative_depth = `uint8` | conditional break that targets a outer nested block | -| `tableswitch` | `0x08` | see below | tableswitch control flow construct | +| `br_table` | `0x08` | see below | branch table control flow construct | | `return` | `0x14` | | return zero or one value from this function | | `unreachable` | `0x15` | | trap immediately | -The `tableswitch` operator has as complex immediate operand which is encoded as follows: +The `br_table` operator has an immediate operand which is encoded as follows: | Field | Type | Description | | ---- | ---- | ---- | -| case_count | `uint16` | number of cases in the case_table | -| target_count | `uint16` | number of targets in the target_table | -| target_table | `uint16*` | target entries where<br>`>= 0x8000` indicates an outer block to which to break<br>`< 0x8000` indicates a case to which to jump | +| target_count | `uint16` | number of targets in the target_table, required to be at least 1 | +| target_table | `uint16*` | target entries that indicate an outer block or loop to which to break | -The table switch operator is then immediately followed by `case_count` case expressions which by default fall through to each other. +The `br_table` operator implements an indirect branch. It accepts one `i32` expression as input and +branches to the block or loop at the given offset within the `target_table`. If the input value is +out of range, `br_table` branches to the last, default, entry in the table. ## Basic operators ([described here](AstSemantics.md#constants)) | Name | Opcode | Immediate | Description | |
