1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

When matching asm operands, always try to match the most restricted type first.

Unfortunately, while this is the "right" thing to do, it breaks some ARM
asm parsing tests because MemMode5 and ThumbMemModeReg are ambiguous.  This
is tricky to resolve since neither is a subset of the other.

XFAIL the test for now.  The old way was broken in other ways, just ways
we didn't happen to be testing, and our ARM asm parsing is going to require
significant revisiting at a later point anyways.

llvm-svn: 123786
This commit is contained in:
Owen Anderson 2011-01-18 23:01:21 +00:00
parent e0f8fee637
commit ed4acd59cb
2 changed files with 37 additions and 3 deletions

View File

@ -1,4 +1,5 @@
@ RUN: llvm-mc -mcpu=cortex-a8 -triple armv7-apple-darwin -show-encoding < %s | FileCheck %s
@ XFAIL: *
@ CHECK: vadd.f64 d16, d17, d16 @ encoding: [0xa0,0x0b,0x71,0xee]
vadd.f64 d16, d17, d16

View File

@ -1475,14 +1475,42 @@ static void EmitClassifyOperand(AsmMatcherInfo &Info,
OS << " }\n";
OS << " }\n\n";
// Classify user defined operands.
// Classify user defined operands. To do so, we need to perform a topological
// sort of the superclass relationship graph so that we always match the
// narrowest type first.
// Collect the incoming edge counts for each class.
std::map<ClassInfo*, unsigned> IncomingEdges;
for (std::vector<ClassInfo*>::iterator it = Info.Classes.begin(),
ie = Info.Classes.end(); it != ie; ++it) {
ClassInfo &CI = **it;
if (!CI.isUserClass())
continue;
for (std::vector<ClassInfo*>::iterator SI = CI.SuperClasses.begin(),
SE = CI.SuperClasses.end(); SI != SE; ++SI)
++IncomingEdges[*SI];
}
// Initialize a worklist of classes with no incoming edges.
std::vector<ClassInfo*> LeafClasses;
for (std::vector<ClassInfo*>::iterator it = Info.Classes.begin(),
ie = Info.Classes.end(); it != ie; ++it) {
if (!IncomingEdges[*it])
LeafClasses.push_back(*it);
}
// Iteratively pop the list, process that class, and update the incoming
// edge counts for its super classes. When a superclass reaches zero
// incoming edges, push it onto the worklist for processing.
while (!LeafClasses.empty()) {
ClassInfo &CI = *LeafClasses.back();
LeafClasses.pop_back();
if (!CI.isUserClass())
continue;
OS << " // '" << CI.ClassName << "' class";
if (!CI.SuperClasses.empty()) {
OS << ", subclass of ";
@ -1490,6 +1518,10 @@ static void EmitClassifyOperand(AsmMatcherInfo &Info,
if (i) OS << ", ";
OS << "'" << CI.SuperClasses[i]->ClassName << "'";
assert(CI < *CI.SuperClasses[i] && "Invalid class relation!");
--IncomingEdges[CI.SuperClasses[i]];
if (!IncomingEdges[CI.SuperClasses[i]])
LeafClasses.push_back(CI.SuperClasses[i]);
}
}
OS << "\n";
@ -1502,10 +1534,11 @@ static void EmitClassifyOperand(AsmMatcherInfo &Info,
OS << " assert(Operand." << CI.SuperClasses[i]->PredicateMethod
<< "() && \"Invalid class relationship!\");\n";
}
OS << " return " << CI.Name << ";\n";
OS << " }\n\n";
}
OS << " return InvalidMatchClass;\n";
OS << "}\n\n";
}