[llvm] r205298 - [mips] Extend ParseJumpTarget to support the full symbol expression syntax.
Daniel Sanders
daniel.sanders at imgtec.com
Tue Apr 1 03:41:48 PDT 2014
Author: dsanders
Date: Tue Apr 1 05:41:48 2014
New Revision: 205298
URL: http://llvm.org/viewvc/llvm-project?rev=205298&view=rev
Log:
[mips] Extend ParseJumpTarget to support the full symbol expression syntax.
Summary:
This should fix the issues the D3222 caused in lld. Testcase is based on
the one that failed in the buildbot.
Depends on D3233
Reviewers: matheusalmeida, vmedic
Reviewed By: matheusalmeida
Differential Revision: http://llvm-reviews.chandlerc.com/D3234
Added:
llvm/trunk/test/MC/Mips/sym-expr.s
Modified:
llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
Modified: llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp?rev=205298&r1=205297&r2=205298&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Tue Apr 1 05:41:48 2014
@@ -1868,35 +1868,14 @@ MipsAsmParser::OperandMatchResultTy Mips
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;
+ const MCExpr *Expr = nullptr;
+ if (Parser.parseExpression(Expr)) {
+ // We have no way of knowing if a symbol was consumed so we must ParseFail
+ return MatchOperand_ParseFail;
}
-
- StringRef Identifier;
- if (Parser.parseIdentifier(Identifier))
- return hasConsumedDollar ? MatchOperand_ParseFail : MatchOperand_NoMatch;
-
- if (hasConsumedDollar)
- Identifier = StringRef("$" + Identifier.str());
-
- SMLoc E = SMLoc::getFromPointer(Parser.getTok().getLoc().getPointer() - 1);
- MCSymbol *Sym = getContext().GetOrCreateSymbol(Identifier);
-
- // Create a symbol reference.
- const MCExpr *Res =
- MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_None, getContext());
-
- Operands.push_back(MipsOperand::CreateImm(Res, S, E, *this));
+ Operands.push_back(
+ MipsOperand::CreateImm(Expr, S, getLexer().getLoc(), *this));
return MatchOperand_Success;
- // // Look for the existing symbol, we should check if
- // // we need to assign the proper RegisterKind.
- // if (searchSymbolAlias(Operands))
- // return false;
-
- return MatchOperand_NoMatch;
}
MipsAsmParser::OperandMatchResultTy
Added: llvm/trunk/test/MC/Mips/sym-expr.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/sym-expr.s?rev=205298&view=auto
==============================================================================
--- llvm/trunk/test/MC/Mips/sym-expr.s (added)
+++ llvm/trunk/test/MC/Mips/sym-expr.s Tue Apr 1 05:41:48 2014
@@ -0,0 +1,14 @@
+# Check parsing symbol expressions
+
+# RUN: llvm-mc -triple=mipsel -show-inst-operands %s 2> %t0
+# RUN: FileCheck %s < %t0
+
+ .global __start
+ .ent __start
+__start:
+ nop
+loc:
+ jal __start + 0x4 # CHECK: instruction: [jal, Imm<__start+4>]
+ jal __start + (-0x10) # CHECK: instruction: [jal, Imm<__start-16>]
+ jal (__start + (-0x10)) # CHECK: instruction: [jal, Imm<__start-16>]
+ .end __start
More information about the llvm-commits
mailing list