@@ -669,6 +669,14 @@ const CSKY_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(
669
669
const LOONGARCH_FEATURES_FOR_CORRECT_VECTOR_ABI : & ' static [ ( u64 , & ' static str ) ] =
670
670
& [ ( 128 , "lsx" ) , ( 256 , "lasx" ) ] ;
671
671
672
+ #[ derive( Copy , Clone , Debug ) ]
673
+ pub struct FeatureConstraints {
674
+ /// Features that must be enabled.
675
+ pub required : & ' static [ & ' static str ] ,
676
+ /// Features that must be disabled.
677
+ pub incompatible : & ' static [ & ' static str ] ,
678
+ }
679
+
672
680
impl Target {
673
681
pub fn rust_target_features ( & self ) -> & ' static [ ( & ' static str , Stability , ImpliedFeatures ) ] {
674
682
match & * self . arch {
@@ -749,8 +757,8 @@ impl Target {
749
757
/// All features enabled/disabled via `-Ctarget-features` and `#[target_features]` are checked
750
758
/// against this. We also check any implied features, based on the information above. If LLVM
751
759
/// implicitly enables more implied features than we do, that could bypass this check!
752
- pub fn abi_required_features ( & self ) -> ( & ' static [ & ' static str ] , & ' static [ & ' static str ] ) {
753
- const NOTHING : ( & ' static [ & ' static str ] , & ' static [ & ' static str ] ) = ( & [ ] , & [ ] ) ;
760
+ pub fn abi_required_features ( & self ) -> FeatureConstraints {
761
+ const NOTHING : FeatureConstraints = FeatureConstraints { required : & [ ] , incompatible : & [ ] } ;
754
762
// Some architectures don't have a clean explicit ABI designation; instead, the ABI is
755
763
// defined by target features. When that is the case, those target features must be
756
764
// "forbidden" in the list above to ensure that there is a consistent answer to the
@@ -763,7 +771,7 @@ impl Target {
763
771
NOTHING
764
772
} else {
765
773
// Hardfloat ABI. x87 must be enabled.
766
- ( & [ "x87" ] , & [ ] )
774
+ FeatureConstraints { required : & [ "x87" ] , incompatible : & [ ] }
767
775
}
768
776
}
769
777
"x86_64" => {
@@ -773,7 +781,7 @@ impl Target {
773
781
NOTHING
774
782
} else {
775
783
// Hardfloat ABI. x87 and SSE2 must be enabled.
776
- ( & [ "x87" , "sse2" ] , & [ ] )
784
+ FeatureConstraints { required : & [ "x87" , "sse2" ] , incompatible : & [ ] }
777
785
}
778
786
}
779
787
"arm" => {
@@ -786,7 +794,7 @@ impl Target {
786
794
}
787
795
FloatAbi :: Hard => {
788
796
// Must have `fpregs` and must not have `soft-float`.
789
- ( & [ "fpregs" ] , & [ "soft-float" ] )
797
+ FeatureConstraints { required : & [ "fpregs" ] , incompatible : & [ "soft-float" ] }
790
798
}
791
799
}
792
800
}
@@ -803,7 +811,7 @@ impl Target {
803
811
_ => {
804
812
// Everything else is assumed to use a hardfloat ABI. neon and fp-armv8 must be enabled.
805
813
// These are Rust feature names and we use "neon" to control both of them.
806
- ( & [ "neon" ] , & [ ] )
814
+ FeatureConstraints { required : & [ "neon" ] , incompatible : & [ ] }
807
815
}
808
816
}
809
817
}
@@ -813,15 +821,15 @@ impl Target {
813
821
match & * self . llvm_abiname {
814
822
"ilp32d" | "lp64d" => {
815
823
// Requires d (which implies f), incompatible with e.
816
- ( & [ "d" ] , & [ "e" ] )
824
+ FeatureConstraints { required : & [ "d" ] , incompatible : & [ "e" ] }
817
825
}
818
826
"ilp32f" | "lp64f" => {
819
827
// Requires f, incompatible with e.
820
- ( & [ "f" ] , & [ "e" ] )
828
+ FeatureConstraints { required : & [ "f" ] , incompatible : & [ "e" ] }
821
829
}
822
830
"ilp32" | "lp64" => {
823
831
// Requires nothing, incompatible with e.
824
- ( & [ ] , & [ "e" ] )
832
+ FeatureConstraints { required : & [ ] , incompatible : & [ "e" ] }
825
833
}
826
834
"ilp32e" => {
827
835
// ilp32e is documented to be incompatible with features that need aligned
@@ -832,7 +840,7 @@ impl Target {
832
840
// Note that the `e` feature is not required: the ABI treats the extra
833
841
// registers as caller-save, so it is safe to use them only in some parts of
834
842
// a program while the rest doesn't know they even exist.
835
- ( & [ ] , & [ "d" ] )
843
+ FeatureConstraints { required : & [ ] , incompatible : & [ "d" ] }
836
844
}
837
845
"lp64e" => {
838
846
// As above, `e` is not required.
0 commit comments