Implement .equ directive as a synonym to .set.
authorRoman Divacky <rdivacky@freebsd.org>
Thu, 28 Oct 2010 16:22:58 +0000 (16:22 +0000)
committerRoman Divacky <rdivacky@freebsd.org>
Thu, 28 Oct 2010 16:22:58 +0000 (16:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117553 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCParser/AsmParser.cpp
test/MC/AsmParser/directive_set.s

index a7045c5cd597072adae9302d40f96ce9b3f22894..aa0f9f0ced9bbe48223b0161f66938d5ad565ee0 100644 (file)
@@ -183,7 +183,7 @@ private:
   bool ParseDirectiveFill(); // ".fill"
   bool ParseDirectiveSpace(); // ".space"
   bool ParseDirectiveZero(); // ".zero"
-  bool ParseDirectiveSet(); // ".set"
+  bool ParseDirectiveSet(StringRef IDVal); // ".set" or ".equ"
   bool ParseDirectiveOrg(); // ".org"
   // ".align{,32}", ".p2align{,w,l}"
   bool ParseDirectiveAlign(bool IsPow2, unsigned ValueSize);
@@ -913,8 +913,8 @@ bool AsmParser::ParseStatement() {
   // Otherwise, we have a normal instruction or directive.
   if (IDVal[0] == '.') {
     // Assembler features
-    if (IDVal == ".set")
-      return ParseDirectiveSet();
+    if (IDVal == ".set" || IDVal == ".equ")
+      return ParseDirectiveSet(IDVal);
 
     // Data directives
 
@@ -1275,14 +1275,14 @@ bool AsmParser::ParseIdentifier(StringRef &Res) {
 
 /// ParseDirectiveSet:
 ///   ::= .set identifier ',' expression
-bool AsmParser::ParseDirectiveSet() {
+bool AsmParser::ParseDirectiveSet(StringRef IDVal) {
   StringRef Name;
 
   if (ParseIdentifier(Name))
-    return TokError("expected identifier after '.set' directive");
+    return TokError("expected identifier after '" + Twine(IDVal.str()) + "'");
 
   if (getLexer().isNot(AsmToken::Comma))
-    return TokError("unexpected token in '.set'");
+    return TokError("unexpected token in '" + Twine(IDVal.str()) + "'");
   Lex();
 
   return ParseAssignment(Name);
index f1fc30a85df1426d264ef1a5c8eb8d97ba2294f1..69abce0db2ffab0685958631163adb615183f87b 100644 (file)
@@ -5,3 +5,8 @@
 TEST0:  
         .set a, 0
         
+# CHECK: TEST1:
+# CHECK: a = 0
+TEST1:  
+        .equ a, 0
+