mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-10 17:29:44 +00:00
merge two large parallel loops in EmitConvertToMCInst, no change
in the generated .inc files. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118083 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a1a45fd254
commit
dda855de8b
@ -1139,49 +1139,73 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
|
|||||||
// Build the conversion function signature.
|
// Build the conversion function signature.
|
||||||
std::string Signature = "Convert";
|
std::string Signature = "Convert";
|
||||||
unsigned CurIndex = 0;
|
unsigned CurIndex = 0;
|
||||||
|
|
||||||
|
std::string CaseBody;
|
||||||
|
raw_string_ostream CaseOS(CaseBody);
|
||||||
|
|
||||||
|
// Compute the convert enum and the case body.
|
||||||
for (unsigned i = 0, e = MIOperandList.size(); i != e; ++i) {
|
for (unsigned i = 0, e = MIOperandList.size(); i != e; ++i) {
|
||||||
MatchableInfo::Operand &Op = II.AsmOperands[MIOperandList[i].second];
|
MatchableInfo::Operand &Op = II.AsmOperands[MIOperandList[i].second];
|
||||||
assert(CurIndex <= Op.OperandInfo->MIOperandNo &&
|
assert(CurIndex <= Op.OperandInfo->MIOperandNo &&
|
||||||
"Duplicate match for instruction operand!");
|
"Duplicate match for instruction operand!");
|
||||||
|
|
||||||
// Skip operands which weren't matched by anything, this occurs when the
|
// Add the implicit operands.
|
||||||
// .td file encodes "implicit" operands as explicit ones.
|
|
||||||
//
|
|
||||||
// FIXME: This should be removed from the MCInst structure.
|
|
||||||
for (; CurIndex != Op.OperandInfo->MIOperandNo; ++CurIndex) {
|
for (; CurIndex != Op.OperandInfo->MIOperandNo; ++CurIndex) {
|
||||||
|
// See if this is a tied operand.
|
||||||
std::pair<unsigned, unsigned> *Tie = GetTiedOperandAtIndex(TiedOperands,
|
std::pair<unsigned, unsigned> *Tie = GetTiedOperandAtIndex(TiedOperands,
|
||||||
CurIndex);
|
CurIndex);
|
||||||
if (!Tie)
|
|
||||||
|
if (!Tie) {
|
||||||
|
// If not, this is some implicit operand. Just assume it is a register
|
||||||
|
// for now.
|
||||||
|
CaseOS << " Inst.addOperand(MCOperand::CreateReg(0));\n";
|
||||||
Signature += "__Imp";
|
Signature += "__Imp";
|
||||||
else
|
} else {
|
||||||
|
// Copy the tied operand.
|
||||||
|
assert(Tie->first>Tie->second && "Tied operand preceeds its target!");
|
||||||
|
CaseOS << " Inst.addOperand(Inst.getOperand("
|
||||||
|
<< Tie->second << "));\n";
|
||||||
Signature += "__Tie" + utostr(Tie->second);
|
Signature += "__Tie" + utostr(Tie->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Signature += "__";
|
|
||||||
|
|
||||||
// Registers are always converted the same, don't duplicate the conversion
|
// Registers are always converted the same, don't duplicate the conversion
|
||||||
// function based on them.
|
// function based on them.
|
||||||
//
|
//
|
||||||
// FIXME: We could generalize this based on the render method, if it
|
// FIXME: We could generalize this based on the render method, if it
|
||||||
// mattered.
|
// mattered.
|
||||||
|
Signature += "__";
|
||||||
if (Op.Class->isRegisterClass())
|
if (Op.Class->isRegisterClass())
|
||||||
Signature += "Reg";
|
Signature += "Reg";
|
||||||
else
|
else
|
||||||
Signature += Op.Class->ClassName;
|
Signature += Op.Class->ClassName;
|
||||||
Signature += utostr(Op.OperandInfo->MINumOperands);
|
Signature += utostr(Op.OperandInfo->MINumOperands);
|
||||||
Signature += "_" + utostr(MIOperandList[i].second);
|
Signature += "_" + utostr(MIOperandList[i].second);
|
||||||
|
|
||||||
|
|
||||||
|
CaseOS << " ((" << TargetOperandClass << "*)Operands["
|
||||||
|
<< MIOperandList[i].second << "+1])->" << Op.Class->RenderMethod
|
||||||
|
<< "(Inst, " << Op.OperandInfo->MINumOperands << ");\n";
|
||||||
CurIndex += Op.OperandInfo->MINumOperands;
|
CurIndex += Op.OperandInfo->MINumOperands;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add any trailing implicit operands.
|
// And add trailing implicit operands.
|
||||||
for (; CurIndex != NumMIOperands; ++CurIndex) {
|
for (; CurIndex != NumMIOperands; ++CurIndex) {
|
||||||
std::pair<unsigned, unsigned> *Tie = GetTiedOperandAtIndex(TiedOperands,
|
std::pair<unsigned, unsigned> *Tie = GetTiedOperandAtIndex(TiedOperands,
|
||||||
CurIndex);
|
CurIndex);
|
||||||
if (!Tie)
|
|
||||||
|
if (!Tie) {
|
||||||
|
// If not, this is some implicit operand. Just assume it is a register
|
||||||
|
// for now.
|
||||||
|
CaseOS << " Inst.addOperand(MCOperand::CreateReg(0));\n";
|
||||||
Signature += "__Imp";
|
Signature += "__Imp";
|
||||||
else
|
} else {
|
||||||
|
// Copy the tied operand.
|
||||||
|
assert(Tie->first>Tie->second && "Tied operand preceeds its target!");
|
||||||
|
CaseOS << " Inst.addOperand(Inst.getOperand("
|
||||||
|
<< Tie->second << "));\n";
|
||||||
Signature += "__Tie" + utostr(Tie->second);
|
Signature += "__Tie" + utostr(Tie->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
II.ConversionFnKind = Signature;
|
II.ConversionFnKind = Signature;
|
||||||
@ -1190,59 +1214,11 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
|
|||||||
if (!GeneratedFns.insert(Signature).second)
|
if (!GeneratedFns.insert(Signature).second)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If not, emit it now.
|
// If not, emit it now. Add to the enum list.
|
||||||
|
|
||||||
// Add to the enum list.
|
|
||||||
OS << " " << Signature << ",\n";
|
OS << " " << Signature << ",\n";
|
||||||
|
|
||||||
// And to the convert function.
|
|
||||||
CvtOS << " case " << Signature << ":\n";
|
CvtOS << " case " << Signature << ":\n";
|
||||||
CurIndex = 0;
|
CvtOS << CaseOS.str();
|
||||||
for (unsigned i = 0, e = MIOperandList.size(); i != e; ++i) {
|
|
||||||
MatchableInfo::Operand &Op = II.AsmOperands[MIOperandList[i].second];
|
|
||||||
|
|
||||||
// Add the implicit operands.
|
|
||||||
for (; CurIndex != Op.OperandInfo->MIOperandNo; ++CurIndex) {
|
|
||||||
// See if this is a tied operand.
|
|
||||||
std::pair<unsigned, unsigned> *Tie = GetTiedOperandAtIndex(TiedOperands,
|
|
||||||
CurIndex);
|
|
||||||
|
|
||||||
if (!Tie) {
|
|
||||||
// If not, this is some implicit operand. Just assume it is a register
|
|
||||||
// for now.
|
|
||||||
CvtOS << " Inst.addOperand(MCOperand::CreateReg(0));\n";
|
|
||||||
} else {
|
|
||||||
// Copy the tied operand.
|
|
||||||
assert(Tie->first>Tie->second && "Tied operand preceeds its target!");
|
|
||||||
CvtOS << " Inst.addOperand(Inst.getOperand("
|
|
||||||
<< Tie->second << "));\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CvtOS << " ((" << TargetOperandClass << "*)Operands["
|
|
||||||
<< MIOperandList[i].second
|
|
||||||
<< "+1])->" << Op.Class->RenderMethod
|
|
||||||
<< "(Inst, " << Op.OperandInfo->MINumOperands << ");\n";
|
|
||||||
CurIndex += Op.OperandInfo->MINumOperands;
|
|
||||||
}
|
|
||||||
|
|
||||||
// And add trailing implicit operands.
|
|
||||||
for (; CurIndex != NumMIOperands; ++CurIndex) {
|
|
||||||
std::pair<unsigned, unsigned> *Tie = GetTiedOperandAtIndex(TiedOperands,
|
|
||||||
CurIndex);
|
|
||||||
|
|
||||||
if (!Tie) {
|
|
||||||
// If not, this is some implicit operand. Just assume it is a register
|
|
||||||
// for now.
|
|
||||||
CvtOS << " Inst.addOperand(MCOperand::CreateReg(0));\n";
|
|
||||||
} else {
|
|
||||||
// Copy the tied operand.
|
|
||||||
assert(Tie->first>Tie->second && "Tied operand preceeds its target!");
|
|
||||||
CvtOS << " Inst.addOperand(Inst.getOperand("
|
|
||||||
<< Tie->second << "));\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CvtOS << " return;\n";
|
CvtOS << " return;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user