mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-17 19:51:13 +00:00
llvm-mc: Add MCAsmParser::getContext.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80571 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
87392fde1f
commit
6ce004dc76
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class MCAsmLexer;
|
class MCAsmLexer;
|
||||||
|
class MCContext;
|
||||||
class MCValue;
|
class MCValue;
|
||||||
class SMLoc;
|
class SMLoc;
|
||||||
class Twine;
|
class Twine;
|
||||||
@ -31,6 +32,8 @@ public:
|
|||||||
|
|
||||||
virtual MCAsmLexer &getLexer() = 0;
|
virtual MCAsmLexer &getLexer() = 0;
|
||||||
|
|
||||||
|
virtual MCContext &getContext() = 0;
|
||||||
|
|
||||||
/// Warning - Emit a warning at the location \arg L, with the message \arg
|
/// Warning - Emit a warning at the location \arg L, with the message \arg
|
||||||
/// Msg.
|
/// Msg.
|
||||||
virtual void Warning(SMLoc L, const Twine &Msg) = 0;
|
virtual void Warning(SMLoc L, const Twine &Msg) = 0;
|
||||||
|
@ -205,7 +205,7 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res) {
|
|||||||
Lexer.Lex(); // Eat the operator.
|
Lexer.Lex(); // Eat the operator.
|
||||||
if (ParsePrimaryExpr(Res))
|
if (ParsePrimaryExpr(Res))
|
||||||
return true;
|
return true;
|
||||||
Res = MCUnaryExpr::CreateLNot(Res, Ctx);
|
Res = MCUnaryExpr::CreateLNot(Res, getContext());
|
||||||
return false;
|
return false;
|
||||||
case AsmToken::String:
|
case AsmToken::String:
|
||||||
case AsmToken::Identifier: {
|
case AsmToken::Identifier: {
|
||||||
@ -213,12 +213,12 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res) {
|
|||||||
// handle things like LFOO+4.
|
// handle things like LFOO+4.
|
||||||
MCSymbol *Sym = CreateSymbol(Lexer.getTok().getIdentifier());
|
MCSymbol *Sym = CreateSymbol(Lexer.getTok().getIdentifier());
|
||||||
|
|
||||||
Res = MCSymbolRefExpr::Create(Sym, Ctx);
|
Res = MCSymbolRefExpr::Create(Sym, getContext());
|
||||||
Lexer.Lex(); // Eat identifier.
|
Lexer.Lex(); // Eat identifier.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case AsmToken::Integer:
|
case AsmToken::Integer:
|
||||||
Res = MCConstantExpr::Create(Lexer.getTok().getIntVal(), Ctx);
|
Res = MCConstantExpr::Create(Lexer.getTok().getIntVal(), getContext());
|
||||||
Lexer.Lex(); // Eat token.
|
Lexer.Lex(); // Eat token.
|
||||||
return false;
|
return false;
|
||||||
case AsmToken::LParen:
|
case AsmToken::LParen:
|
||||||
@ -228,19 +228,19 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res) {
|
|||||||
Lexer.Lex(); // Eat the operator.
|
Lexer.Lex(); // Eat the operator.
|
||||||
if (ParsePrimaryExpr(Res))
|
if (ParsePrimaryExpr(Res))
|
||||||
return true;
|
return true;
|
||||||
Res = MCUnaryExpr::CreateMinus(Res, Ctx);
|
Res = MCUnaryExpr::CreateMinus(Res, getContext());
|
||||||
return false;
|
return false;
|
||||||
case AsmToken::Plus:
|
case AsmToken::Plus:
|
||||||
Lexer.Lex(); // Eat the operator.
|
Lexer.Lex(); // Eat the operator.
|
||||||
if (ParsePrimaryExpr(Res))
|
if (ParsePrimaryExpr(Res))
|
||||||
return true;
|
return true;
|
||||||
Res = MCUnaryExpr::CreatePlus(Res, Ctx);
|
Res = MCUnaryExpr::CreatePlus(Res, getContext());
|
||||||
return false;
|
return false;
|
||||||
case AsmToken::Tilde:
|
case AsmToken::Tilde:
|
||||||
Lexer.Lex(); // Eat the operator.
|
Lexer.Lex(); // Eat the operator.
|
||||||
if (ParsePrimaryExpr(Res))
|
if (ParsePrimaryExpr(Res))
|
||||||
return true;
|
return true;
|
||||||
Res = MCUnaryExpr::CreateNot(Res, Ctx);
|
Res = MCUnaryExpr::CreateNot(Res, getContext());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,7 +300,8 @@ bool AsmParser::ParseParenRelocatableExpression(MCValue &Res) {
|
|||||||
static unsigned getBinOpPrecedence(AsmToken::TokenKind K,
|
static unsigned getBinOpPrecedence(AsmToken::TokenKind K,
|
||||||
MCBinaryExpr::Opcode &Kind) {
|
MCBinaryExpr::Opcode &Kind) {
|
||||||
switch (K) {
|
switch (K) {
|
||||||
default: return 0; // not a binop.
|
default:
|
||||||
|
return 0; // not a binop.
|
||||||
|
|
||||||
// Lowest Precedence: &&, ||
|
// Lowest Precedence: &&, ||
|
||||||
case AsmToken::AmpAmp:
|
case AsmToken::AmpAmp:
|
||||||
@ -397,7 +398,7 @@ bool AsmParser::ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Merge LHS and RHS according to operator.
|
// Merge LHS and RHS according to operator.
|
||||||
Res = MCBinaryExpr::Create(Kind, Res, RHS, Ctx);
|
Res = MCBinaryExpr::Create(Kind, Res, RHS, getContext());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +62,8 @@ public:
|
|||||||
|
|
||||||
virtual MCAsmLexer &getLexer() { return Lexer; }
|
virtual MCAsmLexer &getLexer() { return Lexer; }
|
||||||
|
|
||||||
|
virtual MCContext &getContext() { return Ctx; }
|
||||||
|
|
||||||
virtual void Warning(SMLoc L, const Twine &Meg);
|
virtual void Warning(SMLoc L, const Twine &Meg);
|
||||||
|
|
||||||
virtual bool Error(SMLoc L, const Twine &Msg);
|
virtual bool Error(SMLoc L, const Twine &Msg);
|
||||||
@ -72,6 +74,8 @@ public:
|
|||||||
|
|
||||||
virtual bool ParseRelocatableExpression(MCValue &Res);
|
virtual bool ParseRelocatableExpression(MCValue &Res);
|
||||||
|
|
||||||
|
virtual bool ParseParenRelocatableExpression(MCValue &Res);
|
||||||
|
|
||||||
/// }
|
/// }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -94,16 +98,6 @@ private:
|
|||||||
|
|
||||||
bool ParseAssignment(const StringRef &Name, bool IsDotSet);
|
bool ParseAssignment(const StringRef &Name, bool IsDotSet);
|
||||||
|
|
||||||
/// ParseParenRelocatableExpression - Parse an expression which must be
|
|
||||||
/// relocatable, assuming that an initial '(' has already been consumed.
|
|
||||||
///
|
|
||||||
/// @param Res - The relocatable expression value. The result is undefined on
|
|
||||||
/// error.
|
|
||||||
/// @result - False on success.
|
|
||||||
///
|
|
||||||
/// @see ParseRelocatableExpression, ParseParenExpr.
|
|
||||||
bool ParseParenRelocatableExpression(MCValue &Res);
|
|
||||||
|
|
||||||
bool ParsePrimaryExpr(const MCExpr *&Res);
|
bool ParsePrimaryExpr(const MCExpr *&Res);
|
||||||
bool ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res);
|
bool ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res);
|
||||||
bool ParseParenExpr(const MCExpr *&Res);
|
bool ParseParenExpr(const MCExpr *&Res);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user