[llvm] r176118 - AsmParser: More generic support for integer type suffices.

Jim Grosbach grosbach at apple.com
Tue Feb 26 12:17:10 PST 2013


Author: grosbach
Date: Tue Feb 26 14:17:10 2013
New Revision: 176118

URL: http://llvm.org/viewvc/llvm-project?rev=176118&view=rev
Log:
AsmParser: More generic support for integer type suffices.

For integer constants, allow 'L', 'UL' as well as 'ULL' and 'LL'. This provides
better support for shared headers between .s and .c files that define bunches
of constant values.

rdar://9321056

Modified:
    llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
    llvm/trunk/test/MC/AsmParser/directive_values.s

Modified: llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmLexer.cpp?rev=176118&r1=176117&r2=176118&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmLexer.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmLexer.cpp Tue Feb 26 14:17:10 2013
@@ -156,10 +156,13 @@ AsmToken AsmLexer::LexLineComment() {
 }
 
 static void SkipIgnoredIntegerSuffix(const char *&CurPtr) {
-  if (CurPtr[0] == 'L' && CurPtr[1] == 'L')
-    CurPtr += 2;
-  if (CurPtr[0] == 'U' && CurPtr[1] == 'L' && CurPtr[2] == 'L')
-    CurPtr += 3;
+  // Skip ULL, UL, U, L and LL suffices.
+  if (CurPtr[0] == 'U')
+    ++CurPtr;
+  if (CurPtr[0] == 'L')
+    ++CurPtr;
+  if (CurPtr[0] == 'L')
+    ++CurPtr;
 }
 
 // Look ahead to search for first non-hex digit, if it's [hH], then we treat the
@@ -220,8 +223,8 @@ AsmToken AsmLexer::LexDigit() {
     if (Radix == 2 || Radix == 16)
       ++CurPtr;
 
-    // The darwin/x86 (and x86-64) assembler accepts and ignores ULL and LL
-    // suffixes on integer literals.
+    // The darwin/x86 (and x86-64) assembler accepts and ignores type
+    // suffices on integer literals.
     SkipIgnoredIntegerSuffix(CurPtr);
 
     return AsmToken(AsmToken::Integer, Result, Value);

Modified: llvm/trunk/test/MC/AsmParser/directive_values.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_values.s?rev=176118&r1=176117&r2=176118&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_values.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_values.s Tue Feb 26 14:17:10 2013
@@ -63,3 +63,9 @@ TEST7:
 # CHECK-NEXT:   .byte   2
 # CHECK-NEXT:   .byte   3
 # CHECK-NEXT:   .byte   4
+
+TEST8:
+        .long 0x200000UL+1
+        .long 0x200000L+1
+# CHECK: .long 2097153
+# CHECK: .long 2097153





More information about the llvm-commits mailing list