@@ -5,7 +5,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
5
5
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
6
6
use rustc_span:: { Symbol , sym} ;
7
7
8
- use crate :: spec:: { FloatAbi , Target } ;
8
+ use crate :: spec:: { FloatAbi , RustcAbi , Target } ;
9
9
10
10
/// Features that control behaviour of rustc, rather than the codegen.
11
11
/// These exist globally and are not in the target-specific lists below.
@@ -422,7 +422,9 @@ const X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
422
422
( "sha512" , Unstable ( sym:: sha512_sm_x86) , & [ "avx2" ] ) ,
423
423
( "sm3" , Unstable ( sym:: sha512_sm_x86) , & [ "avx" ] ) ,
424
424
( "sm4" , Unstable ( sym:: sha512_sm_x86) , & [ "avx2" ] ) ,
425
- ( "soft-float" , Stability :: Forbidden { reason : "unsound because it changes float ABI" } , & [ ] ) ,
425
+ // This cannot actually be toggled, the ABI always fixes it, so it'd make little sense to
426
+ // stabilize. It must be in this list for the ABI check to be able to use it.
427
+ ( "soft-float" , Stability :: Unstable ( sym:: x87_target_feature) , & [ ] ) ,
426
428
( "sse" , Stable , & [ ] ) ,
427
429
( "sse2" , Stable , & [ "sse" ] ) ,
428
430
( "sse3" , Stable , & [ "sse2" ] ) ,
@@ -773,23 +775,41 @@ impl Target {
773
775
// questions "which ABI is used".
774
776
match & * self . arch {
775
777
"x86" => {
776
- // We support 2 ABIs, hardfloat (default) and softfloat.
777
- // x86 has no sane ABI indicator so we have to use the target feature.
778
- if self . has_feature ( "soft-float" ) {
779
- NOTHING
780
- } else {
781
- // Hardfloat ABI. x87 must be enabled.
782
- FeatureConstraints { required : & [ "x87" ] , incompatible : & [ ] }
778
+ // We use our own ABI indicator here; LLVM does not have anything native.
779
+ // Every case should require or forbid `soft-float`!
780
+ match self . rustc_abi {
781
+ None => {
782
+ // Default hardfloat ABI.
783
+ // x87 must be enabled, soft-float must be disabled.
784
+ FeatureConstraints { required : & [ "x87" ] , incompatible : & [ "soft-float" ] }
785
+ }
786
+ Some ( RustcAbi :: X86Softfloat ) => {
787
+ // Softfloat ABI, requires corresponding target feature. That feature trumps
788
+ // `x87` and all other FPU features so those do not matter.
789
+ // Note that this one requirement is the entire implementation of the ABI!
790
+ // LLVM handles the rest.
791
+ FeatureConstraints { required : & [ "soft-float" ] , incompatible : & [ ] }
792
+ }
783
793
}
784
794
}
785
795
"x86_64" => {
786
- // We support 2 ABIs, hardfloat (default) and softfloat.
787
- // x86 has no sane ABI indicator so we have to use the target feature.
788
- if self . has_feature ( "soft-float" ) {
789
- NOTHING
790
- } else {
791
- // Hardfloat ABI. x87 and SSE2 must be enabled.
792
- FeatureConstraints { required : & [ "x87" , "sse2" ] , incompatible : & [ ] }
796
+ // We use our own ABI indicator here; LLVM does not have anything native.
797
+ // Every case should require or forbid `soft-float`!
798
+ match self . rustc_abi {
799
+ None => {
800
+ // Default hardfloat ABI. On x86-64, this always includes SSE2.
801
+ FeatureConstraints {
802
+ required : & [ "x87" , "sse2" ] ,
803
+ incompatible : & [ "soft-float" ] ,
804
+ }
805
+ }
806
+ Some ( RustcAbi :: X86Softfloat ) => {
807
+ // Softfloat ABI, requires corresponding target feature. That feature trumps
808
+ // `x87` and all other FPU features so those do not matter.
809
+ // Note that this one requirement is the entire implementation of the ABI!
810
+ // LLVM handles the rest.
811
+ FeatureConstraints { required : & [ "soft-float" ] , incompatible : & [ ] }
812
+ }
793
813
}
794
814
}
795
815
"arm" => {
0 commit comments