Skip to content

Commit 6deb612

Browse files
heiheryetist
authored andcommitted
compiler: Add target features for LoongArch
1 parent ad56f6c commit 6deb612

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

compiler/rustc_codegen_ssa/src/target_features.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,19 @@ const WASM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
293293

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

296+
297+
const LOONGARCH_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
298+
// tidy-alphabetical-start
299+
("d", Some(sym::loongarch_target_feature)),
300+
("f", Some(sym::loongarch_target_feature)),
301+
("lasx", Some(sym::loongarch_target_feature)),
302+
("lbt", Some(sym::loongarch_target_feature)),
303+
("lsx", Some(sym::loongarch_target_feature)),
304+
("lvz", Some(sym::loongarch_target_feature)),
305+
("ual", Some(sym::loongarch_target_feature)),
306+
// tidy-alphabetical-end
307+
];
308+
296309
/// When rustdoc is running, provide a list of all known features so that all their respective
297310
/// primitives may be documented.
298311
///
@@ -308,6 +321,7 @@ pub fn all_known_features() -> impl Iterator<Item = (&'static str, Option<Symbol
308321
.chain(RISCV_ALLOWED_FEATURES.iter())
309322
.chain(WASM_ALLOWED_FEATURES.iter())
310323
.chain(BPF_ALLOWED_FEATURES.iter())
324+
.chain(LOONGARCH_ALLOWED_FEATURES)
311325
.cloned()
312326
}
313327

@@ -322,6 +336,7 @@ pub fn supported_target_features(sess: &Session) -> &'static [(&'static str, Opt
322336
"riscv32" | "riscv64" => RISCV_ALLOWED_FEATURES,
323337
"wasm32" | "wasm64" => WASM_ALLOWED_FEATURES,
324338
"bpf" => BPF_ALLOWED_FEATURES,
339+
"loongarch64" => LOONGARCH_ALLOWED_FEATURES,
325340
_ => &[],
326341
}
327342
}
@@ -399,6 +414,7 @@ pub fn from_target_feature(
399414
Some(sym::ermsb_target_feature) => rust_features.ermsb_target_feature,
400415
Some(sym::bpf_target_feature) => rust_features.bpf_target_feature,
401416
Some(sym::aarch64_ver_target_feature) => rust_features.aarch64_ver_target_feature,
417+
Some(sym::loongarch_target_feature) => rust_features.loongarch_target_feature,
402418
Some(name) => bug!("unknown target feature gate {}", name),
403419
None => true,
404420
};

compiler/rustc_feature/src/active.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ declare_features! (
255255
(active, cmpxchg16b_target_feature, "1.32.0", Some(44839), None),
256256
(active, ermsb_target_feature, "1.49.0", Some(44839), None),
257257
(active, hexagon_target_feature, "1.27.0", Some(44839), None),
258+
(active, loongarch_target_feature, "1.73.0", Some(44839), None),
258259
(active, mips_target_feature, "1.27.0", Some(44839), None),
259260
(active, movbe_target_feature, "1.34.0", Some(44839), None),
260261
(active, powerpc_target_feature, "1.27.0", Some(44839), None),

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@ symbols! {
879879
log_syntax,
880880
logf32,
881881
logf64,
882+
loongarch_target_feature,
882883
loop_break_value,
883884
lt,
884885
macro_at_most_once_rep,

0 commit comments

Comments
 (0)