Skip to main content

Selector

Struct Selector 

Source
pub struct Selector {
    pub table: &'static Table,
    pub shapes: &'static MachineInsts,
    pub address: fn(&str) -> Option<Address>,
    pub frame: &'static FrameInsts,
    pub branch: &'static BranchInsts,
    pub gpr: RegClass,
    pub fence: &'static str,
    pub trap: &'static str,
    pub abi: &'static Insts,
    pub scratch: &'static [PhysReg],
    pub symbols: &'static Symbols,
    pub jumps: &'static Jumps,
}
Expand description

What crate::lower has to know about the machine it selects instructions for.

The lowering is one walk over the IR whichever machine it is for, and everything in it that differs between two machines is a question this answers: which table the rules compiled into, what each opcode’s operands are, what an address constructor’s arguments mean, and the handful of instructions the walk writes itself rather than getting from a rule. A walk that reaches for a machine’s module by name is a walk for that machine only, which is what this is here to stop.

The frame and branch instructions are the same tables crate::pipeline::Machine hands the passes after this one. They are in here as well so that the lowering is handed one thing, rather than a machine and the convention and the rules separately.

Fields§

§table: &'static Table

The rules, compiled.

§shapes: &'static MachineInsts

The shape of each opcode, and the prefix a rule file puts in front of one.

§address: fn(&str) -> Option<Address>

What an address constructor in a replacement stands for, or None for a name that is not one of this machine’s.

§frame: &'static FrameInsts

The instructions that take a frame and give it back, of which the walk writes the address of a local and the move between two registers itself.

§branch: &'static BranchInsts

The instructions a branch becomes, of which the walk writes the indirect jump itself.

§gpr: RegClass

The class an address is in.

§fence: &'static str

The instruction a full fence is, without the prefix.

§trap: &'static str

The instruction a program that must stop here stops with, without the prefix.

§abi: &'static Insts

The instructions the calling convention is written with.

§scratch: &'static [PhysReg]

The address registers held back from the allocator for the rewriter’s reloads, which are the ones the walk must not keep anything in across more than one instruction.

§symbols: &'static Symbols

How the walk comes by the address of a symbol, which is its own business rather than a rule’s because whether it goes through the global offset table is a fact about the link and not about the instruction.

§jumps: &'static Jumps

The instructions a jump through a table is built from, and the address of a label.

Implementations§

Source§

impl Selector

Source

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

What a rule file and the machine IR put in front of this machine’s opcodes.

Source

pub fn operands(&self, name: &str) -> Option<&'static [OperandDesc]>

The operands the opcode of that name has, the name written without the prefix.

Trait Implementations§

Source§

impl Debug for Selector

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.