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 bits: &'static BitInsts,
    pub flags: &'static FlagInsts,
    pub shapes: &'static MachineInsts,
    pub timing: &'static TimingInsts,
    pub short: &'static ShortInsts,
    pub selector: &'static Selector,
    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.

§bits: &'static BitInsts

How much of a register each of the machine’s instructions reads and writes.

§flags: &'static FlagInsts

What each of the machine’s instructions leaves in the condition state.

§shapes: &'static MachineInsts

What shape each of the machine’s instructions is, which is what a pass proposing a new one has its proposal held against.

§timing: &'static TimingInsts

How long each of the machine’s instructions takes, and what it takes it on.

§short: &'static ShortInsts

Which of the machine’s instructions have a shorter spelling of the same answer.

§selector: &'static Selector

What the selector asks of the machine, which is the rules and the instructions it writes itself.

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

Both files are offered. A value the selector produces is in one or the other, which is decided by its type: an integer and an address are general purpose and a float or a double is in a vector register, and the allocator is given each file separately because no move goes between them.

Source

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

The AArch64 machine under that convention.

The scratch registers are x16 and x17, which the convention already keeps out of the allocation order because a linker’s veneer may write them between a call and the function it reaches. That is the property a scratch register wants: nothing lives in one across anything the compiler did not write, so a move the rewriter puts in can have it. The vector file’s two are picked the way the x86 ones are, which lands on v30 and v31.

Nothing selects AArch64 instructions yet, so Machine::for_target does not return this.

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. RISC-V is None until it has a rule file, 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.