Debian Codegraph @

test/diff/diff_files/string_in_ext_inst_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
20 #include "gtest/gtest.h"
21
22 namespace spvtools {
23 namespace diff {
24 namespace {
25
26 // Tests a diff where the an OpString is used only as parameter of OpExtInst.
27 constexpr char kSrc[] = R"( OpCapability Shader
28 OpExtension "SPV_KHR_non_semantic_info"
29 %1 = OpExtInstImport "GLSL.std.450"
30 %12 = OpExtInstImport "NonSemantic.DebugPrintf"
31 OpMemoryModel Logical GLSL450
32 OpEntryPoint GLCompute %main "main"
33 OpExecutionMode %main LocalSize 1 1 1
34 %10 = OpString "unsigned == %u"
35 OpSource GLSL 450
36 OpSourceExtension "GL_EXT_debug_printf"
37 OpName %main "main"
38 OpName %foo "foo"
39 %void = OpTypeVoid
40 %3 = OpTypeFunction %void
41 %uint = OpTypeInt 32 0
42 %_ptr_Function_uint = OpTypePointer Function %uint
43 %uint_127 = OpConstant %uint 127
44 %main = OpFunction %void None %3
45 %5 = OpLabel
46 %foo = OpVariable %_ptr_Function_uint Function
47 OpStore %foo %uint_127
48 %11 = OpLoad %uint %foo
49 %13 = OpExtInst %void %12 1 %10 %11
50 OpReturn
51 OpFunctionEnd)";
52 constexpr char kDst[] = R"( OpCapability Shader
53 OpExtension "SPV_KHR_non_semantic_info"
54 %1 = OpExtInstImport "GLSL.std.450"
55 %12 = OpExtInstImport "NonSemantic.DebugPrintf"
56 OpMemoryModel Logical GLSL450
57 OpEntryPoint GLCompute %main "main"
58 OpExecutionMode %main LocalSize 1 1 1
59 %10 = OpString "signed == %d"
60 OpSource GLSL 450
61 OpSourceExtension "GL_EXT_debug_printf"
62 OpName %main "main"
63 OpName %foo "foo"
64 %void = OpTypeVoid
65 %3 = OpTypeFunction %void
66 %uint = OpTypeInt 32 0
67 %_ptr_Function_uint = OpTypePointer Function %uint
68 %uint_127 = OpConstant %uint 127
69 %main = OpFunction %void None %3
70 %5 = OpLabel
71 %foo = OpVariable %_ptr_Function_uint Function
72 OpStore %foo %uint_127
73 %11 = OpLoad %uint %foo
74 %13 = OpExtInst %void %12 1 %10 %11
75 OpReturn
76 OpFunctionEnd
77 )";
78
79 TEST(DiffTest, StringInExtInst) {
80 constexpr char kDiff[] = R"( ; SPIR-V
81 ; Version: 1.6
82 ; Generator: Khronos SPIR-V Tools Assembler; 0
83 -; Bound: 14
84 +; Bound: 15
85 ; Schema: 0
86 OpCapability Shader
87 OpExtension "SPV_KHR_non_semantic_info"
88 %1 = OpExtInstImport "GLSL.std.450"
89 %12 = OpExtInstImport "NonSemantic.DebugPrintf"
90 OpMemoryModel Logical GLSL450
91 OpEntryPoint GLCompute %2 "main"
92 OpExecutionMode %2 LocalSize 1 1 1
93 -%10 = OpString "unsigned == %u"
94 +%14 = OpString "signed == %d"
95 OpSource GLSL 450
96 OpSourceExtension "GL_EXT_debug_printf"
97 OpName %2 "main"
98 OpName %4 "foo"
99 %6 = OpTypeVoid
100 %3 = OpTypeFunction %6
101 %7 = OpTypeInt 32 0
102 %8 = OpTypePointer Function %7
103 %9 = OpConstant %7 127
104 %2 = OpFunction %6 None %3
105 %5 = OpLabel
106 %4 = OpVariable %8 Function
107 OpStore %4 %9
108 %11 = OpLoad %7 %4
109 -%13 = OpExtInst %6 %12 1 %10 %11
110 +%13 = OpExtInst %6 %12 1 %14 %11
111 OpReturn
112 OpFunctionEnd
113 )";
114 Options options;
115 DoStringDiffTest(kSrc, kDst, kDiff, options);
116 }
117
118 TEST(DiffTest, StringInExtInstNoDebug) {
119 constexpr char kSrcNoDebug[] = R"( OpCapability Shader
120 OpExtension "SPV_KHR_non_semantic_info"
121 %1 = OpExtInstImport "GLSL.std.450"
122 %12 = OpExtInstImport "NonSemantic.DebugPrintf"
123 OpMemoryModel Logical GLSL450
124 OpEntryPoint GLCompute %main "main"
125 OpExecutionMode %main LocalSize 1 1 1
126 %10 = OpString "unsigned == %u"
127 OpSource GLSL 450
128 OpSourceExtension "GL_EXT_debug_printf"
129 %void = OpTypeVoid
130 %3 = OpTypeFunction %void
131 %uint = OpTypeInt 32 0
132 %_ptr_Function_uint = OpTypePointer Function %uint
133 %uint_127 = OpConstant %uint 127
134 %main = OpFunction %void None %3
135 %5 = OpLabel
136 %foo = OpVariable %_ptr_Function_uint Function
137 OpStore %foo %uint_127
138 %11 = OpLoad %uint %foo
139 %13 = OpExtInst %void %12 1 %10 %11
140 OpReturn
141 OpFunctionEnd
142 )";
143 constexpr char kDstNoDebug[] = R"( OpCapability Shader
144 OpExtension "SPV_KHR_non_semantic_info"
145 %1 = OpExtInstImport "GLSL.std.450"
146 %12 = OpExtInstImport "NonSemantic.DebugPrintf"
147 OpMemoryModel Logical GLSL450
148 OpEntryPoint GLCompute %main "main"
149 OpExecutionMode %main LocalSize 1 1 1
150 %10 = OpString "signed == %d"
151 OpSource GLSL 450
152 OpSourceExtension "GL_EXT_debug_printf"
153 %void = OpTypeVoid
154 %3 = OpTypeFunction %void
155 %uint = OpTypeInt 32 0
156 %_ptr_Function_uint = OpTypePointer Function %uint
157 %uint_127 = OpConstant %uint 127
158 %main = OpFunction %void None %3
159 %5 = OpLabel
160 %foo = OpVariable %_ptr_Function_uint Function
161 OpStore %foo %uint_127
162 %11 = OpLoad %uint %foo
163 %13 = OpExtInst %void %12 1 %10 %11
164 OpReturn
165 OpFunctionEnd
166 )";
167 constexpr char kDiff[] = R"( ; SPIR-V
168 ; Version: 1.6
169 ; Generator: Khronos SPIR-V Tools Assembler; 0
170 -; Bound: 14
171 +; Bound: 15
172 ; Schema: 0
173 OpCapability Shader
174 OpExtension "SPV_KHR_non_semantic_info"
175 %1 = OpExtInstImport "GLSL.std.450"
176 %12 = OpExtInstImport "NonSemantic.DebugPrintf"
177 OpMemoryModel Logical GLSL450
178 OpEntryPoint GLCompute %2 "main"
179 OpExecutionMode %2 LocalSize 1 1 1
180 -%10 = OpString "unsigned == %u"
181 +%14 = OpString "signed == %d"
182 OpSource GLSL 450
183 OpSourceExtension "GL_EXT_debug_printf"
184 %4 = OpTypeVoid
185 %3 = OpTypeFunction %4
186 %6 = OpTypeInt 32 0
187 %7 = OpTypePointer Function %6
188 %8 = OpConstant %6 127
189 %2 = OpFunction %4 None %3
190 %5 = OpLabel
191 %9 = OpVariable %7 Function
192 OpStore %9 %8
193 %11 = OpLoad %6 %9
194 -%13 = OpExtInst %4 %12 1 %10 %11
195 +%13 = OpExtInst %4 %12 1 %14 %11
196 OpReturn
197 OpFunctionEnd
198 )";
199 Options options;
200 DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options);
201 }
202
203 } // namespace
204 } // namespace diff
205 } // namespace spvtools