[PATCH] D128871: [MC] Skip lower-cased integer suffices
Keegan Saunders via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 29 19:38:21 PDT 2022
ksaunders created this revision.
ksaunders added a reviewer: MaskRay.
ksaunders added projects: LLVM, All.
Herald added subscribers: StephenFan, hiraditya, kristof.beyls.
ksaunders requested review of this revision.
Herald added a subscriber: llvm-commits.
In the GNU assemblers, lower-cased integer suffices are permitted. However, in LLVM, it causes an error.
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.
For example,
.global main
main:
mov x0, 1024u
ret
Is permitted in AArch64 binutils 2.35.1. However with Clang it produces the following error:
<source>:3:14: error: unexpected token in argument list
mov x0, 1024u
^
This patch addresses this issue.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D128871
Files:
llvm/lib/MC/MCParser/AsmLexer.cpp
llvm/test/MC/AsmParser/exprs.s
Index: llvm/test/MC/AsmParser/exprs.s
===================================================================
--- llvm/test/MC/AsmParser/exprs.s
+++ llvm/test/MC/AsmParser/exprs.s
@@ -18,6 +18,16 @@
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
Index: llvm/lib/MC/MCParser/AsmLexer.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmLexer.cpp
+++ llvm/lib/MC/MCParser/AsmLexer.cpp
@@ -251,12 +251,12 @@
}
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 suffices.
+ 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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128871.441233.patch
Type: text/x-patch
Size: 1342 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220630/e1f790a1/attachment.bin>
More information about the llvm-commits
mailing list