@@ -429,34 +429,26 @@ static std::string getAttributeMaskString(const SmallVector<Record *> Recs) {
429
429
return MaskString;
430
430
}
431
431
432
- // / Emit Enums of DXIL Ops
433
- // / \param A vector of DXIL Ops
434
- // / \param Output stream
435
- static void emitDXILEnums (std::vector<DXILOperationDesc> &Ops,
436
- raw_ostream &OS) {
437
- OS << " #ifdef DXIL_OP_ENUM\n\n " ;
438
- OS << " // Enumeration for operations specified by DXIL\n " ;
439
- OS << " enum class OpCode : unsigned {\n " ;
440
-
441
- for (auto &Op : Ops) {
442
- // Name = ID, // Doc
443
- OS << Op.OpName << " = " << Op.OpCode << " , // " << Op.Doc << " \n " ;
444
- }
445
-
446
- OS << " \n };\n\n " ;
432
+ // / Emit a mapping of DXIL opcode to opname
433
+ static void emitDXILOpCodes (std::vector<DXILOperationDesc> &Ops,
434
+ raw_ostream &OS) {
435
+ OS << " #ifdef DXIL_OPCODE\n " ;
436
+ for (const DXILOperationDesc &Op : Ops)
437
+ OS << " DXIL_OPCODE(" << Op.OpCode << " , " << Op.OpName << " )\n " ;
438
+ OS << " #undef DXIL_OPCODE\n " ;
439
+ OS << " \n " ;
440
+ OS << " #endif\n\n " ;
441
+ }
447
442
448
- OS << " // Groups for DXIL operations with equivalent function templates\n " ;
449
- OS << " enum class OpCodeClass : unsigned {\n " ;
450
- // Build an OpClass set to print
451
- SmallSet<StringRef, 2 > OpClassSet;
452
- for (auto &Op : Ops) {
453
- OpClassSet.insert (Op.OpClass );
454
- }
455
- for (auto &C : OpClassSet) {
456
- OS << C << " ,\n " ;
457
- }
458
- OS << " \n };\n\n " ;
459
- OS << " #undef DXIL_OP_ENUM\n " ;
443
+ // / Emit a list of DXIL op classes
444
+ static void emitDXILOpClasses (RecordKeeper &Records,
445
+ raw_ostream &OS) {
446
+ OS << " #ifdef DXIL_OPCLASS\n " ;
447
+ std::vector<Record *> OpClasses =
448
+ Records.getAllDerivedDefinitions (" DXILOpClass" );
449
+ for (Record *OpClass : OpClasses)
450
+ OS << " DXIL_OPCLASS(" << OpClass->getName () << " )\n " ;
451
+ OS << " #undef DXIL_OPCLASS\n " ;
460
452
OS << " #endif\n\n " ;
461
453
}
462
454
@@ -652,7 +644,8 @@ static void EmitDXILOperation(RecordKeeper &Records, raw_ostream &OS) {
652
644
PrevOp = Desc.OpCode ;
653
645
}
654
646
655
- emitDXILEnums (DXILOps, OS);
647
+ emitDXILOpCodes (DXILOps, OS);
648
+ emitDXILOpClasses (Records, OS);
656
649
emitDXILIntrinsicMap (DXILOps, OS);
657
650
OS << " #ifdef DXIL_OP_OPERATION_TABLE\n\n " ;
658
651
emitDXILOperationTableDataStructs (Records, OS);
0 commit comments