From e9b466d4f09de3b46c0d0d1e71cabddc7cc9021b Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Sat, 23 Jan 2010 00:40:33 +0000 Subject: [PATCH] Modified the register matcher function in AsmMatcher to be static. Also made it possible for clients to get it and no other functions from ...GenAsmMatcher.inc by defining REGISTERS_ONLY before including GenAsmMatcher.inc. This sets the stage for target-specific lexers that can identify registers and return AsmToken::Register as appropriate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94266 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/AsmParser/X86AsmParser.cpp | 10 ++++++---- utils/TableGen/AsmMatcherEmitter.cpp | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index 6ced1f4f151..a367189028f 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -50,10 +50,6 @@ private: bool MatchInstruction(const SmallVectorImpl &Operands, MCInst &Inst); - /// MatchRegisterName - Match the given string to a register name, or 0 if - /// there is no match. - unsigned MatchRegisterName(const StringRef &Name); - /// } public: @@ -68,6 +64,12 @@ public: } // end anonymous namespace +/// @name Auto-generated Match Functions +/// { + +static unsigned MatchRegisterName(const StringRef &Name); + +/// } namespace { diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp index 8c37c3aabe0..ce1521d86a7 100644 --- a/utils/TableGen/AsmMatcherEmitter.cpp +++ b/utils/TableGen/AsmMatcherEmitter.cpp @@ -1390,9 +1390,7 @@ static void EmitMatchRegisterName(CodeGenTarget &Target, Record *AsmParser, "return " + utostr(i + 1) + ";")); } - OS << "unsigned " << Target.getName() - << AsmParser->getValueAsString("AsmParserClassName") - << "::MatchRegisterName(const StringRef &Name) {\n"; + OS << "static unsigned MatchRegisterName(const StringRef &Name) {\n"; EmitStringMatcher("Name", Matches, OS); @@ -1451,6 +1449,8 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { // Emit the function to match a register name to number. EmitMatchRegisterName(Target, AsmParser, OS); + + OS << "#ifndef REGISTERS_ONLY\n\n"; // Generate the unified function to convert operands into an MCInst. EmitConvertToMCInst(Target, Info.Instructions, OS); @@ -1550,4 +1550,6 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { OS << " return true;\n"; OS << "}\n\n"; + + OS << "#endif // REGISTERS_ONLY\n"; } -- 2.34.1