[PATCH] IAS: support .rep as an alias for .rept

Saleem Abdulrasool compnerd at compnerd.org
Sun Dec 22 15:44:51 PST 2013


  Now with 100% more implementation!

Hi rengolin,

http://llvm-reviews.chandlerc.com/D2457

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2457?vs=6229&id=6232#toc

Files:
  lib/MC/MCParser/AsmParser.cpp
  test/MC/AsmParser/directive_rept.s

Index: lib/MC/MCParser/AsmParser.cpp
===================================================================
--- lib/MC/MCParser/AsmParser.cpp
+++ lib/MC/MCParser/AsmParser.cpp
@@ -347,7 +347,8 @@
     DK_LAZY_REFERENCE, DK_NO_DEAD_STRIP, DK_SYMBOL_RESOLVER, DK_PRIVATE_EXTERN,
     DK_REFERENCE, DK_WEAK_DEFINITION, DK_WEAK_REFERENCE,
     DK_WEAK_DEF_CAN_BE_HIDDEN, DK_COMM, DK_COMMON, DK_LCOMM, DK_ABORT,
-    DK_INCLUDE, DK_INCBIN, DK_CODE16, DK_CODE16GCC, DK_REPT, DK_IRP, DK_IRPC,
+    DK_INCLUDE, DK_INCBIN, DK_CODE16, DK_CODE16GCC, DK_REP, DK_REPT,
+    DK_IRP, DK_IRPC,
     DK_IF, DK_IFB, DK_IFNB, DK_IFC, DK_IFNC, DK_IFDEF, DK_IFNDEF, DK_IFNOTDEF,
     DK_ELSEIF, DK_ELSE, DK_ENDIF,
     DK_SPACE, DK_SKIP, DK_FILE, DK_LINE, DK_LOC, DK_STABS,
@@ -453,7 +454,7 @@
   MCAsmMacro *parseMacroLikeBody(SMLoc DirectiveLoc);
   void instantiateMacroLikeBody(MCAsmMacro *M, SMLoc DirectiveLoc,
                                 raw_svector_ostream &OS);
-  bool parseDirectiveRept(SMLoc DirectiveLoc); // ".rept"
+  bool parseDirectiveRept(SMLoc DirectiveLoc, DirectiveKind DK);
   bool parseDirectiveIrp(SMLoc DirectiveLoc);  // ".irp"
   bool parseDirectiveIrpc(SMLoc DirectiveLoc); // ".irpc"
   bool parseDirectiveEndr(SMLoc DirectiveLoc); // ".endr"
@@ -1437,8 +1438,9 @@
     case DK_CODE16:
     case DK_CODE16GCC:
       return TokError(Twine(IDVal) + " not supported yet");
+    case DK_REP:
     case DK_REPT:
-      return parseDirectiveRept(IDLoc);
+      return parseDirectiveRept(IDLoc, DirKind);
     case DK_IRP:
       return parseDirectiveIrp(IDLoc);
     case DK_IRPC:
@@ -3836,6 +3838,7 @@
   DirectiveKindMap[".code16"] = DK_CODE16;
   DirectiveKindMap[".code16gcc"] = DK_CODE16GCC;
   DirectiveKindMap[".rept"] = DK_REPT;
+  DirectiveKindMap[".rep"] = DK_REP;
   DirectiveKindMap[".irp"] = DK_IRP;
   DirectiveKindMap[".irpc"] = DK_IRPC;
   DirectiveKindMap[".endr"] = DK_ENDR;
@@ -3954,16 +3957,20 @@
   Lex();
 }
 
-bool AsmParser::parseDirectiveRept(SMLoc DirectiveLoc) {
+/// parseDirectiveRept
+///   ::= .rep | .rept count
+bool AsmParser::parseDirectiveRept(SMLoc DirectiveLoc, DirectiveKind DK) {
+  Twine Dir = Twine(DK == DK_REP ? ".rep" : ".rept");
+
   int64_t Count;
   if (parseAbsoluteExpression(Count))
-    return TokError("unexpected token in '.rept' directive");
+    return TokError("unexpected token in '" + Dir + "' directive");
 
   if (Count < 0)
     return TokError("Count is negative");
 
   if (Lexer.isNot(AsmToken::EndOfStatement))
-    return TokError("unexpected token in '.rept' directive");
+    return TokError("unexpected token in '" + Dir + "' directive");
 
   // Eat the end of statement.
   Lex();
Index: test/MC/AsmParser/directive_rept.s
===================================================================
--- /dev/null
+++ test/MC/AsmParser/directive_rept.s
@@ -0,0 +1,30 @@
+# RUN: llvm-mc -triple i686-elf -filetype asm -o - %s | FileCheck %s
+
+	.data
+
+	.global two_bad_calls
+	.type two_bad_calls, at function
+two_bad_calls:
+	.rept 2
+	.long 0xbadca11
+	.endr
+
+# CHECK-LABEL: two_bad_calls
+# CHECK: .long	195938833
+# CHECK: .long	195938833
+
+	.global half_a_dozen_daffodils
+	.type half_a_dozen_daffodils, at function
+half_a_dozen_daffodils:
+	.rep 6
+	.long 0xdaff0d11
+	.endr
+
+# CHECK-LABEL: half_a_dozen_daffodils
+# CHECK: .long	3674148113
+# CHECK: .long	3674148113
+# CHECK: .long	3674148113
+# CHECK: .long	3674148113
+# CHECK: .long	3674148113
+# CHECK: .long	3674148113
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2457.2.patch
Type: text/x-patch
Size: 3454 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131222/06b853da/attachment.bin>


More information about the llvm-commits mailing list