@@ -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.
@@ -770,23 +770,39 @@ impl Target {
770
770
// questions "which ABI is used".
771
771
match & * self . arch {
772
772
"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 : & [ ] }
773
+ // We use our own ABI indicator here; LLVM does not have anything native.
774
+ match self . rustc_abi {
775
+ None => {
776
+ // Default hardfloat ABI.
777
+ // x87 must be enabled, soft-float must be disabled.
778
+ FeatureConstraints { required : & [ "x87" ] , incompatible : & [ "soft-float" ] }
779
+ }
780
+ Some ( RustcAbi :: X86Softfloat ) => {
781
+ // Softfloat ABI, requires corresponding target feature. That feature trumps
782
+ // `x87` and all other FPU features so those do not matter.
783
+ // Note that this one requirement is the entire implementation of the ABI!
784
+ // LLVM handles the rest.
785
+ FeatureConstraints { required : & [ "soft-float" ] , incompatible : & [ ] }
786
+ }
780
787
}
781
788
}
782
789
"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 : & [ ] }
790
+ // We use our own ABI indicator here; LLVM does not have anything native.
791
+ match self . rustc_abi {
792
+ None => {
793
+ // Default hardfloat ABI. On x86-64, this always includes SSE2.
794
+ FeatureConstraints {
795
+ required : & [ "x87" , "sse2" ] ,
796
+ incompatible : & [ "soft-float" ] ,
797
+ }
798
+ }
799
+ Some ( RustcAbi :: X86Softfloat ) => {
800
+ // Softfloat ABI, requires corresponding target feature. That feature trumps
801
+ // `x87` and all other FPU features so those do not matter.
802
+ // Note that this one requirement is the entire implementation of the ABI!
803
+ // LLVM handles the rest.
804
+ FeatureConstraints { required : & [ "soft-float" ] , incompatible : & [ ] }
805
+ }
790
806
}
791
807
}
792
808
"arm" => {
0 commit comments