Generates the C++ switch statement to dispatch based on opcode.
| 687 | |
| 688 | /// Generates the C++ switch statement to dispatch based on opcode. |
| 689 | static void generateOpReaderDispatch(const RecordKeeper &records, |
| 690 | raw_ostream &os) { |
| 691 | emitSourceFileHeader("Generated Bytecode Opcode Dispatcher", os); |
| 692 | auto opDefs = records.getAllDerivedDefinitions("Op"); |
| 693 | os << R"(switch (static_cast<Opcode>(opcode)) {)"; |
| 694 | for (const Record *opDef : opDefs) { |
| 695 | Operator op(opDef); |
| 696 | StringRef opClassName = op.getCppClassName(); |
| 697 | os << llvm::formatv(dispatchCaseTemplate, opClassName); |
| 698 | } |
| 699 | os << R"( default: |
| 700 | return reader.emitError() << "unknown or unimplemented opcode: " << static_cast<int>(opcode);})"; |
| 701 | os << R"(//===-------------------------------------------------------------------// |
| 702 | // End of generated dispatcher. |
| 703 | //===-------------------------------------------------------------------// |
| 704 | )"; |
| 705 | } |
| 706 | |
| 707 | /// The main entry point for the TableGen backend. |
| 708 | static bool generateBytecodeReader(const RecordKeeper &records, |
no outgoing calls
no test coverage detected