Skip to main content

Func

Struct Func 

Source
pub struct Func {
    pub name: Symbol,
    /* private fields */
}
Expand description

One function, in machine instructions.

Fields§

§name: Symbol

The name it is called by, which is the name of the IR function it was lowered from.

Implementations§

Source§

impl Func

Source

pub fn new(name: Symbol) -> Self

A function of that name with nothing in it.

Source

pub fn new_vreg(&mut self, class: RegClass) -> Reg

A virtual register of that class, which nothing has defined yet.

§Panics

Panics if the function already has two billion of them, which no function does.

Source

pub fn vregs(&self) -> usize

How many virtual registers the function has, which is what the allocator sizes itself against.

Source

pub fn class_of(&self, reg: Reg) -> Option<RegClass>

The class of a virtual register, or None for a physical one or a number this function never handed out.

Source

pub fn create_block(&mut self) -> Block

Creates a block with no parameters and nothing in it, at the end of the layout.

Source

pub fn entry(&self) -> Option<Block>

The entry block, which is the first in layout order, or None before there is one.

Source

pub fn block_count(&self) -> usize

How many blocks the function has ever had, which is what a table indexed by block is sized against. A block taken out of the layout still counts, because it keeps its index.

Source

pub fn blocks(&self) -> impl Iterator<Item = Block> + use<'_>

Its blocks, in layout order, which is the order they are printed and emitted in.

Source

pub fn append_param(&mut self, block: Block, class: RegClass) -> Reg

Adds a parameter of that class to a block, and gives back the virtual register it arrives as.

Every predecessor’s arm has to grow an argument to match, which is what Func::succs_mut is for.

Source

pub fn append_given_param(&mut self, block: Block, param: Param)

Adds a parameter that is already a particular register, which is what allocation leaves behind.

Source

pub fn succs_mut(&mut self, block: Block) -> &mut Vec<BlockCall>

Where a block goes, to be read or replaced.

The arms are in the order the terminator’s own arms run, so the first is the arm a conditional branch takes when its condition holds.

Source

pub fn insts(&self, block: Block) -> impl Iterator<Item = Inst> + use<'_>

The instructions of a block, in order.

Source

pub fn terminator(&self, block: Block) -> Option<Inst>

The last instruction of a block, which is its terminator once it has one.

Source

pub fn block_of(&self, inst: Inst) -> Option<Block>

Which block an instruction is in, or None for one that has been taken out of its block.

Source

pub fn span(&self, inst: Inst) -> Span

Where an instruction came from.

Source

pub fn build(&mut self, block: Block, opcode: Opcode) -> InstBuilder<'_>

Starts an instruction at the end of that block.

Nothing is added to the function until InstBuilder::finish, so a builder that is dropped leaves no trace.

Source

pub fn append_inst(&mut self, block: Block, inst: Inst)

Puts an instruction that is in no block at the end of one.

§Panics

Panics if the instruction is already in a block, because an instruction in two blocks is the kind of thing that is found much later and somewhere else.

Source

pub fn insert_after(&mut self, after: Inst, inst: Inst)

Puts an instruction that is in no block immediately after another one.

§Panics

Panics if the instruction is already in a block, or if the one it is to follow is in none.

Source

pub fn remove_inst(&mut self, inst: Inst)

Takes an instruction out of its block, leaving it in the function’s tables.

It keeps its index, the way a removed block keeps its number, because renumbering would invalidate every index anything else was holding.

Source

pub fn push_operands(&mut self, operands: &[Operand]) -> OperandList

Puts a run of operands in the operand table and gives back the run.

Source

pub fn add_imm(&mut self, value: i64) -> ImmRef

Puts an immediate in the immediate table.

Source

pub fn add_amode(&mut self, amode: Amode) -> MemRef

Puts an addressing mode in the table of them.

Source

pub fn create_inst(&mut self, data: InstData, span: Span) -> Inst

Creates an instruction that is in no block yet.

Trait Implementations§

Source§

impl Debug for Func

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Index<Idx<Amode>> for Func

Source§

type Output = Amode

The returned type after indexing.
Source§

fn index(&self, at: MemRef) -> &Amode

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<Idx<BlockData>> for Func

Source§

type Output = BlockData

The returned type after indexing.
Source§

fn index(&self, block: Block) -> &BlockData

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<Idx<Imm>> for Func

Source§

type Output = Imm

The returned type after indexing.
Source§

fn index(&self, at: ImmRef) -> &Imm

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<Idx<InstData>> for Func

Source§

type Output = InstData

The returned type after indexing.
Source§

fn index(&self, inst: Inst) -> &InstData

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<IdxRange<Operand>> for Func

Source§

type Output = [Operand]

The returned type after indexing.
Source§

fn index(&self, list: OperandList) -> &[Operand]

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<Idx<InstData>> for Func

Source§

fn index_mut(&mut self, inst: Inst) -> &mut InstData

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<IdxRange<Operand>> for Func

Source§

fn index_mut(&mut self, list: OperandList) -> &mut [Operand]

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl Freeze for Func

§

impl RefUnwindSafe for Func

§

impl Send for Func

§

impl Sync for Func

§

impl Unpin for Func

§

impl UnsafeUnpin for Func

§

impl UnwindSafe for Func

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.