File tree 2 files changed +21
-21
lines changed
2 files changed +21
-21
lines changed Original file line number Diff line number Diff line change @@ -1787,18 +1787,12 @@ pub const Target = struct {
1787
1787
.hexagon ,
1788
1788
.mips ,
1789
1789
.mipsel ,
1790
- .mips64 ,
1791
- .mips64el ,
1792
1790
.powerpc ,
1793
1791
.powerpcle ,
1794
- .powerpc64 ,
1795
- .powerpc64le ,
1796
1792
.r600 ,
1797
1793
.amdgcn ,
1798
1794
.riscv32 ,
1799
- .riscv64 ,
1800
1795
.sparc ,
1801
- .sparcv9 ,
1802
1796
.sparcel ,
1803
1797
.s390x ,
1804
1798
.lanai ,
@@ -1812,10 +1806,20 @@ pub const Target = struct {
1812
1806
},
1813
1807
1814
1808
// 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
1810
// 1. Better machine code when loading into SIMD register.
1817
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
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
1823
.aarch64 ,
1820
1824
.aarch64_be ,
1821
1825
.aarch64_32 ,
@@ -1825,11 +1829,9 @@ pub const Target = struct {
1825
1829
.nvptx64 ,
1826
1830
= > 16 ,
1827
1831
1828
- // Below this comment are unverified and I have chosen a number
1829
- // based on ptrBitWidth.
1830
-
1831
- .spu_2 = > 2 ,
1832
-
1832
+ // Below this comment are unverified but based on the fact that C requires
1833
+ // int128_t to be 16 bytes aligned, it's a safe default.
1834
+ .spu_2 ,
1833
1835
.csky ,
1834
1836
.arc ,
1835
1837
.m68k ,
@@ -1843,16 +1845,14 @@ pub const Target = struct {
1843
1845
.renderscript32 ,
1844
1846
.spirv32 ,
1845
1847
.shave ,
1846
- = > 4 ,
1847
-
1848
1848
.le64 ,
1849
1849
.amdil64 ,
1850
1850
.hsail64 ,
1851
1851
.spir64 ,
1852
1852
.renderscript64 ,
1853
1853
.ve ,
1854
1854
.spirv64 ,
1855
- = > 8 ,
1855
+ = > 16 ,
1856
1856
};
1857
1857
}
1858
1858
};
Original file line number Diff line number Diff line change @@ -77,18 +77,12 @@ test "alignment and size of structs with 128-bit fields" {
77
77
.hexagon ,
78
78
.mips ,
79
79
.mipsel ,
80
- .mips64 ,
81
- .mips64el ,
82
80
.powerpc ,
83
81
.powerpcle ,
84
- .powerpc64 ,
85
- .powerpc64le ,
86
82
.r600 ,
87
83
.amdgcn ,
88
84
.riscv32 ,
89
- .riscv64 ,
90
85
.sparc ,
91
- .sparcv9 ,
92
86
.sparcel ,
93
87
.s390x ,
94
88
.lanai ,
@@ -134,6 +128,12 @@ test "alignment and size of structs with 128-bit fields" {
134
128
},
135
129
},
136
130
131
+ .mips64 ,
132
+ .mips64el ,
133
+ .powerpc64 ,
134
+ .powerpc64le ,
135
+ .riscv64 ,
136
+ .sparcv9 ,
137
137
.x86_64 ,
138
138
.aarch64 ,
139
139
.aarch64_be ,
You can’t perform that action at this time.
0 commit comments