@@ -669,6 +669,14 @@ const CSKY_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(
669669const LOONGARCH_FEATURES_FOR_CORRECT_VECTOR_ABI : & ' static [ ( u64 , & ' static str ) ] =
670670 & [ ( 128 , "lsx" ) , ( 256 , "lasx" ) ] ;
671671
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+
672680impl Target {
673681 pub fn rust_target_features ( & self ) -> & ' static [ ( & ' static str , Stability , ImpliedFeatures ) ] {
674682 match & * self . arch {
@@ -749,8 +757,8 @@ impl Target {
749757 /// All features enabled/disabled via `-Ctarget-features` and `#[target_features]` are checked
750758 /// against this. We also check any implied features, based on the information above. If LLVM
751759 /// 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 : & [ ] } ;
754762 // Some architectures don't have a clean explicit ABI designation; instead, the ABI is
755763 // defined by target features. When that is the case, those target features must be
756764 // "forbidden" in the list above to ensure that there is a consistent answer to the
@@ -763,7 +771,7 @@ impl Target {
763771 NOTHING
764772 } else {
765773 // Hardfloat ABI. x87 must be enabled.
766- ( & [ "x87" ] , & [ ] )
774+ FeatureConstraints { required : & [ "x87" ] , incompatible : & [ ] }
767775 }
768776 }
769777 "x86_64" => {
@@ -773,7 +781,7 @@ impl Target {
773781 NOTHING
774782 } else {
775783 // Hardfloat ABI. x87 and SSE2 must be enabled.
776- ( & [ "x87" , "sse2" ] , & [ ] )
784+ FeatureConstraints { required : & [ "x87" , "sse2" ] , incompatible : & [ ] }
777785 }
778786 }
779787 "arm" => {
@@ -786,7 +794,7 @@ impl Target {
786794 }
787795 FloatAbi :: Hard => {
788796 // Must have `fpregs` and must not have `soft-float`.
789- ( & [ "fpregs" ] , & [ "soft-float" ] )
797+ FeatureConstraints { required : & [ "fpregs" ] , incompatible : & [ "soft-float" ] }
790798 }
791799 }
792800 }
@@ -803,7 +811,7 @@ impl Target {
803811 _ => {
804812 // Everything else is assumed to use a hardfloat ABI. neon and fp-armv8 must be enabled.
805813 // These are Rust feature names and we use "neon" to control both of them.
806- ( & [ "neon" ] , & [ ] )
814+ FeatureConstraints { required : & [ "neon" ] , incompatible : & [ ] }
807815 }
808816 }
809817 }
@@ -813,15 +821,15 @@ impl Target {
813821 match & * self . llvm_abiname {
814822 "ilp32d" | "lp64d" => {
815823 // Requires d (which implies f), incompatible with e.
816- ( & [ "d" ] , & [ "e" ] )
824+ FeatureConstraints { required : & [ "d" ] , incompatible : & [ "e" ] }
817825 }
818826 "ilp32f" | "lp64f" => {
819827 // Requires f, incompatible with e.
820- ( & [ "f" ] , & [ "e" ] )
828+ FeatureConstraints { required : & [ "f" ] , incompatible : & [ "e" ] }
821829 }
822830 "ilp32" | "lp64" => {
823831 // Requires nothing, incompatible with e.
824- ( & [ ] , & [ "e" ] )
832+ FeatureConstraints { required : & [ ] , incompatible : & [ "e" ] }
825833 }
826834 "ilp32e" => {
827835 // ilp32e is documented to be incompatible with features that need aligned
@@ -832,7 +840,7 @@ impl Target {
832840 // Note that the `e` feature is not required: the ABI treats the extra
833841 // registers as caller-save, so it is safe to use them only in some parts of
834842 // a program while the rest doesn't know they even exist.
835- ( & [ ] , & [ "d" ] )
843+ FeatureConstraints { required : & [ ] , incompatible : & [ "d" ] }
836844 }
837845 "lp64e" => {
838846 // As above, `e` is not required.
0 commit comments