Skip to content

Commit 46f2f02

Browse files
committed
Move supported_target_features query provider to cg_ssa
1 parent 53a4c3b commit 46f2f02

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_codegen_ssa::traits::*;
66
use rustc_data_structures::const_cstr;
77
use rustc_data_structures::fx::FxHashMap;
88
use rustc_data_structures::small_c_str::SmallCStr;
9-
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
9+
use rustc_hir::def_id::DefId;
1010
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1111
use rustc_middle::ty::layout::HasTyCtxt;
1212
use rustc_middle::ty::query::Providers;
@@ -352,23 +352,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
352352
}
353353
}
354354

355-
pub fn provide(providers: &mut Providers) {
356-
use rustc_codegen_ssa::target_features::{all_known_features, supported_target_features};
357-
providers.supported_target_features = |tcx, cnum| {
358-
assert_eq!(cnum, LOCAL_CRATE);
359-
if tcx.sess.opts.actually_rustdoc {
360-
// rustdoc needs to be able to document functions that use all the features, so
361-
// provide them all.
362-
all_known_features().map(|(a, b)| (a.to_string(), b)).collect()
363-
} else {
364-
supported_target_features(tcx.sess).iter().map(|&(a, b)| (a.to_string(), b)).collect()
365-
}
366-
};
367-
368-
provide_extern(providers);
369-
}
370-
371-
pub fn provide_extern(providers: &mut Providers) {
355+
pub fn provide_both(providers: &mut Providers) {
372356
providers.wasm_import_module_map = |tcx, cnum| {
373357
// Build up a map from DefId to a `NativeLib` structure, where
374358
// `NativeLib` internally contains information about

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,11 @@ impl CodegenBackend for LlvmCodegenBackend {
249249
}
250250

251251
fn provide(&self, providers: &mut ty::query::Providers) {
252-
attributes::provide(providers);
252+
attributes::provide_both(providers);
253253
}
254254

255255
fn provide_extern(&self, providers: &mut ty::query::Providers) {
256-
attributes::provide_extern(providers);
256+
attributes::provide_both(providers);
257257
}
258258

259259
fn codegen_crate<'tcx>(

compiler/rustc_codegen_ssa/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ pub struct CodegenResults {
144144
pub fn provide(providers: &mut Providers) {
145145
crate::back::symbol_export::provide(providers);
146146
crate::base::provide_both(providers);
147+
crate::target_features::provide(providers);
147148
}
148149

149150
pub fn provide_extern(providers: &mut Providers) {

compiler/rustc_codegen_ssa/src/target_features.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use rustc_hir::def_id::LOCAL_CRATE;
2+
use rustc_middle::ty::query::Providers;
13
use rustc_session::Session;
24
use rustc_span::symbol::sym;
35
use rustc_span::symbol::Symbol;
@@ -148,3 +150,16 @@ pub fn supported_target_features(sess: &Session) -> &'static [(&'static str, Opt
148150
_ => &[],
149151
}
150152
}
153+
154+
pub(crate) fn provide(providers: &mut Providers) {
155+
providers.supported_target_features = |tcx, cnum| {
156+
assert_eq!(cnum, LOCAL_CRATE);
157+
if tcx.sess.opts.actually_rustdoc {
158+
// rustdoc needs to be able to document functions that use all the features, so
159+
// whitelist them all
160+
all_known_features().map(|(a, b)| (a.to_string(), b)).collect()
161+
} else {
162+
supported_target_features(tcx.sess).iter().map(|&(a, b)| (a.to_string(), b)).collect()
163+
}
164+
};
165+
}

0 commit comments

Comments
 (0)