Allow mapping a runtime feature to a set of target_features (#1311)
This commit is contained in:
parent
b186197c7c
commit
ba9ca43154
2 changed files with 17 additions and 4 deletions
|
|
@ -72,7 +72,8 @@ features! {
|
|||
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] pmull: "pmull";
|
||||
/// FEAT_PMULL (Polynomial Multiply)
|
||||
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] fp: "fp";
|
||||
/// FEAT_FP (Floating point support)
|
||||
implied by target_features: ["neon"];
|
||||
/// FEAT_FP (Floating point support) - Implied by `neon` target_feature
|
||||
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] fp16: "fp16";
|
||||
/// FEAT_FP16 (Half-float support)
|
||||
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sve: "sve";
|
||||
|
|
|
|||
|
|
@ -1,3 +1,14 @@
|
|||
#[macro_export]
|
||||
macro_rules! detect_feature {
|
||||
($feature:tt, $feature_lit:tt) => {
|
||||
$crate::detect_feature!($feature, $feature_lit : $feature_lit)
|
||||
};
|
||||
($feature:tt, $feature_lit:tt : $($target_feature_lit:tt),*) => {
|
||||
$(cfg!(target_feature = $target_feature_lit) ||)*
|
||||
$crate::detect::__is_feature_detected::$feature()
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
macro_rules! features {
|
||||
(
|
||||
|
|
@ -7,7 +18,9 @@ macro_rules! features {
|
|||
@MACRO_ATTRS: $(#[$macro_attrs:meta])*
|
||||
$(@BIND_FEATURE_NAME: $bind_feature:tt; $feature_impl:tt; )*
|
||||
$(@NO_RUNTIME_DETECTION: $nort_feature:tt; )*
|
||||
$(@FEATURE: #[$stability_attr:meta] $feature:ident: $feature_lit:tt; $(#[$feature_comment:meta])*)*
|
||||
$(@FEATURE: #[$stability_attr:meta] $feature:ident: $feature_lit:tt;
|
||||
$(implied by target_features: [$($target_feature_lit:tt),*];)?
|
||||
$(#[$feature_comment:meta])*)*
|
||||
) => {
|
||||
#[macro_export]
|
||||
$(#[$macro_attrs])*
|
||||
|
|
@ -17,8 +30,7 @@ macro_rules! features {
|
|||
macro_rules! $macro_name {
|
||||
$(
|
||||
($feature_lit) => {
|
||||
cfg!(target_feature = $feature_lit) ||
|
||||
$crate::detect::__is_feature_detected::$feature()
|
||||
$crate::detect_feature!($feature, $feature_lit $(: $($target_feature_lit),*)?)
|
||||
};
|
||||
)*
|
||||
$(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue