Skip to content

Commit 88b6229

Browse files
authored
[TableGen] Remove unhelpful error messages from PseudoLoweringEmitter. (#135747)
All of the notes using the location of ResultInst will just print the location inside of the PseudoInstExpansion class. There was one note using the location of DI->getDef(), but knowing where one of the two mismatched types is defined isn't helpful. The operand types need to be the same, so the mismatch message we already printed should be enough.
1 parent d0e4af8 commit 88b6229

File tree

1 file changed

+25
-42
lines changed

1 file changed

+25
-42
lines changed

llvm/utils/TableGen/PseudoLoweringEmitter.cpp

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,12 @@ unsigned PseudoLoweringEmitter::addDagOperandMapping(
9090
// problem.
9191
// FIXME: We probably shouldn't ever get a non-zero BaseIdx here.
9292
assert(BaseIdx == 0 && "Named subargument in pseudo expansion?!");
93-
if (DI->getDef() != Insn.Operands[BaseIdx + i].Rec) {
94-
PrintError(Rec, "In pseudo instruction '" + Rec->getName() +
95-
"', operand type '" + DI->getDef()->getName() +
96-
"' does not match expansion operand type '" +
97-
Insn.Operands[BaseIdx + i].Rec->getName() + "'");
98-
PrintFatalNote(DI->getDef(),
99-
"Value was assigned at the following location:");
100-
}
93+
if (DI->getDef() != Insn.Operands[BaseIdx + i].Rec)
94+
PrintFatalError(Rec, "In pseudo instruction '" + Rec->getName() +
95+
"', operand type '" + DI->getDef()->getName() +
96+
"' does not match expansion operand type '" +
97+
Insn.Operands[BaseIdx + i].Rec->getName() +
98+
"'");
10199
// Source operand maps to destination operand. The Data element
102100
// will be filled in later, just set the Kind for now. Do it
103101
// for each corresponding MachineInstr operand, not just the first.
@@ -138,38 +136,26 @@ void PseudoLoweringEmitter::evaluateExpansion(const Record *Rec) {
138136
LLVM_DEBUG(dbgs() << " Result: " << *Dag << "\n");
139137

140138
const DefInit *OpDef = dyn_cast<DefInit>(Dag->getOperator());
141-
if (!OpDef) {
142-
PrintError(Rec, "In pseudo instruction '" + Rec->getName() +
143-
"', result operator is not a record");
144-
PrintFatalNote(Rec->getValue("ResultInst"),
145-
"Result was assigned at the following location:");
146-
}
139+
if (!OpDef)
140+
PrintFatalError(Rec, "In pseudo instruction '" + Rec->getName() +
141+
"', result operator is not a record");
147142
const Record *Operator = OpDef->getDef();
148-
if (!Operator->isSubClassOf("Instruction")) {
149-
PrintError(Rec, "In pseudo instruction '" + Rec->getName() +
150-
"', result operator '" + Operator->getName() +
151-
"' is not an instruction");
152-
PrintFatalNote(Rec->getValue("ResultInst"),
153-
"Result was assigned at the following location:");
154-
}
143+
if (!Operator->isSubClassOf("Instruction"))
144+
PrintFatalError(Rec, "In pseudo instruction '" + Rec->getName() +
145+
"', result operator '" + Operator->getName() +
146+
"' is not an instruction");
155147

156148
CodeGenInstruction Insn(Operator);
157149

158-
if (Insn.isCodeGenOnly || Insn.isPseudo) {
159-
PrintError(Rec, "In pseudo instruction '" + Rec->getName() +
160-
"', result operator '" + Operator->getName() +
161-
"' cannot be a pseudo instruction");
162-
PrintFatalNote(Rec->getValue("ResultInst"),
163-
"Result was assigned at the following location:");
164-
}
150+
if (Insn.isCodeGenOnly || Insn.isPseudo)
151+
PrintFatalError(Rec, "In pseudo instruction '" + Rec->getName() +
152+
"', result operator '" + Operator->getName() +
153+
"' cannot be a pseudo instruction");
165154

166-
if (Insn.Operands.size() != Dag->getNumArgs()) {
167-
PrintError(Rec, "In pseudo instruction '" + Rec->getName() +
168-
"', result operator '" + Operator->getName() +
169-
"' has the wrong number of operands");
170-
PrintFatalNote(Rec->getValue("ResultInst"),
171-
"Result was assigned at the following location:");
172-
}
155+
if (Insn.Operands.size() != Dag->getNumArgs())
156+
PrintFatalError(Rec, "In pseudo instruction '" + Rec->getName() +
157+
"', result operator '" + Operator->getName() +
158+
"' has the wrong number of operands");
173159

174160
unsigned NumMIOperands = 0;
175161
for (const auto &Op : Insn.Operands)
@@ -202,13 +188,10 @@ void PseudoLoweringEmitter::evaluateExpansion(const Record *Rec) {
202188
continue;
203189
StringMap<unsigned>::iterator SourceOp =
204190
SourceOperands.find(Dag->getArgNameStr(i));
205-
if (SourceOp == SourceOperands.end()) {
206-
PrintError(Rec, "In pseudo instruction '" + Rec->getName() +
207-
"', output operand '" + Dag->getArgNameStr(i) +
208-
"' has no matching source operand");
209-
PrintFatalNote(Rec->getValue("ResultInst"),
210-
"Value was assigned at the following location:");
211-
}
191+
if (SourceOp == SourceOperands.end())
192+
PrintFatalError(Rec, "In pseudo instruction '" + Rec->getName() +
193+
"', output operand '" + Dag->getArgNameStr(i) +
194+
"' has no matching source operand");
212195
// Map the source operand to the destination operand index for each
213196
// MachineInstr operand.
214197
for (unsigned I = 0, E = Insn.Operands[i].MINumOperands; I != E; ++I)

0 commit comments

Comments
 (0)