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
impl Machine
Sourcepub fn of(module: &Module, level: OptLevel) -> Self
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.
Sourcepub const fn with(costs: Option<&'static dyn TargetCosts>, goal: Goal) -> Self
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.
Sourcepub const fn unknown() -> Self
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.
Sourcepub fn costs(self) -> Option<&'static dyn TargetCosts>
pub fn costs(self) -> Option<&'static dyn TargetCosts>
The costs for this target, or nothing for one with no table.
Sourcepub fn table(self) -> Option<&'static CostTable>
pub fn table(self) -> Option<&'static CostTable>
The cost table for this target and goal, or nothing for a target with no table.
Sourcepub fn tune(self, flag: TuneFlag) -> bool
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.
Sourcepub fn allocatable(self, class: RegClass) -> Option<u32>
pub fn allocatable(self, class: RegClass) -> Option<u32>
How many registers of that bank the allocator hands out, or nothing without a target.
Sourcepub fn branch_cost(self, predictable: bool) -> Option<Cycles>
pub fn branch_cost(self, predictable: bool) -> Option<Cycles>
What a branch of that predictability costs, or nothing without a target.