Skip to main content

OptimizationConfig

Struct OptimizationConfig 

Source
pub struct OptimizationConfig { /* private fields */ }
Expand description

A live choice of which optimizations are enabled — one bit per Opt.

The default is every optimization on (the speed-tuned baseline). Clearing all bits yields plain, boring Rust.

Implementations§

Source§

impl OptimizationConfig

Source

pub fn all_on() -> Self

Every default-on optimization enabled (the speed baseline).

Source

pub const fn all_off() -> Self

No optimizations enabled — the “boring Rust” config.

Source

pub const fn is_on(&self, opt: Opt) -> bool

Whether a given optimization is on.

Source

pub fn set(&mut self, opt: Opt, on: bool)

Turn an optimization on or off.

Source

pub fn disable(self, opt: Opt) -> Self

Turn an optimization off (builder style).

Source

pub fn enable(self, opt: Opt) -> Self

Turn an optimization on (builder style).

Source

pub fn enable_with_requires(&mut self, opt: Opt)

Turn opt on together with the transitive closure of what it requires.

The complement of normalize’s dependency-closure (which turns dependents off when a requirement goes off): enabling a leaf must pull its whole requires-chain on, or normalize would just turn the leaf back off. This is the on-direction of the UI’s toggle-linking.

Source

pub const fn is_all_off(&self) -> bool

Whether every optimization is off.

Source

pub const fn bits(&self) -> u64

The raw enabled bitmask (bit layout = Opt::bit). Lets callers relate an OptimizationConfig to a FiredOptimizations set bit-for-bit.

Source

pub const fn merged(&self, func: &OptimizationConfig) -> OptimizationConfig

Combine a program-level config with a function’s per-function overrides: an optimization is on for the function only if it is on in both.

Source

pub fn disabled_keywords(&self) -> impl Iterator<Item = &'static str> + '_

The keywords of every optimization currently off (registry order).

Source

pub fn normalize(&mut self) -> NormalizeReport

Resolve conflicts and dependencies, returning what was auto-disabled.

Conflicts: when two mutually exclusive optimizations are both on, the one declared earlier in REGISTRY wins and the later is disabled. Dependencies: any optimization whose requires set is not fully on is disabled (transitively, to a fixed point).

Source

pub fn from_env() -> Self

Build a config from the environment, the single external entry point.

  • LOGOS_OPT=off (or LOGOS_NO_OPTIMIZE=1) disables everything.
  • LOGOS_OPT_PROFILE=speed|memory|safety selects a base profile.
  • LOGOS_OPT_OFF="scalarize,unroll,…" disables the listed keywords.

The result is normalized.

Source

pub fn from_spec( master_off: bool, profile: Option<&str>, off_list: Option<&str>, ) -> Self

The pure, testable core of from_env. master_off disables everything; profile picks the base preset (speed by default); off_list is a comma/space/;-separated list of keywords to disable. The result is normalized.

Source

pub fn from_toggles(toggles: &BTreeMap<String, bool>) -> (Self, Vec<Opt>)

Build a config from a keyword→enabled map (e.g. UI toggles), returning the normalized config and the optimizations normalization forced off.

Trait Implementations§

Source§

impl Clone for OptimizationConfig

Source§

fn clone(&self) -> OptimizationConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for OptimizationConfig

Source§

impl Debug for OptimizationConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OptimizationConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for OptimizationConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for OptimizationConfig

Source§

impl Hash for OptimizationConfig

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for OptimizationConfig

Source§

fn eq(&self, other: &OptimizationConfig) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for OptimizationConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for OptimizationConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.