SPV return from main: Simplify a legacy design such returns are not jumps to exit block.

Structured control-flow rules allow leaving the middle of a construct through
a return, but not through a jump to a block that does a return.

Addresses issue #58.
This commit is contained in:
John Kessenich 2015-09-14 20:58:02 -06:00
parent 5f5b205ce9
commit e770b3e6cf
74 changed files with 9648 additions and 9816 deletions

View file

@ -5,7 +5,7 @@ Linked fragment stage:
// Module Version 99
// Generated by (magic number): 51a00bb
// Id's are bound by 111
// Id's are bound by 110
Source ESSL 300
Capability Shader
@ -14,164 +14,162 @@ Linked fragment stage:
EntryPoint Fragment 4 "main"
ExecutionMode 4 OriginLowerLeft
Name 4 "main"
Name 13 "foo(vf3;"
Name 12 "mv3"
Name 20 "boolfun(vb2;"
Name 19 "bv2"
Name 24 "highfin"
Name 37 "sum"
Name 39 "uniform_medium"
Name 41 "uniform_high"
Name 47 "uniform_low"
Name 52 "arg1"
Name 54 "arg2"
Name 56 "d"
Name 58 "lowfin"
Name 60 "mediumfin"
Name 64 "global_highp"
Name 68 "local_highp"
Name 72 "mediumfout"
Name 101 "ub2"
Name 102 "param"
Decorate 24(highfin) Smooth
Decorate 37(sum) RelaxedPrecision
Decorate 39(uniform_medium) RelaxedPrecision
Decorate 47(uniform_low) RelaxedPrecision
Decorate 52(arg1) RelaxedPrecision
Decorate 54(arg2) RelaxedPrecision
Decorate 56(d) RelaxedPrecision
Decorate 58(lowfin) RelaxedPrecision
Decorate 58(lowfin) Smooth
Decorate 60(mediumfin) RelaxedPrecision
Decorate 60(mediumfin) Smooth
Decorate 72(mediumfout) RelaxedPrecision
Name 12 "foo(vf3;"
Name 11 "mv3"
Name 19 "boolfun(vb2;"
Name 18 "bv2"
Name 23 "highfin"
Name 36 "sum"
Name 38 "uniform_medium"
Name 40 "uniform_high"
Name 46 "uniform_low"
Name 51 "arg1"
Name 53 "arg2"
Name 55 "d"
Name 57 "lowfin"
Name 59 "mediumfin"
Name 63 "global_highp"
Name 67 "local_highp"
Name 71 "mediumfout"
Name 100 "ub2"
Name 101 "param"
Decorate 23(highfin) Smooth
Decorate 36(sum) RelaxedPrecision
Decorate 38(uniform_medium) RelaxedPrecision
Decorate 46(uniform_low) RelaxedPrecision
Decorate 51(arg1) RelaxedPrecision
Decorate 53(arg2) RelaxedPrecision
Decorate 55(d) RelaxedPrecision
Decorate 57(lowfin) RelaxedPrecision
Decorate 57(lowfin) Smooth
Decorate 59(mediumfin) RelaxedPrecision
Decorate 59(mediumfin) Smooth
Decorate 71(mediumfout) RelaxedPrecision
2: TypeVoid
3: TypeFunction 2
7: TypeFloat 32
8: TypeVector 7(float) 3
9: TypePointer Function 8(fvec3)
10: TypeVector 7(float) 2
11: TypeFunction 10(fvec2) 9(ptr)
15: TypeBool
16: TypeVector 15(bool) 2
17: TypePointer Function 16(bvec2)
18: TypeFunction 15(bool) 17(ptr)
22: TypeVector 7(float) 4
23: TypePointer Input 22(fvec4)
24(highfin): 23(ptr) Variable Input
29: 15(bool) ConstantFalse
30: 15(bool) ConstantTrue
31: 16(bvec2) ConstantComposite 29 30
35: TypeInt 32 1
36: TypePointer Function 35(int)
38: TypePointer UniformConstant 35(int)
39(uniform_medium): 38(ptr) Variable UniformConstant
41(uniform_high): 38(ptr) Variable UniformConstant
47(uniform_low): 38(ptr) Variable UniformConstant
51: TypePointer Function 7(float)
53: 7(float) Constant 1078774989
55: 7(float) Constant 1232730691
57: TypePointer Input 7(float)
58(lowfin): 57(ptr) Variable Input
60(mediumfin): 57(ptr) Variable Input
63: TypePointer PrivateGlobal 7(float)
64(global_highp): 63(ptr) Variable PrivateGlobal
67: TypePointer Function 22(fvec4)
71: TypePointer Output 22(fvec4)
72(mediumfout): 71(ptr) Variable Output
81: 35(int) Constant 4
83: TypeVector 35(int) 2
100: TypePointer UniformConstant 16(bvec2)
101(ub2): 100(ptr) Variable UniformConstant
108: 7(float) Constant 1065353216
6: TypeFloat 32
7: TypeVector 6(float) 3
8: TypePointer Function 7(fvec3)
9: TypeVector 6(float) 2
10: TypeFunction 9(fvec2) 8(ptr)
14: TypeBool
15: TypeVector 14(bool) 2
16: TypePointer Function 15(bvec2)
17: TypeFunction 14(bool) 16(ptr)
21: TypeVector 6(float) 4
22: TypePointer Input 21(fvec4)
23(highfin): 22(ptr) Variable Input
28: 14(bool) ConstantFalse
29: 14(bool) ConstantTrue
30: 15(bvec2) ConstantComposite 28 29
34: TypeInt 32 1
35: TypePointer Function 34(int)
37: TypePointer UniformConstant 34(int)
38(uniform_medium): 37(ptr) Variable UniformConstant
40(uniform_high): 37(ptr) Variable UniformConstant
46(uniform_low): 37(ptr) Variable UniformConstant
50: TypePointer Function 6(float)
52: 6(float) Constant 1078774989
54: 6(float) Constant 1232730691
56: TypePointer Input 6(float)
57(lowfin): 56(ptr) Variable Input
59(mediumfin): 56(ptr) Variable Input
62: TypePointer PrivateGlobal 6(float)
63(global_highp): 62(ptr) Variable PrivateGlobal
66: TypePointer Function 21(fvec4)
70: TypePointer Output 21(fvec4)
71(mediumfout): 70(ptr) Variable Output
80: 34(int) Constant 4
82: TypeVector 34(int) 2
99: TypePointer UniformConstant 15(bvec2)
100(ub2): 99(ptr) Variable UniformConstant
107: 6(float) Constant 1065353216
4(main): 2 Function None 3
5: Label
37(sum): 36(ptr) Variable Function
52(arg1): 51(ptr) Variable Function
54(arg2): 51(ptr) Variable Function
56(d): 51(ptr) Variable Function
68(local_highp): 67(ptr) Variable Function
102(param): 17(ptr) Variable Function
40: 35(int) Load 39(uniform_medium)
42: 35(int) Load 41(uniform_high)
43: 35(int) IAdd 40 42
Store 37(sum) 43
44: 35(int) Load 41(uniform_high)
45: 35(int) Load 37(sum)
46: 35(int) IAdd 45 44
Store 37(sum) 46
48: 35(int) Load 47(uniform_low)
49: 35(int) Load 37(sum)
50: 35(int) IAdd 49 48
Store 37(sum) 50
Store 52(arg1) 53
Store 54(arg2) 55
59: 7(float) Load 58(lowfin)
61: 7(float) Load 60(mediumfin)
62: 7(float) ExtInst 1(GLSL.std.450) 66(Distance) 59 61
Store 56(d) 62
65: 22(fvec4) Load 24(highfin)
66: 7(float) ExtInst 1(GLSL.std.450) 65(Length) 65
Store 64(global_highp) 66
69: 7(float) Load 64(global_highp)
70: 22(fvec4) CompositeConstruct 69 69 69 69
Store 68(local_highp) 70
73: 7(float) Load 56(d)
74: 7(float) ExtInst 1(GLSL.std.450) 13(Sin) 73
75: 22(fvec4) CompositeConstruct 74 74 74 74
76: 7(float) Load 54(arg2)
77: 22(fvec4) CompositeConstruct 76 76 76 76
78: 22(fvec4) FAdd 75 77
79: 22(fvec4) Load 68(local_highp)
80: 22(fvec4) FAdd 78 79
Store 72(mediumfout) 80
82: 35(int) Load 47(uniform_low)
84: 83(ivec2) CompositeConstruct 82 82
85: 35(int) Load 41(uniform_high)
86: 83(ivec2) CompositeConstruct 85 85
87: 83(ivec2) IMul 84 86
88: 35(int) Load 41(uniform_high)
89: 83(ivec2) CompositeConstruct 88 88
90: 83(ivec2) IAdd 87 89
91: 35(int) CompositeExtract 90 0
92: 35(int) IAdd 81 91
93: 35(int) Load 37(sum)
94: 35(int) IAdd 93 92
Store 37(sum) 94
95: 35(int) Load 37(sum)
96: 7(float) ConvertSToF 95
97: 22(fvec4) CompositeConstruct 96 96 96 96
98: 22(fvec4) Load 72(mediumfout)
99: 22(fvec4) FAdd 98 97
Store 72(mediumfout) 99
103: 16(bvec2) Load 101(ub2)
Store 102(param) 103
104: 15(bool) FunctionCall 20(boolfun(vb2;) 102(param)
SelectionMerge 106 None
BranchConditional 104 105 106
105: Label
107: 22(fvec4) Load 72(mediumfout)
109: 22(fvec4) CompositeConstruct 108 108 108 108
110: 22(fvec4) FAdd 107 109
Store 72(mediumfout) 110
Branch 106
106: Label
Branch 6
6: Label
36(sum): 35(ptr) Variable Function
51(arg1): 50(ptr) Variable Function
53(arg2): 50(ptr) Variable Function
55(d): 50(ptr) Variable Function
67(local_highp): 66(ptr) Variable Function
101(param): 16(ptr) Variable Function
39: 34(int) Load 38(uniform_medium)
41: 34(int) Load 40(uniform_high)
42: 34(int) IAdd 39 41
Store 36(sum) 42
43: 34(int) Load 40(uniform_high)
44: 34(int) Load 36(sum)
45: 34(int) IAdd 44 43
Store 36(sum) 45
47: 34(int) Load 46(uniform_low)
48: 34(int) Load 36(sum)
49: 34(int) IAdd 48 47
Store 36(sum) 49
Store 51(arg1) 52
Store 53(arg2) 54
58: 6(float) Load 57(lowfin)
60: 6(float) Load 59(mediumfin)
61: 6(float) ExtInst 1(GLSL.std.450) 66(Distance) 58 60
Store 55(d) 61
64: 21(fvec4) Load 23(highfin)
65: 6(float) ExtInst 1(GLSL.std.450) 65(Length) 64
Store 63(global_highp) 65
68: 6(float) Load 63(global_highp)
69: 21(fvec4) CompositeConstruct 68 68 68 68
Store 67(local_highp) 69
72: 6(float) Load 55(d)
73: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 72
74: 21(fvec4) CompositeConstruct 73 73 73 73
75: 6(float) Load 53(arg2)
76: 21(fvec4) CompositeConstruct 75 75 75 75
77: 21(fvec4) FAdd 74 76
78: 21(fvec4) Load 67(local_highp)
79: 21(fvec4) FAdd 77 78
Store 71(mediumfout) 79
81: 34(int) Load 46(uniform_low)
83: 82(ivec2) CompositeConstruct 81 81
84: 34(int) Load 40(uniform_high)
85: 82(ivec2) CompositeConstruct 84 84
86: 82(ivec2) IMul 83 85
87: 34(int) Load 40(uniform_high)
88: 82(ivec2) CompositeConstruct 87 87
89: 82(ivec2) IAdd 86 88
90: 34(int) CompositeExtract 89 0
91: 34(int) IAdd 80 90
92: 34(int) Load 36(sum)
93: 34(int) IAdd 92 91
Store 36(sum) 93
94: 34(int) Load 36(sum)
95: 6(float) ConvertSToF 94
96: 21(fvec4) CompositeConstruct 95 95 95 95
97: 21(fvec4) Load 71(mediumfout)
98: 21(fvec4) FAdd 97 96
Store 71(mediumfout) 98
102: 15(bvec2) Load 100(ub2)
Store 101(param) 102
103: 14(bool) FunctionCall 19(boolfun(vb2;) 101(param)
SelectionMerge 105 None
BranchConditional 103 104 105
104: Label
106: 21(fvec4) Load 71(mediumfout)
108: 21(fvec4) CompositeConstruct 107 107 107 107
109: 21(fvec4) FAdd 106 108
Store 71(mediumfout) 109
Branch 105
105: Label
Return
FunctionEnd
13(foo(vf3;): 10(fvec2) Function None 11
12(mv3): 9(ptr) FunctionParameter
14: Label
25: 22(fvec4) Load 24(highfin)
26: 10(fvec2) VectorShuffle 25 25 0 1
ReturnValue 26
12(foo(vf3;): 9(fvec2) Function None 10
11(mv3): 8(ptr) FunctionParameter
13: Label
24: 21(fvec4) Load 23(highfin)
25: 9(fvec2) VectorShuffle 24 24 0 1
ReturnValue 25
FunctionEnd
20(boolfun(vb2;): 15(bool) Function None 18
19(bv2): 17(ptr) FunctionParameter
21: Label
28: 16(bvec2) Load 19(bv2)
32: 16(bvec2) IEqual 28 31
33: 15(bool) All 32
ReturnValue 33
19(boolfun(vb2;): 14(bool) Function None 17
18(bv2): 16(ptr) FunctionParameter
20: Label
27: 15(bvec2) Load 18(bv2)
31: 15(bvec2) IEqual 27 30
32: 14(bool) All 31
ReturnValue 32
FunctionEnd