[llvm] [DataLayout] Refactor parsing of "ni" specification (PR #104546)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 16 01:42:45 PDT 2024
================
@@ -134,6 +134,46 @@ TEST(DataLayout, LayoutStringFormat) {
FailedWithMessage("empty specification is not allowed"));
}
+TEST(DataLayout, ParseNonIntegralAddrSpace) {
+ for (StringRef Str : {"ni:1", "ni:16777215", "ni:1:16777215"})
+ EXPECT_THAT_EXPECTED(DataLayout::parse(Str), Succeeded());
+
+ for (StringRef Str : {"ni", "ni42", "nix"})
+ EXPECT_THAT_EXPECTED(
+ DataLayout::parse(Str),
+ FailedWithMessage("malformed specification, must be of the form "
+ "\"ni:<address space>[:<address space>]...\""));
+
+ for (StringRef Str : {"ni:", "ni::42", "ni:42:"})
+ EXPECT_THAT_EXPECTED(DataLayout::parse(Str),
+ FailedWithMessage("<address space> is required"));
+
+ for (StringRef Str : {"ni:x", "ni:16777216", "ni:42:16777216"})
+ EXPECT_THAT_EXPECTED(
+ DataLayout::parse(Str),
+ FailedWithMessage("<address space> must be a 24-bit integer"));
----------------
s-barannikov wrote:
It all started with `S<size>` specification, where `<size>` is in fact alignment, but it is neither ABI nor preferred.
I couldn't invent a name for it to pass to `parseAlignment` (see the draft PR) and I started passing "<size>" to the function so that the diagnostic becomes "<size> must be ...".
The rest of the changes were just for consistency.
I guess I can change this to plain English if it reads better and change "<size>" to "stack natural alignment" or something.
https://github.com/llvm/llvm-project/pull/104546
More information about the llvm-commits
mailing list