From fd6b9074ca02d1d7d1daa213ba9f6e91dec03c2d Mon Sep 17 00:00:00 2001 From: Keegan Saunders Date: Wed, 29 Jun 2022 20:55:05 -0700 Subject: [PATCH] [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 --- llvm/lib/MC/MCParser/AsmLexer.cpp | 8 ++++---- llvm/test/MC/AsmParser/exprs.s | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/llvm/lib/MC/MCParser/AsmLexer.cpp b/llvm/lib/MC/MCParser/AsmLexer.cpp index bf9b9e916d6f..c3bc3bff6fa2 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 d2e2334e8361..8ba949db1ba0 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