Skip to content

Commit a85d4ce

Browse files
committed
Revert ReportError refactor
1 parent f78f8b6 commit a85d4ce

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

llvm/utils/TableGen/CodeEmitterGen.cpp

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -447,16 +447,6 @@ void CodeEmitterGen::emitCaseMap(
447447
}
448448
}
449449

450-
static void ReportError(raw_ostream &O, indent Indent) {
451-
static constexpr char ReportErrorCode[] = R"(
452-
{0}std::string msg;
453-
{0}raw_string_ostream Msg(msg);
454-
{0}Msg << "Unsupported instruction: " << MI;
455-
{0}report_fatal_error(Msg.str().c_str());
456-
)";
457-
O << formatv(ReportErrorCode, Indent);
458-
}
459-
460450
void CodeEmitterGen::run(raw_ostream &O) {
461451
emitSourceFileHeader("Machine Code Emitter", O);
462452

@@ -540,12 +530,16 @@ void CodeEmitterGen::run(raw_ostream &O) {
540530
unsigned FirstSupportedOpcode = EncodedInstructions.front()->EnumVal;
541531
O << " constexpr unsigned FirstSupportedOpcode = " << FirstSupportedOpcode
542532
<< ";\n";
543-
544-
O << " const unsigned opcode = MI.getOpcode();\n";
545-
O << " if (opcode < FirstSupportedOpcode) {";
546-
ReportError(O, indent(4));
547-
O << " }\n";
548-
O << " unsigned TableIndex = opcode - FirstSupportedOpcode;\n";
533+
O << R"(
534+
const unsigned opcode = MI.getOpcode();
535+
if (opcode < FirstSupportedOpcode) {
536+
std::string msg;
537+
raw_string_ostream Msg(msg);
538+
Msg << "Unsupported instruction: " << MI;
539+
report_fatal_error(Msg.str().c_str());
540+
}
541+
unsigned TableIndex = opcode - FirstSupportedOpcode;
542+
)";
549543

550544
// Emit initial function code
551545
if (UseAPInt) {
@@ -567,10 +561,13 @@ void CodeEmitterGen::run(raw_ostream &O) {
567561
// Emit each case statement
568562
emitCaseMap(O, CaseMap);
569563

570-
// Default case: unhandled opcode
571-
O << " default:";
572-
ReportError(O, indent(4));
573-
O << " }\n";
564+
// Default case: unhandled opcode.
565+
O << " default:\n"
566+
<< " std::string msg;\n"
567+
<< " raw_string_ostream Msg(msg);\n"
568+
<< " Msg << \"Not supported instr: \" << MI;\n"
569+
<< " report_fatal_error(Msg.str().c_str());\n"
570+
<< " }\n";
574571
if (UseAPInt)
575572
O << " Inst = Value;\n";
576573
else
@@ -585,9 +582,13 @@ void CodeEmitterGen::run(raw_ostream &O) {
585582
<< " const MCSubtargetInfo &STI) const {\n"
586583
<< " switch (MI.getOpcode()) {\n";
587584
emitCaseMap(O, BitOffsetCaseMap);
588-
O << " }\n";
589-
ReportError(O, indent(2));
590-
O << "}\n\n"
585+
O << " }\n"
586+
<< " std::string msg;\n"
587+
<< " raw_string_ostream Msg(msg);\n"
588+
<< " Msg << \"Not supported instr[opcode]: \" << MI << \"[\" << OpNum "
589+
"<< \"]\";\n"
590+
<< " report_fatal_error(Msg.str().c_str());\n"
591+
<< "}\n\n"
591592
<< "#endif // GET_OPERAND_BIT_OFFSET\n\n";
592593
}
593594

0 commit comments

Comments
 (0)