@@ -32,6 +32,8 @@ pub enum Stability<AllowToggle> {
3232 /// This target feature is unstable. It is only present in `#[cfg(target_feature)]` on
3333 /// nightly and using it in `#[target_feature]` requires enabling the given nightly feature.
3434 Unstable {
35+ /// This must be a *language* feature, or else rustc will ICE when reporting a missing
36+ /// feature gate!
3537 nightly_feature : Symbol ,
3638 /// See `Stable::allow_toggle` comment above.
3739 allow_toggle : AllowToggle ,
@@ -168,6 +170,22 @@ const ARM_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[
168170 ( "dotprod" , unstable ( sym:: arm_target_feature) , & [ "neon" ] ) ,
169171 ( "dsp" , unstable ( sym:: arm_target_feature) , & [ ] ) ,
170172 ( "fp-armv8" , unstable ( sym:: arm_target_feature) , & [ "vfp4" ] ) ,
173+ (
174+ "fpregs" ,
175+ Stability :: Unstable {
176+ nightly_feature : sym:: arm_target_feature,
177+ allow_toggle : |target : & Target | {
178+ // Only allow toggling this if the target has `soft-float` set. With `soft-float`,
179+ // `fpregs` isn't needed so changing it cannot affect the ABI.
180+ if target. has_feature ( "soft-float" ) {
181+ Ok ( ( ) )
182+ } else {
183+ Err ( "unsound on hard-float targets because it changes float ABI" )
184+ }
185+ } ,
186+ } ,
187+ & [ ] ,
188+ ) ,
171189 ( "i8mm" , unstable ( sym:: arm_target_feature) , & [ "neon" ] ) ,
172190 ( "mclass" , unstable ( sym:: arm_target_feature) , & [ ] ) ,
173191 ( "neon" , unstable ( sym:: arm_target_feature) , & [ "vfp3" ] ) ,
@@ -191,7 +209,6 @@ const ARM_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[
191209 ( "vfp4" , unstable ( sym:: arm_target_feature) , & [ "vfp3" ] ) ,
192210 ( "virtualization" , unstable ( sym:: arm_target_feature) , & [ ] ) ,
193211 // tidy-alphabetical-end
194- // FIXME: need to also forbid turning off `fpregs` on hardfloat targets
195212] ;
196213
197214const AARCH64_FEATURES : & [ ( & str , StabilityUncomputed , ImpliedFeatures ) ] = & [
@@ -450,13 +467,28 @@ const X86_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[
450467 ( "tbm" , unstable ( sym:: tbm_target_feature) , & [ ] ) ,
451468 ( "vaes" , unstable ( sym:: avx512_target_feature) , & [ "avx2" , "aes" ] ) ,
452469 ( "vpclmulqdq" , unstable ( sym:: avx512_target_feature) , & [ "avx" , "pclmulqdq" ] ) ,
470+ (
471+ "x87" ,
472+ Stability :: Unstable {
473+ nightly_feature : sym:: x87_target_feature,
474+ allow_toggle : |target : & Target | {
475+ // Only allow toggling this if the target has `soft-float` set. With `soft-float`,
476+ // `fpregs` isn't needed so changing it cannot affect the ABI.
477+ if target. has_feature ( "soft-float" ) {
478+ Ok ( ( ) )
479+ } else {
480+ Err ( "unsound on hard-float targets because it changes float ABI" )
481+ }
482+ } ,
483+ } ,
484+ & [ ] ,
485+ ) ,
453486 ( "xop" , unstable ( sym:: xop_target_feature) , & [ /*"fma4", */ "avx" , "sse4a" ] ) ,
454487 ( "xsave" , STABLE , & [ ] ) ,
455488 ( "xsavec" , STABLE , & [ "xsave" ] ) ,
456489 ( "xsaveopt" , STABLE , & [ "xsave" ] ) ,
457490 ( "xsaves" , STABLE , & [ "xsave" ] ) ,
458491 // tidy-alphabetical-end
459- // FIXME: need to also forbid turning off `x87` on hardfloat targets
460492] ;
461493
462494const HEXAGON_FEATURES : & [ ( & str , StabilityUncomputed , ImpliedFeatures ) ] = & [
0 commit comments