summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Sanders <daniel.sanders@imgtec.com>2014-04-01 10:41:48 +0000
committerDaniel Sanders <daniel.sanders@imgtec.com>2014-04-01 10:41:48 +0000
commitf2452c4cec8a4db6e664a1065d9b3795c52c5b3a (patch)
tree323df03bb9237aa76eb52568b980a8fabca837cf
parent1302349706dc77288adfff2b4263c1e1942bc4b1 (diff)
downloadllvm-f2452c4cec8a4db6e664a1065d9b3795c52c5b3a.tar.gz
llvm-f2452c4cec8a4db6e664a1065d9b3795c52c5b3a.tar.bz2
llvm-f2452c4cec8a4db6e664a1065d9b3795c52c5b3a.tar.xz
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205298 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/Mips/AsmParser/MipsAsmParser.cpp33
-rw-r--r--test/MC/Mips/sym-expr.s14
2 files changed, 20 insertions, 27 deletions
diff --git a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index 12469822f7..759a2db283 100644
--- a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -1868,35 +1868,14 @@ MipsAsmParser::OperandMatchResultTy MipsAsmParser::ParseJumpTarget(
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
diff --git a/test/MC/Mips/sym-expr.s b/test/MC/Mips/sym-expr.s
new file mode 100644
index 0000000000..efefb1d5c4
--- /dev/null
+++ b/test/MC/Mips/sym-expr.s
@@ -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