Skip to content

Commit 3833ecc

Browse files
committed
Cleanup styling of abi chapter
1 parent e024391 commit 3833ecc

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/abi.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,28 @@ Two integer types are *abi compatible* if they have the same size and the same s
2626
> Two integer types with different signedness, such as `u8` and `i8` are not *abi compatible*.
2727
2828
r[abi.compatibility.char]
29-
The type `char`is *abi compatible* with the type `u32`.
29+
The type `char` is *abi compatible* with the type `u32`.
3030

3131
r[abi.compatibility.pointer]
3232
Two pointer types, `*mut T` and `*const U`, are *abi compatible* if the *metadata type*s of `T` and `U` are the same type.
3333

34+
> [!NOTE]
35+
> [`Sized`] types have a *metadata type* of `()`.
36+
3437
> [!NOTE]
3538
> With transitivity, this applies regardless of the mutability of either pointer type
3639
3740
r[abi.compatibility.reference-box]
3841
The types `&T`, `&mut T`, [`Box<T>`][core::boxed::Box], and [`NonNull<T>`][core::ptr::NonNull], are *abi compatible* with `*const T`
3942

4043
> [!NOTE]
41-
> With transitivity,t hey are also *abi compatible** with each other, and with `*mut T`, as well as references/`Box` to different types that have the same *metadata type*.
42-
44+
> With transitivity, they are also *abi compatible* with each other, and with `*mut T`, as well as references/`Box` to different types that have the same *metadata type*.
4345
4446
r[abi.compatibility.core]
4547
The types [`MaybeUninit<T>`][core::mem::MaybeUninit], [`UnsafeCell<T>`][core::cell::UnsafeCell], and [`NonZero<T>`][core::num::NonZero], are *abi compatible* with `T`.
4648

4749
r[abi.compatibility.transparent]
48-
A `struct` declared with the `transparent` representation is *abi compatible* with its field that does not have size 0 and alignment 1, if such a field exists
50+
A `struct` declared with the `transparent` representation is *abi compatible* with its field that does not have size 0 and alignment 1, if such a field exists.
4951

5052
r[abi.compatibilty.zst]
5153
Two types, `T` and `U`, are *abi compatible* if both have size 0 and alignment 1.
@@ -68,31 +70,36 @@ Two function signatures are compatible if:
6870
* Each parameter of both signatures, in order, are *abi compatible*, and
6971
* Either both signatures have C-varargs, or neither signature does.
7072

73+
> [!NOTE]
74+
> A signature is compatible with itself.
75+
7176
r[abi.compatibility.simd-abi]
7277
A type has *simd abi requirements* if:
7378
* It is a type declared with the standard-library repr-attrbute `simd`,
7479
* It is a aggregate type, which has a type with *simd abi requirements* as a field.
7580

81+
> [!NOTE]
82+
> The `repr(simd)` attribute cannot be used by Rust code, only by the standard library.
83+
7684
r[abi.compatibility.simd-target-feature]
7785
A type with *simd abi requirements* may have one or more [*salient target features*][target_feature] . In the case of an aggregate type, the set of [*salient target features*][target_feature] is the union of the set of [*salient target features*][target_feature] of each field with *simd abi requirements*.
7886

7987
> [!TARGET-SPECIFIC]
8088
> On x86 and x86-64, the [*salient target features*][target_feature] of the `simd` types are:
81-
> * [`__m128`], [`__m128i`], [`__m128f`], and [`__m128d`]: `sse`
82-
> * [`__m256`], [`__m256i`], [`__m256f`], and [`__m256d`]: `avx`
83-
> * [`__m512`], [`__m512i`], [`__m512f`], and [`__m512d`]: `avx512f` and `avx512vl`
89+
> * [`__m128`], [`__m128i`], [`__m128f`], and [`__m128d`] (128-bit vector types): `sse`
90+
> * [`__m256`], [`__m256i`], [`__m256f`], and [`__m256d`] (256-bit vector types): `avx`
91+
> * [`__m512`], [`__m512i`], [`__m512f`], and [`__m512d`] (512-bit vector types): `avx512f` and `avx512vl`
8492
8593
r[abi.compatibility.call]
86-
A call to a function `f` via a function item or function pointer with a given signature `S` is valid only if the signature of `f` is *compatible* with the signature `S`, and:
87-
* The ABI tag of the function is `extern "Rust"`, or
88-
* If the type of any parameter, the return type, or the type of any argument passed via C-varargs has *simd abi requirements*, each [*salient target features*][target_feature]of that type is either set at both the definition site of the function, and at the call site, or is set at neither site.
94+
A call to a function `f` via a function item or function pointer with a given signature `S` is valid if and only if the signature of the definition `f` is *compatible* with the signature `S`, and:
95+
* The ABI tag of the signature is `extern "Rust"`, or
96+
* If any parameter type, the return type, or the type of any argument passed via C-varargs has *simd abi requirements*, each [*salient target features*][target_feature] of that type is either set at both the definition site of the function, and at the call site, or is set at neither site.
8997

9098
The behaviour a call that is not valid is undefined.
9199

92100
> [!NOTE]
93101
> the ABI tag `extern "Rust"` is the default when the `extern` keyword is not used (either to declare the function within an [`extern` block], or as a [function qualifier][extern functions]). Thus it is safe to call most functions that use simd types.
94102
95-
96103
[`__m128`]: https://doc.rust-lang.org/stable/core/arch/x86_64/struct.__m128.html
97104
[`__m128i`]: https://doc.rust-lang.org/stable/core/arch/x86_64/struct.__m128i.html
98105
[`__m128f`]: https://doc.rust-lang.org/stable/core/arch/x86_64/struct.__m128f.html
@@ -192,8 +199,6 @@ The *`no_mangle` attribute* may be specified as a built-in attribute, using the
192199
r[abi.symbol-name.export_name]
193200
The *`export_name` attribute* may be specified as a built-in attribute, using the [_MetaNameValueStr_] syntax. The *export name* of an item with the *`no_mangle` attribute* is the content of `STRING_LITERAL`.
194201

195-
196-
197202
## The `link_section` attribute
198203

199204
r[abi.link_section]
@@ -234,10 +239,6 @@ pub static VAR1: u32 = 1;
234239
> * `.tbss`: Readable and Writable - Uninitialized and Thread-local.
235240
>
236241
> This is not an exhaustive list, and generally extended versions of these section names such as `.text.foo`, are also defined with the same properties as the base section.
237-
>
238-
>
239-
240-
241242
242243
[_MetaWord_]: attributes.md#meta-item-attribute-syntax
243244
[_MetaNameValueStr_]: attributes.md#meta-item-attribute-syntax

0 commit comments

Comments
 (0)