@@ -6,6 +6,7 @@ use std::{ptr, slice, str};
66
77use libc:: c_int;
88use rustc_codegen_ssa:: base:: wants_wasm_eh;
9+ use rustc_codegen_ssa:: codegen_attrs:: check_tied_features;
910use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
1011use rustc_data_structures:: small_c_str:: SmallCStr ;
1112use rustc_data_structures:: unord:: UnordSet ;
@@ -19,8 +20,8 @@ use rustc_target::target_features::{RUSTC_SPECIAL_FEATURES, RUSTC_SPECIFIC_FEATU
1920
2021use crate :: back:: write:: create_informational_target_machine;
2122use crate :: errors:: {
22- FixedX18InvalidArch , InvalidTargetFeaturePrefix , PossibleFeature , TargetFeatureDisableOrEnable ,
23- UnknownCTargetFeature , UnknownCTargetFeaturePrefix , UnstableCTargetFeature ,
23+ FixedX18InvalidArch , InvalidTargetFeaturePrefix , PossibleFeature , UnknownCTargetFeature ,
24+ UnknownCTargetFeaturePrefix , UnstableCTargetFeature ,
2425} ;
2526use crate :: llvm;
2627
@@ -247,7 +248,9 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
247248 ( "aarch64" , "pmuv3" ) => Some ( LLVMFeature :: new ( "perfmon" ) ) ,
248249 ( "aarch64" , "paca" ) => Some ( LLVMFeature :: new ( "pauth" ) ) ,
249250 ( "aarch64" , "pacg" ) => Some ( LLVMFeature :: new ( "pauth" ) ) ,
250- ( "aarch64" , "sve-b16b16" ) => Some ( LLVMFeature :: new ( "b16b16" ) ) ,
251+ // Before LLVM 20 those two features were packaged together as b16b16
252+ ( "aarch64" , "sve-b16b16" ) if get_version ( ) . 0 < 20 => Some ( LLVMFeature :: new ( "b16b16" ) ) ,
253+ ( "aarch64" , "sme-b16b16" ) if get_version ( ) . 0 < 20 => Some ( LLVMFeature :: new ( "b16b16" ) ) ,
251254 ( "aarch64" , "flagm2" ) => Some ( LLVMFeature :: new ( "altnzcv" ) ) ,
252255 // Rust ties fp and neon together.
253256 ( "aarch64" , "neon" ) => {
@@ -276,25 +279,6 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
276279 }
277280}
278281
279- /// Given a map from target_features to whether they are enabled or disabled,
280- /// ensure only valid combinations are allowed.
281- pub ( crate ) fn check_tied_features (
282- sess : & Session ,
283- features : & FxHashMap < & str , bool > ,
284- ) -> Option < & ' static [ & ' static str ] > {
285- if !features. is_empty ( ) {
286- for tied in sess. target . tied_target_features ( ) {
287- // Tied features must be set to the same value, or not set at all
288- let mut tied_iter = tied. iter ( ) ;
289- let enabled = features. get ( tied_iter. next ( ) . unwrap ( ) ) ;
290- if tied_iter. any ( |f| enabled != features. get ( f) ) {
291- return Some ( tied) ;
292- }
293- }
294- }
295- None
296- }
297-
298282/// Used to generate cfg variables and apply features
299283/// Must express features in the way Rust understands them
300284pub fn target_features ( sess : & Session , allow_unstable : bool ) -> Vec < Symbol > {
@@ -685,7 +669,7 @@ pub(crate) fn global_llvm_features(
685669 features. extend ( feats) ;
686670
687671 if diagnostics && let Some ( f) = check_tied_features ( sess, & featsmap) {
688- sess. dcx ( ) . emit_err ( TargetFeatureDisableOrEnable {
672+ sess. dcx ( ) . emit_err ( rustc_codegen_ssa :: errors :: TargetFeatureDisableOrEnable {
689673 features : f,
690674 span : None ,
691675 missing_features : None ,
0 commit comments