MCPcopy Create free account
hub / github.com/NVIDIA/cuda-tile / generateOpcodeMap

Function generateOpcodeMap

tools/cuda-tile-tblgen/BytecodeGen.cpp:198–229  ·  view source on GitHub ↗

Generates the opcode map implementation from TableGen records

Source from the content-addressed store, hash-verified

196
197/// Generates the opcode map implementation from TableGen records
198static void generateOpcodeMap(const RecordKeeper &records, raw_ostream &os) {
199 emitSourceFileHeader("Generated Opcode Map", os);
200
201 // Get all BytecodeOpcode records.
202 auto opcodeRecords = records.getAllDerivedDefinitions("BytecodeOpcode");
203
204 os << "namespace mlir {\n"
205 << "namespace cuda_tile {\n"
206 << "namespace Bytecode {\n\n"
207 << "const llvm::StringMap<Opcode> &getOpcodeMap() {\n"
208 << " static const llvm::StringMap<Opcode> opcodeMap = {\n"
209 << " // === PUBLIC OPERATIONS ===\n"
210 << " // These mappings are FROZEN and must never change for backward\n"
211 << " // compatibility.\n";
212
213 // Generate public operation mappings.
214 for (const Record *record : opcodeRecords) {
215 if (record->isSubClassOf("PublicOpcode")) {
216 const Record *opRecord = record->getValueAsDef("operation");
217 Operator op(opRecord);
218 os << " {\"" << op.getOperationName()
219 << "\", Opcode::" << op.getCppClassName() << "},\n";
220 }
221 }
222
223 os << " };\n"
224 << " return opcodeMap;\n"
225 << "}\n\n"
226 << "} // namespace Bytecode\n"
227 << "} // namespace cuda_tile\n"
228 << "} // namespace mlir\n";
229}
230
231/// Generates the C++ function signature for the 'write<OpName>' function,
232/// which handles serialization for a specific cuda_tile operation.

Callers 1

generateOpcodesFunction · 0.85

Calls 1

getOperationNameMethod · 0.45

Tested by

no test coverage detected