pub struct TargetFeature {
pub name: String,
pub implies_features: Vec<String>,
pub unstable_feature_gate: Option<String>,
pub globally_enabled: bool,
}
Expand description
Information about a target feature.
Rust target features are used to influence code generation, especially around selecting instructions which are not universally supported by the target architecture.
Target features are commonly enabled by the #[target_feature]
attribute to influence code
generation for a particular function, and less commonly enabled by compiler options like
-Ctarget-feature
or -Ctarget-cpu
. Targets themselves automatically enable certain target
features by default, for example because the target’s ABI specification requires saving specific
registers which only exist in an architectural extension.
Target features can imply other target features: for example, x86-64 avx2
implies avx
, and
aarch64 sve2
implies sve
, since both of these architectural extensions depend on their
predecessors.
Target features can be probed at compile time by #[cfg(target_feature)]
or cfg!(…)
conditional compilation to determine whether a target feature is enabled in a particular
context.
Fields§
§name: String
The name of this target feature.
implies_features: Vec<String>
Other target features which are implied by this target feature, if any.
unstable_feature_gate: Option<String>
If this target feature is unstable, the name of the associated language feature gate.
globally_enabled: bool
Whether this feature is globally enabled for this compilation session.
Target features can be globally enabled implicitly as a result of the target’s definition.
For example, x86-64 hardware floating point ABIs require saving x87 and SSE2 registers,
which in turn requires globally enabling the x87
and sse2
target features so that the
generated machine code conforms to the target’s ABI.
Target features can also be globally enabled explicitly as a result of compiler flags like
-Ctarget-feature
or -Ctarget-cpu
.
Trait Implementations§
Source§impl Clone for TargetFeature
impl Clone for TargetFeature
Source§fn clone(&self) -> TargetFeature
fn clone(&self) -> TargetFeature
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more