summaryrefslogtreecommitdiff
path: root/lib/Target/Mips
diff options
context:
space:
mode:
authorDaniel Sanders <daniel.sanders@imgtec.com>2014-04-01 10:40:14 +0000
committerDaniel Sanders <daniel.sanders@imgtec.com>2014-04-01 10:40:14 +0000
commit1302349706dc77288adfff2b4263c1e1942bc4b1 (patch)
tree4cbb05cf91c1da5779357a773607a6f0bcf39c34 /lib/Target/Mips
parent382fb96882f338e5b92c231f78e99e531c6c63ae (diff)
downloadllvm-1302349706dc77288adfff2b4263c1e1942bc4b1.tar.gz
llvm-1302349706dc77288adfff2b4263c1e1942bc4b1.tar.bz2
llvm-1302349706dc77288adfff2b4263c1e1942bc4b1.tar.xz
[mips] Use AsmLexer::peekTok() to resolve the conflict between $reg and $sym
Summary: Parsing registers no longer consume the $ token before it's confirmed whether it really has a register or not, therefore it's no longer impossible to match symbols if registers were tried first. Depends on D3232 Reviewers: matheusalmeida, vmedic Reviewed By: matheusalmeida Differential Revision: http://llvm-reviews.chandlerc.com/D3233 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205297 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Mips')
-rw-r--r--lib/Target/Mips/AsmParser/MipsAsmParser.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index d3bfe40fc5..12469822f7 100644
--- a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -1781,22 +1781,19 @@ MipsAsmParser::MatchAnyRegisterNameWithoutDollar(
MipsAsmParser::OperandMatchResultTy
MipsAsmParser::ParseAnyRegisterWithoutDollar(
SmallVectorImpl<MCParsedAsmOperand *> &Operands, SMLoc S) {
- auto Token = Parser.getTok();
+ auto Token = Parser.getLexer().peekTok(false);
if (Token.is(AsmToken::Identifier)) {
DEBUG(dbgs() << ".. identifier\n");
StringRef Identifier = Token.getIdentifier();
OperandMatchResultTy ResTy =
MatchAnyRegisterNameWithoutDollar(Operands, Identifier, S);
- if (ResTy == MatchOperand_Success)
- Parser.Lex();
return ResTy;
} else if (Token.is(AsmToken::Integer)) {
DEBUG(dbgs() << ".. integer\n");
Operands.push_back(MipsOperand::CreateNumericReg(
Token.getIntVal(), getContext().getRegisterInfo(), S, Token.getLoc(),
*this));
- Parser.Lex();
return MatchOperand_Success;
}
@@ -1823,12 +1820,12 @@ MipsAsmParser::OperandMatchResultTy MipsAsmParser::ParseAnyRegister(
return MatchOperand_NoMatch;
}
DEBUG(dbgs() << ".. $\n");
- Parser.Lex();
- Token = Parser.getTok();
OperandMatchResultTy ResTy = ParseAnyRegisterWithoutDollar(Operands, S);
- if (ResTy == MatchOperand_NoMatch)
- return MatchOperand_ParseFail; // We ate the $ so NoMatch isn't valid
+ if (ResTy == MatchOperand_Success) {
+ Parser.Lex(); // $
+ Parser.Lex(); // identifier
+ }
return ResTy;
}
@@ -1866,18 +1863,16 @@ MipsAsmParser::OperandMatchResultTy MipsAsmParser::ParseJumpTarget(
if (ResTy != MatchOperand_NoMatch)
return ResTy;
+ // Registers are a valid target and have priority over symbols.
+ ResTy = ParseAnyRegister(Operands);
+ if (ResTy != MatchOperand_NoMatch)
+ return ResTy;
+
// Consume the $ if there is one. We'll add it to the symbol below.
bool hasConsumedDollar = false;
if (getLexer().is(AsmToken::Dollar)) {
Parser.Lex();
hasConsumedDollar = true;
-
- // We have an unfortunate conflict between '$sym' and '$reg' so give
- // registers a chance before we try symbols.
- // The conflict is between 'bc1t $offset', and 'bc1t $fcc, $offset'.
- OperandMatchResultTy ResTy = ParseAnyRegisterWithoutDollar(Operands, S);
- if (ResTy != MatchOperand_NoMatch)
- return ResTy;
}
StringRef Identifier;