Struct target_features::Target
source · pub struct Target { /* private fields */ }
Expand description
A target architecture with optional features.
Implementations§
source§impl Target
impl Target
sourcepub const fn suggested_simd_width<T: SimdType>(&self) -> Option<usize>
pub const fn suggested_simd_width<T: SimdType>(&self) -> Option<usize>
Returns a suggested number of elements for a SIMD vector of the provided type.
The returned value is an approximation and not necessarily indicative of the optimal vector width. A few caveats:
- Every instruction set is different, and this function doesn’t take into account any particular operations–it’s just a guess, and should be accurate at least for basic arithmetic.
- Variable length vector instruction sets (ARM SVE and RISC-V V) only return the minimum vector length.
source§impl Target
impl Target
sourcepub const fn new(architecture: Architecture) -> Self
pub const fn new(architecture: Architecture) -> Self
Create a target with no specified features.
sourcepub const fn from_cpu(
architecture: Architecture,
cpu: &str
) -> Result<Self, UnknownCpu>
pub const fn from_cpu( architecture: Architecture, cpu: &str ) -> Result<Self, UnknownCpu>
Create a target based on a particular CPU.
sourcepub const fn architecture(&self) -> Architecture
pub const fn architecture(&self) -> Architecture
Returns the target architecture.
sourcepub const fn features(&self) -> FeaturesIter ⓘ
pub const fn features(&self) -> FeaturesIter ⓘ
Returns an iterator over the features.
sourcepub const fn supports_feature(&self, feature: Feature) -> bool
pub const fn supports_feature(&self, feature: Feature) -> bool
Returns whether the target supports the specified feature.
sourcepub const fn supports_feature_str(&self, feature: &str) -> bool
pub const fn supports_feature_str(&self, feature: &str) -> bool
Returns whether the target supports the specified feature.
§Panics
Panics if the feature doesn’t belong to the target architecture.
sourcepub const fn with_feature(self, feature: Feature) -> Self
pub const fn with_feature(self, feature: Feature) -> Self
Add a feature to the target.
§Panics
Panics if the feature doesn’t belong to the target architecture.
sourcepub const fn with_feature_str(self, feature: &str) -> Self
pub const fn with_feature_str(self, feature: &str) -> Self
Add a feature to the target.
§Panics
Panics if the requested feature name doesn’t exist for the target architecture.