@@ -325,8 +325,7 @@ static std::string getAttributeMaskString(const SmallVector<Record *> Recs) {
325
325
}
326
326
327
327
// / Emit a mapping of DXIL opcode to opname
328
- static void emitDXILOpCodes (std::vector<DXILOperationDesc> &Ops,
329
- raw_ostream &OS) {
328
+ static void emitDXILOpCodes (ArrayRef<DXILOperationDesc> Ops, raw_ostream &OS) {
330
329
OS << " #ifdef DXIL_OPCODE\n " ;
331
330
for (const DXILOperationDesc &Op : Ops)
332
331
OS << " DXIL_OPCODE(" << Op.OpCode << " , " << Op.OpName << " )\n " ;
@@ -336,23 +335,20 @@ static void emitDXILOpCodes(std::vector<DXILOperationDesc> &Ops,
336
335
}
337
336
338
337
// / Emit a list of DXIL op classes
339
- static void emitDXILOpClasses (RecordKeeper &Records, raw_ostream &OS) {
338
+ static void emitDXILOpClasses (const RecordKeeper &Records, raw_ostream &OS) {
340
339
OS << " #ifdef DXIL_OPCLASS\n " ;
341
- std::vector<Record *> OpClasses =
342
- Records.getAllDerivedDefinitions (" DXILOpClass" );
343
- for (Record *OpClass : OpClasses)
340
+ for (const Record *OpClass : Records.getAllDerivedDefinitions (" DXILOpClass" ))
344
341
OS << " DXIL_OPCLASS(" << OpClass->getName () << " )\n " ;
345
342
OS << " #undef DXIL_OPCLASS\n " ;
346
343
OS << " #endif\n\n " ;
347
344
}
348
345
349
346
// / Emit a list of DXIL op parameter types
350
- static void emitDXILOpParamTypes (RecordKeeper &Records, raw_ostream &OS) {
347
+ static void emitDXILOpParamTypes (const RecordKeeper &Records, raw_ostream &OS) {
351
348
OS << " #ifdef DXIL_OP_PARAM_TYPE\n " ;
352
- std::vector<Record *> OpClasses =
353
- Records.getAllDerivedDefinitions (" DXILOpParamType" );
354
- for (Record *OpClass : OpClasses)
355
- OS << " DXIL_OP_PARAM_TYPE(" << OpClass->getName () << " )\n " ;
349
+ for (const Record *OpParamType :
350
+ Records.getAllDerivedDefinitions (" DXILOpParamType" ))
351
+ OS << " DXIL_OP_PARAM_TYPE(" << OpParamType->getName () << " )\n " ;
356
352
OS << " #undef DXIL_OP_PARAM_TYPE\n " ;
357
353
OS << " #endif\n\n " ;
358
354
}
@@ -378,7 +374,7 @@ static void emitDXILOpFunctionTypes(ArrayRef<DXILOperationDesc> Ops,
378
374
// / Emit map of DXIL operation to LLVM or DirectX intrinsic
379
375
// / \param A vector of DXIL Ops
380
376
// / \param Output stream
381
- static void emitDXILIntrinsicMap (std::vector <DXILOperationDesc> & Ops,
377
+ static void emitDXILIntrinsicMap (ArrayRef <DXILOperationDesc> Ops,
382
378
raw_ostream &OS) {
383
379
OS << " #ifdef DXIL_OP_INTRINSIC\n " ;
384
380
OS << " \n " ;
@@ -396,14 +392,14 @@ static void emitDXILIntrinsicMap(std::vector<DXILOperationDesc> &Ops,
396
392
// / Emit DXIL operation table
397
393
// / \param A vector of DXIL Ops
398
394
// / \param Output stream
399
- static void emitDXILOperationTable (std::vector <DXILOperationDesc> & Ops,
395
+ static void emitDXILOperationTable (ArrayRef <DXILOperationDesc> Ops,
400
396
raw_ostream &OS) {
401
397
// Collect Names.
402
398
SequenceToOffsetTable<std::string> OpClassStrings;
403
399
SequenceToOffsetTable<std::string> OpStrings;
404
400
405
401
StringSet<> ClassSet;
406
- for (auto &Op : Ops) {
402
+ for (const auto &Op : Ops) {
407
403
OpStrings.add (Op.OpName );
408
404
409
405
if (ClassSet.insert (Op.OpClass ).second )
@@ -421,7 +417,7 @@ static void emitDXILOperationTable(std::vector<DXILOperationDesc> &Ops,
421
417
422
418
OS << " static const OpCodeProperty OpCodeProps[] = {\n " ;
423
419
std::string Prefix = " " ;
424
- for (auto &Op : Ops) {
420
+ for (const auto &Op : Ops) {
425
421
OS << Prefix << " { dxil::OpCode::" << Op.OpName << " , "
426
422
<< OpStrings.get (Op.OpName ) << " , OpCodeClass::" << Op.OpClass << " , "
427
423
<< OpClassStrings.get (Op.OpClass .data ()) << " , "
@@ -469,14 +465,15 @@ static void emitDXILOperationTable(std::vector<DXILOperationDesc> &Ops,
469
465
OS << " }\n\n " ;
470
466
}
471
467
472
- static void emitDXILOperationTableDataStructs (RecordKeeper &Records,
468
+ static void emitDXILOperationTableDataStructs (const RecordKeeper &Records,
473
469
raw_ostream &OS) {
474
470
// Get Shader stage records
475
- std::vector<Record *> ShaderKindRecs =
471
+ std::vector<const Record *> ShaderKindRecs =
476
472
Records.getAllDerivedDefinitions (" DXILShaderStage" );
477
473
// Sort records by name
478
- llvm::sort (ShaderKindRecs,
479
- [](Record *A, Record *B) { return A->getName () < B->getName (); });
474
+ llvm::sort (ShaderKindRecs, [](const Record *A, const Record *B) {
475
+ return A->getName () < B->getName ();
476
+ });
480
477
481
478
OS << " // Valid shader kinds\n\n " ;
482
479
// Choose the type of enum ShaderKind based on the number of stages declared.
@@ -508,22 +505,21 @@ static void emitDXILOperationTableDataStructs(RecordKeeper &Records,
508
505
// / Entry function call that invokes the functionality of this TableGen backend
509
506
// / \param Records TableGen records of DXIL Operations defined in DXIL.td
510
507
// / \param OS output stream
511
- static void EmitDXILOperation (RecordKeeper &Records, raw_ostream &OS) {
508
+ static void EmitDXILOperation (const RecordKeeper &Records, raw_ostream &OS) {
512
509
OS << " // Generated code, do not edit.\n " ;
513
510
OS << " \n " ;
514
511
// Get all DXIL Ops property records
515
- std::vector<Record *> OpIntrProps =
516
- Records.getAllDerivedDefinitions (" DXILOp" );
517
512
std::vector<DXILOperationDesc> DXILOps;
518
- for (auto * Record : OpIntrProps ) {
519
- DXILOps.emplace_back (DXILOperationDesc (Record ));
513
+ for (const Record *R : Records. getAllDerivedDefinitions ( " DXILOp " ) ) {
514
+ DXILOps.emplace_back (DXILOperationDesc (R ));
520
515
}
521
516
// Sort by opcode.
522
- llvm::sort (DXILOps, [](DXILOperationDesc &A, DXILOperationDesc &B) {
523
- return A.OpCode < B.OpCode ;
524
- });
517
+ llvm::sort (DXILOps,
518
+ [](const DXILOperationDesc &A, const DXILOperationDesc &B) {
519
+ return A.OpCode < B.OpCode ;
520
+ });
525
521
int PrevOp = -1 ;
526
- for (DXILOperationDesc &Desc : DXILOps) {
522
+ for (const DXILOperationDesc &Desc : DXILOps) {
527
523
if (Desc.OpCode == PrevOp)
528
524
PrintFatalError (Twine (" Duplicate opcode: " ) + Twine (Desc.OpCode ));
529
525
PrevOp = Desc.OpCode ;
0 commit comments