diff options
author | Sean Callanan <scallanan@apple.com> | 2010-01-23 00:40:33 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2010-01-23 00:40:33 +0000 |
commit | 86c1181c3d877c33058a707c8f2a54a220f1d0ab (patch) | |
tree | 8f7c0c9a36149f0b2e849d6c3350dc7fd39485ce | |
parent | 625a515120c6237386371ffe3a2afa82c7a83c62 (diff) | |
download | bcm5719-llvm-86c1181c3d877c33058a707c8f2a54a220f1d0ab.tar.gz bcm5719-llvm-86c1181c3d877c33058a707c8f2a54a220f1d0ab.zip |
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.
llvm-svn: 94266
-rw-r--r-- | llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp | 10 | ||||
-rw-r--r-- | llvm/utils/TableGen/AsmMatcherEmitter.cpp | 8 |
2 files changed, 11 insertions, 7 deletions
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index 6ced1f4f151..a367189028f 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -50,10 +50,6 @@ private: bool MatchInstruction(const SmallVectorImpl<MCParsedAsmOperand*> &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/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp index 8c37c3aabe0..ce1521d86a7 100644 --- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp +++ b/llvm/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"; } |