summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/AsmWriterEmitter.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2011-06-15 04:31:19 +0000
committerBill Wendling <isanbard@gmail.com>2011-06-15 04:31:19 +0000
commit36c0c6db3fcaef4bfebe3b49a294fe8058ed0e92 (patch)
tree6c14c18afe9ff6365bcd4472b54e3f9a79b47394 /llvm/utils/TableGen/AsmWriterEmitter.cpp
parent1778b030c0dc347a6b86f2331cf45bff33790dd5 (diff)
downloadbcm5719-llvm-36c0c6db3fcaef4bfebe3b49a294fe8058ed0e92.tar.gz
bcm5719-llvm-36c0c6db3fcaef4bfebe3b49a294fe8058ed0e92.zip
Improve the heuristic to emit the alias if the number of hard-coded registers
are also greater than the alias. llvm-svn: 133038
Diffstat (limited to 'llvm/utils/TableGen/AsmWriterEmitter.cpp')
-rw-r--r--llvm/utils/TableGen/AsmWriterEmitter.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp b/llvm/utils/TableGen/AsmWriterEmitter.cpp
index 3eedf10f7cb..bfc63c0cf85 100644
--- a/llvm/utils/TableGen/AsmWriterEmitter.cpp
+++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp
@@ -842,6 +842,26 @@ static unsigned CountNumOperands(StringRef AsmString) {
return NumOps;
}
+static unsigned CountResultNumOperands(StringRef AsmString) {
+ unsigned NumOps = 0;
+ std::pair<StringRef, StringRef> ASM = AsmString.split('\t');
+
+ if (!ASM.second.empty()) {
+ size_t I = ASM.second.find('{');
+ StringRef Str = ASM.second;
+ if (I != StringRef::npos)
+ Str = ASM.second.substr(I, ASM.second.find('|', I));
+
+ ASM = Str.split(' ');
+
+ do {
+ ++NumOps;
+ ASM = ASM.second.split(' ');
+ } while (!ASM.second.empty());
+ }
+
+ return NumOps;
+}
void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
CodeGenTarget Target(Records);
@@ -887,9 +907,11 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
II = Aliases.begin(), IE = Aliases.end(); II != IE; ++II) {
const CodeGenInstAlias *CGA = *II;
unsigned LastOpNo = CGA->ResultInstOperandIndex.size();
+ unsigned NumResultOps =
+ CountResultNumOperands(CGA->ResultInst->AsmString);
// Don't emit the alias if it has more operands than what it's aliasing.
- if (LastOpNo < CountNumOperands(CGA->AsmString))
+ if (NumResultOps < CountNumOperands(CGA->AsmString))
continue;
IAPrinter *IAP = new IAPrinter(AWI, CGA->Result->getAsString(),
OpenPOWER on IntegriCloud