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
This commit is contained in:
Sean Callanan 2010-01-23 00:40:33 +00:00
parent 2e369930dc
commit e9b466d4f0
2 changed files with 11 additions and 7 deletions

View File

@ -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 {

View File

@ -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";
}