diff options
author | Jim Grosbach <grosbach@apple.com> | 2012-04-24 22:40:08 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2012-04-24 22:40:08 +0000 |
commit | 14ce6fac242228dacc5c08040e544141a96880e5 (patch) | |
tree | 5bd76367ec49ca7435b76e18a65ce70d95a6cf5e /utils | |
parent | 86b7e2acc9e3b55b8afdfeabda124cc6547e943b (diff) | |
download | llvm-14ce6fac242228dacc5c08040e544141a96880e5.tar.gz llvm-14ce6fac242228dacc5c08040e544141a96880e5.tar.bz2 llvm-14ce6fac242228dacc5c08040e544141a96880e5.tar.xz |
ARM: improved assembler diagnostics for missing CPU features.
When an instruction match is found, but the subtarget features it
requires are not available (missing floating point unit, or thumb vs arm
mode, for example), issue a diagnostic that identifies what the feature
mismatch is.
rdar://11257547
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155499 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/AsmMatcherEmitter.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp index a44fbe6256..03807b1092 100644 --- a/utils/TableGen/AsmMatcherEmitter.cpp +++ b/utils/TableGen/AsmMatcherEmitter.cpp @@ -1951,6 +1951,25 @@ static void emitSubtargetFeatureFlagEnumeration(AsmMatcherInfo &Info, OS << "};\n\n"; } +/// emitGetSubtargetFeatureName - Emit the helper function to get the +/// user-level name for a subtarget feature. +static void emitGetSubtargetFeatureName(AsmMatcherInfo &Info, raw_ostream &OS) { + OS << "// User-level names for subtarget features that participate in\n" + << "// instruction matching.\n" + << "static const char *getSubtargetFeatureName(unsigned Val) {\n" + << " switch(Val) {\n"; + for (std::map<Record*, SubtargetFeatureInfo*>::const_iterator + it = Info.SubtargetFeatures.begin(), + ie = Info.SubtargetFeatures.end(); it != ie; ++it) { + SubtargetFeatureInfo &SFI = *it->second; + // FIXME: Totally just a placeholder name to get the algorithm working. + OS << " case " << SFI.getEnumName() << ": return \"" + << SFI.TheDef->getValueAsString("PredicateName") << "\";\n"; + } + OS << " default: return \"(unknown)\";\n"; + OS << " }\n}\n\n"; +} + /// emitComputeAvailableFeatures - Emit the function to compute the list of /// available features given a subtarget. static void emitComputeAvailableFeatures(AsmMatcherInfo &Info, @@ -2380,6 +2399,9 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { OS << "\n#ifdef GET_MATCHER_IMPLEMENTATION\n"; OS << "#undef GET_MATCHER_IMPLEMENTATION\n\n"; + // Generate the helper function to get the names for subtarget features. + emitGetSubtargetFeatureName(Info, OS); + // Generate the function that remaps for mnemonic aliases. bool HasMnemonicAliases = emitMnemonicAliases(OS, Info); @@ -2510,8 +2532,8 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { << Target.getName() << ClassName << "::\n" << "MatchInstructionImpl(const SmallVectorImpl<MCParsedAsmOperand*>" << " &Operands,\n"; - OS << " MCInst &Inst, unsigned &ErrorInfo,\n"; - OS << " unsigned VariantID) {\n"; + OS << " MCInst &Inst, unsigned &ErrorInfo, "; + OS << "unsigned VariantID) {\n"; // Emit code to get the available features. OS << " // Get the current feature set.\n"; @@ -2586,6 +2608,7 @@ 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 << " continue;\n"; OS << " }\n"; OS << "\n"; @@ -2620,6 +2643,7 @@ 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 Match_MissingFeature;\n"; OS << "}\n\n"; |