summaryrefslogtreecommitdiff
path: root/utils/TableGen/AsmMatcherEmitter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-06 07:31:43 +0000
committerChris Lattner <sabre@nondot.org>2010-11-06 07:31:43 +0000
commit414098571b19fc248fda2be194082cfd012d2729 (patch)
tree6bef9db250e1b7c6f95c6ec9960d6533e197361e /utils/TableGen/AsmMatcherEmitter.cpp
parent662e5a30e864e71111b885d3da3cdd184772035d (diff)
downloadllvm-414098571b19fc248fda2be194082cfd012d2729.tar.gz
llvm-414098571b19fc248fda2be194082cfd012d2729.tar.bz2
llvm-414098571b19fc248fda2be194082cfd012d2729.tar.xz
fix some bugs in the alias support, unblocking changing of "clr" aliases
from c++ hacks to proper .td InstAlias definitions. Change them! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118330 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/AsmMatcherEmitter.cpp')
-rw-r--r--utils/TableGen/AsmMatcherEmitter.cpp40
1 files changed, 37 insertions, 3 deletions
diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp
index be72ab449b..6a70c5a4b5 100644
--- a/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/utils/TableGen/AsmMatcherEmitter.cpp
@@ -372,7 +372,8 @@ struct MatchableInfo {
return -1;
}
- void BuildResultOperands();
+ void BuildInstructionResultOperands();
+ void BuildAliasResultOperands();
/// operator< - Compare two matchables.
bool operator<(const MatchableInfo &RHS) const {
@@ -1112,7 +1113,10 @@ void AsmMatcherInfo::BuildInfo() {
BuildAliasOperandReference(II, OperandName, Op);
}
- II->BuildResultOperands();
+ if (II->DefRec.is<const CodeGenInstruction*>())
+ II->BuildInstructionResultOperands();
+ else
+ II->BuildAliasResultOperands();
}
// Reorder classes so that classes preceed super classes.
@@ -1182,7 +1186,7 @@ void AsmMatcherInfo::BuildAliasOperandReference(MatchableInfo *II,
OperandName.str() + "'");
}
-void MatchableInfo::BuildResultOperands() {
+void MatchableInfo::BuildInstructionResultOperands() {
const CodeGenInstruction *ResultInst = getResultInst();
// Loop over all operands of the result instruction, determining how to
@@ -1212,6 +1216,36 @@ void MatchableInfo::BuildResultOperands() {
}
}
+void MatchableInfo::BuildAliasResultOperands() {
+ const CodeGenInstAlias &CGA = *DefRec.get<const CodeGenInstAlias*>();
+ const CodeGenInstruction *ResultInst = getResultInst();
+
+ // Loop over all operands of the result instruction, determining how to
+ // populate them.
+ unsigned AliasOpNo = 0;
+ for (unsigned i = 0, e = ResultInst->Operands.size(); i != e; ++i) {
+ const CGIOperandList::OperandInfo &OpInfo = ResultInst->Operands[i];
+
+ // If this is a tied operand, just copy from the previously handled operand.
+ int TiedOp = OpInfo.getTiedRegister();
+ if (TiedOp != -1) {
+ ResOperands.push_back(ResOperand::getTiedOp(TiedOp, &OpInfo));
+ continue;
+ }
+
+ // Find out what operand from the asmparser that this MCInst operand comes
+ // from.
+ int SrcOperand = FindAsmOperandNamed(CGA.ResultOperands[AliasOpNo++].Name);
+ if (SrcOperand != -1) {
+ ResOperands.push_back(ResOperand::getRenderedOp(SrcOperand, &OpInfo));
+ continue;
+ }
+
+ throw TGError(TheDef->getLoc(), "Instruction '" +
+ TheDef->getName() + "' has operand '" + OpInfo.Name +
+ "' that doesn't appear in asm string!");
+ }
+}
static void EmitConvertToMCInst(CodeGenTarget &Target,
std::vector<MatchableInfo*> &Infos,