@@ -325,8 +325,7 @@ static std::string getAttributeMaskString(const SmallVector<Record *> Recs) {
325325}
326326
327327// / 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) {
330329 OS << " #ifdef DXIL_OPCODE\n " ;
331330 for (const DXILOperationDesc &Op : Ops)
332331 OS << " DXIL_OPCODE(" << Op.OpCode << " , " << Op.OpName << " )\n " ;
@@ -336,23 +335,20 @@ static void emitDXILOpCodes(std::vector<DXILOperationDesc> &Ops,
336335}
337336
338337// / 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) {
340339 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" ))
344341 OS << " DXIL_OPCLASS(" << OpClass->getName () << " )\n " ;
345342 OS << " #undef DXIL_OPCLASS\n " ;
346343 OS << " #endif\n\n " ;
347344}
348345
349346// / 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) {
351348 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 " ;
356352 OS << " #undef DXIL_OP_PARAM_TYPE\n " ;
357353 OS << " #endif\n\n " ;
358354}
@@ -378,7 +374,7 @@ static void emitDXILOpFunctionTypes(ArrayRef<DXILOperationDesc> Ops,
378374// / Emit map of DXIL operation to LLVM or DirectX intrinsic
379375// / \param A vector of DXIL Ops
380376// / \param Output stream
381- static void emitDXILIntrinsicMap (std::vector <DXILOperationDesc> & Ops,
377+ static void emitDXILIntrinsicMap (ArrayRef <DXILOperationDesc> Ops,
382378 raw_ostream &OS) {
383379 OS << " #ifdef DXIL_OP_INTRINSIC\n " ;
384380 OS << " \n " ;
@@ -396,14 +392,14 @@ static void emitDXILIntrinsicMap(std::vector<DXILOperationDesc> &Ops,
396392// / Emit DXIL operation table
397393// / \param A vector of DXIL Ops
398394// / \param Output stream
399- static void emitDXILOperationTable (std::vector <DXILOperationDesc> & Ops,
395+ static void emitDXILOperationTable (ArrayRef <DXILOperationDesc> Ops,
400396 raw_ostream &OS) {
401397 // Collect Names.
402398 SequenceToOffsetTable<std::string> OpClassStrings;
403399 SequenceToOffsetTable<std::string> OpStrings;
404400
405401 StringSet<> ClassSet;
406- for (auto &Op : Ops) {
402+ for (const auto &Op : Ops) {
407403 OpStrings.add (Op.OpName );
408404
409405 if (ClassSet.insert (Op.OpClass ).second )
@@ -421,7 +417,7 @@ static void emitDXILOperationTable(std::vector<DXILOperationDesc> &Ops,
421417
422418 OS << " static const OpCodeProperty OpCodeProps[] = {\n " ;
423419 std::string Prefix = " " ;
424- for (auto &Op : Ops) {
420+ for (const auto &Op : Ops) {
425421 OS << Prefix << " { dxil::OpCode::" << Op.OpName << " , "
426422 << OpStrings.get (Op.OpName ) << " , OpCodeClass::" << Op.OpClass << " , "
427423 << OpClassStrings.get (Op.OpClass .data ()) << " , "
@@ -469,14 +465,15 @@ static void emitDXILOperationTable(std::vector<DXILOperationDesc> &Ops,
469465 OS << " }\n\n " ;
470466}
471467
472- static void emitDXILOperationTableDataStructs (RecordKeeper &Records,
468+ static void emitDXILOperationTableDataStructs (const RecordKeeper &Records,
473469 raw_ostream &OS) {
474470 // Get Shader stage records
475- std::vector<Record *> ShaderKindRecs =
471+ std::vector<const Record *> ShaderKindRecs =
476472 Records.getAllDerivedDefinitions (" DXILShaderStage" );
477473 // 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+ });
480477
481478 OS << " // Valid shader kinds\n\n " ;
482479 // Choose the type of enum ShaderKind based on the number of stages declared.
@@ -508,22 +505,21 @@ static void emitDXILOperationTableDataStructs(RecordKeeper &Records,
508505// / Entry function call that invokes the functionality of this TableGen backend
509506// / \param Records TableGen records of DXIL Operations defined in DXIL.td
510507// / \param OS output stream
511- static void EmitDXILOperation (RecordKeeper &Records, raw_ostream &OS) {
508+ static void EmitDXILOperation (const RecordKeeper &Records, raw_ostream &OS) {
512509 OS << " // Generated code, do not edit.\n " ;
513510 OS << " \n " ;
514511 // Get all DXIL Ops property records
515- std::vector<Record *> OpIntrProps =
516- Records.getAllDerivedDefinitions (" DXILOp" );
517512 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 ));
520515 }
521516 // 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+ });
525521 int PrevOp = -1 ;
526- for (DXILOperationDesc &Desc : DXILOps) {
522+ for (const DXILOperationDesc &Desc : DXILOps) {
527523 if (Desc.OpCode == PrevOp)
528524 PrintFatalError (Twine (" Duplicate opcode: " ) + Twine (Desc.OpCode ));
529525 PrevOp = Desc.OpCode ;
0 commit comments