[llvm-commits] [llvm] r124467 - in /llvm/trunk: lib/MC/MCParser/AsmParser.cpp test/MC/AsmParser/equ.s
Nico Weber
nicolasweber at gmx.de
Thu Jan 27 19:04:41 PST 2011
Author: nico
Date: Thu Jan 27 21:04:41 2011
New Revision: 124467
URL: http://llvm.org/viewvc/llvm-project?rev=124467&view=rev
Log:
PR8951: Support for .equiv in integrated assembler, patch by Jörg Sonnenberger!
Added:
llvm/trunk/test/MC/AsmParser/equ.s
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=124467&r1=124466&r2=124467&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Thu Jan 27 21:04:41 2011
@@ -168,7 +168,7 @@
/// will be either the EndOfStatement or EOF.
StringRef ParseStringToEndOfStatement();
- bool ParseAssignment(StringRef Name);
+ bool ParseAssignment(StringRef Name, bool allow_redef);
bool ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc);
bool ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res, SMLoc &EndLoc);
@@ -187,7 +187,7 @@
bool ParseDirectiveFill(); // ".fill"
bool ParseDirectiveSpace(); // ".space"
bool ParseDirectiveZero(); // ".zero"
- bool ParseDirectiveSet(StringRef IDVal); // ".set" or ".equ"
+ bool ParseDirectiveSet(StringRef IDVal, bool allow_redef); // ".set", ".equ", ".equiv"
bool ParseDirectiveOrg(); // ".org"
// ".align{,32}", ".p2align{,w,l}"
bool ParseDirectiveAlign(bool IsPow2, unsigned ValueSize);
@@ -941,7 +941,7 @@
// identifier '=' ... -> assignment statement
Lex();
- return ParseAssignment(IDVal);
+ return ParseAssignment(IDVal, true);
default: // Normal instruction or directive.
break;
@@ -956,7 +956,9 @@
if (IDVal[0] == '.') {
// Assembler features
if (IDVal == ".set" || IDVal == ".equ")
- return ParseDirectiveSet(IDVal);
+ return ParseDirectiveSet(IDVal, true);
+ if (IDVal == ".equiv")
+ return ParseDirectiveSet(IDVal, false);
// Data directives
@@ -1263,7 +1265,7 @@
}
}
-bool AsmParser::ParseAssignment(StringRef Name) {
+bool AsmParser::ParseAssignment(StringRef Name, bool allow_redef) {
// FIXME: Use better location, we should use proper tokens.
SMLoc EqualLoc = Lexer.getLoc();
@@ -1289,7 +1291,7 @@
// FIXME: Diagnose assignment to protected identifier (e.g., register name).
if (Sym->isUndefined() && !Sym->isUsed() && !Sym->isVariable())
; // Allow redefinitions of undefined symbols only used in directives.
- else if (!Sym->isUndefined() && !Sym->isAbsolute())
+ else if (!Sym->isUndefined() && (!Sym->isAbsolute() || !allow_redef))
return Error(EqualLoc, "redefinition of '" + Name + "'");
else if (!Sym->isVariable())
return Error(EqualLoc, "invalid assignment to '" + Name + "'");
@@ -1350,8 +1352,10 @@
}
/// ParseDirectiveSet:
+/// ::= .equ identifier ',' expression
+/// ::= .equiv identifier ',' expression
/// ::= .set identifier ',' expression
-bool AsmParser::ParseDirectiveSet(StringRef IDVal) {
+bool AsmParser::ParseDirectiveSet(StringRef IDVal, bool allow_redef) {
StringRef Name;
if (ParseIdentifier(Name))
@@ -1361,7 +1365,7 @@
return TokError("unexpected token in '" + Twine(IDVal) + "'");
Lex();
- return ParseAssignment(Name);
+ return ParseAssignment(Name, allow_redef);
}
bool AsmParser::ParseEscapedString(std::string &Data) {
Added: llvm/trunk/test/MC/AsmParser/equ.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/equ.s?rev=124467&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/equ.s (added)
+++ llvm/trunk/test/MC/AsmParser/equ.s Thu Jan 27 21:04:41 2011
@@ -0,0 +1,9 @@
+// RUN: not llvm-mc -n -triple i386-unknown-unknown %s 2> %t
+// RUN: FileCheck < %t %s
+
+.equ a, 0
+.set a, 1
+.equ a, 2
+.equiv a, 3
+// CHECK: error: redefinition of 'a'
+
More information about the llvm-commits
mailing list