bool AsmParser::ParseAbsoluteExpression(int64_t &Res) {
AsmExpr *Expr;
+ SMLoc StartLoc = Lexer.getLoc();
if (ParseExpression(Expr))
return true;
if (!Expr->EvaluateAsAbsolute(Ctx, Res))
- return TokError("expected absolute expression");
+ return Error(StartLoc, "expected absolute expression");
return false;
}
bool AsmParser::ParseRelocatableExpression(MCValue &Res) {
AsmExpr *Expr;
+ SMLoc StartLoc = Lexer.getLoc();
if (ParseExpression(Expr))
return true;
if (!Expr->EvaluateAsRelocatable(Ctx, Res))
- return TokError("expected relocatable expression");
+ return Error(StartLoc, "expected relocatable expression");
return false;
}
// FIXME: Use better location, we should use proper tokens.
SMLoc EqualLoc = Lexer.getLoc();
- int64_t Value;
- if (ParseAbsoluteExpression(Value))
+ MCValue Value;
+ if (ParseRelocatableExpression(Value))
return true;
if (Lexer.isNot(asmtok::EndOfStatement))
return Error(EqualLoc, "invalid assignment to external symbol");
// Do the assignment.
- Out.EmitAssignment(Sym, MCValue::get(Value), IsDotSet);
+ Out.EmitAssignment(Sym, Value, IsDotSet);
return false;
}
bool AsmParser::ParseDirectiveValue(unsigned Size) {
if (Lexer.isNot(asmtok::EndOfStatement)) {
for (;;) {
- int64_t Expr;
- if (ParseAbsoluteExpression(Expr))
+ MCValue Expr;
+ if (ParseRelocatableExpression(Expr))
return true;
- Out.EmitValue(MCValue::get(Expr), Size);
+ Out.EmitValue(Expr, Size);
if (Lexer.is(asmtok::EndOfStatement))
break;
/// ParseDirectiveOrg
/// ::= .org expression [ , expression ]
bool AsmParser::ParseDirectiveOrg() {
- int64_t Offset;
- if (ParseAbsoluteExpression(Offset))
+ MCValue Offset;
+ if (ParseRelocatableExpression(Offset))
return true;
// Parse optional fill expression.
}
Lexer.Lex();
-
- Out.EmitValueToOffset(MCValue::get(Offset), FillExpr);
+
+ // FIXME: Only limited forms of relocatable expressions are accepted here, it
+ // has to be relative to the current section.
+ Out.EmitValueToOffset(Offset, FillExpr);
return false;
}