[llvm] [DataLayout] Refactor parsing of i/f/v/a specifications (PR #104699)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 18 05:53:41 PDT 2024
================
@@ -376,6 +376,86 @@ static Error getAddrSpace(StringRef R, unsigned &AddrSpace) {
return Error::success();
}
+Error DataLayout::parsePrimitiveSpec(StringRef Spec) {
+ // [ifv]<size>:<abi>[:<pref>]
+ SmallVector<StringRef, 3> Components;
+ char Specifier = Spec.front();
+ assert(Specifier == 'i' || Specifier == 'f' || Specifier == 'v');
+ Spec.drop_front().split(Components, ':');
+
+ if (Components.size() < 2 || Components.size() > 3)
+ return createSpecFormatError(Twine(Specifier) + "<size>:<abi>[:<pref>]");
+
+ // Size. Required, cannot be zero.
+ unsigned BitWidth;
+ if (Error Err = parseSize(Components[0], BitWidth))
+ return Err;
+
+ // ABI alignment. Required, cannot be zero.
+ Align ABIAlign;
+ if (Error Err = parseAlignment(Components[1], ABIAlign, "ABI"))
+ return Err;
+
+ if (Specifier == 'i' && BitWidth == 8 && ABIAlign != 1)
+ return createStringError("i8 must be 8-bit aligned");
+
+ // Preferred alignment. Optional, defaults to the ABI alignment.
+ // Can be zero, meaning use one byte alignment.
----------------
nikic wrote:
This behavior makes little sense to me -- can we remove it?
https://github.com/llvm/llvm-project/pull/104699
More information about the llvm-commits
mailing list