@@ -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.
@@ -417,7 +417,9 @@ const X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
417
417
( "sha512" , Unstable ( sym:: sha512_sm_x86) , & [ "avx2" ] ) ,
418
418
( "sm3" , Unstable ( sym:: sha512_sm_x86) , & [ "avx" ] ) ,
419
419
( "sm4" , Unstable ( sym:: sha512_sm_x86) , & [ "avx2" ] ) ,
420
- ( "soft-float" , Stability :: Forbidden { reason : "unsound because it changes float ABI" } , & [ ] ) ,
420
+ // This cannot actually be toggled, the ABI always fixes it, so it'd make little sense to
421
+ // stabilize. It must be in this list for the ABI check to be able to use it.
422
+ ( "soft-float" , Stability :: Unstable ( sym:: x87_target_feature) , & [ ] ) ,
421
423
( "sse" , Stable , & [ ] ) ,
422
424
( "sse2" , Stable , & [ "sse" ] ) ,
423
425
( "sse3" , Stable , & [ "sse2" ] ) ,
@@ -768,23 +770,41 @@ impl Target {
768
770
// questions "which ABI is used".
769
771
match & * self . arch {
770
772
"x86" => {
771
- // We support 2 ABIs, hardfloat (default) and softfloat.
772
- // x86 has no sane ABI indicator so we have to use the target feature.
773
- if self . has_feature ( "soft-float" ) {
774
- NOTHING
775
- } else {
776
- // Hardfloat ABI. x87 must be enabled.
777
- FeatureConstraints { required : & [ "x87" ] , incompatible : & [ ] }
773
+ // We use our own ABI indicator here; LLVM does not have anything native.
774
+ // Every case should require or forbid `soft-float`!
775
+ match self . rustc_abi {
776
+ None => {
777
+ // Default hardfloat ABI.
778
+ // x87 must be enabled, soft-float must be disabled.
779
+ FeatureConstraints { required : & [ "x87" ] , incompatible : & [ "soft-float" ] }
780
+ }
781
+ Some ( RustcAbi :: X86Softfloat ) => {
782
+ // Softfloat ABI, requires corresponding target feature. That feature trumps
783
+ // `x87` and all other FPU features so those do not matter.
784
+ // Note that this one requirement is the entire implementation of the ABI!
785
+ // LLVM handles the rest.
786
+ FeatureConstraints { required : & [ "soft-float" ] , incompatible : & [ ] }
787
+ }
778
788
}
779
789
}
780
790
"x86_64" => {
781
- // We support 2 ABIs, hardfloat (default) and softfloat.
782
- // x86 has no sane ABI indicator so we have to use the target feature.
783
- if self . has_feature ( "soft-float" ) {
784
- NOTHING
785
- } else {
786
- // Hardfloat ABI. x87 and SSE2 must be enabled.
787
- FeatureConstraints { required : & [ "x87" , "sse2" ] , incompatible : & [ ] }
791
+ // We use our own ABI indicator here; LLVM does not have anything native.
792
+ // Every case should require or forbid `soft-float`!
793
+ match self . rustc_abi {
794
+ None => {
795
+ // Default hardfloat ABI. On x86-64, this always includes SSE2.
796
+ FeatureConstraints {
797
+ required : & [ "x87" , "sse2" ] ,
798
+ incompatible : & [ "soft-float" ] ,
799
+ }
800
+ }
801
+ Some ( RustcAbi :: X86Softfloat ) => {
802
+ // Softfloat ABI, requires corresponding target feature. That feature trumps
803
+ // `x87` and all other FPU features so those do not matter.
804
+ // Note that this one requirement is the entire implementation of the ABI!
805
+ // LLVM handles the rest.
806
+ FeatureConstraints { required : & [ "soft-float" ] , incompatible : & [ ] }
807
+ }
788
808
}
789
809
}
790
810
"arm" => {
0 commit comments