1
Fork 0

Implement RFC 3525.

This commit is contained in:
Luca Versari 2024-06-24 17:17:18 +02:00 committed by Luca Versari
parent 748c54848d
commit 7eb4cfeace
25 changed files with 512 additions and 28 deletions

View file

@ -26,8 +26,8 @@ pub struct CodegenFnAttrs {
/// be set when `link_name` is set. This is for foreign items with the
/// "raw-dylib" kind.
pub link_ordinal: Option<u16>,
/// The `#[target_feature(enable = "...")]` attribute and the enabled
/// features (only enabled features are supported right now).
/// All the target features that are enabled for this function. Some features might be enabled
/// implicitly.
pub target_features: Vec<TargetFeature>,
/// The `#[linkage = "..."]` attribute on Rust-defined items and the value we found.
pub linkage: Option<Linkage>,
@ -55,8 +55,8 @@ pub struct CodegenFnAttrs {
pub struct TargetFeature {
/// The name of the target feature (e.g. "avx")
pub name: Symbol,
/// The feature is implied by another feature, rather than explicitly added by the
/// `#[target_feature]` attribute
/// The feature is implied by another feature or by an argument, rather than explicitly
/// added by the `#[target_feature]` attribute
pub implied: bool,
}

View file

@ -47,7 +47,7 @@ use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir};
use crate::infer::canonical::{self, Canonical};
use crate::lint::LintExpectation;
use crate::metadata::ModChild;
use crate::middle::codegen_fn_attrs::CodegenFnAttrs;
use crate::middle::codegen_fn_attrs::{CodegenFnAttrs, TargetFeature};
use crate::middle::debugger_visualizer::DebuggerVisualizerFile;
use crate::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo};
use crate::middle::lib_features::LibFeatures;
@ -1245,6 +1245,11 @@ rustc_queries! {
feedable
}
query struct_target_features(def_id: DefId) -> &'tcx [TargetFeature] {
separate_provide_extern
desc { |tcx| "computing target features for struct `{}`", tcx.def_path_str(def_id) }
}
query asm_target_features(def_id: DefId) -> &'tcx FxIndexSet<Symbol> {
desc { |tcx| "computing target features for inline asm of `{}`", tcx.def_path_str(def_id) }
}

View file

@ -59,6 +59,7 @@ trivially_parameterized_over_tcx! {
std::string::String,
crate::metadata::ModChild,
crate::middle::codegen_fn_attrs::CodegenFnAttrs,
crate::middle::codegen_fn_attrs::TargetFeature,
crate::middle::debugger_visualizer::DebuggerVisualizerFile,
crate::middle::exported_symbols::SymbolExportInfo,
crate::middle::lib_features::FeatureStability,