[llvm] fd6b907 - [MC] Skip lower-case integer suffixes
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 29 20:55:10 PDT 2022
Author: Keegan Saunders
Date: 2022-06-29T20:55:05-07:00
New Revision: fd6b9074ca02d1d7d1daa213ba9f6e91dec03c2d
URL: https://github.com/llvm/llvm-project/commit/fd6b9074ca02d1d7d1daa213ba9f6e91dec03c2d
DIFF: https://github.com/llvm/llvm-project/commit/fd6b9074ca02d1d7d1daa213ba9f6e91dec03c2d.diff
LOG: [MC] Skip lower-case integer suffixes
`mov x0, 1024u` is permitted in binutils but rejected by the integrated
assembler. Support the case. This is especially important when using the C
pre-processor with the assembler: some shared code between C and assembler may
use lower-cased suffices.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D128871
Added:
Modified:
llvm/lib/MC/MCParser/AsmLexer.cpp
llvm/test/MC/AsmParser/exprs.s
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCParser/AsmLexer.cpp b/llvm/lib/MC/MCParser/AsmLexer.cpp
index bf9b9e916d6f6..c3bc3bff6fa2d 100644
--- a/llvm/lib/MC/MCParser/AsmLexer.cpp
+++ b/llvm/lib/MC/MCParser/AsmLexer.cpp
@@ -251,12 +251,12 @@ AsmToken AsmLexer::LexLineComment() {
}
static void SkipIgnoredIntegerSuffix(const char *&CurPtr) {
- // Skip ULL, UL, U, L and LL suffices.
- if (CurPtr[0] == 'U')
+ // Skip case-insensitive ULL, UL, U, L and LL suffixes.
+ if (CurPtr[0] == 'U' || CurPtr[0] == 'u')
++CurPtr;
- if (CurPtr[0] == 'L')
+ if (CurPtr[0] == 'L' || CurPtr[0] == 'l')
++CurPtr;
- if (CurPtr[0] == 'L')
+ if (CurPtr[0] == 'L' || CurPtr[0] == 'l')
++CurPtr;
}
diff --git a/llvm/test/MC/AsmParser/exprs.s b/llvm/test/MC/AsmParser/exprs.s
index d2e2334e83619..8ba949db1ba0a 100644
--- a/llvm/test/MC/AsmParser/exprs.s
+++ b/llvm/test/MC/AsmParser/exprs.s
@@ -18,6 +18,16 @@ k:
check_expr -1, ~0
check_expr +1, 1
check_expr 1 + 2, 3
+ check_expr 1U + 2U, 3U
+ check_expr 1L + 2L, 3L
+ check_expr 1UL + 2UL, 3UL
+ check_expr 1LL + 2L, 3LL
+ check_expr 1ULL + 2ULL, 3ULL
+ check_expr 1u + 2u, 3u
+ check_expr 1l + 2l, 3l
+ check_expr 1ul + 2ul, 3ul
+ check_expr 1ll + 2L, 3ll
+ check_expr 1ull + 2ull, 3ull
check_expr 1 & 3, 1
check_expr 4 / 2, 2
check_expr 4 / -2, -2
More information about the llvm-commits
mailing list