summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2012-06-18 19:45:46 +0000
committerJim Grosbach <grosbach@apple.com>2012-06-18 19:45:46 +0000
commit325bd661ff57787efddc6b302230f22e9c187655 (patch)
treec120223d43009bb6d57caacf6760c3b4fabef6bb /utils
parent0fad48fd868ec093890e75e4d4128ae4d571c7b7 (diff)
downloadexternal_llvm-325bd661ff57787efddc6b302230f22e9c187655.zip
external_llvm-325bd661ff57787efddc6b302230f22e9c187655.tar.gz
external_llvm-325bd661ff57787efddc6b302230f22e9c187655.tar.bz2
TableGen: AsmMatcher missing-features list minimization.
When returning a 'cannot match due to missing CPU features' error code, if there are multiple potential matches with different feature sets, return the smallest set of missing features from the alternatives as that's most likely to be the one that's desired. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158673 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/AsmMatcherEmitter.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp
index e980b1a..f88e337 100644
--- a/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/utils/TableGen/AsmMatcherEmitter.cpp
@@ -2575,6 +2575,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
OS << " bool HadMatchOtherThanFeatures = false;\n";
OS << " bool HadMatchOtherThanPredicate = false;\n";
OS << " unsigned RetCode = Match_InvalidOperand;\n";
+ OS << " unsigned MissingFeatures = ~0U;\n";
OS << " // Set ErrorInfo to the operand that mismatches if it is\n";
OS << " // wrong for all instances of the instruction.\n";
OS << " ErrorInfo = ~0U;\n";
@@ -2622,7 +2623,11 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
OS << " if ((AvailableFeatures & it->RequiredFeatures) "
<< "!= it->RequiredFeatures) {\n";
OS << " HadMatchOtherThanFeatures = true;\n";
- OS << " ErrorInfo = it->RequiredFeatures & ~AvailableFeatures;\n";
+ OS << " unsigned NewMissingFeatures = it->RequiredFeatures & "
+ "~AvailableFeatures;\n";
+ OS << " if (CountPopulation_32(NewMissingFeatures) <= "
+ "CountPopulation_32(MissingFeatures))\n";
+ OS << " MissingFeatures = NewMissingFeatures;\n";
OS << " continue;\n";
OS << " }\n";
OS << "\n";
@@ -2656,8 +2661,9 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
OS << " // Okay, we had no match. Try to return a useful error code.\n";
OS << " if (HadMatchOtherThanPredicate || !HadMatchOtherThanFeatures)";
- OS << " return RetCode;\n";
- OS << " assert(ErrorInfo && \"missing feature(s) but what?!\");";
+ OS << " return RetCode;\n";
+ OS << " // Missing feature matches return which features were missing\n";
+ OS << " ErrorInfo = MissingFeatures;\n";
OS << " return Match_MissingFeature;\n";
OS << "}\n\n";