llvm-mc: Remove MCAsmParser::Parse[Paren]RelocatableExpression.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80576 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar
2009-08-31 08:08:50 +00:00
parent 8c2eebe407
commit 883f920acb
3 changed files with 27 additions and 55 deletions

View File

@ -68,24 +68,6 @@ public:
/// on error. /// on error.
/// @result - False on success. /// @result - False on success.
virtual bool ParseAbsoluteExpression(int64_t &Res) = 0; virtual bool ParseAbsoluteExpression(int64_t &Res) = 0;
/// ParseRelocatableExpression - Parse an expression which must be
/// relocatable.
///
/// @param Res - The relocatable expression value. The result is undefined on
/// error.
/// @result - False on success.
virtual bool ParseRelocatableExpression(MCValue &Res) = 0;
/// 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.
virtual bool ParseParenRelocatableExpression(MCValue &Res) = 0;
}; };
} // End llvm namespace } // End llvm namespace

View File

@ -279,32 +279,6 @@ bool AsmParser::ParseAbsoluteExpression(int64_t &Res) {
return false; return false;
} }
bool AsmParser::ParseRelocatableExpression(MCValue &Res) {
const MCExpr *Expr;
SMLoc StartLoc = Lexer.getLoc();
if (ParseExpression(Expr))
return true;
if (!Expr->EvaluateAsRelocatable(Ctx, Res))
return Error(StartLoc, "expected relocatable expression");
return false;
}
bool AsmParser::ParseParenRelocatableExpression(MCValue &Res) {
const MCExpr *Expr;
SMLoc StartLoc = Lexer.getLoc();
if (ParseParenExpr(Expr))
return true;
if (!Expr->EvaluateAsRelocatable(Ctx, Res))
return Error(StartLoc, "expected relocatable expression");
return false;
}
static unsigned getBinOpPrecedence(AsmToken::TokenKind K, static unsigned getBinOpPrecedence(AsmToken::TokenKind K,
MCBinaryExpr::Opcode &Kind) { MCBinaryExpr::Opcode &Kind) {
switch (K) { switch (K) {
@ -739,9 +713,14 @@ bool AsmParser::ParseAssignment(const StringRef &Name, bool IsDotSet) {
SMLoc EqualLoc = Lexer.getLoc(); SMLoc EqualLoc = Lexer.getLoc();
MCValue Value; MCValue Value;
if (ParseRelocatableExpression(Value)) const MCExpr *Expr;
SMLoc StartLoc = Lexer.getLoc();
if (ParseExpression(Expr))
return true; return true;
if (!Expr->EvaluateAsRelocatable(Ctx, Value))
return Error(StartLoc, "expected relocatable expression");
if (Lexer.isNot(AsmToken::EndOfStatement)) if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in assignment"); return TokError("unexpected token in assignment");
@ -958,11 +937,16 @@ bool AsmParser::ParseDirectiveAscii(bool ZeroTerminated) {
bool AsmParser::ParseDirectiveValue(unsigned Size) { bool AsmParser::ParseDirectiveValue(unsigned Size) {
if (Lexer.isNot(AsmToken::EndOfStatement)) { if (Lexer.isNot(AsmToken::EndOfStatement)) {
for (;;) { for (;;) {
MCValue Expr; MCValue Value;
if (ParseRelocatableExpression(Expr)) const MCExpr *Expr;
SMLoc StartLoc = Lexer.getLoc();
if (ParseExpression(Expr))
return true; return true;
Out.EmitValue(Expr, Size); if (!Expr->EvaluateAsRelocatable(Ctx, Value))
return Error(StartLoc, "expected relocatable expression");
Out.EmitValue(Value, Size);
if (Lexer.is(AsmToken::EndOfStatement)) if (Lexer.is(AsmToken::EndOfStatement))
break; break;
@ -1054,9 +1038,14 @@ bool AsmParser::ParseDirectiveFill() {
/// ::= .org expression [ , expression ] /// ::= .org expression [ , expression ]
bool AsmParser::ParseDirectiveOrg() { bool AsmParser::ParseDirectiveOrg() {
MCValue Offset; MCValue Offset;
if (ParseRelocatableExpression(Offset)) const MCExpr *Expr;
SMLoc StartLoc = Lexer.getLoc();
if (ParseExpression(Expr))
return true; return true;
if (!Expr->EvaluateAsRelocatable(Ctx, Offset))
return Error(StartLoc, "expected relocatable expression");
// Parse optional fill expression. // Parse optional fill expression.
int64_t FillExpr = 0; int64_t FillExpr = 0;
if (Lexer.isNot(AsmToken::EndOfStatement)) { if (Lexer.isNot(AsmToken::EndOfStatement)) {
@ -1428,10 +1417,15 @@ bool AsmParser::ParseDirectiveDarwinLsym() {
return TokError("unexpected token in '.lsym' directive"); return TokError("unexpected token in '.lsym' directive");
Lexer.Lex(); Lexer.Lex();
MCValue Expr; MCValue Value;
if (ParseRelocatableExpression(Expr)) const MCExpr *Expr;
SMLoc StartLoc = Lexer.getLoc();
if (ParseExpression(Expr))
return true; return true;
if (!Expr->EvaluateAsRelocatable(Ctx, Value))
return Error(StartLoc, "expected relocatable expression");
if (Lexer.isNot(AsmToken::EndOfStatement)) if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.lsym' directive"); return TokError("unexpected token in '.lsym' directive");

View File

@ -74,10 +74,6 @@ public:
virtual bool ParseAbsoluteExpression(int64_t &Res); virtual bool ParseAbsoluteExpression(int64_t &Res);
virtual bool ParseRelocatableExpression(MCValue &Res);
virtual bool ParseParenRelocatableExpression(MCValue &Res);
/// } /// }
private: private: