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() -> OptimizationConfig

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

Source

pub const fn all_off() -> OptimizationConfig

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) -> OptimizationConfig

Turn an optimization off (builder style).

Source

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

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() -> OptimizationConfig

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>, ) -> OptimizationConfig

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>, ) -> (OptimizationConfig, 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 Debug for OptimizationConfig

Source§

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

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

impl Default for OptimizationConfig

Source§

fn default() -> OptimizationConfig

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

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

Source§

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

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

impl Hash for OptimizationConfig

Source§

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

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for OptimizationConfig

Source§

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

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

impl Copy for OptimizationConfig

Source§

impl Eq for OptimizationConfig

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,