Skip to content

Commit

Permalink
Revert r277988: [mips][ias] Fix all the hacks related to MIPS-specifi…
Browse files Browse the repository at this point in the history
…c unary operators (%hi/%lo/%gp_rel/etc.).

It seems that MSVC doesn't like std::tie().



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277990 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dsandersllvm committed Aug 8, 2016
1 parent 0074173 commit 0985f50
Show file tree
Hide file tree
Showing 14 changed files with 185 additions and 287 deletions.
5 changes: 0 additions & 5 deletions include/llvm/MC/MCAsmInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,6 @@ class MCAsmInfo {
// X86_64 ELF.
bool RelaxELFRelocations = true;

// If true, then the lexer and expression parser will support %neg(),
// %hi(), and similar unary operators.
bool HasMipsExpressions = false;

public:
explicit MCAsmInfo();
virtual ~MCAsmInfo();
Expand Down Expand Up @@ -586,7 +582,6 @@ class MCAsmInfo {

bool canRelaxRelocations() const { return RelaxELFRelocations; }
void setRelaxELFRelocations(bool V) { RelaxELFRelocations = V; }
bool hasMipsExpressions() const { return HasMipsExpressions; }
};
}

Expand Down
10 changes: 1 addition & 9 deletions include/llvm/MC/MCParser/MCAsmLexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,7 @@ class AsmToken {
Pipe, PipePipe, Caret,
Amp, AmpAmp, Exclaim, ExclaimEqual, Percent, Hash,
Less, LessEqual, LessLess, LessGreater,
Greater, GreaterEqual, GreaterGreater, At,

// MIPS unary expression operators such as %neg.
PercentCall16, PercentCall_Hi, PercentCall_Lo, PercentDtprel_Hi,
PercentDtprel_Lo, PercentGot, PercentGot_Disp, PercentGot_Hi, PercentGot_Lo,
PercentGot_Ofst, PercentGot_Page, PercentGottprel, PercentGp_Rel, PercentHi,
PercentHigher, PercentHighest, PercentLo, PercentNeg, PercentPcrel_Hi,
PercentPcrel_Lo, PercentTlsgd, PercentTlsldm, PercentTprel_Hi,
PercentTprel_Lo
Greater, GreaterEqual, GreaterGreater, At
};

private:
Expand Down
6 changes: 0 additions & 6 deletions include/llvm/MC/MCParser/MCTargetAsmParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,6 @@ class MCTargetAsmParser : public MCAsmParserExtension {
/// Ensure that all previously parsed instructions have been emitted to the
/// output streamer, if the target does not emit them immediately.
virtual void flushPendingInstructions(MCStreamer &Out) { }

virtual const MCExpr *createTargetUnaryExpr(const MCExpr *E,
AsmToken::TokenKind OperatorToken,
MCContext &Ctx) {
return nullptr;
}
};

} // End llvm namespace
Expand Down
42 changes: 1 addition & 41 deletions lib/MC/MCParser/AsmLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//
//===----------------------------------------------------------------------===//

#include "llvm/ADT/StringSwitch.h"
#include "llvm/MC/MCParser/AsmLexer.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Support/MemoryBuffer.h"
Expand Down Expand Up @@ -601,46 +600,7 @@ AsmToken AsmLexer::LexToken() {
return AsmToken(AsmToken::ExclaimEqual, StringRef(TokStart, 2));
}
return AsmToken(AsmToken::Exclaim, StringRef(TokStart, 1));
case '%':
if (MAI.hasMipsExpressions()) {
AsmToken::TokenKind Operator;
unsigned OperatorLength;

std::tie(Operator, OperatorLength) =
StringSwitch<std::pair<AsmToken::TokenKind, unsigned>>(
StringRef(CurPtr))
.StartsWith("call16", {AsmToken::PercentCall16, 7})
.StartsWith("call_hi", {AsmToken::PercentCall_Hi, 8})
.StartsWith("call_lo", {AsmToken::PercentCall_Lo, 8})
.StartsWith("dtprel_hi", {AsmToken::PercentDtprel_Hi, 10})
.StartsWith("dtprel_lo", {AsmToken::PercentDtprel_Lo, 10})
.StartsWith("got_disp", {AsmToken::PercentGot_Disp, 9})
.StartsWith("got_hi", {AsmToken::PercentGot_Hi, 7})
.StartsWith("got_lo", {AsmToken::PercentGot_Lo, 7})
.StartsWith("got_ofst", {AsmToken::PercentGot_Ofst, 9})
.StartsWith("got_page", {AsmToken::PercentGot_Page, 9})
.StartsWith("gottprel", {AsmToken::PercentGottprel, 9})
.StartsWith("got", {AsmToken::PercentGot, 4})
.StartsWith("gp_rel", {AsmToken::PercentGp_Rel, 7})
.StartsWith("higher", {AsmToken::PercentHigher, 7})
.StartsWith("highest", {AsmToken::PercentHighest, 8})
.StartsWith("hi", {AsmToken::PercentHi, 3})
.StartsWith("lo", {AsmToken::PercentLo, 3})
.StartsWith("neg", {AsmToken::PercentNeg, 4})
.StartsWith("pcrel_hi", {AsmToken::PercentPcrel_Hi, 9})
.StartsWith("pcrel_lo", {AsmToken::PercentPcrel_Lo, 9})
.StartsWith("tlsgd", {AsmToken::PercentTlsgd, 6})
.StartsWith("tlsldm", {AsmToken::PercentTlsldm, 7})
.StartsWith("tprel_hi", {AsmToken::PercentTprel_Hi, 9})
.StartsWith("tprel_lo", {AsmToken::PercentTprel_Lo, 9})
.Default({AsmToken::Percent, 1});

if (Operator != AsmToken::Percent) {
CurPtr += OperatorLength - 1;
return AsmToken(Operator, StringRef(TokStart, OperatorLength));
}
}
return AsmToken(AsmToken::Percent, StringRef(TokStart, 1));
case '%': return AsmToken(AsmToken::Percent, StringRef(TokStart, 1));
case '/':
IsAtStartOfStatement = OldIsAtStartOfStatement;
return LexSlash();
Expand Down
37 changes: 0 additions & 37 deletions lib/MC/MCParser/AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,43 +1064,6 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
return true;
Res = MCUnaryExpr::createNot(Res, getContext());
return false;
// MIPS unary expression operators. The lexer won't generate these tokens if
// MCAsmInfo::HasMipsExpressions is false for the target.
case AsmToken::PercentCall16:
case AsmToken::PercentCall_Hi:
case AsmToken::PercentCall_Lo:
case AsmToken::PercentDtprel_Hi:
case AsmToken::PercentDtprel_Lo:
case AsmToken::PercentGot:
case AsmToken::PercentGot_Disp:
case AsmToken::PercentGot_Hi:
case AsmToken::PercentGot_Lo:
case AsmToken::PercentGot_Ofst:
case AsmToken::PercentGot_Page:
case AsmToken::PercentGottprel:
case AsmToken::PercentGp_Rel:
case AsmToken::PercentHi:
case AsmToken::PercentHigher:
case AsmToken::PercentHighest:
case AsmToken::PercentLo:
case AsmToken::PercentNeg:
case AsmToken::PercentPcrel_Hi:
case AsmToken::PercentPcrel_Lo:
case AsmToken::PercentTlsgd:
case AsmToken::PercentTlsldm:
case AsmToken::PercentTprel_Hi:
case AsmToken::PercentTprel_Lo:
Lex(); // Eat the operator.
if (Lexer.isNot(AsmToken::LParen))
return TokError("expected '(' after operator");
Lex(); // Eat the operator.
if (parseExpression(Res, EndLoc))
return true;
if (Lexer.isNot(AsmToken::RParen))
return TokError("expected ')'");
Lex(); // Eat the operator.
Res = getTargetParser().createTargetUnaryExpr(Res, FirstTokenKind, Ctx);
return !Res;
}
}

Expand Down
Loading

0 comments on commit 0985f50

Please sign in to comment.