Skip to content

Commit f7ae9e1

Browse files
committed
adjust_abi: make fallback logic for ABIs a bit easier to read
1 parent a18bd8a commit f7ae9e1

File tree

1 file changed

+26
-11
lines changed
  • compiler/rustc_target/src/spec

1 file changed

+26
-11
lines changed

compiler/rustc_target/src/spec/mod.rs

+26-11
Original file line numberDiff line numberDiff line change
@@ -2862,20 +2862,35 @@ impl Target {
28622862
// On Windows, `extern "system"` behaves like msvc's `__stdcall`.
28632863
// `__stdcall` only applies on x86 and on non-variadic functions:
28642864
// https://learn.microsoft.com/en-us/cpp/cpp/stdcall?view=msvc-170
2865-
System { unwind } if self.is_like_windows && self.arch == "x86" && !c_variadic => {
2866-
Stdcall { unwind }
2865+
System { unwind } => {
2866+
if self.is_like_windows && self.arch == "x86" && !c_variadic {
2867+
Stdcall { unwind }
2868+
} else {
2869+
C { unwind }
2870+
}
2871+
}
2872+
2873+
EfiApi => {
2874+
if self.arch == "arm" {
2875+
Aapcs { unwind: false }
2876+
} else if self.arch == "x86_64" {
2877+
Win64 { unwind: false }
2878+
} else {
2879+
C { unwind: false }
2880+
}
28672881
}
2868-
System { unwind } => C { unwind },
2869-
EfiApi if self.arch == "arm" => Aapcs { unwind: false },
2870-
EfiApi if self.arch == "x86_64" => Win64 { unwind: false },
2871-
EfiApi => C { unwind: false },
28722882

28732883
// See commentary in `is_abi_supported`.
2874-
Stdcall { .. } | Thiscall { .. } if self.arch == "x86" => abi,
2875-
Stdcall { unwind } | Thiscall { unwind } => C { unwind },
2876-
Fastcall { .. } if self.arch == "x86" => abi,
2877-
Vectorcall { .. } if ["x86", "x86_64"].contains(&&self.arch[..]) => abi,
2878-
Fastcall { unwind } | Vectorcall { unwind } => C { unwind },
2884+
Stdcall { unwind } | Thiscall { unwind } | Fastcall { unwind } => {
2885+
if self.arch == "x86" { abi } else { C { unwind } }
2886+
}
2887+
Vectorcall { unwind } => {
2888+
if ["x86", "x86_64"].contains(&&*self.arch) {
2889+
abi
2890+
} else {
2891+
C { unwind }
2892+
}
2893+
}
28792894

28802895
// The Windows x64 calling convention we use for `extern "Rust"`
28812896
// <https://learn.microsoft.com/en-us/cpp/build/x64-software-conventions#register-volatility-and-preservation>

0 commit comments

Comments
 (0)