Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 939e970

Browse files
committed
[AsmParser][TableGen] Make the generated mnemonic spell checker function a file local static function.
Also only emit in targets that specificially request it. This is required so we don't get an unused static function error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316640 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 34837ae commit 939e970

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3297,7 +3297,7 @@ bool AArch64AsmParser::validateInstruction(MCInst &Inst,
32973297
}
32983298
}
32993299

3300-
std::string AArch64MnemonicSpellCheck(StringRef S, uint64_t FBS);
3300+
static std::string AArch64MnemonicSpellCheck(StringRef S, uint64_t FBS);
33013301

33023302
bool AArch64AsmParser::showMatchError(SMLoc Loc, unsigned ErrCode,
33033303
OperandVector &Operands) {
@@ -4255,6 +4255,7 @@ extern "C" void LLVMInitializeAArch64AsmParser() {
42554255
#define GET_REGISTER_MATCHER
42564256
#define GET_SUBTARGET_FEATURE_NAME
42574257
#define GET_MATCHER_IMPLEMENTATION
4258+
#define GET_MNEMONIC_SPELL_CHECKER
42584259
#include "AArch64GenAsmMatcher.inc"
42594260

42604261
// Define this matcher function after the auto-generated include so we

lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9040,7 +9040,7 @@ unsigned ARMAsmParser::MatchInstruction(OperandVector &Operands, MCInst &Inst,
90409040
return PlainMatchResult;
90419041
}
90429042

9043-
std::string ARMMnemonicSpellCheck(StringRef S, uint64_t FBS);
9043+
static std::string ARMMnemonicSpellCheck(StringRef S, uint64_t FBS);
90449044

90459045
static const char *getSubtargetFeatureName(uint64_t Val);
90469046
bool ARMAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
@@ -10120,6 +10120,7 @@ extern "C" void LLVMInitializeARMAsmParser() {
1012010120
#define GET_REGISTER_MATCHER
1012110121
#define GET_SUBTARGET_FEATURE_NAME
1012210122
#define GET_MATCHER_IMPLEMENTATION
10123+
#define GET_MNEMONIC_SPELL_CHECKER
1012310124
#include "ARMGenAsmMatcher.inc"
1012410125

1012510126
// Some diagnostics need to vary with subtarget features, so they are handled

lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ class SystemZAsmParser : public MCTargetAsmParser {
543543
#define GET_REGISTER_MATCHER
544544
#define GET_SUBTARGET_FEATURE_NAME
545545
#define GET_MATCHER_IMPLEMENTATION
546+
#define GET_MNEMONIC_SPELL_CHECKER
546547
#include "SystemZGenAsmMatcher.inc"
547548

548549
// Used for the .insn directives; contains information needed to parse the
@@ -1168,7 +1169,7 @@ bool SystemZAsmParser::parseOperand(OperandVector &Operands,
11681169
return false;
11691170
}
11701171

1171-
std::string SystemZMnemonicSpellCheck(StringRef S, uint64_t FBS);
1172+
static std::string SystemZMnemonicSpellCheck(StringRef S, uint64_t FBS);
11721173

11731174
bool SystemZAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
11741175
OperandVector &Operands,

utils/TableGen/AsmMatcherEmitter.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2823,7 +2823,8 @@ static void emitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target,
28232823

28242824
static void emitMnemonicSpellChecker(raw_ostream &OS, CodeGenTarget &Target,
28252825
unsigned VariantCount) {
2826-
OS << "std::string " << Target.getName() << "MnemonicSpellCheck(StringRef S, uint64_t FBS) {\n";
2826+
OS << "static std::string " << Target.getName()
2827+
<< "MnemonicSpellCheck(StringRef S, uint64_t FBS) {\n";
28272828
if (!VariantCount)
28282829
OS << " return \"\";";
28292830
else {
@@ -3159,8 +3160,6 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
31593160
OS << "};\n\n";
31603161
}
31613162

3162-
emitMnemonicSpellChecker(OS, Target, VariantCount);
3163-
31643163
OS << "#include \"llvm/Support/Debug.h\"\n";
31653164
OS << "#include \"llvm/Support/Format.h\"\n\n";
31663165

@@ -3576,6 +3575,13 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
35763575
MaxMnemonicIndex, HasMnemonicFirst);
35773576

35783577
OS << "#endif // GET_MATCHER_IMPLEMENTATION\n\n";
3578+
3579+
OS << "\n#ifdef GET_MNEMONIC_SPELL_CHECKER\n";
3580+
OS << "#undef GET_MNEMONIC_SPELL_CHECKER\n\n";
3581+
3582+
emitMnemonicSpellChecker(OS, Target, VariantCount);
3583+
3584+
OS << "#endif // GET_MNEMONIC_SPELL_CHECKER\n\n";
35793585
}
35803586

35813587
namespace llvm {

0 commit comments

Comments
 (0)