cleanups.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118228 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-11-04 01:55:23 +00:00
parent 567820c1e0
commit ba3b5b6382

View File

@ -370,6 +370,13 @@ struct MatchableInfo {
Record *getSingletonRegisterForAsmOperand(unsigned i, Record *getSingletonRegisterForAsmOperand(unsigned i,
const AsmMatcherInfo &Info) const; const AsmMatcherInfo &Info) const;
int FindAsmOperandNamed(StringRef N) const {
for (unsigned i = 0, e = AsmOperands.size(); i != e; ++i)
if (N == AsmOperands[i].SrcOpName)
return i;
return -1;
}
void BuildResultOperands(); void BuildResultOperands();
/// operator< - Compare two matchables. /// operator< - Compare two matchables.
@ -1129,27 +1136,29 @@ BuildInstructionOperandReference(MatchableInfo *II,
throw TGError(II->TheDef->getLoc(), "error: unable to find operand: '" + throw TGError(II->TheDef->getLoc(), "error: unable to find operand: '" +
OperandName.str() + "'"); OperandName.str() + "'");
// FIXME: This is annoying, the named operand may be tied (e.g., // Set up the operand class.
// XCHG8rm). What we want is the untied operand, which we now have to Op.Class = getOperandClass(Token, Operands[Idx]);
// grovel for. Only worry about this for single entry operands, we have to
// clean this up anyway. // If the named operand is tied, canonicalize it to the untied operand.
const CGIOperandList::OperandInfo *OI = &Operands[Idx]; // For example, something like:
int OITied = OI->getTiedRegister(); // (outs GPR:$dst), (ins GPR:$src)
// with an asmstring of
// "inc $src"
// we want to canonicalize to:
// "inc $dst"
// so that we know how to provide the $dst operand when filling in the result.
int OITied = Operands[Idx].getTiedRegister();
if (OITied != -1) { if (OITied != -1) {
// The tied operand index is an MIOperand index, find the operand that // The tied operand index is an MIOperand index, find the operand that
// contains it. // contains it.
for (unsigned i = 0, e = Operands.size(); i != e; ++i) { for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
if (Operands[i].MIOperandNo == unsigned(OITied)) { if (Operands[i].MIOperandNo == unsigned(OITied)) {
OI = &Operands[i]; OperandName = Operands[i].Name;
OperandName = OI->Name;
break; break;
} }
} }
assert(OI && "Unable to find tied operand target!");
} }
Op.Class = getOperandClass(Token, *OI);
Op.SrcOpName = OperandName; Op.SrcOpName = OperandName;
} }
@ -1166,12 +1175,7 @@ void MatchableInfo::BuildResultOperands() {
// Find out what operand from the asmparser that this MCInst operand comes // Find out what operand from the asmparser that this MCInst operand comes
// from. // from.
int SrcOperand = -1; int SrcOperand = FindAsmOperandNamed(OpInfo.Name);
for (unsigned op = 0, e = AsmOperands.size(); op != e; ++op)
if (OpInfo.Name == AsmOperands[op].SrcOpName) {
SrcOperand = op;
break;
}
if (!OpInfo.Name.empty() && SrcOperand != -1) { if (!OpInfo.Name.empty() && SrcOperand != -1) {
ResOperands.push_back(ResOperand::getRenderedOp(SrcOperand, &OpInfo)); ResOperands.push_back(ResOperand::getRenderedOp(SrcOperand, &OpInfo));