summaryrefslogtreecommitdiffstats
path: root/llvm/utils
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2014-05-15 13:36:01 +0000
committerTim Northover <tnorthover@apple.com>2014-05-15 13:36:01 +0000
commit60091cfeb9c827187d8877aaef600bdea3d5c17d (patch)
treece1f51bd66ff4da9ddcbf333e88beaf00b94dfc1 /llvm/utils
parentcb7f9c40f872a2d786be318674a403b5ce5fa695 (diff)
downloadbcm5719-llvm-60091cfeb9c827187d8877aaef600bdea3d5c17d.tar.gz
bcm5719-llvm-60091cfeb9c827187d8877aaef600bdea3d5c17d.zip
TableGen: use correct MIOperand when printing aliases
Previously, TableGen assumed that every aliased operand consumed precisely 1 MachineInstr slot (this was reasonable because until a couple of days ago, nothing more complicated was eligible for printing). This allows a couple more ARM64 aliases to print so we can remove the special code. On the X86 side, I've gone for explicit AT&T size specifiers as the default, so turned off a few of the aliases that would have just started printing. llvm-svn: 208880
Diffstat (limited to 'llvm/utils')
-rw-r--r--llvm/utils/TableGen/AsmWriterEmitter.cpp26
-rw-r--r--llvm/utils/TableGen/CodeGenInstruction.cpp17
-rw-r--r--llvm/utils/TableGen/CodeGenInstruction.h2
3 files changed, 36 insertions, 9 deletions
diff --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp b/llvm/utils/TableGen/AsmWriterEmitter.cpp
index 77d92c3cb40..617aa827376 100644
--- a/llvm/utils/TableGen/AsmWriterEmitter.cpp
+++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp
@@ -827,12 +827,17 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
IAPrinter *IAP = new IAPrinter(CGA->Result->getAsString(),
CGA->AsmString);
+ unsigned NumMIOps = 0;
+ for (auto &Operand : CGA->ResultOperands)
+ NumMIOps += Operand.getMINumOperands();
+
std::string Cond;
- Cond = std::string("MI->getNumOperands() == ") + llvm::utostr(LastOpNo);
+ Cond = std::string("MI->getNumOperands() == ") + llvm::utostr(NumMIOps);
IAP->addCond(Cond);
bool CantHandle = false;
+ unsigned MIOpNum = 0;
for (unsigned i = 0, e = LastOpNo; i != e; ++i) {
const CodeGenInstAlias::ResultOperand &RO = CGA->ResultOperands[i];
@@ -860,34 +865,36 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
if (Rec->isSubClassOf("RegisterOperand"))
Rec = Rec->getValueAsDef("RegClass");
if (Rec->isSubClassOf("RegisterClass")) {
- Cond = std::string("MI->getOperand(")+llvm::utostr(i)+").isReg()";
+ Cond = std::string("MI->getOperand(") + llvm::utostr(MIOpNum) +
+ ").isReg()";
IAP->addCond(Cond);
if (!IAP->isOpMapped(ROName)) {
- IAP->addOperand(ROName, i, PrintMethodIdx);
+ IAP->addOperand(ROName, MIOpNum, PrintMethodIdx);
Record *R = CGA->ResultOperands[i].getRecord();
if (R->isSubClassOf("RegisterOperand"))
R = R->getValueAsDef("RegClass");
Cond = std::string("MRI.getRegClass(") + Target.getName() + "::" +
- R->getName() + "RegClassID)"
- ".contains(MI->getOperand(" + llvm::utostr(i) + ").getReg())";
+ R->getName() + "RegClassID)"
+ ".contains(MI->getOperand(" +
+ llvm::utostr(MIOpNum) + ").getReg())";
IAP->addCond(Cond);
} else {
Cond = std::string("MI->getOperand(") +
- llvm::utostr(i) + ").getReg() == MI->getOperand(" +
+ llvm::utostr(MIOpNum) + ").getReg() == MI->getOperand(" +
llvm::utostr(IAP->getOpIndex(ROName)) + ").getReg()";
IAP->addCond(Cond);
}
} else {
// Assume all printable operands are desired for now. This can be
// overridden in the InstAlias instantiation if necessary.
- IAP->addOperand(ROName, i, PrintMethodIdx);
+ IAP->addOperand(ROName, MIOpNum, PrintMethodIdx);
}
break;
}
case CodeGenInstAlias::ResultOperand::K_Imm: {
- std::string Op = "MI->getOperand(" + llvm::utostr(i) + ")";
+ std::string Op = "MI->getOperand(" + llvm::utostr(MIOpNum) + ")";
// Just because the alias has an immediate result, doesn't mean the
// MCInst will. An MCExpr could be present, for example.
@@ -907,13 +914,14 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
}
Cond = std::string("MI->getOperand(") +
- llvm::utostr(i) + ").getReg() == " + Target.getName() +
+ llvm::utostr(MIOpNum) + ").getReg() == " + Target.getName() +
"::" + CGA->ResultOperands[i].getRegister()->getName();
IAP->addCond(Cond);
break;
}
if (!IAP) break;
+ MIOpNum += RO.getMINumOperands();
}
if (CantHandle) continue;
diff --git a/llvm/utils/TableGen/CodeGenInstruction.cpp b/llvm/utils/TableGen/CodeGenInstruction.cpp
index c924ce8d836..2577ad4d919 100644
--- a/llvm/utils/TableGen/CodeGenInstruction.cpp
+++ b/llvm/utils/TableGen/CodeGenInstruction.cpp
@@ -536,6 +536,23 @@ bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
return false;
}
+unsigned CodeGenInstAlias::ResultOperand::getMINumOperands() const {
+ if (!isRecord())
+ return 1;
+
+ Record *Rec = getRecord();
+ if (!Rec->isSubClassOf("Operand"))
+ return 1;
+
+ DagInit *MIOpInfo = Rec->getValueAsDag("MIOperandInfo");
+ if (MIOpInfo->getNumArgs() == 0) {
+ // Unspecified, so it defaults to 1
+ return 1;
+ }
+
+ return MIOpInfo->getNumArgs();
+}
+
CodeGenInstAlias::CodeGenInstAlias(Record *R, unsigned Variant,
CodeGenTarget &T)
: TheDef(R) {
diff --git a/llvm/utils/TableGen/CodeGenInstruction.h b/llvm/utils/TableGen/CodeGenInstruction.h
index 818d0e1d36d..f143875131b 100644
--- a/llvm/utils/TableGen/CodeGenInstruction.h
+++ b/llvm/utils/TableGen/CodeGenInstruction.h
@@ -324,6 +324,8 @@ namespace llvm {
Record *getRecord() const { assert(isRecord()); return R; }
int64_t getImm() const { assert(isImm()); return Imm; }
Record *getRegister() const { assert(isReg()); return R; }
+
+ unsigned getMINumOperands() const;
};
/// ResultOperands - The decoded operands for the result instruction.
OpenPOWER on IntegriCloud