mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
[naga wgsl-in] Allow trailing comma in switch cases (#8165)
This commit is contained in:
parent
023f124fa5
commit
b55c24cf27
@ -218,6 +218,7 @@ By @cwfitzgerald in [#8162](https://github.com/gfx-rs/wgpu/pull/8162).
|
|||||||
#### naga
|
#### naga
|
||||||
|
|
||||||
- [wgsl-in] Allow a trailing comma in `@blend_src(…)` attributes. By @ErichDonGubler in [#8137](https://github.com/gfx-rs/wgpu/pull/8137).
|
- [wgsl-in] Allow a trailing comma in `@blend_src(…)` attributes. By @ErichDonGubler in [#8137](https://github.com/gfx-rs/wgpu/pull/8137).
|
||||||
|
- [wgsl-in] Allow a trailing comma in the list of `case` values inside a `switch`. By @reima in [#8165](https://github.com/gfx-rs/wgpu/pull/8165).
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
|
|||||||
@ -2121,7 +2121,7 @@ impl Parser {
|
|||||||
let _ = lexer.next();
|
let _ = lexer.next();
|
||||||
this.pop_rule_span(lexer);
|
this.pop_rule_span(lexer);
|
||||||
}
|
}
|
||||||
(Token::Paren('{') | Token::Attribute, _) => {
|
(token, _) if is_start_of_compound_statement(token) => {
|
||||||
let (inner, span) = this.block(lexer, ctx, brace_nesting_level)?;
|
let (inner, span) = this.block(lexer, ctx, brace_nesting_level)?;
|
||||||
block.stmts.push(ast::Statement {
|
block.stmts.push(ast::Statement {
|
||||||
kind: ast::StatementKind::Block(inner),
|
kind: ast::StatementKind::Block(inner),
|
||||||
@ -2287,11 +2287,14 @@ impl Parser {
|
|||||||
let value = loop {
|
let value = loop {
|
||||||
let value = this.switch_value(lexer, ctx)?;
|
let value = this.switch_value(lexer, ctx)?;
|
||||||
if lexer.skip(Token::Separator(',')) {
|
if lexer.skip(Token::Separator(',')) {
|
||||||
if lexer.skip(Token::Separator(':')) {
|
// list of values ends with ':' or a compound statement
|
||||||
|
let next_token = lexer.peek().0;
|
||||||
|
if next_token == Token::Separator(':')
|
||||||
|
|| is_start_of_compound_statement(next_token)
|
||||||
|
{
|
||||||
break value;
|
break value;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lexer.skip(Token::Separator(':'));
|
|
||||||
break value;
|
break value;
|
||||||
}
|
}
|
||||||
cases.push(ast::SwitchCase {
|
cases.push(ast::SwitchCase {
|
||||||
@ -2301,6 +2304,8 @@ impl Parser {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lexer.skip(Token::Separator(':'));
|
||||||
|
|
||||||
let body = this.block(lexer, ctx, brace_nesting_level)?.0;
|
let body = this.block(lexer, ctx, brace_nesting_level)?.0;
|
||||||
|
|
||||||
cases.push(ast::SwitchCase {
|
cases.push(ast::SwitchCase {
|
||||||
@ -3244,3 +3249,7 @@ impl Parser {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fn is_start_of_compound_statement<'a>(token: Token<'a>) -> bool {
|
||||||
|
matches!(token, Token::Attribute | Token::Paren('{'))
|
||||||
|
}
|
||||||
|
|||||||
@ -58,6 +58,25 @@ fn control_flow() {
|
|||||||
pos = 3;
|
pos = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trailing commas
|
||||||
|
switch pos {
|
||||||
|
case 1, {
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
case 2,: {
|
||||||
|
pos = 1;
|
||||||
|
}
|
||||||
|
case 3, 4, {
|
||||||
|
pos = 2;
|
||||||
|
}
|
||||||
|
case 5, 6,: {
|
||||||
|
pos = 3;
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
pos = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn switch_default_break(i: i32) {
|
fn switch_default_break(i: i32) {
|
||||||
|
|||||||
@ -58,17 +58,42 @@ void control_flow() {
|
|||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
pos = 1;
|
pos = 1;
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
pos = 2;
|
pos = 2;
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
pos = 3;
|
pos = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int _e15 = pos;
|
||||||
|
switch(_e15) {
|
||||||
|
case 1: {
|
||||||
|
pos = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
pos = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 4: {
|
||||||
|
pos = 2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
case 6: {
|
||||||
|
pos = 3;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
pos = 4;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,17 +49,42 @@ void control_flow()
|
|||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
pos = int(1);
|
pos = int(1);
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
pos = int(2);
|
pos = int(2);
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
pos = int(3);
|
pos = int(3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int _e15 = pos;
|
||||||
|
switch(_e15) {
|
||||||
|
case 1: {
|
||||||
|
pos = int(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
pos = int(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 4: {
|
||||||
|
pos = int(2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
case 6: {
|
||||||
|
pos = int(3);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
pos = int(4);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,17 +58,42 @@ void control_flow(
|
|||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
pos = 1;
|
pos = 1;
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
pos = 2;
|
pos = 2;
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
pos = 3;
|
pos = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int _e15 = pos;
|
||||||
|
switch(_e15) {
|
||||||
|
case 1: {
|
||||||
|
pos = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
pos = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 4: {
|
||||||
|
pos = 2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
case 6: {
|
||||||
|
pos = 3;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
pos = 4;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
; SPIR-V
|
; SPIR-V
|
||||||
; Version: 1.1
|
; Version: 1.1
|
||||||
; Generator: rspirv
|
; Generator: rspirv
|
||||||
; Bound: 234
|
; Bound: 241
|
||||||
OpCapability Shader
|
OpCapability Shader
|
||||||
%1 = OpExtInstImport "GLSL.std.450"
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
OpMemoryModel Logical GLSL450
|
OpMemoryModel Logical GLSL450
|
||||||
OpEntryPoint GLCompute %224 "main"
|
OpEntryPoint GLCompute %231 "main"
|
||||||
OpExecutionMode %224 LocalSize 1 1 1
|
OpExecutionMode %231 LocalSize 1 1 1
|
||||||
%2 = OpTypeVoid
|
%2 = OpTypeVoid
|
||||||
%3 = OpTypeInt 32 1
|
%3 = OpTypeInt 32 1
|
||||||
%6 = OpTypeFunction %2
|
%6 = OpTypeFunction %2
|
||||||
@ -24,16 +24,16 @@ OpExecutionMode %224 LocalSize 1 1 1
|
|||||||
%20 = OpConstant %12 72
|
%20 = OpConstant %12 72
|
||||||
%21 = OpConstant %12 264
|
%21 = OpConstant %12 264
|
||||||
%22 = OpConstant %12 2056
|
%22 = OpConstant %12 2056
|
||||||
%45 = OpTypeFunction %2 %3
|
%52 = OpTypeFunction %2 %3
|
||||||
%82 = OpTypeVector %12 2
|
%89 = OpTypeVector %12 2
|
||||||
%83 = OpTypePointer Function %82
|
%90 = OpTypePointer Function %89
|
||||||
%84 = OpTypeBool
|
%91 = OpTypeBool
|
||||||
%85 = OpTypeVector %84 2
|
%92 = OpTypeVector %91 2
|
||||||
%86 = OpConstantComposite %82 %13 %13
|
%93 = OpConstantComposite %89 %13 %13
|
||||||
%87 = OpConstant %12 4294967295
|
%94 = OpConstant %12 4294967295
|
||||||
%88 = OpConstantComposite %82 %87 %87
|
%95 = OpConstantComposite %89 %94 %94
|
||||||
%108 = OpTypeFunction %2 %3 %3 %3
|
%115 = OpTypeFunction %2 %3 %3 %3
|
||||||
%177 = OpTypeFunction %2 %3 %3 %3 %3
|
%184 = OpTypeFunction %2 %3 %3 %3 %3
|
||||||
%5 = OpFunction %2 None %6
|
%5 = OpFunction %2 None %6
|
||||||
%4 = OpLabel
|
%4 = OpLabel
|
||||||
%14 = OpVariable %15 Function %16
|
%14 = OpVariable %15 Function %16
|
||||||
@ -82,343 +82,362 @@ OpStore %14 %8
|
|||||||
OpBranch %36
|
OpBranch %36
|
||||||
%38 = OpLabel
|
%38 = OpLabel
|
||||||
OpStore %14 %7
|
OpStore %14 %7
|
||||||
OpReturn
|
OpBranch %36
|
||||||
%39 = OpLabel
|
%39 = OpLabel
|
||||||
OpStore %14 %9
|
OpStore %14 %9
|
||||||
OpReturn
|
OpBranch %36
|
||||||
%40 = OpLabel
|
%40 = OpLabel
|
||||||
OpReturn
|
OpBranch %36
|
||||||
%41 = OpLabel
|
%41 = OpLabel
|
||||||
OpStore %14 %10
|
OpStore %14 %10
|
||||||
OpReturn
|
OpBranch %36
|
||||||
%36 = OpLabel
|
%36 = OpLabel
|
||||||
|
%42 = OpLoad %3 %14
|
||||||
|
OpSelectionMerge %43 None
|
||||||
|
OpSwitch %42 %48 1 %44 2 %45 3 %46 4 %46 5 %47 6 %47
|
||||||
|
%44 = OpLabel
|
||||||
|
OpStore %14 %8
|
||||||
|
OpReturn
|
||||||
|
%45 = OpLabel
|
||||||
|
OpStore %14 %7
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
|
||||||
%44 = OpFunction %2 None %45
|
|
||||||
%43 = OpFunctionParameter %3
|
|
||||||
%42 = OpLabel
|
|
||||||
OpBranch %46
|
|
||||||
%46 = OpLabel
|
%46 = OpLabel
|
||||||
OpSelectionMerge %47 None
|
OpStore %14 %9
|
||||||
OpSwitch %43 %48
|
OpReturn
|
||||||
%48 = OpLabel
|
|
||||||
OpBranch %47
|
|
||||||
%47 = OpLabel
|
%47 = OpLabel
|
||||||
|
OpStore %14 %10
|
||||||
|
OpReturn
|
||||||
|
%48 = OpLabel
|
||||||
|
OpStore %14 %11
|
||||||
|
OpReturn
|
||||||
|
%43 = OpLabel
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%50 = OpFunction %2 None %6
|
%51 = OpFunction %2 None %52
|
||||||
|
%50 = OpFunctionParameter %3
|
||||||
%49 = OpLabel
|
%49 = OpLabel
|
||||||
OpBranch %51
|
OpBranch %53
|
||||||
%51 = OpLabel
|
|
||||||
OpSelectionMerge %52 None
|
|
||||||
OpSwitch %8 %54 0 %53
|
|
||||||
%53 = OpLabel
|
%53 = OpLabel
|
||||||
OpBranch %52
|
OpSelectionMerge %54 None
|
||||||
|
OpSwitch %50 %55
|
||||||
|
%55 = OpLabel
|
||||||
|
OpBranch %54
|
||||||
%54 = OpLabel
|
%54 = OpLabel
|
||||||
OpBranch %52
|
|
||||||
%52 = OpLabel
|
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%56 = OpFunction %2 None %6
|
%57 = OpFunction %2 None %6
|
||||||
%55 = OpLabel
|
%56 = OpLabel
|
||||||
OpBranch %57
|
|
||||||
%57 = OpLabel
|
|
||||||
OpSelectionMerge %58 None
|
|
||||||
OpSwitch %13 %60 0 %59
|
|
||||||
%59 = OpLabel
|
|
||||||
OpBranch %58
|
|
||||||
%60 = OpLabel
|
|
||||||
OpBranch %58
|
OpBranch %58
|
||||||
%58 = OpLabel
|
%58 = OpLabel
|
||||||
OpSelectionMerge %61 None
|
OpSelectionMerge %59 None
|
||||||
OpSwitch %13 %63 0 %62
|
OpSwitch %8 %61 0 %60
|
||||||
%62 = OpLabel
|
%60 = OpLabel
|
||||||
OpReturn
|
OpBranch %59
|
||||||
%63 = OpLabel
|
|
||||||
OpReturn
|
|
||||||
%61 = OpLabel
|
%61 = OpLabel
|
||||||
|
OpBranch %59
|
||||||
|
%59 = OpLabel
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%65 = OpFunction %2 None %6
|
%63 = OpFunction %2 None %6
|
||||||
|
%62 = OpLabel
|
||||||
|
OpBranch %64
|
||||||
%64 = OpLabel
|
%64 = OpLabel
|
||||||
OpBranch %66
|
OpSelectionMerge %65 None
|
||||||
|
OpSwitch %13 %67 0 %66
|
||||||
%66 = OpLabel
|
%66 = OpLabel
|
||||||
OpSelectionMerge %67 None
|
OpBranch %65
|
||||||
OpSwitch %8 %73 0 %68 1 %69 2 %70 3 %71 4 %72
|
%67 = OpLabel
|
||||||
%68 = OpLabel
|
OpBranch %65
|
||||||
OpReturn
|
%65 = OpLabel
|
||||||
|
OpSelectionMerge %68 None
|
||||||
|
OpSwitch %13 %70 0 %69
|
||||||
%69 = OpLabel
|
%69 = OpLabel
|
||||||
OpReturn
|
OpReturn
|
||||||
%70 = OpLabel
|
%70 = OpLabel
|
||||||
OpReturn
|
OpReturn
|
||||||
%71 = OpLabel
|
%68 = OpLabel
|
||||||
OpReturn
|
|
||||||
%72 = OpLabel
|
|
||||||
OpReturn
|
|
||||||
%73 = OpLabel
|
|
||||||
OpReturn
|
|
||||||
%67 = OpLabel
|
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%76 = OpFunction %2 None %45
|
%72 = OpFunction %2 None %6
|
||||||
%75 = OpFunctionParameter %3
|
%71 = OpLabel
|
||||||
%74 = OpLabel
|
OpBranch %73
|
||||||
%89 = OpVariable %83 Function %88
|
%73 = OpLabel
|
||||||
OpBranch %77
|
OpSelectionMerge %74 None
|
||||||
|
OpSwitch %8 %80 0 %75 1 %76 2 %77 3 %78 4 %79
|
||||||
|
%75 = OpLabel
|
||||||
|
OpReturn
|
||||||
|
%76 = OpLabel
|
||||||
|
OpReturn
|
||||||
%77 = OpLabel
|
%77 = OpLabel
|
||||||
OpBranch %78
|
OpReturn
|
||||||
%78 = OpLabel
|
%78 = OpLabel
|
||||||
OpLoopMerge %79 %81 None
|
OpReturn
|
||||||
OpBranch %90
|
|
||||||
%90 = OpLabel
|
|
||||||
%91 = OpLoad %82 %89
|
|
||||||
%92 = OpIEqual %85 %86 %91
|
|
||||||
%93 = OpAll %84 %92
|
|
||||||
OpSelectionMerge %94 None
|
|
||||||
OpBranchConditional %93 %79 %94
|
|
||||||
%94 = OpLabel
|
|
||||||
%95 = OpCompositeExtract %12 %91 1
|
|
||||||
%96 = OpIEqual %84 %95 %13
|
|
||||||
%97 = OpSelect %12 %96 %19 %13
|
|
||||||
%98 = OpCompositeConstruct %82 %97 %19
|
|
||||||
%99 = OpISub %82 %91 %98
|
|
||||||
OpStore %89 %99
|
|
||||||
OpBranch %80
|
|
||||||
%80 = OpLabel
|
|
||||||
OpSelectionMerge %100 None
|
|
||||||
OpSwitch %75 %102 1 %101
|
|
||||||
%101 = OpLabel
|
|
||||||
OpBranch %81
|
|
||||||
%102 = OpLabel
|
|
||||||
OpBranch %100
|
|
||||||
%100 = OpLabel
|
|
||||||
OpBranch %81
|
|
||||||
%81 = OpLabel
|
|
||||||
OpBranch %78
|
|
||||||
%79 = OpLabel
|
%79 = OpLabel
|
||||||
OpReturn
|
OpReturn
|
||||||
|
%80 = OpLabel
|
||||||
|
OpReturn
|
||||||
|
%74 = OpLabel
|
||||||
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%107 = OpFunction %2 None %108
|
%83 = OpFunction %2 None %52
|
||||||
%104 = OpFunctionParameter %3
|
%82 = OpFunctionParameter %3
|
||||||
%105 = OpFunctionParameter %3
|
%81 = OpLabel
|
||||||
%106 = OpFunctionParameter %3
|
%96 = OpVariable %90 Function %95
|
||||||
%103 = OpLabel
|
OpBranch %84
|
||||||
%114 = OpVariable %83 Function %88
|
%84 = OpLabel
|
||||||
%136 = OpVariable %83 Function %88
|
OpBranch %85
|
||||||
%156 = OpVariable %83 Function %88
|
%85 = OpLabel
|
||||||
OpBranch %109
|
OpLoopMerge %86 %88 None
|
||||||
|
OpBranch %97
|
||||||
|
%97 = OpLabel
|
||||||
|
%98 = OpLoad %89 %96
|
||||||
|
%99 = OpIEqual %92 %93 %98
|
||||||
|
%100 = OpAll %91 %99
|
||||||
|
OpSelectionMerge %101 None
|
||||||
|
OpBranchConditional %100 %86 %101
|
||||||
|
%101 = OpLabel
|
||||||
|
%102 = OpCompositeExtract %12 %98 1
|
||||||
|
%103 = OpIEqual %91 %102 %13
|
||||||
|
%104 = OpSelect %12 %103 %19 %13
|
||||||
|
%105 = OpCompositeConstruct %89 %104 %19
|
||||||
|
%106 = OpISub %89 %98 %105
|
||||||
|
OpStore %96 %106
|
||||||
|
OpBranch %87
|
||||||
|
%87 = OpLabel
|
||||||
|
OpSelectionMerge %107 None
|
||||||
|
OpSwitch %82 %109 1 %108
|
||||||
|
%108 = OpLabel
|
||||||
|
OpBranch %88
|
||||||
%109 = OpLabel
|
%109 = OpLabel
|
||||||
OpBranch %110
|
OpBranch %107
|
||||||
|
%107 = OpLabel
|
||||||
|
OpBranch %88
|
||||||
|
%88 = OpLabel
|
||||||
|
OpBranch %85
|
||||||
|
%86 = OpLabel
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%114 = OpFunction %2 None %115
|
||||||
|
%111 = OpFunctionParameter %3
|
||||||
|
%112 = OpFunctionParameter %3
|
||||||
|
%113 = OpFunctionParameter %3
|
||||||
%110 = OpLabel
|
%110 = OpLabel
|
||||||
OpLoopMerge %111 %113 None
|
%121 = OpVariable %90 Function %95
|
||||||
OpBranch %115
|
%143 = OpVariable %90 Function %95
|
||||||
%115 = OpLabel
|
%163 = OpVariable %90 Function %95
|
||||||
%116 = OpLoad %82 %114
|
OpBranch %116
|
||||||
%117 = OpIEqual %85 %86 %116
|
%116 = OpLabel
|
||||||
%118 = OpAll %84 %117
|
OpBranch %117
|
||||||
OpSelectionMerge %119 None
|
%117 = OpLabel
|
||||||
OpBranchConditional %118 %111 %119
|
OpLoopMerge %118 %120 None
|
||||||
%119 = OpLabel
|
OpBranch %122
|
||||||
%120 = OpCompositeExtract %12 %116 1
|
%122 = OpLabel
|
||||||
%121 = OpIEqual %84 %120 %13
|
%123 = OpLoad %89 %121
|
||||||
%122 = OpSelect %12 %121 %19 %13
|
%124 = OpIEqual %92 %93 %123
|
||||||
%123 = OpCompositeConstruct %82 %122 %19
|
%125 = OpAll %91 %124
|
||||||
%124 = OpISub %82 %116 %123
|
OpSelectionMerge %126 None
|
||||||
OpStore %114 %124
|
OpBranchConditional %125 %118 %126
|
||||||
OpBranch %112
|
|
||||||
%112 = OpLabel
|
|
||||||
OpSelectionMerge %125 None
|
|
||||||
OpSwitch %104 %128 1 %126 2 %127
|
|
||||||
%126 = OpLabel
|
%126 = OpLabel
|
||||||
OpBranch %113
|
%127 = OpCompositeExtract %12 %123 1
|
||||||
%127 = OpLabel
|
%128 = OpIEqual %91 %127 %13
|
||||||
OpSelectionMerge %129 None
|
%129 = OpSelect %12 %128 %19 %13
|
||||||
OpSwitch %105 %131 1 %130
|
%130 = OpCompositeConstruct %89 %129 %19
|
||||||
%130 = OpLabel
|
%131 = OpISub %89 %123 %130
|
||||||
OpBranch %113
|
OpStore %121 %131
|
||||||
%131 = OpLabel
|
OpBranch %119
|
||||||
OpBranch %132
|
%119 = OpLabel
|
||||||
%132 = OpLabel
|
OpSelectionMerge %132 None
|
||||||
OpLoopMerge %133 %135 None
|
OpSwitch %111 %135 1 %133 2 %134
|
||||||
OpBranch %137
|
|
||||||
%137 = OpLabel
|
|
||||||
%138 = OpLoad %82 %136
|
|
||||||
%139 = OpIEqual %85 %86 %138
|
|
||||||
%140 = OpAll %84 %139
|
|
||||||
OpSelectionMerge %141 None
|
|
||||||
OpBranchConditional %140 %133 %141
|
|
||||||
%141 = OpLabel
|
|
||||||
%142 = OpCompositeExtract %12 %138 1
|
|
||||||
%143 = OpIEqual %84 %142 %13
|
|
||||||
%144 = OpSelect %12 %143 %19 %13
|
|
||||||
%145 = OpCompositeConstruct %82 %144 %19
|
|
||||||
%146 = OpISub %82 %138 %145
|
|
||||||
OpStore %136 %146
|
|
||||||
OpBranch %134
|
|
||||||
%134 = OpLabel
|
|
||||||
OpSelectionMerge %147 None
|
|
||||||
OpSwitch %106 %149 1 %148
|
|
||||||
%148 = OpLabel
|
|
||||||
OpBranch %135
|
|
||||||
%149 = OpLabel
|
|
||||||
OpBranch %147
|
|
||||||
%147 = OpLabel
|
|
||||||
OpBranch %135
|
|
||||||
%135 = OpLabel
|
|
||||||
OpBranch %132
|
|
||||||
%133 = OpLabel
|
%133 = OpLabel
|
||||||
OpBranch %129
|
OpBranch %120
|
||||||
%129 = OpLabel
|
%134 = OpLabel
|
||||||
OpBranch %125
|
OpSelectionMerge %136 None
|
||||||
%128 = OpLabel
|
OpSwitch %112 %138 1 %137
|
||||||
OpBranch %125
|
%137 = OpLabel
|
||||||
%125 = OpLabel
|
OpBranch %120
|
||||||
OpSelectionMerge %150 None
|
%138 = OpLabel
|
||||||
OpSwitch %105 %151
|
OpBranch %139
|
||||||
%151 = OpLabel
|
%139 = OpLabel
|
||||||
OpBranch %113
|
OpLoopMerge %140 %142 None
|
||||||
%150 = OpLabel
|
OpBranch %144
|
||||||
OpBranch %113
|
%144 = OpLabel
|
||||||
%113 = OpLabel
|
%145 = OpLoad %89 %143
|
||||||
OpBranch %110
|
%146 = OpIEqual %92 %93 %145
|
||||||
%111 = OpLabel
|
%147 = OpAll %91 %146
|
||||||
OpBranch %152
|
OpSelectionMerge %148 None
|
||||||
%152 = OpLabel
|
OpBranchConditional %147 %140 %148
|
||||||
OpLoopMerge %153 %155 None
|
%148 = OpLabel
|
||||||
OpBranch %157
|
%149 = OpCompositeExtract %12 %145 1
|
||||||
%157 = OpLabel
|
%150 = OpIEqual %91 %149 %13
|
||||||
%158 = OpLoad %82 %156
|
%151 = OpSelect %12 %150 %19 %13
|
||||||
%159 = OpIEqual %85 %86 %158
|
%152 = OpCompositeConstruct %89 %151 %19
|
||||||
%160 = OpAll %84 %159
|
%153 = OpISub %89 %145 %152
|
||||||
OpSelectionMerge %161 None
|
OpStore %143 %153
|
||||||
OpBranchConditional %160 %153 %161
|
OpBranch %141
|
||||||
%161 = OpLabel
|
%141 = OpLabel
|
||||||
%162 = OpCompositeExtract %12 %158 1
|
OpSelectionMerge %154 None
|
||||||
%163 = OpIEqual %84 %162 %13
|
OpSwitch %113 %156 1 %155
|
||||||
%164 = OpSelect %12 %163 %19 %13
|
%155 = OpLabel
|
||||||
%165 = OpCompositeConstruct %82 %164 %19
|
OpBranch %142
|
||||||
%166 = OpISub %82 %158 %165
|
%156 = OpLabel
|
||||||
OpStore %156 %166
|
|
||||||
OpBranch %154
|
OpBranch %154
|
||||||
%154 = OpLabel
|
%154 = OpLabel
|
||||||
OpSelectionMerge %167 None
|
OpBranch %142
|
||||||
OpSwitch %105 %168 1 %168
|
%142 = OpLabel
|
||||||
|
OpBranch %139
|
||||||
|
%140 = OpLabel
|
||||||
|
OpBranch %136
|
||||||
|
%136 = OpLabel
|
||||||
|
OpBranch %132
|
||||||
|
%135 = OpLabel
|
||||||
|
OpBranch %132
|
||||||
|
%132 = OpLabel
|
||||||
|
OpSelectionMerge %157 None
|
||||||
|
OpSwitch %112 %158
|
||||||
|
%158 = OpLabel
|
||||||
|
OpBranch %120
|
||||||
|
%157 = OpLabel
|
||||||
|
OpBranch %120
|
||||||
|
%120 = OpLabel
|
||||||
|
OpBranch %117
|
||||||
|
%118 = OpLabel
|
||||||
|
OpBranch %159
|
||||||
|
%159 = OpLabel
|
||||||
|
OpLoopMerge %160 %162 None
|
||||||
|
OpBranch %164
|
||||||
|
%164 = OpLabel
|
||||||
|
%165 = OpLoad %89 %163
|
||||||
|
%166 = OpIEqual %92 %93 %165
|
||||||
|
%167 = OpAll %91 %166
|
||||||
|
OpSelectionMerge %168 None
|
||||||
|
OpBranchConditional %167 %160 %168
|
||||||
%168 = OpLabel
|
%168 = OpLabel
|
||||||
OpSelectionMerge %169 None
|
%169 = OpCompositeExtract %12 %165 1
|
||||||
OpSwitch %106 %170
|
%170 = OpIEqual %91 %169 %13
|
||||||
%170 = OpLabel
|
%171 = OpSelect %12 %170 %19 %13
|
||||||
OpBranch %155
|
%172 = OpCompositeConstruct %89 %171 %19
|
||||||
%169 = OpLabel
|
%173 = OpISub %89 %165 %172
|
||||||
OpBranch %167
|
OpStore %163 %173
|
||||||
%167 = OpLabel
|
OpBranch %161
|
||||||
OpBranch %155
|
%161 = OpLabel
|
||||||
%155 = OpLabel
|
OpSelectionMerge %174 None
|
||||||
OpBranch %152
|
OpSwitch %112 %175 1 %175
|
||||||
%153 = OpLabel
|
%175 = OpLabel
|
||||||
|
OpSelectionMerge %176 None
|
||||||
|
OpSwitch %113 %177
|
||||||
|
%177 = OpLabel
|
||||||
|
OpBranch %162
|
||||||
|
%176 = OpLabel
|
||||||
|
OpBranch %174
|
||||||
|
%174 = OpLabel
|
||||||
|
OpBranch %162
|
||||||
|
%162 = OpLabel
|
||||||
|
OpBranch %159
|
||||||
|
%160 = OpLabel
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%176 = OpFunction %2 None %177
|
%183 = OpFunction %2 None %184
|
||||||
%172 = OpFunctionParameter %3
|
%179 = OpFunctionParameter %3
|
||||||
%173 = OpFunctionParameter %3
|
%180 = OpFunctionParameter %3
|
||||||
%174 = OpFunctionParameter %3
|
%181 = OpFunctionParameter %3
|
||||||
%175 = OpFunctionParameter %3
|
%182 = OpFunctionParameter %3
|
||||||
%171 = OpLabel
|
%178 = OpLabel
|
||||||
%178 = OpVariable %15 Function %8
|
%185 = OpVariable %15 Function %8
|
||||||
%184 = OpVariable %83 Function %88
|
%191 = OpVariable %90 Function %95
|
||||||
%202 = OpVariable %83 Function %88
|
%209 = OpVariable %90 Function %95
|
||||||
OpBranch %179
|
OpBranch %186
|
||||||
%179 = OpLabel
|
%186 = OpLabel
|
||||||
OpBranch %180
|
OpBranch %187
|
||||||
%180 = OpLabel
|
%187 = OpLabel
|
||||||
OpLoopMerge %181 %183 None
|
OpLoopMerge %188 %190 None
|
||||||
OpBranch %185
|
OpBranch %192
|
||||||
%185 = OpLabel
|
%192 = OpLabel
|
||||||
%186 = OpLoad %82 %184
|
%193 = OpLoad %89 %191
|
||||||
%187 = OpIEqual %85 %86 %186
|
%194 = OpIEqual %92 %93 %193
|
||||||
%188 = OpAll %84 %187
|
%195 = OpAll %91 %194
|
||||||
OpSelectionMerge %189 None
|
OpSelectionMerge %196 None
|
||||||
OpBranchConditional %188 %181 %189
|
OpBranchConditional %195 %188 %196
|
||||||
%189 = OpLabel
|
|
||||||
%190 = OpCompositeExtract %12 %186 1
|
|
||||||
%191 = OpIEqual %84 %190 %13
|
|
||||||
%192 = OpSelect %12 %191 %19 %13
|
|
||||||
%193 = OpCompositeConstruct %82 %192 %19
|
|
||||||
%194 = OpISub %82 %186 %193
|
|
||||||
OpStore %184 %194
|
|
||||||
OpBranch %182
|
|
||||||
%182 = OpLabel
|
|
||||||
OpSelectionMerge %195 None
|
|
||||||
OpSwitch %172 %197 1 %196
|
|
||||||
%196 = OpLabel
|
%196 = OpLabel
|
||||||
OpStore %178 %7
|
%197 = OpCompositeExtract %12 %193 1
|
||||||
OpBranch %195
|
%198 = OpIEqual %91 %197 %13
|
||||||
%197 = OpLabel
|
%199 = OpSelect %12 %198 %19 %13
|
||||||
OpBranch %195
|
%200 = OpCompositeConstruct %89 %199 %19
|
||||||
%195 = OpLabel
|
%201 = OpISub %89 %193 %200
|
||||||
OpBranch %183
|
OpStore %191 %201
|
||||||
%183 = OpLabel
|
OpBranch %189
|
||||||
OpBranch %180
|
%189 = OpLabel
|
||||||
%181 = OpLabel
|
OpSelectionMerge %202 None
|
||||||
OpBranch %198
|
OpSwitch %179 %204 1 %203
|
||||||
%198 = OpLabel
|
|
||||||
OpLoopMerge %199 %201 None
|
|
||||||
OpBranch %203
|
|
||||||
%203 = OpLabel
|
%203 = OpLabel
|
||||||
%204 = OpLoad %82 %202
|
OpStore %185 %7
|
||||||
%205 = OpIEqual %85 %86 %204
|
OpBranch %202
|
||||||
%206 = OpAll %84 %205
|
%204 = OpLabel
|
||||||
OpSelectionMerge %207 None
|
OpBranch %202
|
||||||
OpBranchConditional %206 %199 %207
|
%202 = OpLabel
|
||||||
%207 = OpLabel
|
OpBranch %190
|
||||||
%208 = OpCompositeExtract %12 %204 1
|
%190 = OpLabel
|
||||||
%209 = OpIEqual %84 %208 %13
|
OpBranch %187
|
||||||
%210 = OpSelect %12 %209 %19 %13
|
%188 = OpLabel
|
||||||
%211 = OpCompositeConstruct %82 %210 %19
|
OpBranch %205
|
||||||
%212 = OpISub %82 %204 %211
|
%205 = OpLabel
|
||||||
OpStore %202 %212
|
OpLoopMerge %206 %208 None
|
||||||
OpBranch %200
|
OpBranch %210
|
||||||
%200 = OpLabel
|
%210 = OpLabel
|
||||||
OpSelectionMerge %213 None
|
%211 = OpLoad %89 %209
|
||||||
OpSwitch %172 %216 1 %214 2 %215
|
%212 = OpIEqual %92 %93 %211
|
||||||
|
%213 = OpAll %91 %212
|
||||||
|
OpSelectionMerge %214 None
|
||||||
|
OpBranchConditional %213 %206 %214
|
||||||
%214 = OpLabel
|
%214 = OpLabel
|
||||||
OpBranch %213
|
%215 = OpCompositeExtract %12 %211 1
|
||||||
%215 = OpLabel
|
%216 = OpIEqual %91 %215 %13
|
||||||
OpSelectionMerge %217 None
|
%217 = OpSelect %12 %216 %19 %13
|
||||||
OpSwitch %173 %219 1 %218
|
%218 = OpCompositeConstruct %89 %217 %19
|
||||||
%218 = OpLabel
|
%219 = OpISub %89 %211 %218
|
||||||
OpBranch %201
|
OpStore %209 %219
|
||||||
%219 = OpLabel
|
OpBranch %207
|
||||||
|
%207 = OpLabel
|
||||||
OpSelectionMerge %220 None
|
OpSelectionMerge %220 None
|
||||||
OpSwitch %174 %222 1 %221
|
OpSwitch %179 %223 1 %221 2 %222
|
||||||
%221 = OpLabel
|
%221 = OpLabel
|
||||||
OpStore %178 %9
|
|
||||||
OpBranch %220
|
OpBranch %220
|
||||||
%222 = OpLabel
|
%222 = OpLabel
|
||||||
|
OpSelectionMerge %224 None
|
||||||
|
OpSwitch %180 %226 1 %225
|
||||||
|
%225 = OpLabel
|
||||||
|
OpBranch %208
|
||||||
|
%226 = OpLabel
|
||||||
|
OpSelectionMerge %227 None
|
||||||
|
OpSwitch %181 %229 1 %228
|
||||||
|
%228 = OpLabel
|
||||||
|
OpStore %185 %9
|
||||||
|
OpBranch %227
|
||||||
|
%229 = OpLabel
|
||||||
|
OpBranch %227
|
||||||
|
%227 = OpLabel
|
||||||
|
OpBranch %224
|
||||||
|
%224 = OpLabel
|
||||||
|
OpBranch %220
|
||||||
|
%223 = OpLabel
|
||||||
OpBranch %220
|
OpBranch %220
|
||||||
%220 = OpLabel
|
%220 = OpLabel
|
||||||
OpBranch %217
|
OpBranch %208
|
||||||
%217 = OpLabel
|
%208 = OpLabel
|
||||||
OpBranch %213
|
OpBranch %205
|
||||||
%216 = OpLabel
|
%206 = OpLabel
|
||||||
OpBranch %213
|
|
||||||
%213 = OpLabel
|
|
||||||
OpBranch %201
|
|
||||||
%201 = OpLabel
|
|
||||||
OpBranch %198
|
|
||||||
%199 = OpLabel
|
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%224 = OpFunction %2 None %6
|
%231 = OpFunction %2 None %6
|
||||||
%223 = OpLabel
|
%230 = OpLabel
|
||||||
OpBranch %225
|
OpBranch %232
|
||||||
%225 = OpLabel
|
%232 = OpLabel
|
||||||
%226 = OpFunctionCall %2 %5
|
%233 = OpFunctionCall %2 %5
|
||||||
%227 = OpFunctionCall %2 %44 %7
|
%234 = OpFunctionCall %2 %51 %7
|
||||||
%228 = OpFunctionCall %2 %50
|
%235 = OpFunctionCall %2 %57
|
||||||
%229 = OpFunctionCall %2 %56
|
%236 = OpFunctionCall %2 %63
|
||||||
%230 = OpFunctionCall %2 %65
|
%237 = OpFunctionCall %2 %72
|
||||||
%231 = OpFunctionCall %2 %76 %7
|
%238 = OpFunctionCall %2 %83 %7
|
||||||
%232 = OpFunctionCall %2 %107 %7 %9 %10
|
%239 = OpFunctionCall %2 %114 %7 %9 %10
|
||||||
%233 = OpFunctionCall %2 %176 %7 %9 %10 %11
|
%240 = OpFunctionCall %2 %183 %7 %9 %10 %11
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
@ -42,17 +42,36 @@ fn control_flow() {
|
|||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
pos = 1i;
|
pos = 1i;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
pos = 2i;
|
pos = 2i;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
pos = 3i;
|
pos = 3i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let _e15 = pos;
|
||||||
|
switch _e15 {
|
||||||
|
case 1: {
|
||||||
|
pos = 0i;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
pos = 1i;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 3, 4: {
|
||||||
|
pos = 2i;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 5, 6: {
|
||||||
|
pos = 3i;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
pos = 4i;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user