blob: 608d11992bef501934133d2a1d8372125b999fd6 [file] [log] [blame]
David Neto59de6102017-12-03 12:30:08 -05001// Copyright (c) 2017 Google Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#include "unit_spirv.h"
16
17#include <gmock/gmock.h>
18#include "DebugInfo.h"
19#include "test_fixture.h"
20
21// This file tests the correctness of encoding and decoding of instructions
22// involving the DebugInfo extended instruction set.
23// Semantic correctness should be the responsibility of validator.
24//
25// See https://www.khronos.org/registry/spir-v/specs/1.0/DebugInfo.html
26
27namespace {
28
29using spvtest::Concatenate;
30using spvtest::MakeInstruction;
31using spvtest::MakeVector;
32using testing::Eq;
33
34struct InstructionCase {
35 uint32_t opcode;
36 std::string name;
37 std::string operands;
38 std::vector<uint32_t> expected_operands;
39};
40
41using ExtInstDebugInfoRoundTripTest =
42 spvtest::TextToBinaryTestBase<::testing::TestWithParam<InstructionCase>>;
43using ExtInstDebugInfoRoundTripTestExplicit = spvtest::TextToBinaryTest;
44
45TEST_P(ExtInstDebugInfoRoundTripTest, ParameterizedExtInst) {
46 const std::string input =
47 "%1 = OpExtInstImport \"DebugInfo\"\n"
48 "%3 = OpExtInst %2 %1 " +
49 GetParam().name + GetParam().operands + "\n";
50 // First make sure it assembles correctly.
51 EXPECT_THAT(
52 CompiledInstructions(input),
53 Eq(Concatenate(
54 {MakeInstruction(SpvOpExtInstImport, {1}, MakeVector("DebugInfo")),
55 MakeInstruction(SpvOpExtInst, {2, 3, 1, GetParam().opcode},
56 GetParam().expected_operands)})))
57 << input;
58 // Now check the round trip through the disassembler.
59 EXPECT_THAT(EncodeAndDecodeSuccessfully(input), input) << input;
60}
61
62#define CASE_0(Enum) \
63 { \
64 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, "", {} \
65 }
66
67#define CASE_ILL(Enum, L0, L1) \
68 { \
69 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 " #L0 " " #L1, { \
70 4, L0, L1 \
71 } \
72 }
73
74#define CASE_IL(Enum, L0) \
75 { \
76 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 " #L0, { 4, L0 } \
77 }
78
79#define CASE_I(Enum) \
80 { \
81 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4", { 4 } \
82 }
83
84#define CASE_II(Enum) \
85 { \
86 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 %5", { 4, 5 } \
87 }
88
89#define CASE_III(Enum) \
90 { \
91 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 %5 %6", { 4, 5, 6 } \
92 }
93
94#define CASE_IIII(Enum) \
95 { \
96 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 %5 %6 %7", { \
97 4, 5, 6, 7 \
98 } \
99 }
100
101#define CASE_IIIII(Enum) \
102 { \
103 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 %5 %6 %7 %8", { \
104 4, 5, 6, 7, 8 \
105 } \
106 }
107
108#define CASE_IIIIII(Enum) \
109 { \
110 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 %5 %6 %7 %8 %9", { \
111 4, 5, 6, 7, 8, 9 \
112 } \
113 }
114
115#define CASE_IIIIIII(Enum) \
116 { \
117 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 %5 %6 %7 %8 %9 %10", { \
118 4, 5, 6, 7, 8, 9, 10 \
119 } \
120 }
121
122#define CASE_IIILLI(Enum, L0, L1) \
123 { \
124 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
125 " %4 %5 %6 " #L0 " " #L1 " %7", { \
126 4, 5, 6, L0, L1, 7 \
127 } \
128 }
129
130#define CASE_IIILLIL(Enum, L0, L1, L2) \
131 { \
132 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
133 " %4 %5 %6 " #L0 " " #L1 " %7 " #L2, { \
134 4, 5, 6, L0, L1, 7, L2 \
135 } \
136 }
137
138#define CASE_IE(Enum, E0) \
139 { \
140 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 " #E0, { \
141 4, uint32_t(DebugInfo##E0) \
142 } \
143 }
144
145#define CASE_IIE(Enum, E0) \
146 { \
147 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 %5 " #E0, { \
148 4, 5, uint32_t(DebugInfo##E0) \
149 } \
150 }
151
152#define CASE_ISF(Enum, S0, Fstr, Fnum) \
153 { \
154 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 " #S0 " " Fstr, { \
155 4, uint32_t(SpvStorageClass##S0), Fnum \
156 } \
157 }
158
159#define CASE_LII(Enum, L0) \
160 { \
161 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " " #L0 " %4 %5", { \
162 L0, 4, 5 \
163 } \
164 }
165
166#define CASE_ILI(Enum, L0) \
167 { \
168 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 " #L0 " %5", { \
169 4, L0, 5 \
170 } \
171 }
172
173#define CASE_ILII(Enum, L0) \
174 { \
175 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 " #L0 " %5 %6", { \
176 4, L0, 5, 6 \
177 } \
178 }
179
180#define CASE_ILLII(Enum, L0, L1) \
181 { \
182 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
183 " %4 " #L0 " " #L1 " %5 %6", { \
184 4, L0, L1, 5, 6 \
185 } \
186 }
187
188#define CASE_IIILLIIF(Enum, L0, L1, Fstr, Fnum) \
189 { \
190 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
191 " %4 %5 %6 " #L0 " " #L1 " %7 %8 " Fstr, { \
192 4, 5, 6, L0, L1, 7, 8, Fnum \
193 } \
194 }
195
196#define CASE_IIILLIIFII(Enum, L0, L1, Fstr, Fnum) \
197 { \
198 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
199 " %4 %5 %6 " #L0 " " #L1 " %7 %8 " Fstr " %9 %10", { \
200 4, 5, 6, L0, L1, 7, 8, Fnum, 9, 10 \
201 } \
202 }
203
204#define CASE_IIILLIIFIIII(Enum, L0, L1, Fstr, Fnum) \
205 { \
206 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
207 " %4 %5 %6 " #L0 " " #L1 " %7 %8 " Fstr " %9 %10 %11 %12", { \
208 4, 5, 6, L0, L1, 7, 8, Fnum, 9, 10, 11, 12 \
209 } \
210 }
211
212#define CASE_IIILLIIFIIIIII(Enum, L0, L1, Fstr, Fnum) \
213 { \
214 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
215 " %4 %5 %6 " #L0 " " #L1 " %7 %8 " Fstr " %9 %10 %11 %12 %13 %14", { \
216 4, 5, 6, L0, L1, 7, 8, Fnum, 9, 10, 11, 12, 13, 14 \
217 } \
218 }
219
220#define CASE_IEILLIIF(Enum, E0, L0, L1, Fstr, Fnum) \
221 { \
222 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
223 " %4 " #E0 " %5 " #L0 " " #L1 " %6 %7 " Fstr, { \
224 4, uint32_t(DebugInfo##E0), 5, L0, L1, 6, 7, Fnum \
225 } \
226 }
227
228#define CASE_IEILLIIFI(Enum, E0, L0, L1, Fstr, Fnum) \
229 { \
230 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
231 " %4 " #E0 " %5 " #L0 " " #L1 " %6 %7 " Fstr " %8", { \
232 4, uint32_t(DebugInfo##E0), 5, L0, L1, 6, 7, Fnum, 8 \
233 } \
234 }
235
236#define CASE_IEILLIIFII(Enum, E0, L0, L1, Fstr, Fnum) \
237 { \
238 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
239 " %4 " #E0 " %5 " #L0 " " #L1 " %6 %7 " Fstr " %8 %9", { \
240 4, uint32_t(DebugInfo##E0), 5, L0, L1, 6, 7, Fnum, 8, 9 \
241 } \
242 }
243
244#define CASE_IEILLIIFIII(Enum, E0, L0, L1, Fstr, Fnum) \
245 { \
246 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
247 " %4 " #E0 " %5 " #L0 " " #L1 " %6 %7 " Fstr " %8 %9 %10", { \
248 4, uint32_t(DebugInfo##E0), 5, L0, L1, 6, 7, Fnum, 8, 9, 10 \
249 } \
250 }
251
252#define CASE_IEILLIIFIIII(Enum, E0, L0, L1, Fstr, Fnum) \
253 { \
254 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
255 " %4 " #E0 " %5 " #L0 " " #L1 " %6 %7 " Fstr " %8 %9 %10 %11", { \
256 4, uint32_t(DebugInfo##E0), 5, L0, L1, 6, 7, Fnum, 8, 9, 10, 11 \
257 } \
258 }
259
260#define CASE_IIILLIIIF(Enum, L0, L1, Fstr, Fnum) \
261 { \
262 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
263 " %4 %5 %6 " #L0 " " #L1 " %7 %8 %9 " Fstr, { \
264 4, 5, 6, L0, L1, 7, 8, 9, Fnum \
265 } \
266 }
267
268#define CASE_IIILLIIIFI(Enum, L0, L1, Fstr, Fnum) \
269 { \
270 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
271 " %4 %5 %6 " #L0 " " #L1 " %7 %8 %9 " Fstr " %10", { \
272 4, 5, 6, L0, L1, 7, 8, 9, Fnum, 10 \
273 } \
274 }
275
276#define CASE_IIIIF(Enum, Fstr, Fnum) \
277 { \
278 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 %5 %6 %7 " Fstr, { \
279 4, 5, 6, 7, Fnum \
280 } \
281 }
282
283#define CASE_IIILL(Enum, L0, L1) \
284 { \
285 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 %5 %6 " #L0 " " #L1, { \
286 4, 5, 6, L0, L1 \
287 } \
288 }
289
290#define CASE_IIIILL(Enum, L0, L1) \
291 { \
292 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
293 " %4 %5 %6 %7 " #L0 " " #L1, { \
294 4, 5, 6, 7, L0, L1 \
295 } \
296 }
297
298#define CASE_IILLI(Enum, L0, L1) \
299 { \
300 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
301 " %4 %5 " #L0 " " #L1 " %6", { \
302 4, 5, L0, L1, 6 \
303 } \
304 }
305
306#define CASE_IILLII(Enum, L0, L1) \
307 { \
308 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
309 " %4 %5 " #L0 " " #L1 " %6 %7", { \
310 4, 5, L0, L1, 6, 7 \
311 } \
312 }
313
314#define CASE_IILLIII(Enum, L0, L1) \
315 { \
316 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
317 " %4 %5 " #L0 " " #L1 " %6 %7 %8", { \
318 4, 5, L0, L1, 6, 7, 8 \
319 } \
320 }
321
322#define CASE_IILLIIII(Enum, L0, L1) \
323 { \
324 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
325 " %4 %5 " #L0 " " #L1 " %6 %7 %8 %9", { \
326 4, 5, L0, L1, 6, 7, 8, 9 \
327 } \
328 }
329
330#define CASE_IIILLIIFLI(Enum, L0, L1, Fstr, Fnum, L2) \
331 { \
332 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
333 " %4 %5 %6 " #L0 " " #L1 " %7 %8 " Fstr " " #L2 " %9", { \
334 4, 5, 6, L0, L1, 7, 8, Fnum, L2, 9 \
335 } \
336 }
337
338#define CASE_IIILLIIFLII(Enum, L0, L1, Fstr, Fnum, L2) \
339 { \
340 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, \
341 " %4 %5 %6 " #L0 " " #L1 " %7 %8 " Fstr " " #L2 " %9 %10", { \
342 4, 5, 6, L0, L1, 7, 8, Fnum, L2, 9, 10 \
343 } \
344 }
345
346#define CASE_E(Enum, E0) \
347 { \
348 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " " #E0, { \
349 uint32_t(DebugInfo##E0) \
350 } \
351 }
352
353#define CASE_EL(Enum, E0, L0) \
354 { \
355 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " " #E0 " " #L0, { \
356 uint32_t(DebugInfo##E0), L0 \
357 } \
358 }
359
360#define CASE_ELL(Enum, E0, L0, L1) \
361 { \
362 uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " " #E0 " " #L0 " " #L1, { \
363 uint32_t(DebugInfo##E0), L0, L1 \
364 } \
365 }
366
367// DebugInfo 4.1 Absent Debugging Information
368INSTANTIATE_TEST_CASE_P(DebugInfoDebugInfoNone, ExtInstDebugInfoRoundTripTest,
369 ::testing::ValuesIn(std::vector<InstructionCase>({
370 CASE_0(InfoNone), // enum value 0
371 })), );
372
373// DebugInfo 4.2 Compilation Unit
374INSTANTIATE_TEST_CASE_P(DebugInfoDebugCompilationUnit,
375 ExtInstDebugInfoRoundTripTest,
376 ::testing::ValuesIn(std::vector<InstructionCase>({
377 CASE_ILL(CompilationUnit, 100, 42),
378 })), );
379
380// DebugInfo 4.3 Type instructions
381INSTANTIATE_TEST_CASE_P(DebugInfoDebugTypeBasic, ExtInstDebugInfoRoundTripTest,
382 ::testing::ValuesIn(std::vector<InstructionCase>({
383 CASE_IIE(TypeBasic, Unspecified),
384 CASE_IIE(TypeBasic, Address),
385 CASE_IIE(TypeBasic, Boolean),
386 CASE_IIE(TypeBasic, Float),
387 CASE_IIE(TypeBasic, Signed),
388 CASE_IIE(TypeBasic, SignedChar),
389 CASE_IIE(TypeBasic, Unsigned),
390 CASE_IIE(TypeBasic, UnsignedChar),
391 })), );
392
393// The FlagIsPublic is value is (1 << 0) | (1 << 2) which is the same
394// as the bitwise-OR of FlagIsProtected and FlagIsPrivate.
395// The disassembler will emit the compound expression instead.
396// There is no simple fix for this. This enum is not really a mask
397// for the bottom two bits.
398TEST_F(ExtInstDebugInfoRoundTripTestExplicit, FlagIsPublic) {
399 const std::string prefix =
400 "%1 = OpExtInstImport \"DebugInfo\"\n"
401 "%3 = OpExtInst %2 %1 DebugTypePointer %4 Private ";
402 const std::string input = prefix + "FlagIsPublic\n";
403 const std::string expected = prefix + "FlagIsProtected|FlagIsPrivate\n";
404 // First make sure it assembles correctly.
405 EXPECT_THAT(
406 CompiledInstructions(input),
407 Eq(Concatenate(
408 {MakeInstruction(SpvOpExtInstImport, {1}, MakeVector("DebugInfo")),
409 MakeInstruction(SpvOpExtInst, {2, 3, 1, DebugInfoDebugTypePointer, 4,
410 uint32_t(SpvStorageClassPrivate),
411 DebugInfoFlagIsPublic})})))
412 << input;
413 // Now check the round trip through the disassembler.
414 EXPECT_THAT(EncodeAndDecodeSuccessfully(input), Eq(expected)) << input;
415}
416
417INSTANTIATE_TEST_CASE_P(
418 DebugInfoDebugTypePointer, ExtInstDebugInfoRoundTripTest,
419 ::testing::ValuesIn(std::vector<InstructionCase>({
420
421 //// Use each flag independently.
422 CASE_ISF(TypePointer, Private, "FlagIsProtected",
423 uint32_t(DebugInfoFlagIsProtected)),
424 CASE_ISF(TypePointer, Private, "FlagIsPrivate",
425 uint32_t(DebugInfoFlagIsPrivate)),
426
427 // FlagIsPublic is tested above.
428
429 CASE_ISF(TypePointer, Private, "FlagIsLocal",
430 uint32_t(DebugInfoFlagIsLocal)),
431 CASE_ISF(TypePointer, Private, "FlagIsDefinition",
432 uint32_t(DebugInfoFlagIsDefinition)),
433 CASE_ISF(TypePointer, Private, "FlagFwdDecl",
434 uint32_t(DebugInfoFlagFwdDecl)),
435 CASE_ISF(TypePointer, Private, "FlagArtificial",
436 uint32_t(DebugInfoFlagArtificial)),
437 CASE_ISF(TypePointer, Private, "FlagExplicit",
438 uint32_t(DebugInfoFlagExplicit)),
439 CASE_ISF(TypePointer, Private, "FlagPrototyped",
440 uint32_t(DebugInfoFlagPrototyped)),
441 CASE_ISF(TypePointer, Private, "FlagObjectPointer",
442 uint32_t(DebugInfoFlagObjectPointer)),
443 CASE_ISF(TypePointer, Private, "FlagStaticMember",
444 uint32_t(DebugInfoFlagStaticMember)),
445 CASE_ISF(TypePointer, Private, "FlagIndirectVariable",
446 uint32_t(DebugInfoFlagIndirectVariable)),
447 CASE_ISF(TypePointer, Private, "FlagLValueReference",
448 uint32_t(DebugInfoFlagLValueReference)),
449 CASE_ISF(TypePointer, Private, "FlagIsOptimized",
450 uint32_t(DebugInfoFlagIsOptimized)),
451
452 //// Use flags in combination, and try different storage classes.
453 CASE_ISF(TypePointer, Function, "FlagIsProtected|FlagIsPrivate",
454 uint32_t(DebugInfoFlagIsProtected) |
455 uint32_t(DebugInfoFlagIsPrivate)),
456 CASE_ISF(
457 TypePointer, Workgroup,
458 "FlagIsPrivate|FlagFwdDecl|FlagIndirectVariable|FlagIsOptimized",
459 uint32_t(DebugInfoFlagIsPrivate) | uint32_t(DebugInfoFlagFwdDecl) |
460 uint32_t(DebugInfoFlagIndirectVariable) |
461 uint32_t(DebugInfoFlagIsOptimized)),
462
463 })), );
464
465INSTANTIATE_TEST_CASE_P(DebugInfoDebugTypeQualifier,
466 ExtInstDebugInfoRoundTripTest,
467 ::testing::ValuesIn(std::vector<InstructionCase>({
468 CASE_IE(TypeQualifier, ConstType),
469 CASE_IE(TypeQualifier, VolatileType),
470 CASE_IE(TypeQualifier, RestrictType),
471 })), );
472
473INSTANTIATE_TEST_CASE_P(DebugInfoDebugTypeArray, ExtInstDebugInfoRoundTripTest,
474 ::testing::ValuesIn(std::vector<InstructionCase>({
475 CASE_II(TypeArray),
476 CASE_III(TypeArray),
477 CASE_IIII(TypeArray),
478 CASE_IIIII(TypeArray),
479 })), );
480
481INSTANTIATE_TEST_CASE_P(DebugInfoDebugTypeVector, ExtInstDebugInfoRoundTripTest,
482 ::testing::ValuesIn(std::vector<InstructionCase>({
483 CASE_IL(TypeVector, 2),
484 CASE_IL(TypeVector, 3),
485 CASE_IL(TypeVector, 4),
486 CASE_IL(TypeVector, 16),
487 })), );
488
489INSTANTIATE_TEST_CASE_P(DebugInfoDebugTypedef, ExtInstDebugInfoRoundTripTest,
490 ::testing::ValuesIn(std::vector<InstructionCase>({
491 CASE_IIILLI(Typedef, 12, 13),
492 CASE_IIILLI(Typedef, 14, 99),
493 })), );
494
495INSTANTIATE_TEST_CASE_P(DebugInfoDebugTypeFunction,
496 ExtInstDebugInfoRoundTripTest,
497 ::testing::ValuesIn(std::vector<InstructionCase>({
498 CASE_I(TypeFunction),
499 CASE_II(TypeFunction),
500 CASE_III(TypeFunction),
501 CASE_IIII(TypeFunction),
502 CASE_IIIII(TypeFunction),
503 })), );
504
505INSTANTIATE_TEST_CASE_P(
506 DebugInfoDebugTypeEnum, ExtInstDebugInfoRoundTripTest,
507 ::testing::ValuesIn(std::vector<InstructionCase>({
508 CASE_IIILLIIFII(
509 TypeEnum, 12, 13,
510 "FlagIsPrivate|FlagFwdDecl|FlagIndirectVariable|FlagIsOptimized",
511 uint32_t(DebugInfoFlagIsPrivate) | uint32_t(DebugInfoFlagFwdDecl) |
512 uint32_t(DebugInfoFlagIndirectVariable) |
513 uint32_t(DebugInfoFlagIsOptimized)),
514 CASE_IIILLIIFIIII(TypeEnum, 17, 18, "FlagStaticMember",
515 uint32_t(DebugInfoFlagStaticMember)),
516 CASE_IIILLIIFIIIIII(TypeEnum, 99, 1, "FlagStaticMember",
517 uint32_t(DebugInfoFlagStaticMember)),
518 })), );
519
520INSTANTIATE_TEST_CASE_P(
521 DebugInfoDebugTypeComposite, ExtInstDebugInfoRoundTripTest,
522 ::testing::ValuesIn(std::vector<InstructionCase>({
523 CASE_IEILLIIF(
524 TypeComposite, Class, 12, 13,
525 "FlagIsPrivate|FlagFwdDecl|FlagIndirectVariable|FlagIsOptimized",
526 uint32_t(DebugInfoFlagIsPrivate) | uint32_t(DebugInfoFlagFwdDecl) |
527 uint32_t(DebugInfoFlagIndirectVariable) |
528 uint32_t(DebugInfoFlagIsOptimized)),
529 // Cover all tag values: Class, Structure, Union
530 CASE_IEILLIIF(TypeComposite, Class, 12, 13, "FlagIsPrivate",
531 uint32_t(DebugInfoFlagIsPrivate)),
532 CASE_IEILLIIF(TypeComposite, Structure, 12, 13, "FlagIsPrivate",
533 uint32_t(DebugInfoFlagIsPrivate)),
534 CASE_IEILLIIF(TypeComposite, Union, 12, 13, "FlagIsPrivate",
535 uint32_t(DebugInfoFlagIsPrivate)),
536 // Now add members
537 CASE_IEILLIIFI(TypeComposite, Class, 9, 10, "FlagIsPrivate",
538 uint32_t(DebugInfoFlagIsPrivate)),
539 CASE_IEILLIIFII(TypeComposite, Class, 9, 10, "FlagIsPrivate",
540 uint32_t(DebugInfoFlagIsPrivate)),
541 CASE_IEILLIIFIII(TypeComposite, Class, 9, 10, "FlagIsPrivate",
542 uint32_t(DebugInfoFlagIsPrivate)),
543 CASE_IEILLIIFIIII(TypeComposite, Class, 9, 10, "FlagIsPrivate",
544 uint32_t(DebugInfoFlagIsPrivate)),
545 })), );
546
547INSTANTIATE_TEST_CASE_P(DebugInfoDebugTypeMember, ExtInstDebugInfoRoundTripTest,
548 ::testing::ValuesIn(std::vector<InstructionCase>({
549 CASE_IIILLIIIF(TypeMember, 12, 13, "FlagIsPrivate",
550 uint32_t(DebugInfoFlagIsPrivate)),
551 CASE_IIILLIIIF(TypeMember, 99, 100,
552 "FlagIsPrivate|FlagFwdDecl",
553 uint32_t(DebugInfoFlagIsPrivate) |
554 uint32_t(DebugInfoFlagFwdDecl)),
555 // Add the optional Id argument.
556 CASE_IIILLIIIFI(TypeMember, 12, 13, "FlagIsPrivate",
557 uint32_t(DebugInfoFlagIsPrivate)),
558 })), );
559
560INSTANTIATE_TEST_CASE_P(
561 DebugInfoDebugTypeInheritance, ExtInstDebugInfoRoundTripTest,
562 ::testing::ValuesIn(std::vector<InstructionCase>({
563 CASE_IIIIF(TypeInheritance, "FlagIsPrivate",
564 uint32_t(DebugInfoFlagIsPrivate)),
565 CASE_IIIIF(TypeInheritance, "FlagIsPrivate|FlagFwdDecl",
566 uint32_t(DebugInfoFlagIsPrivate) |
567 uint32_t(DebugInfoFlagFwdDecl)),
568 })), );
569
570INSTANTIATE_TEST_CASE_P(DebugInfoDebugTypePtrToMember,
571 ExtInstDebugInfoRoundTripTest,
572 ::testing::ValuesIn(std::vector<InstructionCase>({
573 CASE_II(TypePtrToMember),
574 })), );
575
576// DebugInfo 4.4 Templates
577
578INSTANTIATE_TEST_CASE_P(DebugInfoDebugTypeTemplate,
579 ExtInstDebugInfoRoundTripTest,
580 ::testing::ValuesIn(std::vector<InstructionCase>({
581 CASE_II(TypeTemplate),
582 CASE_III(TypeTemplate),
583 CASE_IIII(TypeTemplate),
584 CASE_IIIII(TypeTemplate),
585 })), );
586
587INSTANTIATE_TEST_CASE_P(DebugInfoDebugTypeTemplateParameter,
588 ExtInstDebugInfoRoundTripTest,
589 ::testing::ValuesIn(std::vector<InstructionCase>({
590 CASE_IIIILL(TypeTemplateParameter, 1, 2),
591 CASE_IIIILL(TypeTemplateParameter, 99, 102),
592 CASE_IIIILL(TypeTemplateParameter, 10, 7),
593 })), );
594
595INSTANTIATE_TEST_CASE_P(DebugInfoDebugTypeTemplateTemplateParameter,
596 ExtInstDebugInfoRoundTripTest,
597 ::testing::ValuesIn(std::vector<InstructionCase>({
598 CASE_IIILL(TypeTemplateTemplateParameter, 1, 2),
599 CASE_IIILL(TypeTemplateTemplateParameter, 99, 102),
600 CASE_IIILL(TypeTemplateTemplateParameter, 10, 7),
601 })), );
602
603INSTANTIATE_TEST_CASE_P(DebugInfoDebugTypeTemplateParameterPack,
604 ExtInstDebugInfoRoundTripTest,
605 ::testing::ValuesIn(std::vector<InstructionCase>({
606 CASE_IILLI(TypeTemplateParameterPack, 1, 2),
607 CASE_IILLII(TypeTemplateParameterPack, 99, 102),
608 CASE_IILLIII(TypeTemplateParameterPack, 10, 7),
609 CASE_IILLIIII(TypeTemplateParameterPack, 10, 7),
610 })), );
611
612// DebugInfo 4.5 Global Variables
613
614INSTANTIATE_TEST_CASE_P(
615 DebugInfoDebugGlobalVariable, ExtInstDebugInfoRoundTripTest,
616 ::testing::ValuesIn(std::vector<InstructionCase>({
617 CASE_IIILLIIIF(GlobalVariable, 1, 2, "FlagIsOptimized",
618 uint32_t(DebugInfoFlagIsOptimized)),
619 CASE_IIILLIIIF(GlobalVariable, 42, 43, "FlagIsOptimized",
620 uint32_t(DebugInfoFlagIsOptimized)),
621 CASE_IIILLIIIFI(GlobalVariable, 1, 2, "FlagIsOptimized",
622 uint32_t(DebugInfoFlagIsOptimized)),
623 CASE_IIILLIIIFI(GlobalVariable, 42, 43, "FlagIsOptimized",
624 uint32_t(DebugInfoFlagIsOptimized)),
625 })), );
626
627// DebugInfo 4.6 Functions
628
629INSTANTIATE_TEST_CASE_P(
630 DebugInfoDebugFunctionDeclaration, ExtInstDebugInfoRoundTripTest,
631 ::testing::ValuesIn(std::vector<InstructionCase>({
632 CASE_IIILLIIF(FunctionDeclaration, 1, 2, "FlagIsOptimized",
633 uint32_t(DebugInfoFlagIsOptimized)),
634 CASE_IIILLIIF(FunctionDeclaration, 42, 43, "FlagFwdDecl",
635 uint32_t(DebugInfoFlagFwdDecl)),
636 })), );
637
638INSTANTIATE_TEST_CASE_P(
639 DebugInfoDebugFunction, ExtInstDebugInfoRoundTripTest,
640 ::testing::ValuesIn(std::vector<InstructionCase>({
641 CASE_IIILLIIFLI(Function, 1, 2, "FlagIsOptimized",
642 uint32_t(DebugInfoFlagIsOptimized), 3),
643 CASE_IIILLIIFLI(Function, 42, 43, "FlagFwdDecl",
644 uint32_t(DebugInfoFlagFwdDecl), 44),
645 // Add the optional declaration Id.
646 CASE_IIILLIIFLII(Function, 1, 2, "FlagIsOptimized",
647 uint32_t(DebugInfoFlagIsOptimized), 3),
648 CASE_IIILLIIFLII(Function, 42, 43, "FlagFwdDecl",
649 uint32_t(DebugInfoFlagFwdDecl), 44),
650 })), );
651
652// DebugInfo 4.7 Local Information
653
654INSTANTIATE_TEST_CASE_P(DebugInfoDebugLexicalBlock,
655 ExtInstDebugInfoRoundTripTest,
656 ::testing::ValuesIn(std::vector<InstructionCase>({
657 CASE_ILLII(LexicalBlock, 1, 2),
658 CASE_ILLII(LexicalBlock, 42, 43),
659 })), );
660
661INSTANTIATE_TEST_CASE_P(DebugInfoDebugLexicalBlockDiscriminator,
662 ExtInstDebugInfoRoundTripTest,
663 ::testing::ValuesIn(std::vector<InstructionCase>({
664 CASE_ILI(LexicalBlockDiscriminator, 1),
665 CASE_ILI(LexicalBlockDiscriminator, 42),
666 })), );
667
668INSTANTIATE_TEST_CASE_P(DebugInfoDebugScope, ExtInstDebugInfoRoundTripTest,
669 ::testing::ValuesIn(std::vector<InstructionCase>({
670 CASE_I(Scope),
671 CASE_II(Scope),
672 })), );
673
674INSTANTIATE_TEST_CASE_P(DebugInfoDebugNoScope, ExtInstDebugInfoRoundTripTest,
675 ::testing::ValuesIn(std::vector<InstructionCase>({
676 CASE_0(NoScope),
677 })), );
678
679INSTANTIATE_TEST_CASE_P(DebugInfoDebugInlinedAt, ExtInstDebugInfoRoundTripTest,
680 ::testing::ValuesIn(std::vector<InstructionCase>({
681 CASE_LII(InlinedAt, 1),
682 CASE_LII(InlinedAt, 42),
683 })), );
684
685// DebugInfo 4.8 Local Variables
686
687INSTANTIATE_TEST_CASE_P(DebugInfoDebugLocalVariable,
688 ExtInstDebugInfoRoundTripTest,
689 ::testing::ValuesIn(std::vector<InstructionCase>({
690 CASE_IIILLI(LocalVariable, 1, 2),
691 CASE_IIILLI(LocalVariable, 42, 43),
692 CASE_IIILLIL(LocalVariable, 1, 2, 3),
693 CASE_IIILLIL(LocalVariable, 42, 43, 44),
694 })), );
695
696INSTANTIATE_TEST_CASE_P(DebugInfoDebugInlinedVariable,
697 ExtInstDebugInfoRoundTripTest,
698 ::testing::ValuesIn(std::vector<InstructionCase>({
699 CASE_II(InlinedVariable),
700 })), );
701
702INSTANTIATE_TEST_CASE_P(DebugInfoDebugDebugDeclare,
703 ExtInstDebugInfoRoundTripTest,
704 ::testing::ValuesIn(std::vector<InstructionCase>({
705 CASE_III(Declare),
706 })), );
707
708INSTANTIATE_TEST_CASE_P(
709 DebugInfoDebugDebugValue, ExtInstDebugInfoRoundTripTest,
710 ::testing::ValuesIn(std::vector<InstructionCase>({
711 CASE_III(Value),
712 CASE_IIII(Value),
713 CASE_IIIII(Value),
714 CASE_IIIIII(Value),
715 // Test up to 4 id parameters. We can always try more.
716 CASE_IIIIIII(Value),
717 })), );
718
719INSTANTIATE_TEST_CASE_P(DebugInfoDebugDebugOperation,
720 ExtInstDebugInfoRoundTripTest,
721 ::testing::ValuesIn(std::vector<InstructionCase>({
722 CASE_E(Operation, Deref),
723 CASE_E(Operation, Plus),
724 CASE_E(Operation, Minus),
725 CASE_EL(Operation, PlusUconst, 1),
726 CASE_EL(Operation, PlusUconst, 42),
727 CASE_ELL(Operation, BitPiece, 1, 2),
728 CASE_ELL(Operation, BitPiece, 4, 5),
729 CASE_E(Operation, Swap),
730 CASE_E(Operation, Xderef),
731 CASE_E(Operation, StackValue),
732 CASE_EL(Operation, Constu, 1),
733 CASE_EL(Operation, Constu, 42),
734 })), );
735
736INSTANTIATE_TEST_CASE_P(DebugInfoDebugDebugExpression,
737 ExtInstDebugInfoRoundTripTest,
738 ::testing::ValuesIn(std::vector<InstructionCase>({
739 CASE_0(Expression),
740 CASE_I(Expression),
741 CASE_II(Expression),
742 CASE_III(Expression),
743 CASE_IIII(Expression),
744 CASE_IIIII(Expression),
745 CASE_IIIIII(Expression),
746 CASE_IIIIIII(Expression),
747 })), );
748
749// DebugInfo 4.9 Macros
750
751INSTANTIATE_TEST_CASE_P(DebugInfoDebugMacroDef, ExtInstDebugInfoRoundTripTest,
752 ::testing::ValuesIn(std::vector<InstructionCase>({
753 CASE_ILI(MacroDef, 1),
754 CASE_ILI(MacroDef, 42),
755 CASE_ILII(MacroDef, 1),
756 CASE_ILII(MacroDef, 42),
757 })), );
758
759INSTANTIATE_TEST_CASE_P(DebugInfoDebugMacroUndef, ExtInstDebugInfoRoundTripTest,
760 ::testing::ValuesIn(std::vector<InstructionCase>({
761 CASE_ILI(MacroUndef, 1),
762 CASE_ILI(MacroUndef, 42),
763 })), );
764
765#undef CASE_0
766#undef CASE_ILL
767#undef CASE_IL
768#undef CASE_I
769#undef CASE_II
770#undef CASE_III
771#undef CASE_IIII
772#undef CASE_IIIII
773#undef CASE_IIIIII
774#undef CASE_IIIIIII
775#undef CASE_IIILLI
776#undef CASE_IIILLIL
777#undef CASE_IE
778#undef CASE_IIE
779#undef CASE_ISF
780#undef CASE_LII
781#undef CASE_ILI
782#undef CASE_ILII
783#undef CASE_ILLII
784#undef CASE_IIILLIIF
785#undef CASE_IIILLIIFII
786#undef CASE_IIILLIIFIIII
787#undef CASE_IIILLIIFIIIIII
788#undef CASE_IEILLIIF
789#undef CASE_IEILLIIFI
790#undef CASE_IEILLIIFII
791#undef CASE_IEILLIIFIII
792#undef CASE_IEILLIIFIIII
793#undef CASE_IIILLIIIF
794#undef CASE_IIILLIIIFI
795#undef CASE_IIIIF
796#undef CASE_IIILL
797#undef CASE_IIIILL
798#undef CASE_IILLI
799#undef CASE_IILLII
800#undef CASE_IILLIII
801#undef CASE_IILLIIII
802#undef CASE_IIILLIIFLI
803#undef CASE_IIILLIIFLII
804#undef CASE_E
805#undef CASE_EL
806#undef CASE_ELL
807
808} // anonymous namespace