[llvm] [DataLayout] Use member initialization (NFC) (PR #103712)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 14 01:31:30 PDT 2024


================
@@ -198,37 +198,38 @@ const char *DataLayout::getManglingComponent(const Triple &T) {
   return "-m:e";
 }
 
-static const std::pair<AlignTypeEnum, LayoutAlignElem> DefaultAlignments[] = {
-    {INTEGER_ALIGN, {1, Align(1), Align(1)}},    // i1
-    {INTEGER_ALIGN, {8, Align(1), Align(1)}},    // i8
-    {INTEGER_ALIGN, {16, Align(2), Align(2)}},   // i16
-    {INTEGER_ALIGN, {32, Align(4), Align(4)}},   // i32
-    {INTEGER_ALIGN, {64, Align(4), Align(8)}},   // i64
-    {FLOAT_ALIGN, {16, Align(2), Align(2)}},     // half, bfloat
-    {FLOAT_ALIGN, {32, Align(4), Align(4)}},     // float
-    {FLOAT_ALIGN, {64, Align(8), Align(8)}},     // double
-    {FLOAT_ALIGN, {128, Align(16), Align(16)}},  // ppcf128, quad, ...
-    {VECTOR_ALIGN, {64, Align(8), Align(8)}},    // v2i32, v1i64, ...
-    {VECTOR_ALIGN, {128, Align(16), Align(16)}}, // v16i8, v8i16, v4i32, ...
+// Default primitive type specifications.
+// NOTE: These arrays must be sorted by type bit width.
+constexpr LayoutAlignElem DataLayout::DefaultIntSpecs[] = {
----------------
s-barannikov wrote:

In the next patch I make LayoutAlignElem a private nested class of DataLayout, which can't be used in unrelated array declaration (because it is private).
I was also thinking about make it *public* nested class, this could help me with unittests I was planning to improve next.

If that's OK to expose LayoutAlignElem etc I can make those arrays local to cpp file.


https://github.com/llvm/llvm-project/pull/103712


More information about the llvm-commits mailing list