summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorSander de Smalen <sander.desmalen@arm.com>2017-11-20 14:36:40 +0000
committerSander de Smalen <sander.desmalen@arm.com>2017-11-20 14:36:40 +0000
commitb2ea712e111735c36c7ed3e31912e57fd8cb3637 (patch)
tree79257c239cd2de8d52681b1f87268f5049539d41 /utils
parentaeb7444c9bd7363e086cfe32737f2373517beaef (diff)
[AArch64][TableGen] Skip tied result operands for InstAlias
Summary: This patch fixes an issue so that the right alias is printed when the instruction has tied operands. It checks the number of operands in the resulting instruction as opposed to the alias, and then skips over tied operands that should not be printed in the alias. This allows to generate the preferred assembly syntax for the AArch64 'ins' instruction, which should always be displayed as 'mov' according to the ARM Architecture Reference Manual. Several unit tests have changed as a result, but only to reflect the preferred disassembly. Some other InstAlias patterns (movk/bic/orr) needed a slight adjustment to stop them becoming the default and breaking other unit tests. Please note that the patch is mostly the same as https://reviews.llvm.org/D29219 which was reverted because of an issue found when running TableGen with the Address Sanitizer. That issue has been addressed in this iteration of the patch. Reviewers: rengolin, stoklund, huntergr, SjoerdMeijer, rovka Reviewed By: rengolin, SjoerdMeijer Subscribers: fhahn, aemerson, javed.absar, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D40030 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318650 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/AsmWriterEmitter.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/utils/TableGen/AsmWriterEmitter.cpp b/utils/TableGen/AsmWriterEmitter.cpp
index 52b4c39255f..723c0cd773f 100644
--- a/utils/TableGen/AsmWriterEmitter.cpp
+++ b/utils/TableGen/AsmWriterEmitter.cpp
@@ -820,8 +820,8 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
}
unsigned NumMIOps = 0;
- for (auto &Operand : CGA.ResultOperands)
- NumMIOps += Operand.getMINumOperands();
+ for (auto &ResultInstOpnd : CGA.ResultInst->Operands)
+ NumMIOps += ResultInstOpnd.MINumOperands;
std::string Cond;
Cond = std::string("MI->getNumOperands() == ") + utostr(NumMIOps);
@@ -831,6 +831,19 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
unsigned MIOpNum = 0;
for (unsigned i = 0, e = LastOpNo; i != e; ++i) {
+ // Skip over tied operands as they're not part of an alias declaration.
+ auto &Operands = CGA.ResultInst->Operands;
+ unsigned OpNum = Operands.getSubOperandNumber(MIOpNum).first;
+ if (Operands[OpNum].MINumOperands == 1 &&
+ Operands[OpNum].getTiedRegister() != -1) {
+ // Tied operands of different RegisterClass should be explicit within
+ // an instruction's syntax and so cannot be skipped.
+ int TiedOpNum = Operands[OpNum].getTiedRegister();
+ if (Operands[OpNum].Rec->getName() ==
+ Operands[TiedOpNum].Rec->getName())
+ ++MIOpNum;
+ }
+
std::string Op = "MI->getOperand(" + utostr(MIOpNum) + ")";
const CodeGenInstAlias::ResultOperand &RO = CGA.ResultOperands[i];