mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-24 20:44:51 +00:00
MC: Fix bug where trailing tied operands were forgotten; the X86 assembler
matcher is now free of implicit operands! - Still need to clean up the code now that we don't to worry about implicit operands, and to make it a hard error if an instruction fails to specify all of its operands for some reason. llvm-svn: 95956
This commit is contained in:
parent
d4e67c4648
commit
08f1b2f670
@ -975,6 +975,16 @@ void AsmMatcherInfo::BuildInfo(CodeGenTarget &Target) {
|
|||||||
std::sort(Classes.begin(), Classes.end(), less_ptr<ClassInfo>());
|
std::sort(Classes.begin(), Classes.end(), less_ptr<ClassInfo>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::pair<unsigned, unsigned> *
|
||||||
|
GetTiedOperandAtIndex(SmallVectorImpl<std::pair<unsigned, unsigned> > &List,
|
||||||
|
unsigned Index) {
|
||||||
|
for (unsigned i = 0, e = List.size(); i != e; ++i)
|
||||||
|
if (Index == List[i].first)
|
||||||
|
return &List[i];
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void EmitConvertToMCInst(CodeGenTarget &Target,
|
static void EmitConvertToMCInst(CodeGenTarget &Target,
|
||||||
std::vector<InstructionInfo*> &Infos,
|
std::vector<InstructionInfo*> &Infos,
|
||||||
raw_ostream &OS) {
|
raw_ostream &OS) {
|
||||||
@ -1051,15 +1061,12 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
|
|||||||
//
|
//
|
||||||
// FIXME: This should be removed from the MCInst structure.
|
// 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,
|
||||||
unsigned i, e = TiedOperands.size();
|
CurIndex);
|
||||||
for (i = 0; i != e; ++i)
|
if (!Tie)
|
||||||
if (CurIndex == TiedOperands[i].first)
|
|
||||||
break;
|
|
||||||
if (i == e)
|
|
||||||
Signature += "__Imp";
|
Signature += "__Imp";
|
||||||
else
|
else
|
||||||
Signature += "__Tie" + utostr(TiedOperands[i].second);
|
Signature += "__Tie" + utostr(Tie->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
Signature += "__";
|
Signature += "__";
|
||||||
@ -1080,8 +1087,14 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add any trailing implicit operands.
|
// Add any trailing implicit operands.
|
||||||
for (; CurIndex != NumMIOperands; ++CurIndex)
|
for (; CurIndex != NumMIOperands; ++CurIndex) {
|
||||||
Signature += "__Imp";
|
std::pair<unsigned, unsigned> *Tie = GetTiedOperandAtIndex(TiedOperands,
|
||||||
|
CurIndex);
|
||||||
|
if (!Tie)
|
||||||
|
Signature += "__Imp";
|
||||||
|
else
|
||||||
|
Signature += "__Tie" + utostr(Tie->second);
|
||||||
|
}
|
||||||
|
|
||||||
II.ConversionFnKind = Signature;
|
II.ConversionFnKind = Signature;
|
||||||
|
|
||||||
@ -1103,21 +1116,18 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
|
|||||||
// Add the implicit operands.
|
// Add the implicit operands.
|
||||||
for (; CurIndex != Op.OperandInfo->MIOperandNo; ++CurIndex) {
|
for (; CurIndex != Op.OperandInfo->MIOperandNo; ++CurIndex) {
|
||||||
// See if this is a tied operand.
|
// See if this is a tied operand.
|
||||||
unsigned i, e = TiedOperands.size();
|
std::pair<unsigned, unsigned> *Tie = GetTiedOperandAtIndex(TiedOperands,
|
||||||
for (i = 0; i != e; ++i)
|
CurIndex);
|
||||||
if (CurIndex == TiedOperands[i].first)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (i == e) {
|
if (!Tie) {
|
||||||
// If not, this is some implicit operand. Just assume it is a register
|
// If not, this is some implicit operand. Just assume it is a register
|
||||||
// for now.
|
// for now.
|
||||||
CvtOS << " Inst.addOperand(MCOperand::CreateReg(0));\n";
|
CvtOS << " Inst.addOperand(MCOperand::CreateReg(0));\n";
|
||||||
} else {
|
} else {
|
||||||
// Copy the tied operand.
|
// Copy the tied operand.
|
||||||
assert(TiedOperands[i].first > TiedOperands[i].second &&
|
assert(Tie->first>Tie->second && "Tied operand preceeds its target!");
|
||||||
"Tied operand preceeds its target!");
|
|
||||||
CvtOS << " Inst.addOperand(Inst.getOperand("
|
CvtOS << " Inst.addOperand(Inst.getOperand("
|
||||||
<< TiedOperands[i].second << "));\n";
|
<< Tie->second << "));\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1129,8 +1139,22 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// And add trailing implicit operands.
|
// And add trailing implicit operands.
|
||||||
for (; CurIndex != NumMIOperands; ++CurIndex)
|
for (; CurIndex != NumMIOperands; ++CurIndex) {
|
||||||
CvtOS << " Inst.addOperand(MCOperand::CreateReg(0));\n";
|
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 << " break;\n";
|
CvtOS << " break;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user