Teach the table generated emitPseudoExpansionLowering function to not emit a switch statement containing only a default statement (and no cases). Updated some of the code to use range-based for loops as well. No functional changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209521 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Aaron Ballman 2014-05-23 15:33:39 +00:00
parent a4df7d473f
commit 2bd2c560ee

View File

@ -200,11 +200,12 @@ void PseudoLoweringEmitter::emitLoweringEmitter(raw_ostream &o) {
o << "bool " << Target.getName() + "AsmPrinter" << "::\n"
<< "emitPseudoExpansionLowering(MCStreamer &OutStreamer,\n"
<< " const MachineInstr *MI) {\n"
<< " switch (MI->getOpcode()) {\n"
<< " const MachineInstr *MI) {\n";
if (!Expansions.empty()) {
o << " switch (MI->getOpcode()) {\n"
<< " default: return false;\n";
for (unsigned i = 0, e = Expansions.size(); i != e; ++i) {
PseudoExpansion &Expansion = Expansions[i];
for (auto &Expansion : Expansions) {
CodeGenInstruction &Source = Expansion.Source;
CodeGenInstruction &Dest = Expansion.Dest;
o << " case " << Source.Namespace << "::"
@ -219,11 +220,9 @@ void PseudoLoweringEmitter::emitLoweringEmitter(raw_ostream &o) {
// in ARM, for example shouldn't need explicit values in the
// expansion DAG.
unsigned MIOpNo = 0;
for (unsigned OpNo = 0, E = Dest.Operands.size(); OpNo != E;
++OpNo) {
o << " // Operand: " << Dest.Operands[OpNo].Name << "\n";
for (unsigned i = 0, e = Dest.Operands[OpNo].MINumOperands;
i != e; ++i) {
for (const auto &DestOperand : Dest.Operands) {
o << " // Operand: " << DestOperand.Name << "\n";
for (unsigned i = 0, e = DestOperand.MINumOperands; i != e; ++i) {
switch (Expansion.OperandMap[MIOpNo + i].Kind) {
case OpData::Operand:
o << " lowerOperand(MI->getOperand("
@ -243,13 +242,14 @@ void PseudoLoweringEmitter::emitLoweringEmitter(raw_ostream &o) {
if (Reg->getName() == "zero_reg")
o << "0";
else
o << Reg->getValueAsString("Namespace") << "::" << Reg->getName();
o << Reg->getValueAsString("Namespace") << "::"
<< Reg->getName();
o << "));\n";
break;
}
}
}
MIOpNo += Dest.Operands[OpNo].MINumOperands;
MIOpNo += DestOperand.MINumOperands;
}
if (Dest.Operands.isVariadic) {
MIOpNo = Source.Operands.size() + 1;
@ -263,7 +263,11 @@ void PseudoLoweringEmitter::emitLoweringEmitter(raw_ostream &o) {
<< " break;\n"
<< " }\n";
}
o << " }\n return true;\n}\n\n";
o << " }\n return true;";
} else
o << " return false;";
o << "\n}\n\n";
}
void PseudoLoweringEmitter::run(raw_ostream &o) {