authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-04 19:11:02-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-04 19:11:02-07:00
log0bebb688fbc4c6ffb88a2b0aefcf536143bb5f2e
tree9d6b8e844ab56425202e44c1be70260a099f203b
parentaf7e945a7dc00a2a5055d9770b9ecda253d64a8e

stage2: change max int align from 8 to 16 for more ISAs

These targets now have a similar disagreement with LLVM about the alignment of 128-bit integers as x86_64: * riscv64 * powerpc64 * powerpc64le * mips64 * mips64el * sparcv9 See #2987

2 files changed, 21 insertions(+), 21 deletions(-)

lib/std/target.zig+15-15
...@@ -1787,18 +1787,12 @@ pub const Target = struct {...@@ -1787,18 +1787,12 @@ pub const Target = struct {
1787 .hexagon,1787 .hexagon,
1788 .mips,1788 .mips,
1789 .mipsel,1789 .mipsel,
1790 .mips64,
1791 .mips64el,
1792 .powerpc,1790 .powerpc,
1793 .powerpcle,1791 .powerpcle,
1794 .powerpc64,
1795 .powerpc64le,
1796 .r600,1792 .r600,
1797 .amdgcn,1793 .amdgcn,
1798 .riscv32,1794 .riscv32,
1799 .riscv64,
1800 .sparc,1795 .sparc,
1801 .sparcv9,
1802 .sparcel,1796 .sparcel,
1803 .s390x,1797 .s390x,
1804 .lanai,1798 .lanai,
...@@ -1812,10 +1806,20 @@ pub const Target = struct {...@@ -1812,10 +1806,20 @@ pub const Target = struct {
1812 },1806 },
18131807
1814 // For x86_64, LLVMABIAlignmentOfType(i128) reports 8. However I think 161808 // For x86_64, LLVMABIAlignmentOfType(i128) reports 8. However I think 16
1815 // is a better number because of two reasons:1809 // is a better number for two reasons:
1816 // 1. Better machine code when loading into SIMD register.1810 // 1. Better machine code when loading into SIMD register.
1817 // 2. The C ABI wants 16 for extern structs.1811 // 2. The C ABI wants 16 for extern structs.
1812 // 3. 16-byte cmpxchg needs 16-byte alignment.
1813 // Same logic for riscv64, powerpc64, mips64, sparcv9.
1818 .x86_64,1814 .x86_64,
1815 .riscv64,
1816 .powerpc64,
1817 .powerpc64le,
1818 .mips64,
1819 .mips64el,
1820 .sparcv9,
1821
1822 // Even LLVMABIAlignmentOfType(i128) agrees on these targets.
1819 .aarch64,1823 .aarch64,
1820 .aarch64_be,1824 .aarch64_be,
1821 .aarch64_32,1825 .aarch64_32,
...@@ -1825,11 +1829,9 @@ pub const Target = struct {...@@ -1825,11 +1829,9 @@ pub const Target = struct {
1825 .nvptx64,1829 .nvptx64,
1826 => 16,1830 => 16,
18271831
1828 // Below this comment are unverified and I have chosen a number1832 // Below this comment are unverified but based on the fact that C requires
1829 // based on ptrBitWidth.1833 // int128_t to be 16 bytes aligned, it's a safe default.
18301834 .spu_2,
1831 .spu_2 => 2,
1832
1833 .csky,1835 .csky,
1834 .arc,1836 .arc,
1835 .m68k,1837 .m68k,
...@@ -1843,8 +1845,6 @@ pub const Target = struct {...@@ -1843,8 +1845,6 @@ pub const Target = struct {
1843 .renderscript32,1845 .renderscript32,
1844 .spirv32,1846 .spirv32,
1845 .shave,1847 .shave,
1846 => 4,
1847
1848 .le64,1848 .le64,
1849 .amdil64,1849 .amdil64,
1850 .hsail64,1850 .hsail64,
...@@ -1852,7 +1852,7 @@ pub const Target = struct {...@@ -1852,7 +1852,7 @@ pub const Target = struct {
1852 .renderscript64,1852 .renderscript64,
1853 .ve,1853 .ve,
1854 .spirv64,1854 .spirv64,
1855 => 8,1855 => 16,
1856 };1856 };
1857 }1857 }
1858};1858};
test/behavior/align.zig+6-6
...@@ -77,18 +77,12 @@ test "alignment and size of structs with 128-bit fields" {...@@ -77,18 +77,12 @@ test "alignment and size of structs with 128-bit fields" {
77 .hexagon,77 .hexagon,
78 .mips,78 .mips,
79 .mipsel,79 .mipsel,
80 .mips64,
81 .mips64el,
82 .powerpc,80 .powerpc,
83 .powerpcle,81 .powerpcle,
84 .powerpc64,
85 .powerpc64le,
86 .r600,82 .r600,
87 .amdgcn,83 .amdgcn,
88 .riscv32,84 .riscv32,
89 .riscv64,
90 .sparc,85 .sparc,
91 .sparcv9,
92 .sparcel,86 .sparcel,
93 .s390x,87 .s390x,
94 .lanai,88 .lanai,
...@@ -134,6 +128,12 @@ test "alignment and size of structs with 128-bit fields" {...@@ -134,6 +128,12 @@ test "alignment and size of structs with 128-bit fields" {
134 },128 },
135 },129 },
136130
131 .mips64,
132 .mips64el,
133 .powerpc64,
134 .powerpc64le,
135 .riscv64,
136 .sparcv9,
137 .x86_64,137 .x86_64,
138 .aarch64,138 .aarch64,
139 .aarch64_be,139 .aarch64_be,