Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 89fc2e0

Browse files
committedOct 20, 2023
Auto merge of rust-lang#116943 - heiher:target-features, r=wesleywiser
Add target features for LoongArch
2 parents 7849162 + 1df855e commit 89fc2e0

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed
 

‎compiler/rustc_codegen_ssa/src/target_features.rs

+16
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,19 @@ const CSKY_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
342342
("hard-float-abi", Some(sym::csky_target_feature)),
343343
// tidy-alphabetical-end
344344
];
345+
346+
const LOONGARCH_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
347+
// tidy-alphabetical-start
348+
("d", Some(sym::loongarch_target_feature)),
349+
("f", Some(sym::loongarch_target_feature)),
350+
("lasx", Some(sym::loongarch_target_feature)),
351+
("lbt", Some(sym::loongarch_target_feature)),
352+
("lsx", Some(sym::loongarch_target_feature)),
353+
("lvz", Some(sym::loongarch_target_feature)),
354+
("ual", Some(sym::loongarch_target_feature)),
355+
// tidy-alphabetical-end
356+
];
357+
345358
/// When rustdoc is running, provide a list of all known features so that all their respective
346359
/// primitives may be documented.
347360
///
@@ -358,6 +371,7 @@ pub fn all_known_features() -> impl Iterator<Item = (&'static str, Option<Symbol
358371
.chain(WASM_ALLOWED_FEATURES.iter())
359372
.chain(BPF_ALLOWED_FEATURES.iter())
360373
.chain(CSKY_ALLOWED_FEATURES)
374+
.chain(LOONGARCH_ALLOWED_FEATURES)
361375
.cloned()
362376
}
363377

@@ -373,6 +387,7 @@ pub fn supported_target_features(sess: &Session) -> &'static [(&'static str, Opt
373387
"wasm32" | "wasm64" => WASM_ALLOWED_FEATURES,
374388
"bpf" => BPF_ALLOWED_FEATURES,
375389
"csky" => CSKY_ALLOWED_FEATURES,
390+
"loongarch64" => LOONGARCH_ALLOWED_FEATURES,
376391
_ => &[],
377392
}
378393
}
@@ -445,6 +460,7 @@ pub fn from_target_feature(
445460
Some(sym::bpf_target_feature) => rust_features.bpf_target_feature,
446461
Some(sym::aarch64_ver_target_feature) => rust_features.aarch64_ver_target_feature,
447462
Some(sym::csky_target_feature) => rust_features.csky_target_feature,
463+
Some(sym::loongarch_target_feature) => rust_features.loongarch_target_feature,
448464
Some(name) => bug!("unknown target feature gate {}", name),
449465
None => true,
450466
};

‎compiler/rustc_feature/src/unstable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ declare_features! (
288288
(unstable, csky_target_feature, "1.73.0", Some(44839), None),
289289
(unstable, ermsb_target_feature, "1.49.0", Some(44839), None),
290290
(unstable, hexagon_target_feature, "1.27.0", Some(44839), None),
291+
(unstable, loongarch_target_feature, "1.73.0", Some(44839), None),
291292
(unstable, mips_target_feature, "1.27.0", Some(44839), None),
292293
(unstable, powerpc_target_feature, "1.27.0", Some(44839), None),
293294
(unstable, riscv_target_feature, "1.45.0", Some(44839), None),

‎compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ symbols! {
955955
log_syntax,
956956
logf32,
957957
logf64,
958+
loongarch_target_feature,
958959
loop_break_value,
959960
lt,
960961
macro_at_most_once_rep,

‎tests/ui/target-feature/gate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// gate-test-bpf_target_feature
1919
// gate-test-aarch64_ver_target_feature
2020
// gate-test-csky_target_feature
21+
// gate-test-loongarch_target_feature
2122

2223
#[target_feature(enable = "avx512bw")]
2324
//~^ ERROR: currently unstable

‎tests/ui/target-feature/gate.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: the target feature `avx512bw` is currently unstable
2-
--> $DIR/gate.rs:22:18
2+
--> $DIR/gate.rs:23:18
33
|
44
LL | #[target_feature(enable = "avx512bw")]
55
| ^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)
Please sign in to comment.