Skip to content

Commit

Permalink
Enable usage of XMM0 per-target
Browse files Browse the repository at this point in the history
Activating SSE2 with -C target-feature doesn't change the Rust ABI anymore,
while deactivating it still does.
  • Loading branch information
Günther Brammer committed Oct 8, 2023
1 parent fed8bd1 commit 2b153e7
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/i686_apple_darwin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub fn target() -> Target {
base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m32"]);
base.stack_probes = StackProbeType::X86;
base.frame_pointer = FramePointer::Always;
base.x86_use_xmm0 = true;

Target {
// Clang automatically chooses a more specific target based on
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/i686_linux_android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub fn target() -> Target {
base.cpu = "pentiumpro".into();
base.features = "+mmx,+sse,+sse2,+sse3,+ssse3".into();
base.stack_probes = StackProbeType::X86;
base.x86_use_xmm0 = true;

Target {
llvm_target: "i686-linux-android".into(),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub fn target() -> Target {
&["-m", "i386pe", "--large-address-aware"],
);
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-Wl,--large-address-aware"]);
base.x86_use_xmm0 = true;

Target {
llvm_target: "i686-pc-windows-gnu".into(),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/i686_pc_windows_gnullvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub fn target() -> Target {
LinkerFlavor::Gnu(Cc::No, Lld::No),
&["-m", "i386pe", "--large-address-aware"],
);
base.x86_use_xmm0 = true;

Target {
llvm_target: "i686-pc-windows-gnu".into(),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn target() -> Target {
);
// Workaround for #95429
base.has_thread_local = false;
base.x86_use_xmm0 = true;

Target {
llvm_target: "i686-pc-windows-msvc".into(),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/i686_unknown_freebsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub fn target() -> Target {
base.max_atomic_width = Some(64);
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-znotext"]);
base.stack_probes = StackProbeType::X86;
base.x86_use_xmm0 = true;

Target {
llvm_target: "i686-unknown-freebsd".into(),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/i686_unknown_haiku.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub fn target() -> Target {
base.max_atomic_width = Some(64);
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
base.stack_probes = StackProbeType::X86;
base.x86_use_xmm0 = true;

Target {
llvm_target: "i686-unknown-haiku".into(),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub fn target() -> Target {
base.supported_sanitizers = SanitizerSet::ADDRESS;
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
base.stack_probes = StackProbeType::X86;
base.x86_use_xmm0 = true;

Target {
llvm_target: "i686-unknown-linux-gnu".into(),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub fn target() -> Target {
// This may or may not be related to this bug:
// https://llvm.org/bugs/show_bug.cgi?id=30879
base.frame_pointer = FramePointer::Always;
base.x86_use_xmm0 = true;

Target {
llvm_target: "i686-unknown-linux-musl".into(),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/i686_unknown_netbsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub fn target() -> Target {
base.max_atomic_width = Some(64);
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
base.stack_probes = StackProbeType::X86;
base.x86_use_xmm0 = true;

Target {
llvm_target: "i686-unknown-netbsdelf".into(),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/i686_unknown_openbsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub fn target() -> Target {
base.max_atomic_width = Some(64);
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-fuse-ld=lld"]);
base.stack_probes = StackProbeType::X86;
base.x86_use_xmm0 = true;

Target {
llvm_target: "i686-unknown-openbsd".into(),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub fn target() -> Target {
&["-m", "i386pe", "--large-address-aware"],
);
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-Wl,--large-address-aware"]);
base.x86_use_xmm0 = true;

Target {
llvm_target: "i686-pc-windows-gnu".into(),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub fn target() -> Target {
let mut base = super::windows_uwp_msvc_base::opts();
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);
base.x86_use_xmm0 = true;

Target {
llvm_target: "i686-pc-windows-msvc".into(),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/i686_wrs_vxworks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub fn target() -> Target {
base.max_atomic_width = Some(64);
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
base.stack_probes = StackProbeType::X86;
base.x86_use_xmm0 = true;

Target {
llvm_target: "i686-unknown-linux-gnu".into(),
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1935,6 +1935,9 @@ pub struct TargetOptions {
/// wasm32 where the whole program either has simd or not.
pub simd_types_indirect: bool,

/// On x86, use XMM0 instead of FP0 as float return register for the Rust ABI
pub x86_use_xmm0: bool,

/// Pass a list of symbol which should be exported in the dylib to the linker.
pub limit_rdylib_exports: bool,

Expand Down Expand Up @@ -2213,6 +2216,7 @@ impl Default for TargetOptions {
requires_uwtable: false,
default_uwtable: false,
simd_types_indirect: true,
x86_use_xmm0: false,
limit_rdylib_exports: true,
override_export_symbols: None,
merge_functions: MergeFunctions::Aliases,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ty_utils/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ fn fn_abi_new_uncached<'tcx>(
let target_env_gnu_like = matches!(&target.env[..], "gnu" | "musl" | "uclibc");
let win_x64_gnu = target.os == "windows" && target.arch == "x86_64" && target.env == "gnu";
let x86_sse2 = target.arch == "x86"
&& target.x86_use_xmm0
&& cx.tcx.sess.parse_sess.config.contains(&(sym::target_feature, Some(sym::sse2)));
let linux_s390x_gnu_like =
target.os == "linux" && target.arch == "s390x" && target_env_gnu_like;
Expand Down

0 comments on commit 2b153e7

Please sign in to comment.