2014-02-19 18:56:33 -08:00
|
|
|
use std::fmt;
|
2013-03-13 22:25:28 -04:00
|
|
|
|
2019-11-09 22:27:52 +01:00
|
|
|
use rustc_macros::HashStable_Generic;
|
|
|
|
|
2019-08-01 03:20:03 +03:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests;
|
|
|
|
|
2020-06-11 15:49:57 +01:00
|
|
|
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Debug)]
|
|
|
|
#[derive(HashStable_Generic, Encodable, Decodable)]
|
2013-03-13 22:25:28 -04:00
|
|
|
pub enum Abi {
|
2020-06-01 22:20:12 -04:00
|
|
|
// Multiplatform / generic ABIs
|
|
|
|
//
|
|
|
|
// These ABIs come first because every time we add a new ABI, we
|
|
|
|
// have to re-bless all the hashing tests. These are used in many
|
|
|
|
// places, so giving them stable values reduces test churn. The
|
|
|
|
// specific values are meaningless.
|
rustc_target: add "unwind" payloads to `Abi`
### Overview
This commit begins the implementation work for RFC 2945. For more
information, see the rendered RFC [1] and tracking issue [2].
A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
and `Thiscall` variants, marking whether unwinding across FFI
boundaries is acceptable. The cases where each of these variants'
`unwind` member is true correspond with the `C-unwind`,
`system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings
introduced in RFC 2945 [3].
### Feature Gate and Unstable Book
This commit adds a `c_unwind` feature gate for the new ABI strings.
Tests for this feature gate are included in `src/test/ui/c-unwind/`,
which ensure that this feature gate works correctly for each of the
new ABIs.
A new language features entry in the unstable book is added as well.
### Further Work To Be Done
This commit does not proceed to implement the new unwinding ABIs,
and is intentionally scoped specifically to *defining* the ABIs and
their feature flag.
### One Note on Test Churn
This will lead to some test churn, in re-blessing hash tests, as the
deleted comment in `src/librustc_target/spec/abi.rs` mentioned,
because we can no longer guarantee the ordering of the `Abi`
variants.
While this is a downside, this decision was made bearing in mind
that RFC 2945 states the following, in the "Other `unwind` Strings"
section [3]:
> More unwind variants of existing ABI strings may be introduced,
> with the same semantics, without an additional RFC.
Adding a new variant for each of these cases, rather than specifying
a payload for a given ABI, would quickly become untenable, and make
working with the `Abi` enum prone to mistakes.
This approach encodes the unwinding information *into* a given ABI,
to account for the future possibility of other `-unwind` ABI
strings.
### Ignore Directives
`ignore-*` directives are used in two of our `*-unwind` ABI test
cases.
Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases
ignore architectures that do not support `stdcall` and
`thiscall`, respectively.
These directives are cribbed from
`src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and
`src/test/ui/extern/extern-thiscall.rs` for `thiscall`.
This would otherwise fail on some targets, see:
https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60
### Footnotes
[1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
[2]: https://github.com/rust-lang/rust/issues/74990
[3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings
2020-08-27 11:49:18 -04:00
|
|
|
Rust,
|
|
|
|
C { unwind: bool },
|
2020-06-01 22:20:12 -04:00
|
|
|
|
2016-10-24 11:04:04 +02:00
|
|
|
// Single platform ABIs
|
2013-03-13 22:25:28 -04:00
|
|
|
Cdecl,
|
rustc_target: add "unwind" payloads to `Abi`
### Overview
This commit begins the implementation work for RFC 2945. For more
information, see the rendered RFC [1] and tracking issue [2].
A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
and `Thiscall` variants, marking whether unwinding across FFI
boundaries is acceptable. The cases where each of these variants'
`unwind` member is true correspond with the `C-unwind`,
`system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings
introduced in RFC 2945 [3].
### Feature Gate and Unstable Book
This commit adds a `c_unwind` feature gate for the new ABI strings.
Tests for this feature gate are included in `src/test/ui/c-unwind/`,
which ensure that this feature gate works correctly for each of the
new ABIs.
A new language features entry in the unstable book is added as well.
### Further Work To Be Done
This commit does not proceed to implement the new unwinding ABIs,
and is intentionally scoped specifically to *defining* the ABIs and
their feature flag.
### One Note on Test Churn
This will lead to some test churn, in re-blessing hash tests, as the
deleted comment in `src/librustc_target/spec/abi.rs` mentioned,
because we can no longer guarantee the ordering of the `Abi`
variants.
While this is a downside, this decision was made bearing in mind
that RFC 2945 states the following, in the "Other `unwind` Strings"
section [3]:
> More unwind variants of existing ABI strings may be introduced,
> with the same semantics, without an additional RFC.
Adding a new variant for each of these cases, rather than specifying
a payload for a given ABI, would quickly become untenable, and make
working with the `Abi` enum prone to mistakes.
This approach encodes the unwinding information *into* a given ABI,
to account for the future possibility of other `-unwind` ABI
strings.
### Ignore Directives
`ignore-*` directives are used in two of our `*-unwind` ABI test
cases.
Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases
ignore architectures that do not support `stdcall` and
`thiscall`, respectively.
These directives are cribbed from
`src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and
`src/test/ui/extern/extern-thiscall.rs` for `thiscall`.
This would otherwise fail on some targets, see:
https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60
### Footnotes
[1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
[2]: https://github.com/rust-lang/rust/issues/74990
[3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings
2020-08-27 11:49:18 -04:00
|
|
|
Stdcall { unwind: bool },
|
2013-03-13 22:25:28 -04:00
|
|
|
Fastcall,
|
2015-12-26 21:29:28 +01:00
|
|
|
Vectorcall,
|
rustc_target: add "unwind" payloads to `Abi`
### Overview
This commit begins the implementation work for RFC 2945. For more
information, see the rendered RFC [1] and tracking issue [2].
A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
and `Thiscall` variants, marking whether unwinding across FFI
boundaries is acceptable. The cases where each of these variants'
`unwind` member is true correspond with the `C-unwind`,
`system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings
introduced in RFC 2945 [3].
### Feature Gate and Unstable Book
This commit adds a `c_unwind` feature gate for the new ABI strings.
Tests for this feature gate are included in `src/test/ui/c-unwind/`,
which ensure that this feature gate works correctly for each of the
new ABIs.
A new language features entry in the unstable book is added as well.
### Further Work To Be Done
This commit does not proceed to implement the new unwinding ABIs,
and is intentionally scoped specifically to *defining* the ABIs and
their feature flag.
### One Note on Test Churn
This will lead to some test churn, in re-blessing hash tests, as the
deleted comment in `src/librustc_target/spec/abi.rs` mentioned,
because we can no longer guarantee the ordering of the `Abi`
variants.
While this is a downside, this decision was made bearing in mind
that RFC 2945 states the following, in the "Other `unwind` Strings"
section [3]:
> More unwind variants of existing ABI strings may be introduced,
> with the same semantics, without an additional RFC.
Adding a new variant for each of these cases, rather than specifying
a payload for a given ABI, would quickly become untenable, and make
working with the `Abi` enum prone to mistakes.
This approach encodes the unwinding information *into* a given ABI,
to account for the future possibility of other `-unwind` ABI
strings.
### Ignore Directives
`ignore-*` directives are used in two of our `*-unwind` ABI test
cases.
Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases
ignore architectures that do not support `stdcall` and
`thiscall`, respectively.
These directives are cribbed from
`src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and
`src/test/ui/extern/extern-thiscall.rs` for `thiscall`.
This would otherwise fail on some targets, see:
https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60
### Footnotes
[1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
[2]: https://github.com/rust-lang/rust/issues/74990
[3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings
2020-08-27 11:49:18 -04:00
|
|
|
Thiscall { unwind: bool },
|
2013-03-13 22:25:28 -04:00
|
|
|
Aapcs,
|
2013-11-16 18:25:56 -05:00
|
|
|
Win64,
|
2016-06-27 02:34:02 +02:00
|
|
|
SysV64,
|
2016-12-22 16:24:29 -05:00
|
|
|
PtxKernel,
|
2016-12-18 23:45:20 -05:00
|
|
|
Msp430Interrupt,
|
2017-02-14 21:39:42 +01:00
|
|
|
X86Interrupt,
|
2018-07-01 22:42:00 -05:00
|
|
|
AmdGpuKernel,
|
2019-10-24 15:29:29 +00:00
|
|
|
EfiApi,
|
2016-05-06 09:32:10 -04:00
|
|
|
AvrInterrupt,
|
|
|
|
AvrNonBlockingInterrupt,
|
2021-01-24 17:15:05 +00:00
|
|
|
CCmseNonSecureCall,
|
2013-03-13 22:25:28 -04:00
|
|
|
|
2016-10-24 11:04:04 +02:00
|
|
|
// Multiplatform / generic ABIs
|
rustc_target: add "unwind" payloads to `Abi`
### Overview
This commit begins the implementation work for RFC 2945. For more
information, see the rendered RFC [1] and tracking issue [2].
A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
and `Thiscall` variants, marking whether unwinding across FFI
boundaries is acceptable. The cases where each of these variants'
`unwind` member is true correspond with the `C-unwind`,
`system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings
introduced in RFC 2945 [3].
### Feature Gate and Unstable Book
This commit adds a `c_unwind` feature gate for the new ABI strings.
Tests for this feature gate are included in `src/test/ui/c-unwind/`,
which ensure that this feature gate works correctly for each of the
new ABIs.
A new language features entry in the unstable book is added as well.
### Further Work To Be Done
This commit does not proceed to implement the new unwinding ABIs,
and is intentionally scoped specifically to *defining* the ABIs and
their feature flag.
### One Note on Test Churn
This will lead to some test churn, in re-blessing hash tests, as the
deleted comment in `src/librustc_target/spec/abi.rs` mentioned,
because we can no longer guarantee the ordering of the `Abi`
variants.
While this is a downside, this decision was made bearing in mind
that RFC 2945 states the following, in the "Other `unwind` Strings"
section [3]:
> More unwind variants of existing ABI strings may be introduced,
> with the same semantics, without an additional RFC.
Adding a new variant for each of these cases, rather than specifying
a payload for a given ABI, would quickly become untenable, and make
working with the `Abi` enum prone to mistakes.
This approach encodes the unwinding information *into* a given ABI,
to account for the future possibility of other `-unwind` ABI
strings.
### Ignore Directives
`ignore-*` directives are used in two of our `*-unwind` ABI test
cases.
Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases
ignore architectures that do not support `stdcall` and
`thiscall`, respectively.
These directives are cribbed from
`src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and
`src/test/ui/extern/extern-thiscall.rs` for `thiscall`.
This would otherwise fail on some targets, see:
https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60
### Footnotes
[1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
[2]: https://github.com/rust-lang/rust/issues/74990
[3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings
2020-08-27 11:49:18 -04:00
|
|
|
System { unwind: bool },
|
2013-03-13 22:25:28 -04:00
|
|
|
RustIntrinsic,
|
2014-05-28 22:26:56 -07:00
|
|
|
RustCall,
|
2015-08-06 11:11:26 -07:00
|
|
|
PlatformIntrinsic,
|
2019-12-22 17:42:04 -05:00
|
|
|
Unadjusted,
|
2013-03-13 22:25:28 -04:00
|
|
|
}
|
|
|
|
|
2015-03-30 09:38:59 -04:00
|
|
|
#[derive(Copy, Clone)]
|
2014-02-27 18:48:21 +11:00
|
|
|
pub struct AbiData {
|
2013-03-13 22:25:28 -04:00
|
|
|
abi: Abi,
|
|
|
|
|
2016-10-24 11:04:04 +02:00
|
|
|
/// Name of this ABI as we like it called.
|
2013-03-13 22:25:28 -04:00
|
|
|
name: &'static str,
|
|
|
|
|
2016-10-24 11:04:04 +02:00
|
|
|
/// A generic ABI is supported on all platforms.
|
|
|
|
generic: bool,
|
2013-03-13 22:25:28 -04:00
|
|
|
}
|
|
|
|
|
2014-10-27 15:37:07 -07:00
|
|
|
#[allow(non_upper_case_globals)]
|
2018-08-09 15:42:43 +02:00
|
|
|
const AbiDatas: &[AbiData] = &[
|
2020-06-01 22:20:12 -04:00
|
|
|
// Cross-platform ABIs
|
|
|
|
AbiData { abi: Abi::Rust, name: "Rust", generic: true },
|
rustc_target: add "unwind" payloads to `Abi`
### Overview
This commit begins the implementation work for RFC 2945. For more
information, see the rendered RFC [1] and tracking issue [2].
A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
and `Thiscall` variants, marking whether unwinding across FFI
boundaries is acceptable. The cases where each of these variants'
`unwind` member is true correspond with the `C-unwind`,
`system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings
introduced in RFC 2945 [3].
### Feature Gate and Unstable Book
This commit adds a `c_unwind` feature gate for the new ABI strings.
Tests for this feature gate are included in `src/test/ui/c-unwind/`,
which ensure that this feature gate works correctly for each of the
new ABIs.
A new language features entry in the unstable book is added as well.
### Further Work To Be Done
This commit does not proceed to implement the new unwinding ABIs,
and is intentionally scoped specifically to *defining* the ABIs and
their feature flag.
### One Note on Test Churn
This will lead to some test churn, in re-blessing hash tests, as the
deleted comment in `src/librustc_target/spec/abi.rs` mentioned,
because we can no longer guarantee the ordering of the `Abi`
variants.
While this is a downside, this decision was made bearing in mind
that RFC 2945 states the following, in the "Other `unwind` Strings"
section [3]:
> More unwind variants of existing ABI strings may be introduced,
> with the same semantics, without an additional RFC.
Adding a new variant for each of these cases, rather than specifying
a payload for a given ABI, would quickly become untenable, and make
working with the `Abi` enum prone to mistakes.
This approach encodes the unwinding information *into* a given ABI,
to account for the future possibility of other `-unwind` ABI
strings.
### Ignore Directives
`ignore-*` directives are used in two of our `*-unwind` ABI test
cases.
Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases
ignore architectures that do not support `stdcall` and
`thiscall`, respectively.
These directives are cribbed from
`src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and
`src/test/ui/extern/extern-thiscall.rs` for `thiscall`.
This would otherwise fail on some targets, see:
https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60
### Footnotes
[1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
[2]: https://github.com/rust-lang/rust/issues/74990
[3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings
2020-08-27 11:49:18 -04:00
|
|
|
AbiData { abi: Abi::C { unwind: false }, name: "C", generic: true },
|
|
|
|
AbiData { abi: Abi::C { unwind: true }, name: "C-unwind", generic: true },
|
2013-03-13 22:25:28 -04:00
|
|
|
// Platform-specific ABIs
|
2019-12-22 17:42:04 -05:00
|
|
|
AbiData { abi: Abi::Cdecl, name: "cdecl", generic: false },
|
rustc_target: add "unwind" payloads to `Abi`
### Overview
This commit begins the implementation work for RFC 2945. For more
information, see the rendered RFC [1] and tracking issue [2].
A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
and `Thiscall` variants, marking whether unwinding across FFI
boundaries is acceptable. The cases where each of these variants'
`unwind` member is true correspond with the `C-unwind`,
`system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings
introduced in RFC 2945 [3].
### Feature Gate and Unstable Book
This commit adds a `c_unwind` feature gate for the new ABI strings.
Tests for this feature gate are included in `src/test/ui/c-unwind/`,
which ensure that this feature gate works correctly for each of the
new ABIs.
A new language features entry in the unstable book is added as well.
### Further Work To Be Done
This commit does not proceed to implement the new unwinding ABIs,
and is intentionally scoped specifically to *defining* the ABIs and
their feature flag.
### One Note on Test Churn
This will lead to some test churn, in re-blessing hash tests, as the
deleted comment in `src/librustc_target/spec/abi.rs` mentioned,
because we can no longer guarantee the ordering of the `Abi`
variants.
While this is a downside, this decision was made bearing in mind
that RFC 2945 states the following, in the "Other `unwind` Strings"
section [3]:
> More unwind variants of existing ABI strings may be introduced,
> with the same semantics, without an additional RFC.
Adding a new variant for each of these cases, rather than specifying
a payload for a given ABI, would quickly become untenable, and make
working with the `Abi` enum prone to mistakes.
This approach encodes the unwinding information *into* a given ABI,
to account for the future possibility of other `-unwind` ABI
strings.
### Ignore Directives
`ignore-*` directives are used in two of our `*-unwind` ABI test
cases.
Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases
ignore architectures that do not support `stdcall` and
`thiscall`, respectively.
These directives are cribbed from
`src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and
`src/test/ui/extern/extern-thiscall.rs` for `thiscall`.
This would otherwise fail on some targets, see:
https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60
### Footnotes
[1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
[2]: https://github.com/rust-lang/rust/issues/74990
[3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings
2020-08-27 11:49:18 -04:00
|
|
|
AbiData { abi: Abi::Stdcall { unwind: false }, name: "stdcall", generic: false },
|
|
|
|
AbiData { abi: Abi::Stdcall { unwind: true }, name: "stdcall-unwind", generic: false },
|
2019-12-22 17:42:04 -05:00
|
|
|
AbiData { abi: Abi::Fastcall, name: "fastcall", generic: false },
|
|
|
|
AbiData { abi: Abi::Vectorcall, name: "vectorcall", generic: false },
|
rustc_target: add "unwind" payloads to `Abi`
### Overview
This commit begins the implementation work for RFC 2945. For more
information, see the rendered RFC [1] and tracking issue [2].
A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
and `Thiscall` variants, marking whether unwinding across FFI
boundaries is acceptable. The cases where each of these variants'
`unwind` member is true correspond with the `C-unwind`,
`system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings
introduced in RFC 2945 [3].
### Feature Gate and Unstable Book
This commit adds a `c_unwind` feature gate for the new ABI strings.
Tests for this feature gate are included in `src/test/ui/c-unwind/`,
which ensure that this feature gate works correctly for each of the
new ABIs.
A new language features entry in the unstable book is added as well.
### Further Work To Be Done
This commit does not proceed to implement the new unwinding ABIs,
and is intentionally scoped specifically to *defining* the ABIs and
their feature flag.
### One Note on Test Churn
This will lead to some test churn, in re-blessing hash tests, as the
deleted comment in `src/librustc_target/spec/abi.rs` mentioned,
because we can no longer guarantee the ordering of the `Abi`
variants.
While this is a downside, this decision was made bearing in mind
that RFC 2945 states the following, in the "Other `unwind` Strings"
section [3]:
> More unwind variants of existing ABI strings may be introduced,
> with the same semantics, without an additional RFC.
Adding a new variant for each of these cases, rather than specifying
a payload for a given ABI, would quickly become untenable, and make
working with the `Abi` enum prone to mistakes.
This approach encodes the unwinding information *into* a given ABI,
to account for the future possibility of other `-unwind` ABI
strings.
### Ignore Directives
`ignore-*` directives are used in two of our `*-unwind` ABI test
cases.
Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases
ignore architectures that do not support `stdcall` and
`thiscall`, respectively.
These directives are cribbed from
`src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and
`src/test/ui/extern/extern-thiscall.rs` for `thiscall`.
This would otherwise fail on some targets, see:
https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60
### Footnotes
[1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
[2]: https://github.com/rust-lang/rust/issues/74990
[3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings
2020-08-27 11:49:18 -04:00
|
|
|
AbiData { abi: Abi::Thiscall { unwind: false }, name: "thiscall", generic: false },
|
|
|
|
AbiData { abi: Abi::Thiscall { unwind: true }, name: "thiscall-unwind", generic: false },
|
2019-12-22 17:42:04 -05:00
|
|
|
AbiData { abi: Abi::Aapcs, name: "aapcs", generic: false },
|
|
|
|
AbiData { abi: Abi::Win64, name: "win64", generic: false },
|
|
|
|
AbiData { abi: Abi::SysV64, name: "sysv64", generic: false },
|
|
|
|
AbiData { abi: Abi::PtxKernel, name: "ptx-kernel", generic: false },
|
|
|
|
AbiData { abi: Abi::Msp430Interrupt, name: "msp430-interrupt", generic: false },
|
|
|
|
AbiData { abi: Abi::X86Interrupt, name: "x86-interrupt", generic: false },
|
|
|
|
AbiData { abi: Abi::AmdGpuKernel, name: "amdgpu-kernel", generic: false },
|
|
|
|
AbiData { abi: Abi::EfiApi, name: "efiapi", generic: false },
|
2016-05-06 09:32:10 -04:00
|
|
|
AbiData { abi: Abi::AvrInterrupt, name: "avr-interrupt", generic: false },
|
|
|
|
AbiData {
|
|
|
|
abi: Abi::AvrNonBlockingInterrupt,
|
|
|
|
name: "avr-non-blocking-interrupt",
|
|
|
|
generic: false,
|
|
|
|
},
|
2021-01-24 17:15:05 +00:00
|
|
|
AbiData { abi: Abi::CCmseNonSecureCall, name: "C-cmse-nonsecure-call", generic: false },
|
2013-03-13 22:25:28 -04:00
|
|
|
// Cross-platform ABIs
|
rustc_target: add "unwind" payloads to `Abi`
### Overview
This commit begins the implementation work for RFC 2945. For more
information, see the rendered RFC [1] and tracking issue [2].
A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
and `Thiscall` variants, marking whether unwinding across FFI
boundaries is acceptable. The cases where each of these variants'
`unwind` member is true correspond with the `C-unwind`,
`system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings
introduced in RFC 2945 [3].
### Feature Gate and Unstable Book
This commit adds a `c_unwind` feature gate for the new ABI strings.
Tests for this feature gate are included in `src/test/ui/c-unwind/`,
which ensure that this feature gate works correctly for each of the
new ABIs.
A new language features entry in the unstable book is added as well.
### Further Work To Be Done
This commit does not proceed to implement the new unwinding ABIs,
and is intentionally scoped specifically to *defining* the ABIs and
their feature flag.
### One Note on Test Churn
This will lead to some test churn, in re-blessing hash tests, as the
deleted comment in `src/librustc_target/spec/abi.rs` mentioned,
because we can no longer guarantee the ordering of the `Abi`
variants.
While this is a downside, this decision was made bearing in mind
that RFC 2945 states the following, in the "Other `unwind` Strings"
section [3]:
> More unwind variants of existing ABI strings may be introduced,
> with the same semantics, without an additional RFC.
Adding a new variant for each of these cases, rather than specifying
a payload for a given ABI, would quickly become untenable, and make
working with the `Abi` enum prone to mistakes.
This approach encodes the unwinding information *into* a given ABI,
to account for the future possibility of other `-unwind` ABI
strings.
### Ignore Directives
`ignore-*` directives are used in two of our `*-unwind` ABI test
cases.
Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases
ignore architectures that do not support `stdcall` and
`thiscall`, respectively.
These directives are cribbed from
`src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and
`src/test/ui/extern/extern-thiscall.rs` for `thiscall`.
This would otherwise fail on some targets, see:
https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60
### Footnotes
[1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
[2]: https://github.com/rust-lang/rust/issues/74990
[3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings
2020-08-27 11:49:18 -04:00
|
|
|
AbiData { abi: Abi::System { unwind: false }, name: "system", generic: true },
|
|
|
|
AbiData { abi: Abi::System { unwind: true }, name: "system-unwind", generic: true },
|
2019-12-22 17:42:04 -05:00
|
|
|
AbiData { abi: Abi::RustIntrinsic, name: "rust-intrinsic", generic: true },
|
|
|
|
AbiData { abi: Abi::RustCall, name: "rust-call", generic: true },
|
|
|
|
AbiData { abi: Abi::PlatformIntrinsic, name: "platform-intrinsic", generic: true },
|
|
|
|
AbiData { abi: Abi::Unadjusted, name: "unadjusted", generic: true },
|
2013-03-13 22:25:28 -04:00
|
|
|
];
|
|
|
|
|
2014-06-09 13:12:30 -07:00
|
|
|
/// Returns the ABI with the given name (if any).
|
2013-03-13 22:25:28 -04:00
|
|
|
pub fn lookup(name: &str) -> Option<Abi> {
|
2014-06-12 06:13:25 -04:00
|
|
|
AbiDatas.iter().find(|abi_data| name == abi_data.name).map(|&x| x.abi)
|
2013-03-13 22:25:28 -04:00
|
|
|
}
|
|
|
|
|
2014-02-28 13:09:09 -08:00
|
|
|
pub fn all_names() -> Vec<&'static str> {
|
2014-02-28 12:54:01 -08:00
|
|
|
AbiDatas.iter().map(|d| d.name).collect()
|
2013-03-13 22:25:28 -04:00
|
|
|
}
|
|
|
|
|
2013-05-31 15:17:22 -07:00
|
|
|
impl Abi {
|
2013-03-13 22:25:28 -04:00
|
|
|
#[inline]
|
2018-08-09 15:42:43 +02:00
|
|
|
pub fn index(self) -> usize {
|
rustc_target: add "unwind" payloads to `Abi`
### Overview
This commit begins the implementation work for RFC 2945. For more
information, see the rendered RFC [1] and tracking issue [2].
A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
and `Thiscall` variants, marking whether unwinding across FFI
boundaries is acceptable. The cases where each of these variants'
`unwind` member is true correspond with the `C-unwind`,
`system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings
introduced in RFC 2945 [3].
### Feature Gate and Unstable Book
This commit adds a `c_unwind` feature gate for the new ABI strings.
Tests for this feature gate are included in `src/test/ui/c-unwind/`,
which ensure that this feature gate works correctly for each of the
new ABIs.
A new language features entry in the unstable book is added as well.
### Further Work To Be Done
This commit does not proceed to implement the new unwinding ABIs,
and is intentionally scoped specifically to *defining* the ABIs and
their feature flag.
### One Note on Test Churn
This will lead to some test churn, in re-blessing hash tests, as the
deleted comment in `src/librustc_target/spec/abi.rs` mentioned,
because we can no longer guarantee the ordering of the `Abi`
variants.
While this is a downside, this decision was made bearing in mind
that RFC 2945 states the following, in the "Other `unwind` Strings"
section [3]:
> More unwind variants of existing ABI strings may be introduced,
> with the same semantics, without an additional RFC.
Adding a new variant for each of these cases, rather than specifying
a payload for a given ABI, would quickly become untenable, and make
working with the `Abi` enum prone to mistakes.
This approach encodes the unwinding information *into* a given ABI,
to account for the future possibility of other `-unwind` ABI
strings.
### Ignore Directives
`ignore-*` directives are used in two of our `*-unwind` ABI test
cases.
Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases
ignore architectures that do not support `stdcall` and
`thiscall`, respectively.
These directives are cribbed from
`src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and
`src/test/ui/extern/extern-thiscall.rs` for `thiscall`.
This would otherwise fail on some targets, see:
https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60
### Footnotes
[1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
[2]: https://github.com/rust-lang/rust/issues/74990
[3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings
2020-08-27 11:49:18 -04:00
|
|
|
// N.B., this ordering MUST match the AbiDatas array above.
|
|
|
|
// (This is ensured by the test indices_are_correct().)
|
|
|
|
use Abi::*;
|
2020-10-23 18:49:34 -04:00
|
|
|
let i = match self {
|
rustc_target: add "unwind" payloads to `Abi`
### Overview
This commit begins the implementation work for RFC 2945. For more
information, see the rendered RFC [1] and tracking issue [2].
A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
and `Thiscall` variants, marking whether unwinding across FFI
boundaries is acceptable. The cases where each of these variants'
`unwind` member is true correspond with the `C-unwind`,
`system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings
introduced in RFC 2945 [3].
### Feature Gate and Unstable Book
This commit adds a `c_unwind` feature gate for the new ABI strings.
Tests for this feature gate are included in `src/test/ui/c-unwind/`,
which ensure that this feature gate works correctly for each of the
new ABIs.
A new language features entry in the unstable book is added as well.
### Further Work To Be Done
This commit does not proceed to implement the new unwinding ABIs,
and is intentionally scoped specifically to *defining* the ABIs and
their feature flag.
### One Note on Test Churn
This will lead to some test churn, in re-blessing hash tests, as the
deleted comment in `src/librustc_target/spec/abi.rs` mentioned,
because we can no longer guarantee the ordering of the `Abi`
variants.
While this is a downside, this decision was made bearing in mind
that RFC 2945 states the following, in the "Other `unwind` Strings"
section [3]:
> More unwind variants of existing ABI strings may be introduced,
> with the same semantics, without an additional RFC.
Adding a new variant for each of these cases, rather than specifying
a payload for a given ABI, would quickly become untenable, and make
working with the `Abi` enum prone to mistakes.
This approach encodes the unwinding information *into* a given ABI,
to account for the future possibility of other `-unwind` ABI
strings.
### Ignore Directives
`ignore-*` directives are used in two of our `*-unwind` ABI test
cases.
Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases
ignore architectures that do not support `stdcall` and
`thiscall`, respectively.
These directives are cribbed from
`src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and
`src/test/ui/extern/extern-thiscall.rs` for `thiscall`.
This would otherwise fail on some targets, see:
https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60
### Footnotes
[1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
[2]: https://github.com/rust-lang/rust/issues/74990
[3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings
2020-08-27 11:49:18 -04:00
|
|
|
// Cross-platform ABIs
|
|
|
|
Rust => 0,
|
|
|
|
C { unwind: false } => 1,
|
|
|
|
C { unwind: true } => 2,
|
|
|
|
// Platform-specific ABIs
|
|
|
|
Cdecl => 3,
|
|
|
|
Stdcall { unwind: false } => 4,
|
|
|
|
Stdcall { unwind: true } => 5,
|
|
|
|
Fastcall => 6,
|
|
|
|
Vectorcall => 7,
|
|
|
|
Thiscall { unwind: false } => 8,
|
|
|
|
Thiscall { unwind: true } => 9,
|
|
|
|
Aapcs => 10,
|
|
|
|
Win64 => 11,
|
|
|
|
SysV64 => 12,
|
|
|
|
PtxKernel => 13,
|
|
|
|
Msp430Interrupt => 14,
|
|
|
|
X86Interrupt => 15,
|
|
|
|
AmdGpuKernel => 16,
|
|
|
|
EfiApi => 17,
|
|
|
|
AvrInterrupt => 18,
|
|
|
|
AvrNonBlockingInterrupt => 19,
|
|
|
|
CCmseNonSecureCall => 20,
|
|
|
|
// Cross-platform ABIs
|
|
|
|
System { unwind: false } => 21,
|
|
|
|
System { unwind: true } => 22,
|
|
|
|
RustIntrinsic => 23,
|
|
|
|
RustCall => 24,
|
|
|
|
PlatformIntrinsic => 25,
|
|
|
|
Unadjusted => 26,
|
2020-10-23 18:49:34 -04:00
|
|
|
};
|
|
|
|
debug_assert!(
|
|
|
|
AbiDatas
|
|
|
|
.iter()
|
|
|
|
.enumerate()
|
|
|
|
.find(|(_, AbiData { abi, .. })| *abi == self)
|
|
|
|
.map(|(index, _)| index)
|
|
|
|
.expect("abi variant has associated data")
|
|
|
|
== i,
|
|
|
|
"Abi index did not match `AbiDatas` ordering"
|
|
|
|
);
|
|
|
|
i
|
2013-03-13 22:25:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2018-08-09 15:42:43 +02:00
|
|
|
pub fn data(self) -> &'static AbiData {
|
2013-03-13 22:25:28 -04:00
|
|
|
&AbiDatas[self.index()]
|
|
|
|
}
|
|
|
|
|
2018-08-09 15:42:43 +02:00
|
|
|
pub fn name(self) -> &'static str {
|
2013-03-13 22:25:28 -04:00
|
|
|
self.data().name
|
|
|
|
}
|
2016-10-24 11:04:04 +02:00
|
|
|
|
2018-08-09 15:42:43 +02:00
|
|
|
pub fn generic(self) -> bool {
|
2016-10-24 11:04:04 +02:00
|
|
|
self.data().generic
|
|
|
|
}
|
2013-03-13 22:25:28 -04:00
|
|
|
}
|
|
|
|
|
2015-01-20 15:45:07 -08:00
|
|
|
impl fmt::Display for Abi {
|
2019-02-08 21:00:07 +09:00
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
rustc_target: add "unwind" payloads to `Abi`
### Overview
This commit begins the implementation work for RFC 2945. For more
information, see the rendered RFC [1] and tracking issue [2].
A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
and `Thiscall` variants, marking whether unwinding across FFI
boundaries is acceptable. The cases where each of these variants'
`unwind` member is true correspond with the `C-unwind`,
`system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings
introduced in RFC 2945 [3].
### Feature Gate and Unstable Book
This commit adds a `c_unwind` feature gate for the new ABI strings.
Tests for this feature gate are included in `src/test/ui/c-unwind/`,
which ensure that this feature gate works correctly for each of the
new ABIs.
A new language features entry in the unstable book is added as well.
### Further Work To Be Done
This commit does not proceed to implement the new unwinding ABIs,
and is intentionally scoped specifically to *defining* the ABIs and
their feature flag.
### One Note on Test Churn
This will lead to some test churn, in re-blessing hash tests, as the
deleted comment in `src/librustc_target/spec/abi.rs` mentioned,
because we can no longer guarantee the ordering of the `Abi`
variants.
While this is a downside, this decision was made bearing in mind
that RFC 2945 states the following, in the "Other `unwind` Strings"
section [3]:
> More unwind variants of existing ABI strings may be introduced,
> with the same semantics, without an additional RFC.
Adding a new variant for each of these cases, rather than specifying
a payload for a given ABI, would quickly become untenable, and make
working with the `Abi` enum prone to mistakes.
This approach encodes the unwinding information *into* a given ABI,
to account for the future possibility of other `-unwind` ABI
strings.
### Ignore Directives
`ignore-*` directives are used in two of our `*-unwind` ABI test
cases.
Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases
ignore architectures that do not support `stdcall` and
`thiscall`, respectively.
These directives are cribbed from
`src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and
`src/test/ui/extern/extern-thiscall.rs` for `thiscall`.
This would otherwise fail on some targets, see:
https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60
### Footnotes
[1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
[2]: https://github.com/rust-lang/rust/issues/74990
[3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings
2020-08-27 11:49:18 -04:00
|
|
|
match self {
|
|
|
|
abi => write!(f, "\"{}\"", abi.name()),
|
|
|
|
}
|
2013-03-13 22:25:28 -04:00
|
|
|
}
|
|
|
|
}
|