Skip to main content

Machine

Struct Machine 

Source
pub struct Machine {
    pub conv: &'static CallRegs,
    pub file: RegFile,
    pub insts: &'static FrameInsts,
    pub branch: &'static BranchInsts,
    pub env: Env,
}
Expand description

Everything about a machine that compiling a function for it needs.

The fields are different kinds of fact and they come from different places: where the convention puts things, what registers the machine has, which instructions build a frame, which instructions a branch becomes, and which registers the allocator may hand out. The last one is not a target fact on its own, because holding a register back as scratch is a decision about the allocator rather than about the machine, which is why it is built here rather than in rucc_target.

Fields§

§conv: &'static CallRegs

Where the convention this function is compiled for puts things.

§file: RegFile

The registers the machine has, which is what says how wide a spill slot of a class is.

§insts: &'static FrameInsts

The instructions that take a frame and give it back.

§branch: &'static BranchInsts

The instructions a branch becomes once the blocks are in an order.

§env: Env

What the allocator may hand out, and what it holds back.

Implementations§

Source§

impl Machine

Source

pub fn x86_64(conv: &'static CallRegs) -> Self

The x86-64 machine under that convention.

Only the general purpose registers are offered, because every rule in the set is about an integer and no value the selector produces is in any other class. A call still destroys the vector registers and still says so, and that costs nothing while nothing is in one.

Source

pub fn for_target(target: &TargetInfo) -> Option<Self>

The machine a target describes, or None when no backend in this crate covers it.

TargetInfo already carries the convention, because the front end needs it to lay a va_list out, so the only thing this decides is which architecture’s frame instructions and register file go with it. AArch64 and RISC-V are None until M6 fills them in, and a caller that gets one reports a target it cannot compile for rather than compiling wrongly.

Trait Implementations§

Source§

impl Debug for Machine

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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.