Skip to content

Commit 25e11b1

Browse files
committed
rename known_target_features → rust_target_features
1 parent d77f450 commit 25e11b1

File tree

7 files changed

+54
-53
lines changed

7 files changed

+54
-53
lines changed

compiler/rustc_codegen_gcc/src/gcc_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
4444
);
4545

4646
// -Ctarget-features
47-
let known_features = sess.target.known_target_features();
47+
let known_features = sess.target.rust_target_features();
4848
let mut featsmap = FxHashMap::default();
4949
let feats = sess
5050
.opts

compiler/rustc_codegen_gcc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ pub fn target_features(
484484
) -> Vec<Symbol> {
485485
// TODO(antoyo): use global_gcc_features.
486486
sess.target
487-
.known_target_features()
487+
.rust_target_features()
488488
.iter()
489489
.filter_map(|&(feature, gate, _)| {
490490
if sess.is_nightly_build() || allow_unstable || gate.is_stable() {

compiler/rustc_codegen_llvm/src/llvm_util.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
309309
// Compute which of the known target features are enabled in the 'base' target machine.
310310
features.extend(
311311
sess.target
312-
.known_target_features()
312+
.rust_target_features()
313313
.iter()
314314
.filter(|(feature, _, _)| {
315315
// skip checking special features, as LLVM may not understands them
@@ -356,7 +356,7 @@ pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
356356

357357
// Filter enabled features based on feature gates
358358
sess.target
359-
.known_target_features()
359+
.rust_target_features()
360360
.iter()
361361
.filter_map(|&(feature, gate, _)| {
362362
if sess.is_nightly_build() || allow_unstable || gate.is_stable() {
@@ -419,7 +419,7 @@ fn print_target_features(out: &mut String, sess: &Session, tm: &llvm::TargetMach
419419
let mut known_llvm_target_features = FxHashSet::<&'static str>::default();
420420
let mut rustc_target_features = sess
421421
.target
422-
.known_target_features()
422+
.rust_target_features()
423423
.iter()
424424
.filter_map(|(feature, gate, _implied)| {
425425
if matches!(gate, Stability::Forbidden) {
@@ -592,7 +592,7 @@ pub(crate) fn global_llvm_features(
592592

593593
// -Ctarget-features
594594
if !only_base_features {
595-
let known_features = sess.target.known_target_features();
595+
let known_features = sess.target.rust_target_features();
596596
let (llvm_major, _, _) = get_version();
597597
let mut featsmap = FxHashMap::default();
598598

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
7272
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_BUILTINS;
7373
}
7474

75-
let known_target_features = tcx.known_target_features(LOCAL_CRATE);
75+
let rust_target_features = tcx.rust_target_features(LOCAL_CRATE);
7676

7777
let mut inline_span = None;
7878
let mut link_ordinal_span = None;
@@ -301,7 +301,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
301301
from_target_feature_attr(
302302
tcx,
303303
attr,
304-
known_target_features,
304+
rust_target_features,
305305
&mut codegen_fn_attrs.target_features,
306306
);
307307
}

compiler/rustc_codegen_ssa/src/target_features.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::errors;
2121
pub fn from_target_feature_attr(
2222
tcx: TyCtxt<'_>,
2323
attr: &ast::Attribute,
24-
known_target_features: &UnordMap<String, target_features::Stability>,
24+
rust_target_features: &UnordMap<String, target_features::Stability>,
2525
target_features: &mut Vec<TargetFeature>,
2626
) {
2727
let Some(list) = attr.meta_item_list() else { return };
@@ -50,12 +50,12 @@ pub fn from_target_feature_attr(
5050

5151
// We allow comma separation to enable multiple features.
5252
added_target_features.extend(value.as_str().split(',').filter_map(|feature| {
53-
let Some(stability) = known_target_features.get(feature) else {
53+
let Some(stability) = rust_target_features.get(feature) else {
5454
let msg = format!("the feature named `{feature}` is not valid for this target");
5555
let mut err = tcx.dcx().struct_span_err(item.span(), msg);
5656
err.span_label(item.span(), format!("`{feature}` is not valid for this target"));
5757
if let Some(stripped) = feature.strip_prefix('+') {
58-
let valid = known_target_features.contains_key(stripped);
58+
let valid = rust_target_features.contains_key(stripped);
5959
if valid {
6060
err.help("consider removing the leading `+` in the feature name");
6161
}
@@ -197,7 +197,7 @@ pub fn check_target_feature_trait_unsafe(tcx: TyCtxt<'_>, id: LocalDefId, attr_s
197197

198198
pub(crate) fn provide(providers: &mut Providers) {
199199
*providers = Providers {
200-
known_target_features: |tcx, cnum| {
200+
rust_target_features: |tcx, cnum| {
201201
assert_eq!(cnum, LOCAL_CRATE);
202202
if tcx.sess.opts.actually_rustdoc {
203203
// rustdoc needs to be able to document functions that use all the features, so
@@ -208,7 +208,7 @@ pub(crate) fn provide(providers: &mut Providers) {
208208
} else {
209209
tcx.sess
210210
.target
211-
.known_target_features()
211+
.rust_target_features()
212212
.iter()
213213
.map(|&(a, b, _)| (a.to_string(), b))
214214
.collect()

compiler/rustc_middle/src/query/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2160,10 +2160,11 @@ rustc_queries! {
21602160
desc { "computing autoderef types for `{}`", goal.value.value }
21612161
}
21622162

2163-
query known_target_features(_: CrateNum) -> &'tcx UnordMap<String, rustc_target::target_features::Stability> {
2163+
/// Returns the Rust target features for the current target. These are not always the same as LLVM target features!
2164+
query rust_target_features(_: CrateNum) -> &'tcx UnordMap<String, rustc_target::target_features::Stability> {
21642165
arena_cache
21652166
eval_always
2166-
desc { "looking up known target features" }
2167+
desc { "looking up Rust target features" }
21672168
}
21682169

21692170
query implied_target_features(feature: Symbol) -> &'tcx Vec<Symbol> {

compiler/rustc_target/src/target_features.rs

+38-38
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl Stability {
8383

8484
type ImpliedFeatures = &'static [&'static str];
8585

86-
const ARM_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
86+
const ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
8787
// tidy-alphabetical-start
8888
("aclass", Unstable(sym::arm_target_feature), &[]),
8989
("aes", Unstable(sym::arm_target_feature), &["neon"]),
@@ -116,7 +116,7 @@ const ARM_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
116116
// tidy-alphabetical-end
117117
];
118118

119-
const AARCH64_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
119+
const AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
120120
// tidy-alphabetical-start
121121
// FEAT_AES & FEAT_PMULL
122122
("aes", Stable, &["neon"]),
@@ -304,7 +304,7 @@ const AARCH64_TIED_FEATURES: &[&[&str]] = &[
304304
&["paca", "pacg"], // Together these represent `pauth` in LLVM
305305
];
306306

307-
const X86_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
307+
const X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
308308
// tidy-alphabetical-start
309309
("adx", Stable, &[]),
310310
("aes", Stable, &["sse2"]),
@@ -375,14 +375,14 @@ const X86_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
375375
// tidy-alphabetical-end
376376
];
377377

378-
const HEXAGON_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
378+
const HEXAGON_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
379379
// tidy-alphabetical-start
380380
("hvx", Unstable(sym::hexagon_target_feature), &[]),
381381
("hvx-length128b", Unstable(sym::hexagon_target_feature), &["hvx"]),
382382
// tidy-alphabetical-end
383383
];
384384

385-
const POWERPC_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
385+
const POWERPC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
386386
// tidy-alphabetical-start
387387
("altivec", Unstable(sym::powerpc_target_feature), &[]),
388388
("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
@@ -394,15 +394,15 @@ const POWERPC_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
394394
// tidy-alphabetical-end
395395
];
396396

397-
const MIPS_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
397+
const MIPS_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
398398
// tidy-alphabetical-start
399399
("fp64", Unstable(sym::mips_target_feature), &[]),
400400
("msa", Unstable(sym::mips_target_feature), &[]),
401401
("virt", Unstable(sym::mips_target_feature), &[]),
402402
// tidy-alphabetical-end
403403
];
404404

405-
const RISCV_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
405+
const RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
406406
// tidy-alphabetical-start
407407
("a", Stable, &[]),
408408
("c", Stable, &[]),
@@ -439,7 +439,7 @@ const RISCV_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
439439
// tidy-alphabetical-end
440440
];
441441

442-
const WASM_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
442+
const WASM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
443443
// tidy-alphabetical-start
444444
("atomics", Unstable(sym::wasm_target_feature), &[]),
445445
("bulk-memory", Stable, &[]),
@@ -455,10 +455,10 @@ const WASM_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
455455
// tidy-alphabetical-end
456456
];
457457

458-
const BPF_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] =
458+
const BPF_FEATURES: &[(&str, Stability, ImpliedFeatures)] =
459459
&[("alu32", Unstable(sym::bpf_target_feature), &[])];
460460

461-
const CSKY_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
461+
const CSKY_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
462462
// tidy-alphabetical-start
463463
("10e60", Unstable(sym::csky_target_feature), &["7e10"]),
464464
("2e3", Unstable(sym::csky_target_feature), &["e2"]),
@@ -505,7 +505,7 @@ const CSKY_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
505505
// tidy-alphabetical-end
506506
];
507507

508-
const LOONGARCH_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
508+
const LOONGARCH_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
509509
// tidy-alphabetical-start
510510
("d", Unstable(sym::loongarch_target_feature), &["f"]),
511511
("f", Unstable(sym::loongarch_target_feature), &[]),
@@ -519,7 +519,7 @@ const LOONGARCH_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
519519
// tidy-alphabetical-end
520520
];
521521

522-
const IBMZ_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
522+
const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
523523
// tidy-alphabetical-start
524524
("backchain", Unstable(sym::s390x_target_feature), &[]),
525525
("vector", Unstable(sym::s390x_target_feature), &[]),
@@ -532,37 +532,37 @@ const IBMZ_KNOWN_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
532532
/// IMPORTANT: If you're adding another feature list above, make sure to add it to this iterator!
533533
pub fn all_known_features() -> impl Iterator<Item = (&'static str, Stability)> {
534534
std::iter::empty()
535-
.chain(ARM_KNOWN_FEATURES.iter())
536-
.chain(AARCH64_KNOWN_FEATURES.iter())
537-
.chain(X86_KNOWN_FEATURES.iter())
538-
.chain(HEXAGON_KNOWN_FEATURES.iter())
539-
.chain(POWERPC_KNOWN_FEATURES.iter())
540-
.chain(MIPS_KNOWN_FEATURES.iter())
541-
.chain(RISCV_KNOWN_FEATURES.iter())
542-
.chain(WASM_KNOWN_FEATURES.iter())
543-
.chain(BPF_KNOWN_FEATURES.iter())
544-
.chain(CSKY_KNOWN_FEATURES)
545-
.chain(LOONGARCH_KNOWN_FEATURES)
546-
.chain(IBMZ_KNOWN_FEATURES)
535+
.chain(ARM_FEATURES.iter())
536+
.chain(AARCH64_FEATURES.iter())
537+
.chain(X86_FEATURES.iter())
538+
.chain(HEXAGON_FEATURES.iter())
539+
.chain(POWERPC_FEATURES.iter())
540+
.chain(MIPS_FEATURES.iter())
541+
.chain(RISCV_FEATURES.iter())
542+
.chain(WASM_FEATURES.iter())
543+
.chain(BPF_FEATURES.iter())
544+
.chain(CSKY_FEATURES)
545+
.chain(LOONGARCH_FEATURES)
546+
.chain(IBMZ_FEATURES)
547547
.cloned()
548548
.map(|(f, s, _)| (f, s))
549549
}
550550

551551
impl super::spec::Target {
552-
pub fn known_target_features(&self) -> &'static [(&'static str, Stability, ImpliedFeatures)] {
552+
pub fn rust_target_features(&self) -> &'static [(&'static str, Stability, ImpliedFeatures)] {
553553
match &*self.arch {
554-
"arm" => ARM_KNOWN_FEATURES,
555-
"aarch64" | "arm64ec" => AARCH64_KNOWN_FEATURES,
556-
"x86" | "x86_64" => X86_KNOWN_FEATURES,
557-
"hexagon" => HEXAGON_KNOWN_FEATURES,
558-
"mips" | "mips32r6" | "mips64" | "mips64r6" => MIPS_KNOWN_FEATURES,
559-
"powerpc" | "powerpc64" => POWERPC_KNOWN_FEATURES,
560-
"riscv32" | "riscv64" => RISCV_KNOWN_FEATURES,
561-
"wasm32" | "wasm64" => WASM_KNOWN_FEATURES,
562-
"bpf" => BPF_KNOWN_FEATURES,
563-
"csky" => CSKY_KNOWN_FEATURES,
564-
"loongarch64" => LOONGARCH_KNOWN_FEATURES,
565-
"s390x" => IBMZ_KNOWN_FEATURES,
554+
"arm" => ARM_FEATURES,
555+
"aarch64" | "arm64ec" => AARCH64_FEATURES,
556+
"x86" | "x86_64" => X86_FEATURES,
557+
"hexagon" => HEXAGON_FEATURES,
558+
"mips" | "mips32r6" | "mips64" | "mips64r6" => MIPS_FEATURES,
559+
"powerpc" | "powerpc64" => POWERPC_FEATURES,
560+
"riscv32" | "riscv64" => RISCV_FEATURES,
561+
"wasm32" | "wasm64" => WASM_FEATURES,
562+
"bpf" => BPF_FEATURES,
563+
"csky" => CSKY_FEATURES,
564+
"loongarch64" => LOONGARCH_FEATURES,
565+
"s390x" => IBMZ_FEATURES,
566566
_ => &[],
567567
}
568568
}
@@ -579,7 +579,7 @@ impl super::spec::Target {
579579
base_features: impl Iterator<Item = Symbol>,
580580
) -> FxHashSet<Symbol> {
581581
let implied_features = self
582-
.known_target_features()
582+
.rust_target_features()
583583
.iter()
584584
.map(|(f, _, i)| (Symbol::intern(f), i))
585585
.collect::<FxHashMap<_, _>>();

0 commit comments

Comments
 (0)