[llvm-commits] [llvm] r74498 - in /llvm/trunk: test/MC/AsmParser/exprs.s tools/llvm-mc/AsmParser.cpp
Daniel Dunbar
daniel at zuster.org
Mon Jun 29 19:10:03 PDT 2009
Author: ddunbar
Date: Mon Jun 29 21:10:03 2009
New Revision: 74498
URL: http://llvm.org/viewvc/llvm-project?rev=74498&view=rev
Log:
llvm-mc: Accept relocatable expressions for .org, assignments, .byte, etc.
Modified:
llvm/trunk/test/MC/AsmParser/exprs.s
llvm/trunk/tools/llvm-mc/AsmParser.cpp
Modified: llvm/trunk/test/MC/AsmParser/exprs.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/exprs.s?rev=74498&r1=74497&r2=74498&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/exprs.s (original)
+++ llvm/trunk/test/MC/AsmParser/exprs.s Mon Jun 29 21:10:03 2009
@@ -3,7 +3,13 @@
// greps).
// RUN: llvm-mc %s > %t
-
+
+ .text
+g:
+h:
+j:
+k:
+ .data
.byte !1 + 2
.byte !0
.byte ~0
@@ -36,4 +42,14 @@
.set c, 10
.byte c + 1
+
+ d = e + 10
+ .long d
+
+ f = g - h + 5
+ .long f
+
+ i = (j + 10) - (k + 2)
+ .long i
+
\ No newline at end of file
Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=74498&r1=74497&r2=74498&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Mon Jun 29 21:10:03 2009
@@ -144,11 +144,12 @@
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;
}
@@ -156,11 +157,12 @@
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;
}
@@ -525,8 +527,8 @@
// 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))
@@ -549,7 +551,7 @@
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;
}
@@ -651,11 +653,11 @@
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;
@@ -746,8 +748,8 @@
/// ParseDirectiveOrg
/// ::= .org expression [ , expression ]
bool AsmParser::ParseDirectiveOrg() {
- int64_t Offset;
- if (ParseAbsoluteExpression(Offset))
+ MCValue Offset;
+ if (ParseRelocatableExpression(Offset))
return true;
// Parse optional fill expression.
@@ -765,8 +767,10 @@
}
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;
}
More information about the llvm-commits
mailing list