pub fn cfg_target_feature<'a, const N: usize>(
sess: &Session,
to_backend_features: impl Fn(&'a str) -> SmallVec<[&'a str; N]>,
target_base_has_feature: impl FnMut(&str) -> bool,
) -> (Vec<Symbol>, Vec<Symbol>)Expand description
Utility function for a codegen backend to compute cfg(target_feature), or more specifically,
to populate sess.unstable_target_features and sess.target_features (these are the first and
2nd component of the return value, respectively).
to_backend_features converts a Rust feature name into a list of backend feature names; this is
used for diagnostic purposes only.
target_base_has_feature should check whether the given feature (a Rust feature name!) is
enabled in the “base” target machine, i.e., without applying -Ctarget-feature. Note that LLVM
may consider features to be implied that we do not and vice-versa. We want cfg to be entirely
consistent with Rust feature implications, and thus only consult LLVM to expand the target CPU
to target features.
We do not have to worry about RUSTC_SPECIFIC_FEATURES here, those are handled elsewhere.