Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,8 @@ crate::target_spec_enum! {
X86Sse2 = "x86-sse2",
/// On x86-32/64 only: do not use any FPU or SIMD registers for the ABI.
X86Softfloat = "x86-softfloat",
// On S390x only: do not use any FPU or Vector registers for the ABI.
S390xSoftFloat = "s390x-softfloat",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just rename X86Softfloat to Softfloat and use that also for s390x?

}

parse_error_type = "rustc abi";
Expand Down Expand Up @@ -3198,6 +3200,11 @@ impl Target {
Arch::X86 | Arch::X86_64,
"`x86-softfloat` ABI is only valid for x86 targets"
),
RustcAbi::S390xSoftFloat => check_matches!(
self.arch,
Arch::S390x,
"`s390x-softfloat` ABI is only valid for s390x targets"
),
}
}

Expand Down
22 changes: 19 additions & 3 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ impl Target {
// LLVM handles the rest.
FeatureConstraints { required: &["soft-float"], incompatible: &[] }
}
Some(r) => panic!("invalid Rust ABI for x86: {r:?}"),
}
}
Arch::X86_64 => {
Expand Down Expand Up @@ -1211,11 +1212,26 @@ impl Target {
}
}
Arch::S390x => {
// We don't currently support a softfloat target on this architecture.
// As usual, we have to reject swapping the `soft-float` target feature.
// Same as x86, We use our own ABI indicator here;
// LLVM does not have anything native and will switch ABI based
// on the soft-float target feature.
// Every case should require or forbid `soft-float`!
// The "vector" target feature does not affect the ABI for floats
// because the vector and float registers overlap.
FeatureConstraints { required: &[], incompatible: &["soft-float"] }
match self.rustc_abi {
None => {
// Default hardfloat ABI.
FeatureConstraints { required: &[], incompatible: &["soft-float"] }
}
Some(RustcAbi::S390xSoftFloat) => {
// Softfloat ABI, requires corresponding target feature.
// llvm will switch to soft-float ABI just based on this feature.
FeatureConstraints { required: &["soft-float"], incompatible: &[] }
}
Some(r) => {
panic!("invalid Rust ABI for s390x: {r:?}");
}
}
}
_ => NOTHING,
}
Expand Down
Loading