From 1bfcecb88a6aa5a8c0a95e8a1aadf20adba66486 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 2 Dec 2015 10:29:30 -0800 Subject: [PATCH 1/2] Reorder select's operands to put the condition last. --- AstSemantics.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/AstSemantics.md b/AstSemantics.md index 43d562ac..90203370 100644 --- a/AstSemantics.md +++ b/AstSemantics.md @@ -550,10 +550,9 @@ outside the range which rounds to an integer in range) traps. ## Type-parameterized operators. - * `select`: a ternary operator with a boolean (i32) condition and two - additional operands, which must have the same type as each other. `select` - returns the the first of these two operands if the condition operand is - non-zero, or the second otherwise. + * `select`: a ternary operator with two operands, which have the same type as + each other, plus a boolean (i32) condition. `select` returns the first + operand if the condition operand is non-zero, or the second otherwise. ## Feature test From e9eeffca1efc2c17f8d00264a70ae628d16cc30e Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 2 Dec 2015 11:11:49 -0800 Subject: [PATCH 2/2] Specify that branch instructions' return value operands come first. --- AstSemantics.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/AstSemantics.md b/AstSemantics.md index 90203370..f6ec6f22 100644 --- a/AstSemantics.md +++ b/AstSemantics.md @@ -246,14 +246,16 @@ a value and may appear as children of other expressions. ### Branches and nesting The `br` and `br_if` constructs express low-level branching. -Branches that exit a `block`, `loop`, or `tableswitch` may take a subexpression -that yields a value for the exited construct. Branches may only reference labels defined by an outer *enclosing construct*. This means that, for example, references to a `block`'s label can only occur within the `block`'s body. In practice, outer `block`s can be used to place labels for any given branching pattern, except for one restriction: one can't branch into the middle of a loop from outside it. This restriction ensures all control flow graphs are well-structured. +Branches that exit a `block`, `loop`, or `tableswitch` may take a subexpression +that yields a value for the exited construct. If present, it is the first operand +before any others. + ### Yielding values from control constructs The `nop`, `if`, `br`, `br_if`, `case`, and `return` constructs do not yield values.