summaryrefslogtreecommitdiff
path: root/utils/TableGen/AsmMatcherEmitter.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-02-12 01:46:54 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-02-12 01:46:54 +0000
commit3b6910dcd466bf091b386bb136f42522c89473f7 (patch)
treefaaf9ee2340fb60c2edc8e9290bb7c2571897e4b /utils/TableGen/AsmMatcherEmitter.cpp
parent906d57ffe826c29eeedc1d4f77542fd3f2349b8f (diff)
downloadllvm-3b6910dcd466bf091b386bb136f42522c89473f7.tar.gz
llvm-3b6910dcd466bf091b386bb136f42522c89473f7.tar.bz2
llvm-3b6910dcd466bf091b386bb136f42522c89473f7.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95956 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/AsmMatcherEmitter.cpp')
-rw-r--r--utils/TableGen/AsmMatcherEmitter.cpp62
1 files changed, 43 insertions, 19 deletions
diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp
index aafa5b39a4..b823e57b37 100644
--- a/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/utils/TableGen/AsmMatcherEmitter.cpp
@@ -975,6 +975,16 @@ void AsmMatcherInfo::BuildInfo(CodeGenTarget &Target) {
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,
std::vector<InstructionInfo*> &Infos,
raw_ostream &OS) {
@@ -1051,15 +1061,12 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
//
// FIXME: This should be removed from the MCInst structure.
for (; CurIndex != Op.OperandInfo->MIOperandNo; ++CurIndex) {
- // See if this is a tied operand.
- unsigned i, e = TiedOperands.size();
- for (i = 0; i != e; ++i)
- if (CurIndex == TiedOperands[i].first)
- break;
- if (i == e)
+ std::pair<unsigned, unsigned> *Tie = GetTiedOperandAtIndex(TiedOperands,
+ CurIndex);
+ if (!Tie)
Signature += "__Imp";
else
- Signature += "__Tie" + utostr(TiedOperands[i].second);
+ Signature += "__Tie" + utostr(Tie->second);
}
Signature += "__";
@@ -1080,8 +1087,14 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
}
// Add any trailing implicit operands.
- for (; CurIndex != NumMIOperands; ++CurIndex)
- Signature += "__Imp";
+ for (; CurIndex != NumMIOperands; ++CurIndex) {
+ std::pair<unsigned, unsigned> *Tie = GetTiedOperandAtIndex(TiedOperands,
+ CurIndex);
+ if (!Tie)
+ Signature += "__Imp";
+ else
+ Signature += "__Tie" + utostr(Tie->second);
+ }
II.ConversionFnKind = Signature;
@@ -1103,21 +1116,18 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
// Add the implicit operands.
for (; CurIndex != Op.OperandInfo->MIOperandNo; ++CurIndex) {
// See if this is a tied operand.
- unsigned i, e = TiedOperands.size();
- for (i = 0; i != e; ++i)
- if (CurIndex == TiedOperands[i].first)
- break;
+ std::pair<unsigned, unsigned> *Tie = GetTiedOperandAtIndex(TiedOperands,
+ CurIndex);
- if (i == e) {
+ 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(TiedOperands[i].first > TiedOperands[i].second &&
- "Tied operand preceeds its target!");
+ assert(Tie->first>Tie->second && "Tied operand preceeds its target!");
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.
- for (; CurIndex != NumMIOperands; ++CurIndex)
- CvtOS << " Inst.addOperand(MCOperand::CreateReg(0));\n";
+ 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 << " break;\n";
}