Skip to main content

Machine

Struct Machine 

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

The target a pass is compiling for, and which of its two cost tables applies.

Implementations§

Source§

impl Machine

Source

pub fn of(module: &Module, level: OptLevel) -> Self

The machine a module is being compiled for at that level.

Both halves come from things the pipeline already has, which is why no flag was added for this. The architecture is on the module, because a module is built for a target and says so, and the goal is whether the level optimizes for size, which is one call on the level.

Source

pub const fn with(costs: Option<&'static dyn TargetCosts>, goal: Goal) -> Self

The machine for costs already in hand.

What Machine::of is written in terms of, and what a caller that resolved a target some other way uses. None is a target with no cost table, which is every architecture rucc has no back end for.

Source

pub const fn unknown() -> Self

A machine nobody has a cost table for, which is what a test that does not care wants.

Named for what it is rather than called default, because a default machine is the thing this module exists to avoid: a pass that got one silently would be optimizing for a target that does not exist.

Source

pub fn costs(self) -> Option<&'static dyn TargetCosts>

The costs for this target, or nothing for one with no table.

Source

pub const fn goal(self) -> Goal

Which table applies, which is the goal the level asked for.

Source

pub fn table(self) -> Option<&'static CostTable>

The cost table for this target and goal, or nothing for a target with no table.

Source

pub fn tune(self, flag: TuneFlag) -> bool

What this target answers for a tuning flag, and the flag’s documented default without one.

A default is right here and wrong for a number, which is the asymmetry Tuning::untuned already records: a tuning flag is a question whose safe answer is written down, and a cost is a measurement of a machine.

Source

pub fn allocatable(self, class: RegClass) -> Option<u32>

How many registers of that bank the allocator hands out, or nothing without a target.

Source

pub fn branch_cost(self, predictable: bool) -> Option<Cycles>

What a branch of that predictability costs, or nothing without a target.

Source

pub fn name(self) -> &'static str

What the machine is called in a dump, and unknown for a target with no table.

Trait Implementations§

Source§

impl Clone for Machine

Source§

fn clone(&self) -> Machine

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 Machine

Source§

impl Debug for Machine

Source§

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

The name and the goal, because a dyn TargetCosts has no Debug and the pointer would say nothing to anybody reading a dump.

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.