Skip to main content

std_detect/detect/arch/
loongarch.rs

1//! Run-time feature detection on LoongArch.
2
3#[doc = r" Check for the presence of a CPU feature at runtime."]
#[doc = r""]
#[doc =
r" When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)"]
#[doc = r" the macro expands to `true`."]
#[doc = r""]
#[doc = r" Supported arguments are:"]
#[doc = r""]
#[doc = r#" * `"32s"`"#]
#[doc = r#" * `"f"`"#]
#[doc = r#" * `"d"`"#]
#[doc = r#" * `"frecipe"`"#]
#[doc = r#" * `"div32"`"#]
#[doc = r#" * `"lsx"`"#]
#[doc = r#" * `"lasx"`"#]
#[doc = r#" * `"lam-bh"`"#]
#[doc = r#" * `"lamcas"`"#]
#[doc = r#" * `"ld-seq-sa"`"#]
#[doc = r#" * `"scq"`"#]
#[doc = r#" * `"lbt"`"#]
#[doc = r#" * `"lvz"`"#]
#[doc = r#" * `"ual"`"#]
#[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")]
#[macro_export]
macro_rules! is_loongarch_feature_detected {
    ("32s") =>
    {
        compile_error!
        (concat!
        (r#"This macro cannot be used on the current target.
                            You can prevent it from being used in other architectures by
                            guarding it behind a cfg("#,
        stringify!
        (any(target_arch = "loongarch32", target_arch = "loongarch64")),
        ")."))
    }; ("f") =>
    {
        compile_error!
        (concat!
        (r#"This macro cannot be used on the current target.
                            You can prevent it from being used in other architectures by
                            guarding it behind a cfg("#,
        stringify!
        (any(target_arch = "loongarch32", target_arch = "loongarch64")),
        ")."))
    }; ("d") =>
    {
        compile_error!
        (concat!
        (r#"This macro cannot be used on the current target.
                            You can prevent it from being used in other architectures by
                            guarding it behind a cfg("#,
        stringify!
        (any(target_arch = "loongarch32", target_arch = "loongarch64")),
        ")."))
    }; ("frecipe") =>
    {
        compile_error!
        (concat!
        (r#"This macro cannot be used on the current target.
                            You can prevent it from being used in other architectures by
                            guarding it behind a cfg("#,
        stringify!
        (any(target_arch = "loongarch32", target_arch = "loongarch64")),
        ")."))
    }; ("div32") =>
    {
        compile_error!
        (concat!
        (r#"This macro cannot be used on the current target.
                            You can prevent it from being used in other architectures by
                            guarding it behind a cfg("#,
        stringify!
        (any(target_arch = "loongarch32", target_arch = "loongarch64")),
        ")."))
    }; ("lsx") =>
    {
        compile_error!
        (concat!
        (r#"This macro cannot be used on the current target.
                            You can prevent it from being used in other architectures by
                            guarding it behind a cfg("#,
        stringify!
        (any(target_arch = "loongarch32", target_arch = "loongarch64")),
        ")."))
    }; ("lasx") =>
    {
        compile_error!
        (concat!
        (r#"This macro cannot be used on the current target.
                            You can prevent it from being used in other architectures by
                            guarding it behind a cfg("#,
        stringify!
        (any(target_arch = "loongarch32", target_arch = "loongarch64")),
        ")."))
    }; ("lam-bh") =>
    {
        compile_error!
        (concat!
        (r#"This macro cannot be used on the current target.
                            You can prevent it from being used in other architectures by
                            guarding it behind a cfg("#,
        stringify!
        (any(target_arch = "loongarch32", target_arch = "loongarch64")),
        ")."))
    }; ("lamcas") =>
    {
        compile_error!
        (concat!
        (r#"This macro cannot be used on the current target.
                            You can prevent it from being used in other architectures by
                            guarding it behind a cfg("#,
        stringify!
        (any(target_arch = "loongarch32", target_arch = "loongarch64")),
        ")."))
    }; ("ld-seq-sa") =>
    {
        compile_error!
        (concat!
        (r#"This macro cannot be used on the current target.
                            You can prevent it from being used in other architectures by
                            guarding it behind a cfg("#,
        stringify!
        (any(target_arch = "loongarch32", target_arch = "loongarch64")),
        ")."))
    }; ("scq") =>
    {
        compile_error!
        (concat!
        (r#"This macro cannot be used on the current target.
                            You can prevent it from being used in other architectures by
                            guarding it behind a cfg("#,
        stringify!
        (any(target_arch = "loongarch32", target_arch = "loongarch64")),
        ")."))
    }; ("lbt") =>
    {
        compile_error!
        (concat!
        (r#"This macro cannot be used on the current target.
                            You can prevent it from being used in other architectures by
                            guarding it behind a cfg("#,
        stringify!
        (any(target_arch = "loongarch32", target_arch = "loongarch64")),
        ")."))
    }; ("lvz") =>
    {
        compile_error!
        (concat!
        (r#"This macro cannot be used on the current target.
                            You can prevent it from being used in other architectures by
                            guarding it behind a cfg("#,
        stringify!
        (any(target_arch = "loongarch32", target_arch = "loongarch64")),
        ")."))
    }; ("ual") =>
    {
        compile_error!
        (concat!
        (r#"This macro cannot be used on the current target.
                            You can prevent it from being used in other architectures by
                            guarding it behind a cfg("#,
        stringify!
        (any(target_arch = "loongarch32", target_arch = "loongarch64")),
        ")."))
    }; ($t : tt,) => { crate :: is_loongarch_feature_detected ! ($t); };
    ($t : tt) =>
    {
        compile_error!
        (concat!
        (concat! ("unknown ", stringify! (loongarch)), concat!
        (" target feature: ", $t)))
    };
}
#[deny(unexpected_cfgs)]
#[deny(unfulfilled_lint_expectations)]
const _: () =
    {
        false;
        ;
        false;
        ;
        false;
        ;
        false;
        ;
        false;
        ;
        false;
        ;
        false;
        ;
        false;
        ;
        false;
        ;
        false;
        ;
        false;
        ;
        false;
        ;
        false;
        ;
        false;
        ;
    };features! {
4    @TARGET: loongarch;
5    @CFG: any(target_arch = "loongarch32", target_arch = "loongarch64");
6    @MACRO_NAME: is_loongarch_feature_detected;
7    @MACRO_ATTRS:
8    /// Check for the presence of a CPU feature at runtime.
9    ///
10    /// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
11    /// the macro expands to `true`.
12    ///
13    /// Supported arguments are:
14    ///
15    /// * `"32s"`
16    /// * `"f"`
17    /// * `"d"`
18    /// * `"frecipe"`
19    /// * `"div32"`
20    /// * `"lsx"`
21    /// * `"lasx"`
22    /// * `"lam-bh"`
23    /// * `"lamcas"`
24    /// * `"ld-seq-sa"`
25    /// * `"scq"`
26    /// * `"lbt"`
27    /// * `"lvz"`
28    /// * `"ual"`
29    #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")]
30    @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] _32s: "32s";
31    /// 32S
32    @FEATURE: #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] f: "f";
33    /// F
34    @FEATURE: #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] d: "d";
35    /// D
36    @FEATURE: #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] frecipe: "frecipe";
37    /// Frecipe
38    @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] div32: "div32";
39    /// Div32
40    @FEATURE: #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] lsx: "lsx";
41    /// LSX
42    @FEATURE: #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] lasx: "lasx";
43    /// LASX
44    @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lam_bh: "lam-bh";
45    /// LAM-BH
46    @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lamcas: "lamcas";
47    /// LAM-CAS
48    @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] ld_seq_sa: "ld-seq-sa";
49    /// LD-SEQ-SA
50    @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] scq: "scq";
51    /// SCQ
52    @FEATURE: #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] lbt: "lbt";
53    /// LBT
54    @FEATURE: #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] lvz: "lvz";
55    /// LVZ
56    @FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] ual: "ual";
57    /// UAL
58}