12
12
// ===----------------------------------------------------------------------===//
13
13
#include " DXILRootSignature.h"
14
14
#include " DirectX.h"
15
- #include " llvm/ADT/STLForwardCompat.h"
16
15
#include " llvm/ADT/StringSwitch.h"
17
16
#include " llvm/ADT/Twine.h"
18
17
#include " llvm/Analysis/DXILMetadataAnalysis.h"
31
30
#include < cstdint>
32
31
#include < optional>
33
32
#include < utility>
34
- #include < variant>
35
33
36
34
using namespace llvm ;
37
35
using namespace llvm ::dxil;
@@ -227,10 +225,7 @@ static bool verifyRegisterSpace(uint32_t RegisterSpace) {
227
225
return !(RegisterSpace >= 0xFFFFFFF0 && RegisterSpace <= 0xFFFFFFFF );
228
226
}
229
227
230
- static bool verifyDescriptorFlag (uint32_t Flags) {
231
- return (Flags & ~0xE ) == 0 ;
232
- }
233
-
228
+ static bool verifyDescriptorFlag (uint32_t Flags) { return (Flags & ~0xE ) == 0 ; }
234
229
235
230
static bool validate (LLVMContext *Ctx, const mcdxbc::RootSignatureDesc &RSD) {
236
231
@@ -249,37 +244,38 @@ static bool validate(LLVMContext *Ctx, const mcdxbc::RootSignatureDesc &RSD) {
249
244
250
245
assert (dxbc::isValidParameterType (Info.Header .ParameterType ) &&
251
246
" Invalid value for ParameterType" );
252
-
253
-
247
+
254
248
auto P = RSD.ParametersContainer .getParameter (&Info);
255
- if (!P)
256
- return reportError (Ctx, " Cannot locate parameter from Header Info" );
257
-
258
- if ( std::holds_alternative<const dxbc::RTS0::v1::RootDescriptor *>(*P)){
259
- auto *Descriptor = std::get<const dxbc::RTS0::v1::RootDescriptor *>(P.value ());
249
+ if (!P)
250
+ return reportError (Ctx, " Cannot locate parameter from Header Info" );
251
+
252
+ if (std::holds_alternative<const dxbc::RTS0::v1::RootDescriptor *>(*P)) {
253
+ auto *Descriptor =
254
+ std::get<const dxbc::RTS0::v1::RootDescriptor *>(P.value ());
260
255
261
- if (!verifyRegisterValue (Descriptor->ShaderRegister ))
256
+ if (!verifyRegisterValue (Descriptor->ShaderRegister ))
262
257
return reportValueError (Ctx, " ShaderRegister" ,
263
258
Descriptor->ShaderRegister );
264
-
265
- if (!verifyRegisterSpace (Descriptor->RegisterSpace ))
259
+
260
+ if (!verifyRegisterSpace (Descriptor->RegisterSpace ))
266
261
return reportValueError (Ctx, " RegisterSpace" ,
267
262
Descriptor->RegisterSpace );
268
263
269
- } else if ( std::holds_alternative<const dxbc::RTS0::v2::RootDescriptor *>(*P)){
270
- auto *Descriptor = std::get<const dxbc::RTS0::v2::RootDescriptor *>(P.value ());
264
+ } else if (std::holds_alternative<const dxbc::RTS0::v2::RootDescriptor *>(
265
+ *P)) {
266
+ auto *Descriptor =
267
+ std::get<const dxbc::RTS0::v2::RootDescriptor *>(P.value ());
271
268
272
- if (!verifyRegisterValue (Descriptor->ShaderRegister ))
269
+ if (!verifyRegisterValue (Descriptor->ShaderRegister ))
273
270
return reportValueError (Ctx, " ShaderRegister" ,
274
271
Descriptor->ShaderRegister );
275
-
276
- if (!verifyRegisterSpace (Descriptor->RegisterSpace ))
272
+
273
+ if (!verifyRegisterSpace (Descriptor->RegisterSpace ))
277
274
return reportValueError (Ctx, " RegisterSpace" ,
278
275
Descriptor->RegisterSpace );
279
276
280
- if (!verifyDescriptorFlag (Descriptor->Flags ))
281
- return reportValueError (Ctx, " DescriptorFlag" ,
282
- Descriptor->Flags );
277
+ if (!verifyDescriptorFlag (Descriptor->Flags ))
278
+ return reportValueError (Ctx, " DescriptorFlag" , Descriptor->Flags );
283
279
}
284
280
}
285
281
@@ -417,20 +413,21 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
417
413
<< " Shader Register: " << Constants->ShaderRegister << " \n " ;
418
414
OS << indent (Space + 2 )
419
415
<< " Num 32 Bit Values: " << Constants->Num32BitValues << " \n " ;
420
- } else if (std::holds_alternative<const dxbc::RTS0::v1::RootDescriptor *>(*P)) {
416
+ } else if (std::holds_alternative<const dxbc::RTS0::v1::RootDescriptor *>(
417
+ *P)) {
421
418
auto *Constants = std::get<const dxbc::RTS0::v1::RootDescriptor *>(*P);
422
419
OS << indent (Space + 2 )
423
420
<< " Register Space: " << Constants->RegisterSpace << " \n " ;
424
421
OS << indent (Space + 2 )
425
422
<< " Shader Register: " << Constants->ShaderRegister << " \n " ;
426
- } else if (std::holds_alternative<const dxbc::RTS0::v2::RootDescriptor *>(*P)) {
423
+ } else if (std::holds_alternative<const dxbc::RTS0::v2::RootDescriptor *>(
424
+ *P)) {
427
425
auto *Constants = std::get<const dxbc::RTS0::v2::RootDescriptor *>(*P);
428
426
OS << indent (Space + 2 )
429
427
<< " Register Space: " << Constants->RegisterSpace << " \n " ;
430
428
OS << indent (Space + 2 )
431
429
<< " Shader Register: " << Constants->ShaderRegister << " \n " ;
432
- OS << indent (Space + 2 )
433
- << " Flags: " << Constants->Flags << " \n " ;
430
+ OS << indent (Space + 2 ) << " Flags: " << Constants->Flags << " \n " ;
434
431
}
435
432
}
436
433
Space--;
0 commit comments