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