Skip to content

Commit a5709ad

Browse files
veluca93Amanieu
authored andcommitted
Clarify the layout documentation for x86 SIMD types.
1 parent 83c4981 commit a5709ad

File tree

1 file changed

+75
-30
lines changed
  • crates/core_arch/src/x86

1 file changed

+75
-30
lines changed

crates/core_arch/src/x86/mod.rs

Lines changed: 75 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ types! {
2828
/// internal bits differently, check the documentation of the intrinsic
2929
/// to see how it's being used.
3030
///
31-
/// The memory layout of this type (*not* the ABI!) is the same as the
32-
/// layout of the corresponding array type(s).
31+
/// The in-memory representation of this type is the same as the one of an
32+
/// equivalent array (i.e. the in-memory order of elements is the same, and
33+
/// there is no padding); however, the alignment is different and equal to
34+
/// the size of the type. Note that the ABI for function calls may *not* be
35+
/// the same.
3336
///
3437
/// Note that this means that an instance of `__m128i` typically just means
3538
/// a "bag of bits" which is left up to interpretation at the point of use.
@@ -69,8 +72,11 @@ types! {
6972
/// of `__m128` always corresponds to `f32x4`, or four `f32` types packed
7073
/// together.
7174
///
72-
/// The memory layout of this type (*not* the ABI!) is the same as the
73-
/// layout of the corresponding array type(s).
75+
/// The in-memory representation of this type is the same as the one of an
76+
/// equivalent array (i.e. the in-memory order of elements is the same, and
77+
/// there is no padding); however, the alignment is different and equal to
78+
/// the size of the type. Note that the ABI for function calls may *not* be
79+
/// the same.
7480
///
7581
/// Most intrinsics using `__m128` are prefixed with `_mm_` and are
7682
/// suffixed with "ps" (or otherwise contain "ps"). Not to be confused with
@@ -108,8 +114,11 @@ types! {
108114
/// of `__m128d` always corresponds to `f64x2`, or two `f64` types packed
109115
/// together.
110116
///
111-
/// The memory layout of this type (*not* the ABI!) is the same as the
112-
/// layout of the corresponding array type(s).
117+
/// The in-memory representation of this type is the same as the one of an
118+
/// equivalent array (i.e. the in-memory order of elements is the same, and
119+
/// there is no padding); however, the alignment is different and equal to
120+
/// the size of the type. Note that the ABI for function calls may *not* be
121+
/// the same.
113122
///
114123
/// Most intrinsics using `__m128d` are prefixed with `_mm_` and are
115124
/// suffixed with "pd" (or otherwise contain "pd"). Not to be confused with
@@ -152,8 +161,11 @@ types! {
152161
/// internal bits differently, check the documentation of the intrinsic
153162
/// to see how it's being used.
154163
///
155-
/// The memory layout of this type (*not* the ABI!) is the same as the
156-
/// layout of the corresponding array type(s).
164+
/// The in-memory representation of this type is the same as the one of an
165+
/// equivalent array (i.e. the in-memory order of elements is the same, and
166+
/// there is no padding); however, the alignment is different and equal to
167+
/// the size of the type. Note that the ABI for function calls may *not* be
168+
/// the same.
157169
///
158170
/// Note that this means that an instance of `__m256i` typically just means
159171
/// a "bag of bits" which is left up to interpretation at the point of use.
@@ -190,8 +202,11 @@ types! {
190202
/// of `__m256` always corresponds to `f32x8`, or eight `f32` types packed
191203
/// together.
192204
///
193-
/// The memory layout of this type (*not* the ABI!) is the same as the
194-
/// layout of the corresponding array type(s).
205+
/// The in-memory representation of this type is the same as the one of an
206+
/// equivalent array (i.e. the in-memory order of elements is the same, and
207+
/// there is no padding between two consecutive elements); however, the
208+
/// alignment is different and equal to the size of the type. Note that the
209+
/// ABI for function calls may *not* be the same.
195210
///
196211
/// Most intrinsics using `__m256` are prefixed with `_mm256_` and are
197212
/// suffixed with "ps" (or otherwise contain "ps"). Not to be confused with
@@ -229,8 +244,11 @@ types! {
229244
/// of `__m256d` always corresponds to `f64x4`, or four `f64` types packed
230245
/// together.
231246
///
232-
/// The memory layout of this type (*not* the ABI!) is the same as the
233-
/// layout of the corresponding array type(s).
247+
/// The in-memory representation of this type is the same as the one of an
248+
/// equivalent array (i.e. the in-memory order of elements is the same, and
249+
/// there is no padding); however, the alignment is different and equal to
250+
/// the size of the type. Note that the ABI for function calls may *not* be
251+
/// the same.
234252
///
235253
/// Most intrinsics using `__m256d` are prefixed with `_mm256_` and are
236254
/// suffixed with "pd" (or otherwise contain "pd"). Not to be confused with
@@ -277,8 +295,11 @@ types! {
277295
/// internal bits differently, check the documentation of the intrinsic
278296
/// to see how it's being used.
279297
///
280-
/// The memory layout of this type (*not* the ABI!) is the same as the
281-
/// layout of the corresponding array type(s).
298+
/// The in-memory representation of this type is the same as the one of an
299+
/// equivalent array (i.e. the in-memory order of elements is the same, and
300+
/// there is no padding); however, the alignment is different and equal to
301+
/// the size of the type. Note that the ABI for function calls may *not* be
302+
/// the same.
282303
///
283304
/// Note that this means that an instance of `__m512i` typically just means
284305
/// a "bag of bits" which is left up to interpretation at the point of use.
@@ -296,8 +317,11 @@ types! {
296317
/// of `__m512` always corresponds to `f32x16`, or sixteen `f32` types
297318
/// packed together.
298319
///
299-
/// The memory layout of this type (*not* the ABI!) is the same as the
300-
/// layout of the corresponding array type(s).
320+
/// The in-memory representation of this type is the same as the one of an
321+
/// equivalent array (i.e. the in-memory order of elements is the same, and
322+
/// there is no padding between two consecutive elements); however, the
323+
/// alignment is different and equal to the size of the type. Note that the
324+
/// ABI for function calls may *not* be the same.
301325
///
302326
/// Most intrinsics using `__m512` are prefixed with `_mm512_` and are
303327
/// suffixed with "ps" (or otherwise contain "ps"). Not to be confused with
@@ -316,8 +340,11 @@ types! {
316340
/// of `__m512d` always corresponds to `f64x4`, or eight `f64` types packed
317341
/// together.
318342
///
319-
/// The memory layout of this type (*not* the ABI!) is the same as the
320-
/// layout of the corresponding array type(s).
343+
/// The in-memory representation of this type is the same as the one of an
344+
/// equivalent array (i.e. the in-memory order of elements is the same, and
345+
/// there is no padding between two consecutive elements); however, the
346+
/// alignment is different and equal to the size of the type. Note that the
347+
/// ABI for function calls may *not* be the same.
321348
///
322349
/// Most intrinsics using `__m512d` are prefixed with `_mm512_` and are
323350
/// suffixed with "pd" (or otherwise contain "pd"). Not to be confused with
@@ -334,8 +361,11 @@ types! {
334361
/// eight packed `u16` instances. Its purpose is for bf16 related intrinsic
335362
/// implementations.
336363
///
337-
/// The memory layout of this type (*not* the ABI!) is the same as the
338-
/// layout of the corresponding array type(s).
364+
/// The in-memory representation of this type is the same as the one of an
365+
/// equivalent array (i.e. the in-memory order of elements is the same, and
366+
/// there is no padding); however, the alignment is different and equal to
367+
/// the size of the type. Note that the ABI for function calls may *not* be
368+
/// the same.
339369
pub struct __m128bh(8 x u16);
340370

341371
/// 256-bit wide set of 16 `u16` types, x86-specific
@@ -345,8 +375,11 @@ types! {
345375
/// 16 packed `u16` instances. Its purpose is for bf16 related intrinsic
346376
/// implementations.
347377
///
348-
/// The memory layout of this type (*not* the ABI!) is the same as the
349-
/// layout of the corresponding array type(s).
378+
/// The in-memory representation of this type is the same as the one of an
379+
/// equivalent array (i.e. the in-memory order of elements is the same, and
380+
/// there is no padding); however, the alignment is different and equal to
381+
/// the size of the type. Note that the ABI for function calls may *not* be
382+
/// the same.
350383
pub struct __m256bh(16 x u16);
351384

352385
/// 512-bit wide set of 32 `u16` types, x86-specific
@@ -356,8 +389,11 @@ types! {
356389
/// 32 packed `u16` instances. Its purpose is for bf16 related intrinsic
357390
/// implementations.
358391
///
359-
/// The memory layout of this type (*not* the ABI!) is the same as the
360-
/// layout of the corresponding array type(s).
392+
/// The in-memory representation of this type is the same as the one of an
393+
/// equivalent array (i.e. the in-memory order of elements is the same, and
394+
/// there is no padding); however, the alignment is different and equal to
395+
/// the size of the type. Note that the ABI for function calls may *not* be
396+
/// the same.
361397
pub struct __m512bh(32 x u16);
362398
}
363399

@@ -371,8 +407,11 @@ types! {
371407
/// 8 packed `f16` instances. its purpose is for f16 related intrinsic
372408
/// implementations.
373409
///
374-
/// The memory layout of this type (*not* the ABI!) is the same as the
375-
/// layout of the corresponding array type(s).
410+
/// The in-memory representation of this type is the same as the one of an
411+
/// equivalent array (i.e. the in-memory order of elements is the same, and
412+
/// there is no padding); however, the alignment is different and equal to
413+
/// the size of the type. Note that the ABI for function calls may *not* be
414+
/// the same.
376415
pub struct __m128h(8 x f16);
377416

378417
/// 256-bit wide set of 16 `f16` types, x86-specific
@@ -382,8 +421,11 @@ types! {
382421
/// 16 packed `f16` instances. its purpose is for f16 related intrinsic
383422
/// implementations.
384423
///
385-
/// The memory layout of this type (*not* the ABI!) is the same as the
386-
/// layout of the corresponding array type(s).
424+
/// The in-memory representation of this type is the same as the one of an
425+
/// equivalent array (i.e. the in-memory order of elements is the same, and
426+
/// there is no padding); however, the alignment is different and equal to
427+
/// the size of the type. Note that the ABI for function calls may *not* be
428+
/// the same.
387429
pub struct __m256h(16 x f16);
388430

389431
/// 512-bit wide set of 32 `f16` types, x86-specific
@@ -393,8 +435,11 @@ types! {
393435
/// 32 packed `f16` instances. its purpose is for f16 related intrinsic
394436
/// implementations.
395437
///
396-
/// The memory layout of this type (*not* the ABI!) is the same as the
397-
/// layout of the corresponding array type(s).
438+
/// The in-memory representation of this type is the same as the one of an
439+
/// equivalent array (i.e. the in-memory order of elements is the same, and
440+
/// there is no padding); however, the alignment is different and equal to
441+
/// the size of the type. Note that the ABI for function calls may *not* be
442+
/// the same.
398443
pub struct __m512h(32 x f16);
399444
}
400445

0 commit comments

Comments
 (0)