Debian Codegraph @

test/diff/diff_files/function_group_by_mapped_id_autogen.cpp

raw
1 // GENERATED FILE - DO NOT EDIT.
2 // Generated by generate_tests.py
3 //
4 // Copyright (c) 2022 Google LLC.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17
18 #include "../diff_test_utils.h"
19 #include "gtest/gtest.h"
20
21 namespace spvtools {
22 namespace diff {
23 namespace {
24
25 // Don't forget to map between source and destination ids when grouping
26 // functions by return type.
27 constexpr char kSrc[] = R"( OpCapability Shader
28 OpCapability Linkage
29 OpMemoryModel Logical GLSL450
30 %void = OpTypeVoid
31 %1 = OpTypeInt 32 0
32 %2 = OpTypeInt 32 1
33
34 %fn_uint = OpTypeFunction %1
35 %fn_int = OpTypeFunction %2
36
37 %uint_42 = OpConstant %1 42
38 %int_1729 = OpConstant %2 1729
39
40 %f = OpFunction %1 None %fn_uint
41 %f_prologue = OpLabel
42 OpReturnValue %uint_42
43 OpFunctionEnd
44
45 %g = OpFunction %2 None %fn_int
46 %g_prologue = OpLabel
47 OpReturnValue %int_1729
48 OpFunctionEnd)";
49 constexpr char kDst[] =
50 R"(;; Don't forget to map between source and destination ids when grouping functions by return type.
51 OpCapability Shader
52 OpCapability Linkage
53 OpMemoryModel Logical GLSL450
54 %void = OpTypeVoid
55 %2 = OpTypeInt 32 0
56 %1 = OpTypeInt 32 1
57
58 %fn_uint = OpTypeFunction %2
59 %fn_int = OpTypeFunction %1
60
61 %uint_42 = OpConstant %2 42
62 %int_1729 = OpConstant %1 1729
63
64 %f = OpFunction %2 None %fn_uint
65 %f_prologue = OpLabel
66 OpReturnValue %uint_42
67 OpFunctionEnd
68
69 %g = OpFunction %1 None %fn_int
70 %g_prologue = OpLabel
71 OpReturnValue %int_1729
72 OpFunctionEnd
73 )";
74
75 TEST(DiffTest, FunctionGroupByMappedId) {
76 constexpr char kDiff[] = R"( ; SPIR-V
77 ; Version: 1.6
78 ; Generator: Khronos SPIR-V Tools Assembler; 0
79 ; Bound: 12
80 ; Schema: 0
81 OpCapability Shader
82 OpCapability Linkage
83 OpMemoryModel Logical GLSL450
84 %3 = OpTypeVoid
85 %1 = OpTypeInt 32 0
86 %2 = OpTypeInt 32 1
87 %4 = OpTypeFunction %1
88 %5 = OpTypeFunction %2
89 %6 = OpConstant %1 42
90 %7 = OpConstant %2 1729
91 %8 = OpFunction %1 None %4
92 %9 = OpLabel
93 OpReturnValue %6
94 OpFunctionEnd
95 %10 = OpFunction %2 None %5
96 %11 = OpLabel
97 OpReturnValue %7
98 OpFunctionEnd
99 )";
100 Options options;
101 DoStringDiffTest(kSrc, kDst, kDiff, options);
102 }
103
104 TEST(DiffTest, FunctionGroupByMappedIdNoDebug) {
105 constexpr char kSrcNoDebug[] = R"( OpCapability Shader
106 OpCapability Linkage
107 OpMemoryModel Logical GLSL450
108 %void = OpTypeVoid
109 %1 = OpTypeInt 32 0
110 %2 = OpTypeInt 32 1
111
112 %fn_uint = OpTypeFunction %1
113 %fn_int = OpTypeFunction %2
114
115 %uint_42 = OpConstant %1 42
116 %int_1729 = OpConstant %2 1729
117
118 %f = OpFunction %1 None %fn_uint
119 %f_prologue = OpLabel
120 OpReturnValue %uint_42
121 OpFunctionEnd
122
123 %g = OpFunction %2 None %fn_int
124 %g_prologue = OpLabel
125 OpReturnValue %int_1729
126 OpFunctionEnd
127 )";
128 constexpr char kDstNoDebug[] = R"( OpCapability Shader
129 OpCapability Linkage
130 OpMemoryModel Logical GLSL450
131 %void = OpTypeVoid
132 %2 = OpTypeInt 32 0
133 %1 = OpTypeInt 32 1
134
135 %fn_uint = OpTypeFunction %2
136 %fn_int = OpTypeFunction %1
137
138 %uint_42 = OpConstant %2 42
139 %int_1729 = OpConstant %1 1729
140
141 %f = OpFunction %2 None %fn_uint
142 %f_prologue = OpLabel
143 OpReturnValue %uint_42
144 OpFunctionEnd
145
146 %g = OpFunction %1 None %fn_int
147 %g_prologue = OpLabel
148 OpReturnValue %int_1729
149 OpFunctionEnd
150 )";
151 constexpr char kDiff[] = R"( ; SPIR-V
152 ; Version: 1.6
153 ; Generator: Khronos SPIR-V Tools Assembler; 0
154 ; Bound: 12
155 ; Schema: 0
156 OpCapability Shader
157 OpCapability Linkage
158 OpMemoryModel Logical GLSL450
159 %3 = OpTypeVoid
160 %1 = OpTypeInt 32 0
161 %2 = OpTypeInt 32 1
162 %4 = OpTypeFunction %1
163 %5 = OpTypeFunction %2
164 %6 = OpConstant %1 42
165 %7 = OpConstant %2 1729
166 %8 = OpFunction %1 None %4
167 %9 = OpLabel
168 OpReturnValue %6
169 OpFunctionEnd
170 %10 = OpFunction %2 None %5
171 %11 = OpLabel
172 OpReturnValue %7
173 OpFunctionEnd
174 )";
175 Options options;
176 DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options);
177 }
178
179 } // namespace
180 } // namespace diff
181 } // namespace spvtools