Skip to content

Commit b7dfd48

Browse files
author
Günther Brammer
committed
Enable usage of XMM0 per-target
Activating SSE2 with -C target-feature doesn't change the Rust ABI anymore, while deactivating it still does.
1 parent fed8bd1 commit b7dfd48

16 files changed

+21
-0
lines changed

compiler/rustc_target/src/spec/i686_apple_darwin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub fn target() -> Target {
99
base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m32"]);
1010
base.stack_probes = StackProbeType::X86;
1111
base.frame_pointer = FramePointer::Always;
12+
base.x86_use_xmm0 = true;
1213

1314
Target {
1415
// Clang automatically chooses a more specific target based on

compiler/rustc_target/src/spec/i686_linux_android.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub fn target() -> Target {
1212
base.cpu = "pentiumpro".into();
1313
base.features = "+mmx,+sse,+sse2,+sse3,+ssse3".into();
1414
base.stack_probes = StackProbeType::X86;
15+
base.x86_use_xmm0 = true;
1516

1617
Target {
1718
llvm_target: "i686-linux-android".into(),

compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub fn target() -> Target {
1414
&["-m", "i386pe", "--large-address-aware"],
1515
);
1616
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-Wl,--large-address-aware"]);
17+
base.x86_use_xmm0 = true;
1718

1819
Target {
1920
llvm_target: "i686-pc-windows-gnu".into(),

compiler/rustc_target/src/spec/i686_pc_windows_gnullvm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub fn target() -> Target {
1313
LinkerFlavor::Gnu(Cc::No, Lld::No),
1414
&["-m", "i386pe", "--large-address-aware"],
1515
);
16+
base.x86_use_xmm0 = true;
1617

1718
Target {
1819
llvm_target: "i686-pc-windows-gnu".into(),

compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn target() -> Target {
1919
);
2020
// Workaround for #95429
2121
base.has_thread_local = false;
22+
base.x86_use_xmm0 = true;
2223

2324
Target {
2425
llvm_target: "i686-pc-windows-msvc".into(),

compiler/rustc_target/src/spec/i686_unknown_freebsd.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub fn target() -> Target {
66
base.max_atomic_width = Some(64);
77
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-znotext"]);
88
base.stack_probes = StackProbeType::X86;
9+
base.x86_use_xmm0 = true;
910

1011
Target {
1112
llvm_target: "i686-unknown-freebsd".into(),

compiler/rustc_target/src/spec/i686_unknown_haiku.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub fn target() -> Target {
66
base.max_atomic_width = Some(64);
77
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
88
base.stack_probes = StackProbeType::X86;
9+
base.x86_use_xmm0 = true;
910

1011
Target {
1112
llvm_target: "i686-unknown-haiku".into(),

compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub fn target() -> Target {
77
base.supported_sanitizers = SanitizerSet::ADDRESS;
88
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
99
base.stack_probes = StackProbeType::X86;
10+
base.x86_use_xmm0 = true;
1011

1112
Target {
1213
llvm_target: "i686-unknown-linux-gnu".into(),

compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub fn target() -> Target {
2020
// This may or may not be related to this bug:
2121
// https://llvm.org/bugs/show_bug.cgi?id=30879
2222
base.frame_pointer = FramePointer::Always;
23+
base.x86_use_xmm0 = true;
2324

2425
Target {
2526
llvm_target: "i686-unknown-linux-musl".into(),

compiler/rustc_target/src/spec/i686_unknown_netbsd.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub fn target() -> Target {
66
base.max_atomic_width = Some(64);
77
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
88
base.stack_probes = StackProbeType::X86;
9+
base.x86_use_xmm0 = true;
910

1011
Target {
1112
llvm_target: "i686-unknown-netbsdelf".into(),

compiler/rustc_target/src/spec/i686_unknown_openbsd.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub fn target() -> Target {
66
base.max_atomic_width = Some(64);
77
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-fuse-ld=lld"]);
88
base.stack_probes = StackProbeType::X86;
9+
base.x86_use_xmm0 = true;
910

1011
Target {
1112
llvm_target: "i686-unknown-openbsd".into(),

compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub fn target() -> Target {
1313
&["-m", "i386pe", "--large-address-aware"],
1414
);
1515
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-Wl,--large-address-aware"]);
16+
base.x86_use_xmm0 = true;
1617

1718
Target {
1819
llvm_target: "i686-pc-windows-gnu".into(),

compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub fn target() -> Target {
44
let mut base = super::windows_uwp_msvc_base::opts();
55
base.cpu = "pentium4".into();
66
base.max_atomic_width = Some(64);
7+
base.x86_use_xmm0 = true;
78

89
Target {
910
llvm_target: "i686-pc-windows-msvc".into(),

compiler/rustc_target/src/spec/i686_wrs_vxworks.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub fn target() -> Target {
66
base.max_atomic_width = Some(64);
77
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
88
base.stack_probes = StackProbeType::X86;
9+
base.x86_use_xmm0 = true;
910

1011
Target {
1112
llvm_target: "i686-unknown-linux-gnu".into(),

compiler/rustc_target/src/spec/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1935,6 +1935,9 @@ pub struct TargetOptions {
19351935
/// wasm32 where the whole program either has simd or not.
19361936
pub simd_types_indirect: bool,
19371937

1938+
/// On x86, use XMM0 instead of FP0 as float return register for the Rust ABI
1939+
pub x86_use_xmm0: bool,
1940+
19381941
/// Pass a list of symbol which should be exported in the dylib to the linker.
19391942
pub limit_rdylib_exports: bool,
19401943

@@ -2213,6 +2216,7 @@ impl Default for TargetOptions {
22132216
requires_uwtable: false,
22142217
default_uwtable: false,
22152218
simd_types_indirect: true,
2219+
x86_use_xmm0: false,
22162220
limit_rdylib_exports: true,
22172221
override_export_symbols: None,
22182222
merge_functions: MergeFunctions::Aliases,
@@ -2878,6 +2882,7 @@ impl Target {
28782882
key!(requires_uwtable, bool);
28792883
key!(default_uwtable, bool);
28802884
key!(simd_types_indirect, bool);
2885+
key!(x86_use_xmm0, bool);
28812886
key!(limit_rdylib_exports, bool);
28822887
key!(override_export_symbols, opt_list);
28832888
key!(merge_functions, MergeFunctions)?;
@@ -3135,6 +3140,7 @@ impl ToJson for Target {
31353140
target_option_val!(requires_uwtable);
31363141
target_option_val!(default_uwtable);
31373142
target_option_val!(simd_types_indirect);
3143+
target_option_val!(x86_use_xmm0);
31383144
target_option_val!(limit_rdylib_exports);
31393145
target_option_val!(override_export_symbols);
31403146
target_option_val!(merge_functions);

compiler/rustc_ty_utils/src/abi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ fn fn_abi_new_uncached<'tcx>(
373373
let target_env_gnu_like = matches!(&target.env[..], "gnu" | "musl" | "uclibc");
374374
let win_x64_gnu = target.os == "windows" && target.arch == "x86_64" && target.env == "gnu";
375375
let x86_sse2 = target.arch == "x86"
376+
&& target.x86_use_xmm0
376377
&& cx.tcx.sess.parse_sess.config.contains(&(sym::target_feature, Some(sym::sse2)));
377378
let linux_s390x_gnu_like =
378379
target.os == "linux" && target.arch == "s390x" && target_env_gnu_like;

0 commit comments

Comments
 (0)