You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: BinaryEncoding.md
+20-14Lines changed: 20 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -321,27 +321,30 @@ It is legal to have several entries with the same type.
321
321
322
322
## Control flow operators ([described here](AstSemantics.md#control-flow-structures))
323
323
324
-
| Name | Opcode |Immediate| Description |
324
+
| Name | Opcode |Immediates| Description |
325
325
| ---- | ---- | ---- | ---- |
326
326
|`nop`|`0x00`|| no operation |
327
327
|`block`|`0x01`|| begin a sequence of expressions, the last of which yields a value |
328
328
|`loop`|`0x02`|| begin a block which can also form control flow loops |
329
329
|`if`|`0x03`|| begin if expression |
330
330
|`else`|`0x04`|| begin else expression of if |
331
331
|`select`|`0x05`|| select one of two values based on condition |
332
-
|`br`|`0x06`| relative_depth =`varuint32`| break that targets an outer nested block |
333
-
|`br_if`|`0x07`| relative_depth =`varuint32`| conditional break that targets an outer nested block |
332
+
|`br`|`0x06`|argument_count : `varuint1`, relative_depth :`varuint32`| break that targets an outer nested block |
333
+
|`br_if`|`0x07`|argument_count : `varuint1`, relative_depth :`varuint32`| conditional break that targets an outer nested block |
334
334
|`br_table`|`0x08`| see below | branch table control flow construct |
335
-
|`return`|`0x09`|| return zero or one value from this function |
335
+
|`return`|`0x09`|argument_count : `varuint1`| return zero or one value from this function |
336
336
|`unreachable`|`0x0a`|| trap immediately |
337
337
|`end`|`0x0f`|| end a block, loop, or if |
338
338
339
339
Note that there is no explicit `if_else` opcode, as the else clause is encoded with the `else` bytecode.
340
340
341
+
The counts following the break and return operators specify how many preceding operands are taken as transfer arguments; in the MVP, all these values must be either 0 or 1.
342
+
341
343
The `br_table` operator has an immediate operand which is encoded as follows:
342
344
343
345
| Field | Type | Description |
344
346
| ---- | ---- | ---- |
347
+
| arity |`varuint1`| number of arguments |
345
348
| target_count |`varuint32`| number of targets in the target_table |
346
349
| target_table |`uint32*`| target entries that indicate an outer block or loop to which to break |
347
350
| default_target |`uint32`| an outer block or loop to which to break in the default case |
@@ -352,17 +355,20 @@ branches to the block or loop at the given offset within the `target_table`. If
352
355
out of range, `br_table` branches to the default target.
0 commit comments