Skip to content

Commit daeccc4

Browse files
heiherAmanieu
authored andcommitted
std_detect: Add target features for LoongArch v1.1
1 parent 6bc700f commit daeccc4

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

crates/std_detect/src/detect/arch/loongarch.rs

+15
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ features! {
1111
/// * `"f"`
1212
/// * `"d"`
1313
/// * `"frecipe"`
14+
/// * `"div32"`
1415
/// * `"lsx"`
1516
/// * `"lasx"`
17+
/// * `"lam-bh"`
18+
/// * `"lamcas"`
19+
/// * `"ld-seq-sa"`
20+
/// * `"scq"`
1621
/// * `"lbt"`
1722
/// * `"lvz"`
1823
/// * `"ual"`
@@ -23,10 +28,20 @@ features! {
2328
/// D
2429
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] frecipe: "frecipe";
2530
/// Frecipe
31+
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] div32: "div32";
32+
/// Div32
2633
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lsx: "lsx";
2734
/// LSX
2835
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lasx: "lasx";
2936
/// LASX
37+
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lam_bh: "lam-bh";
38+
/// LAM-BH
39+
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lamcas: "lamcas";
40+
/// LAM-CAS
41+
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] ld_seq_sa: "ld-seq-sa";
42+
/// LD-SEQ-SA
43+
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] scq: "scq";
44+
/// SCQ
3045
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lbt: "lbt";
3146
/// LBT
3247
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lvz: "lvz";

crates/std_detect/src/detect/os/linux/loongarch.rs

+13
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,20 @@ pub(crate) fn detect_features() -> cache::Initializer {
2424
options(pure, nomem, preserves_flags, nostack)
2525
);
2626
}
27+
let cpucfg3: usize;
28+
unsafe {
29+
asm!(
30+
"cpucfg {}, {}",
31+
out(reg) cpucfg3, in(reg) 3,
32+
options(pure, nomem, preserves_flags, nostack)
33+
);
34+
}
2735
enable_feature(&mut value, Feature::frecipe, bit::test(cpucfg2, 25));
36+
enable_feature(&mut value, Feature::div32, bit::test(cpucfg2, 26));
37+
enable_feature(&mut value, Feature::lam_bh, bit::test(cpucfg2, 27));
38+
enable_feature(&mut value, Feature::lamcas, bit::test(cpucfg2, 28));
39+
enable_feature(&mut value, Feature::scq, bit::test(cpucfg2, 30));
40+
enable_feature(&mut value, Feature::ld_seq_sa, bit::test(cpucfg3, 23));
2841

2942
// The values are part of the platform-specific [asm/hwcap.h][hwcap]
3043
//

0 commit comments

Comments
 (0)