Skip to content

Commit

Permalink
[MC] Skip lower-case integer suffixes
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
Keegan Saunders authored and MaskRay committed Jun 30, 2022
1 parent 7a567c6 commit fd6b907
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions llvm/lib/MC/MCParser/AsmLexer.cpp
Expand Up @@ -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;
}

Expand Down
10 changes: 10 additions & 0 deletions llvm/test/MC/AsmParser/exprs.s
Expand Up @@ -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
Expand Down

0 comments on commit fd6b907

Please sign in to comment.