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