@@ -590,9 +590,69 @@ const RISCV_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[
590
590
// tidy-alphabetical-start
591
591
( "a" , STABLE , & [ "zaamo" , "zalrsc" ] ) ,
592
592
( "c" , STABLE , & [ ] ) ,
593
- ( "d" , unstable ( sym:: riscv_target_feature) , & [ "f" ] ) ,
594
- ( "e" , unstable ( sym:: riscv_target_feature) , & [ ] ) ,
595
- ( "f" , unstable ( sym:: riscv_target_feature) , & [ ] ) ,
593
+ (
594
+ "d" ,
595
+ Stability :: Unstable {
596
+ nightly_feature : sym:: riscv_target_feature,
597
+ allow_toggle : |target, enable| match & * target. llvm_abiname {
598
+ "ilp32d" | "lp64d" if !enable => {
599
+ // The ABI requires the `d` feature, so it cannot be disabled.
600
+ Err ( "feature is required by ABI" )
601
+ }
602
+ "ilp32e" if enable => {
603
+ // The `d` feature apparently is incompatible with this ABI.
604
+ Err ( "feature is incompatible with ABI" )
605
+ }
606
+ _ => Ok ( ( ) ) ,
607
+ } ,
608
+ } ,
609
+ & [ "f" ] ,
610
+ ) ,
611
+ (
612
+ "e" ,
613
+ Stability :: Unstable {
614
+ nightly_feature : sym:: riscv_target_feature,
615
+ allow_toggle : |target, enable| {
616
+ match & * target. llvm_abiname {
617
+ _ if !enable => {
618
+ // This is a negative feature, *disabling* it is always okay.
619
+ Ok ( ( ) )
620
+ }
621
+ "ilp32e" | "lp64e" => {
622
+ // Embedded ABIs should already have the feature anyway, it's fine to enable
623
+ // it again.
624
+ Ok ( ( ) )
625
+ }
626
+ _ => {
627
+ // *Not* an embedded ABI. Enabling `e` is invalid.
628
+ Err ( "feature is required by ABI" )
629
+ }
630
+ }
631
+ } ,
632
+ } ,
633
+ & [ ] ,
634
+ ) ,
635
+ (
636
+ "f" ,
637
+ Stability :: Unstable {
638
+ nightly_feature : sym:: riscv_target_feature,
639
+ allow_toggle : |target, enable| {
640
+ match & * target. llvm_abiname {
641
+ "ilp32f" | "ilp32d" | "lp64f" | "lp64d" if !enable => {
642
+ // The ABI requires the `f` feature, so it cannot be disabled.
643
+ Err ( "feature is required by ABI" )
644
+ }
645
+ _ => Ok ( ( ) ) ,
646
+ }
647
+ } ,
648
+ } ,
649
+ & [ ] ,
650
+ ) ,
651
+ (
652
+ "forced-atomics" ,
653
+ Stability :: Forbidden { reason : "unsound because it changes the ABI of atomic operations" } ,
654
+ & [ ] ,
655
+ ) ,
596
656
( "m" , STABLE , & [ ] ) ,
597
657
( "relax" , unstable ( sym:: riscv_target_feature) , & [ ] ) ,
598
658
( "unaligned-scalar-mem" , unstable ( sym:: riscv_target_feature) , & [ ] ) ,
0 commit comments