llvm-mc/AsmMatcher: Switch token matching to use the new string matcher.
Also, redefined MatchRegisterName to just return the register value or a
sentinel, to simplify the generated code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78504 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 841b427..ea5528a 100644
--- a/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -46,7 +46,9 @@
bool MatchInstruction(SmallVectorImpl<X86Operand> &Operands,
MCInst &Inst);
- bool MatchRegisterName(const StringRef &Name, unsigned &RegNo);
+ /// MatchRegisterName - Match the given string to a register name, or 0 if
+ /// there is no match.
+ unsigned MatchRegisterName(const StringRef &Name);
/// }
@@ -214,7 +216,9 @@
// validation later, so maybe there is no need for this here.
unsigned RegNo;
assert(Tok.getString().startswith("%") && "Invalid register name!");
- if (MatchRegisterName(Tok.getString().substr(1), RegNo))
+
+ RegNo = MatchRegisterName(Tok.getString().substr(1));
+ if (RegNo == 0)
return Error(Tok.getLoc(), "invalid register name");
Op = X86Operand::CreateReg(RegNo);