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

@@ -7,7 +7,7 @@ Linked fragment stage:
// Module Version 99
// Generated by (magic number): 51a00bb
// Id's are bound by 104
// Id's are bound by 103
Source GLSL 430
Capability Shader
@@ -16,139 +16,137 @@ Linked fragment stage:
EntryPoint Fragment 4 "main"
ExecutionMode 4 OriginLowerLeft
Name 4 "main"
Name 18 "foo(f1[5][7];"
Name 17 "a"
Name 21 "r"
Name 39 "outfloat"
Name 42 "g4"
Name 44 "g5"
Name 45 "param"
Name 48 "u"
Name 52 "param"
Name 66 "many"
Name 68 "i"
Name 70 "j"
Name 72 "k"
Name 78 "infloat"
Name 94 "uAofA"
MemberName 94(uAofA) 0 "f"
Name 98 "nameAofA"
Decorate 44(g5) Smooth
Decorate 78(infloat) Smooth
Decorate 94(uAofA) GLSLShared
Decorate 94(uAofA) Block
Name 17 "foo(f1[5][7];"
Name 16 "a"
Name 20 "r"
Name 38 "outfloat"
Name 41 "g4"
Name 43 "g5"
Name 44 "param"
Name 47 "u"
Name 51 "param"
Name 65 "many"
Name 67 "i"
Name 69 "j"
Name 71 "k"
Name 77 "infloat"
Name 93 "uAofA"
MemberName 93(uAofA) 0 "f"
Name 97 "nameAofA"
Decorate 43(g5) Smooth
Decorate 77(infloat) Smooth
Decorate 93(uAofA) GLSLShared
Decorate 93(uAofA) Block
2: TypeVoid
3: TypeFunction 2
7: TypeFloat 32
8: TypeInt 32 0
9: 8(int) Constant 7
10: TypeArray 7(float) 9
11: 8(int) Constant 5
12: TypeArray 10 11
13: TypePointer Function 12
14: 8(int) Constant 4
15: TypeArray 10 14
16: TypeFunction 15 13(ptr)
20: TypePointer Function 10
22: TypeInt 32 1
23: 22(int) Constant 2
26: 22(int) Constant 0
29: 22(int) Constant 1
33: 22(int) Constant 3
38: TypePointer Output 7(float)
39(outfloat): 38(ptr) Variable Output
40: 7(float) Constant 0
41: TypePointer PrivateGlobal 15
42(g4): 41(ptr) Variable PrivateGlobal
43: TypePointer Input 12
44(g5): 43(ptr) Variable Input
49: 7(float) Constant 1077936128
50: TypePointer Function 7(float)
55: 8(int) Constant 6
56: TypeArray 7(float) 55
57: TypeArray 56 11
58: TypeArray 57 14
59: 8(int) Constant 3
60: TypeArray 58 59
61: 8(int) Constant 2
62: TypeArray 60 61
63: 8(int) Constant 1
64: TypeArray 62 63
65: TypePointer PrivateGlobal 64
66(many): 65(ptr) Variable PrivateGlobal
67: TypePointer UniformConstant 22(int)
68(i): 67(ptr) Variable UniformConstant
70(j): 67(ptr) Variable UniformConstant
72(k): 67(ptr) Variable UniformConstant
77: TypePointer Input 7(float)
78(infloat): 77(ptr) Variable Input
80: TypePointer PrivateGlobal 7(float)
92: TypeArray 7(float) 14
93: TypeArray 92 61
94(uAofA): TypeStruct 93
95: TypeArray 94(uAofA) 11
96: TypeArray 95 59
97: TypePointer Uniform 96
98(nameAofA): 97(ptr) Variable Uniform
99: TypePointer Uniform 7(float)
6: TypeFloat 32
7: TypeInt 32 0
8: 7(int) Constant 7
9: TypeArray 6(float) 8
10: 7(int) Constant 5
11: TypeArray 9 10
12: TypePointer Function 11
13: 7(int) Constant 4
14: TypeArray 9 13
15: TypeFunction 14 12(ptr)
19: TypePointer Function 9
21: TypeInt 32 1
22: 21(int) Constant 2
25: 21(int) Constant 0
28: 21(int) Constant 1
32: 21(int) Constant 3
37: TypePointer Output 6(float)
38(outfloat): 37(ptr) Variable Output
39: 6(float) Constant 0
40: TypePointer PrivateGlobal 14
41(g4): 40(ptr) Variable PrivateGlobal
42: TypePointer Input 11
43(g5): 42(ptr) Variable Input
48: 6(float) Constant 1077936128
49: TypePointer Function 6(float)
54: 7(int) Constant 6
55: TypeArray 6(float) 54
56: TypeArray 55 10
57: TypeArray 56 13
58: 7(int) Constant 3
59: TypeArray 57 58
60: 7(int) Constant 2
61: TypeArray 59 60
62: 7(int) Constant 1
63: TypeArray 61 62
64: TypePointer PrivateGlobal 63
65(many): 64(ptr) Variable PrivateGlobal
66: TypePointer UniformConstant 21(int)
67(i): 66(ptr) Variable UniformConstant
69(j): 66(ptr) Variable UniformConstant
71(k): 66(ptr) Variable UniformConstant
76: TypePointer Input 6(float)
77(infloat): 76(ptr) Variable Input
79: TypePointer PrivateGlobal 6(float)
91: TypeArray 6(float) 13
92: TypeArray 91 60
93(uAofA): TypeStruct 92
94: TypeArray 93(uAofA) 10
95: TypeArray 94 58
96: TypePointer Uniform 95
97(nameAofA): 96(ptr) Variable Uniform
98: TypePointer Uniform 6(float)
4(main): 2 Function None 3
5: Label
45(param): 13(ptr) Variable Function
48(u): 13(ptr) Variable Function
52(param): 13(ptr) Variable Function
Store 39(outfloat) 40
46: 12 Load 44(g5)
Store 45(param) 46
47: 15 FunctionCall 18(foo(f1[5][7];) 45(param)
Store 42(g4) 47
51: 50(ptr) AccessChain 48(u) 23 23
Store 51 49
53: 12 Load 48(u)
Store 52(param) 53
54: 15 FunctionCall 18(foo(f1[5][7];) 52(param)
69: 22(int) Load 68(i)
71: 22(int) Load 70(j)
73: 22(int) Load 72(k)
74: 22(int) Load 68(i)
75: 22(int) Load 70(j)
76: 22(int) Load 72(k)
79: 7(float) Load 78(infloat)
81: 80(ptr) AccessChain 66(many) 69 71 73 74 75 76
Store 81 79
82: 22(int) Load 70(j)
83: 22(int) Load 70(j)
84: 22(int) Load 70(j)
85: 22(int) Load 70(j)
86: 22(int) Load 70(j)
87: 22(int) Load 70(j)
88: 80(ptr) AccessChain 66(many) 82 83 84 85 86 87
89: 7(float) Load 88
90: 7(float) Load 39(outfloat)
91: 7(float) FAdd 90 89
Store 39(outfloat) 91
100: 99(ptr) AccessChain 98(nameAofA) 29 23 26 26 33
101: 7(float) Load 100
102: 7(float) Load 39(outfloat)
103: 7(float) FAdd 102 101
Store 39(outfloat) 103
Branch 6
6: Label
44(param): 12(ptr) Variable Function
47(u): 12(ptr) Variable Function
51(param): 12(ptr) Variable Function
Store 38(outfloat) 39
45: 11 Load 43(g5)
Store 44(param) 45
46: 14 FunctionCall 17(foo(f1[5][7];) 44(param)
Store 41(g4) 46
50: 49(ptr) AccessChain 47(u) 22 22
Store 50 48
52: 11 Load 47(u)
Store 51(param) 52
53: 14 FunctionCall 17(foo(f1[5][7];) 51(param)
68: 21(int) Load 67(i)
70: 21(int) Load 69(j)
72: 21(int) Load 71(k)
73: 21(int) Load 67(i)
74: 21(int) Load 69(j)
75: 21(int) Load 71(k)
78: 6(float) Load 77(infloat)
80: 79(ptr) AccessChain 65(many) 68 70 72 73 74 75
Store 80 78
81: 21(int) Load 69(j)
82: 21(int) Load 69(j)
83: 21(int) Load 69(j)
84: 21(int) Load 69(j)
85: 21(int) Load 69(j)
86: 21(int) Load 69(j)
87: 79(ptr) AccessChain 65(many) 81 82 83 84 85 86
88: 6(float) Load 87
89: 6(float) Load 38(outfloat)
90: 6(float) FAdd 89 88
Store 38(outfloat) 90
99: 98(ptr) AccessChain 97(nameAofA) 28 22 25 25 32
100: 6(float) Load 99
101: 6(float) Load 38(outfloat)
102: 6(float) FAdd 101 100
Store 38(outfloat) 102
Return
FunctionEnd
18(foo(f1[5][7];): 15 Function None 16
17(a): 13(ptr) FunctionParameter
19: Label
21(r): 20(ptr) Variable Function
24: 20(ptr) AccessChain 17(a) 23
25: 10 Load 24
Store 21(r) 25
27: 20(ptr) AccessChain 17(a) 26
28: 10 Load 27
30: 20(ptr) AccessChain 17(a) 29
31: 10 Load 30
32: 10 Load 21(r)
34: 20(ptr) AccessChain 17(a) 33
35: 10 Load 34
36: 15 CompositeConstruct 28 31 32 35
ReturnValue 36
17(foo(f1[5][7];): 14 Function None 15
16(a): 12(ptr) FunctionParameter
18: Label
20(r): 19(ptr) Variable Function
23: 19(ptr) AccessChain 16(a) 22
24: 9 Load 23
Store 20(r) 24
26: 19(ptr) AccessChain 16(a) 25
27: 9 Load 26
29: 19(ptr) AccessChain 16(a) 28
30: 9 Load 29
31: 9 Load 20(r)
33: 19(ptr) AccessChain 16(a) 32
34: 9 Load 33
35: 14 CompositeConstruct 27 30 31 34
ReturnValue 35
FunctionEnd