Skip to content

Commit 6c64c7c

Browse files
committed
compiler: Add target features for LoongArch
(cherry picked from commit cb61816)
1 parent 07863b2 commit 6c64c7c

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

compiler/rustc_codegen_ssa/src/target_features.rs

+15
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,18 @@ const WASM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
297297

298298
const BPF_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[("alu32", Some(sym::bpf_target_feature))];
299299

300+
const LOONGARCH_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
301+
// tidy-alphabetical-start
302+
("d", Some(sym::loongarch_target_feature)),
303+
("f", Some(sym::loongarch_target_feature)),
304+
("lasx", Some(sym::loongarch_target_feature)),
305+
("lbt", Some(sym::loongarch_target_feature)),
306+
("lsx", Some(sym::loongarch_target_feature)),
307+
("lvz", Some(sym::loongarch_target_feature)),
308+
("ual", Some(sym::loongarch_target_feature)),
309+
// tidy-alphabetical-end
310+
];
311+
300312
/// When rustdoc is running, provide a list of all known features so that all their respective
301313
/// primitives may be documented.
302314
///
@@ -312,6 +324,7 @@ pub fn all_known_features() -> impl Iterator<Item = (&'static str, Option<Symbol
312324
.chain(RISCV_ALLOWED_FEATURES.iter())
313325
.chain(WASM_ALLOWED_FEATURES.iter())
314326
.chain(BPF_ALLOWED_FEATURES.iter())
327+
.chain(LOONGARCH_ALLOWED_FEATURES)
315328
.cloned()
316329
}
317330

@@ -326,6 +339,7 @@ pub fn supported_target_features(sess: &Session) -> &'static [(&'static str, Opt
326339
"riscv32" | "riscv64" => RISCV_ALLOWED_FEATURES,
327340
"wasm32" | "wasm64" => WASM_ALLOWED_FEATURES,
328341
"bpf" => BPF_ALLOWED_FEATURES,
342+
"loongarch64" => LOONGARCH_ALLOWED_FEATURES,
329343
_ => &[],
330344
}
331345
}
@@ -401,6 +415,7 @@ pub fn from_target_feature(
401415
Some(sym::ermsb_target_feature) => rust_features.ermsb_target_feature,
402416
Some(sym::bpf_target_feature) => rust_features.bpf_target_feature,
403417
Some(sym::aarch64_ver_target_feature) => rust_features.aarch64_ver_target_feature,
418+
Some(sym::loongarch_target_feature) => rust_features.loongarch_target_feature,
404419
Some(name) => bug!("unknown target feature gate {}", name),
405420
None => true,
406421
};

compiler/rustc_feature/src/active.rs

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ declare_features! (
260260
(active, bpf_target_feature, "1.54.0", Some(44839), None),
261261
(active, ermsb_target_feature, "1.49.0", Some(44839), None),
262262
(active, hexagon_target_feature, "1.27.0", Some(44839), None),
263+
(active, loongarch_target_feature, "1.72.0", Some(44839), None),
263264
(active, mips_target_feature, "1.27.0", Some(44839), None),
264265
(active, powerpc_target_feature, "1.27.0", Some(44839), None),
265266
(active, riscv_target_feature, "1.45.0", Some(44839), None),

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,7 @@ symbols! {
906906
log_syntax,
907907
logf32,
908908
logf64,
909+
loongarch_target_feature,
909910
loop_break_value,
910911
lt,
911912
macro_at_most_once_rep,

0 commit comments

Comments
 (0)