about summary refs log tree commit diff
path: root/library/stdarch/crates/std_detect
diff options
context:
space:
mode:
authorWANG Rui <wangrui@loongson.cn>2025-03-18 13:54:15 +0800
committerAmanieu d'Antras <amanieu@gmail.com>2025-03-20 22:26:36 +0000
commitad03413c3912548e2bf400d91e29bd974e7ecdd7 (patch)
tree99599e37664238cf642f16bc7e964c55e443fda2 /library/stdarch/crates/std_detect
parentc0fc23f2d894655ec747c5cde9f798f682903a1a (diff)
downloadrust-ad03413c3912548e2bf400d91e29bd974e7ecdd7.tar.gz
rust-ad03413c3912548e2bf400d91e29bd974e7ecdd7.zip
std_detect: Add target features for LoongArch v1.1
Diffstat (limited to 'library/stdarch/crates/std_detect')
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/loongarch.rs15
-rw-r--r--library/stdarch/crates/std_detect/src/detect/os/linux/loongarch.rs13
2 files changed, 28 insertions, 0 deletions
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/loongarch.rs b/library/stdarch/crates/std_detect/src/detect/arch/loongarch.rs
index c55f4ea272b..5405ff74cf6 100644
--- a/library/stdarch/crates/std_detect/src/detect/arch/loongarch.rs
+++ b/library/stdarch/crates/std_detect/src/detect/arch/loongarch.rs
@@ -11,8 +11,13 @@ features! {
     /// * `"f"`
     /// * `"d"`
     /// * `"frecipe"`
+    /// * `"div32"`
     /// * `"lsx"`
     /// * `"lasx"`
+    /// * `"lam-bh"`
+    /// * `"lamcas"`
+    /// * `"ld-seq-sa"`
+    /// * `"scq"`
     /// * `"lbt"`
     /// * `"lvz"`
     /// * `"ual"`
@@ -23,10 +28,20 @@ features! {
     /// D
     @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] frecipe: "frecipe";
     /// Frecipe
+    @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] div32: "div32";
+    /// Div32
     @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lsx: "lsx";
     /// LSX
     @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lasx: "lasx";
     /// LASX
+    @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lam_bh: "lam-bh";
+    /// LAM-BH
+    @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lamcas: "lamcas";
+    /// LAM-CAS
+    @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] ld_seq_sa: "ld-seq-sa";
+    /// LD-SEQ-SA
+    @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] scq: "scq";
+    /// SCQ
     @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lbt: "lbt";
     /// LBT
     @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lvz: "lvz";
diff --git a/library/stdarch/crates/std_detect/src/detect/os/linux/loongarch.rs b/library/stdarch/crates/std_detect/src/detect/os/linux/loongarch.rs
index a46a4a9d087..14cc7a73183 100644
--- a/library/stdarch/crates/std_detect/src/detect/os/linux/loongarch.rs
+++ b/library/stdarch/crates/std_detect/src/detect/os/linux/loongarch.rs
@@ -24,7 +24,20 @@ pub(crate) fn detect_features() -> cache::Initializer {
             options(pure, nomem, preserves_flags, nostack)
         );
     }
+    let cpucfg3: usize;
+    unsafe {
+        asm!(
+            "cpucfg {}, {}",
+            out(reg) cpucfg3, in(reg) 3,
+            options(pure, nomem, preserves_flags, nostack)
+        );
+    }
     enable_feature(&mut value, Feature::frecipe, bit::test(cpucfg2, 25));
+    enable_feature(&mut value, Feature::div32, bit::test(cpucfg2, 26));
+    enable_feature(&mut value, Feature::lam_bh, bit::test(cpucfg2, 27));
+    enable_feature(&mut value, Feature::lamcas, bit::test(cpucfg2, 28));
+    enable_feature(&mut value, Feature::scq, bit::test(cpucfg2, 30));
+    enable_feature(&mut value, Feature::ld_seq_sa, bit::test(cpucfg3, 23));
 
     // The values are part of the platform-specific [asm/hwcap.h][hwcap]
     //