@@ -103,7 +103,9 @@ use rustc_codegen_ssa::back::write::{
103103} ;
104104use rustc_codegen_ssa:: base:: codegen_crate;
105105use rustc_codegen_ssa:: traits:: { CodegenBackend , ExtraBackendMethods , WriteBackendMethods } ;
106- use rustc_codegen_ssa:: { CodegenResults , CompiledModule , ModuleCodegen , TargetConfig } ;
106+ use rustc_codegen_ssa:: {
107+ CodegenResults , CompiledModule , ModuleCodegen , TargetConfig , target_features,
108+ } ;
107109use rustc_data_structures:: fx:: FxIndexMap ;
108110use rustc_data_structures:: sync:: IntoDynSyncSend ;
109111use rustc_errors:: DiagCtxtHandle ;
@@ -476,42 +478,25 @@ fn to_gcc_opt_level(optlevel: Option<OptLevel>) -> OptimizationLevel {
476478
477479/// Returns the features that should be set in `cfg(target_feature)`.
478480fn target_config ( sess : & Session , target_info : & LockedTargetInfo ) -> TargetConfig {
479- // TODO(antoyo): use global_gcc_features.
480- let f = |allow_unstable| {
481- sess. target
482- . rust_target_features ( )
483- . iter ( )
484- . filter_map ( |& ( feature, gate, _) | {
485- if allow_unstable
486- || ( gate. in_cfg ( )
487- && ( sess. is_nightly_build ( ) || gate. requires_nightly ( ) . is_none ( ) ) )
488- {
489- Some ( feature)
490- } else {
491- None
492- }
493- } )
494- . filter ( |feature| {
495- // TODO: we disable Neon for now since we don't support the LLVM intrinsics for it.
496- if * feature == "neon" {
497- return false ;
498- }
499- target_info. cpu_supports ( feature)
500- // cSpell:disable
501- /*
502- adx, aes, avx, avx2, avx512bf16, avx512bitalg, avx512bw, avx512cd, avx512dq, avx512er, avx512f, avx512fp16, avx512ifma,
503- avx512pf, avx512vbmi, avx512vbmi2, avx512vl, avx512vnni, avx512vp2intersect, avx512vpopcntdq,
504- bmi1, bmi2, cmpxchg16b, ermsb, f16c, fma, fxsr, gfni, lzcnt, movbe, pclmulqdq, popcnt, rdrand, rdseed, rtm,
505- sha, sse, sse2, sse3, sse4.1, sse4.2, sse4a, ssse3, tbm, vaes, vpclmulqdq, xsave, xsavec, xsaveopt, xsaves
506- */
507- // cSpell:enable
508- } )
509- . map ( Symbol :: intern)
510- . collect ( )
511- } ;
512-
513- let target_features = f ( false ) ;
514- let unstable_target_features = f ( true ) ;
481+ let ( unstable_target_features, target_features) = target_features:: cfg_target_feature (
482+ sess,
483+ /* FIXME: we ignore `-Ctarget-feature` */ "" ,
484+ |feature| {
485+ // TODO: we disable Neon for now since we don't support the LLVM intrinsics for it.
486+ if feature == "neon" {
487+ return false ;
488+ }
489+ target_info. cpu_supports ( feature)
490+ // cSpell:disable
491+ /*
492+ adx, aes, avx, avx2, avx512bf16, avx512bitalg, avx512bw, avx512cd, avx512dq, avx512er, avx512f, avx512fp16, avx512ifma,
493+ avx512pf, avx512vbmi, avx512vbmi2, avx512vl, avx512vnni, avx512vp2intersect, avx512vpopcntdq,
494+ bmi1, bmi2, cmpxchg16b, ermsb, f16c, fma, fxsr, gfni, lzcnt, movbe, pclmulqdq, popcnt, rdrand, rdseed, rtm,
495+ sha, sse, sse2, sse3, sse4.1, sse4.2, sse4a, ssse3, tbm, vaes, vpclmulqdq, xsave, xsavec, xsaveopt, xsaves
496+ */
497+ // cSpell:enable
498+ } ,
499+ ) ;
515500
516501 let has_reliable_f16 = target_info. supports_target_dependent_type ( CType :: Float16 ) ;
517502 let has_reliable_f128 = target_info. supports_target_dependent_type ( CType :: Float128 ) ;
0 commit comments