calyx_ir::rewriter

Struct Rewriter

Source
pub struct Rewriter {
    pub port_map: PortRewriteMap,
    pub cell_map: RewriteMap<Cell>,
    pub group_map: RewriteMap<Group>,
    pub comb_group_map: RewriteMap<CombGroup>,
    pub static_group_map: RewriteMap<StaticGroup>,
}
Expand description

A structure to track rewrite maps for ports. Stores both cell rewrites and direct port rewrites. Attempts to apply port rewrites first before trying the cell rewrite.

Fields§

§port_map: PortRewriteMap

Mapping from canonical names of ports to port instances

§cell_map: RewriteMap<Cell>

Mapping from names of cells to cell instance.

§group_map: RewriteMap<Group>

Mapping from names of groups to group instance.

§comb_group_map: RewriteMap<CombGroup>

Mapping from names of combinational groups to combinational group instance.

§static_group_map: RewriteMap<StaticGroup>

Mapping from names of static groups to static group instance.

Implementations§

Source§

impl Rewriter

Source

pub fn get_cell_rewrite(&self, cell: &Id) -> Option<RRC<Cell>>

Return the rewrite for a cell

Source

pub fn get(&self, port_ref: &RRC<Port>) -> Option<RRC<Port>>

Get any port rewrite defined for the given port.

Source

pub fn rewrite_guard<T>(&self, guard: &mut Guard<T>)

Rewrite assignments in a guard

Source

pub fn rewrite_assign<T>(&self, assign: &mut Assignment<T>)

Rewrite an assignment

Source

pub fn rewrite_invoke(&self, inv: &mut Invoke)

Rewrite a invoke node using a RewriteMapir::Cell and a RewriteMapir::CombGroup

Source

pub fn rewrite_static_invoke(&self, inv: &mut StaticInvoke)

Rewrite a static invoke node using a RewriteMapir::Cell and a RewriteMapir::CombGroup

Source

pub fn rewrite_static_control(&self, sc: &mut StaticControl)

Given a control program, rewrite all uses of cells, groups, and comb groups using the given rewrite maps.

Source

pub fn rewrite_control(&self, c: &mut Control)

Given a control program, rewrite all uses of cells, groups, and comb groups using the given rewrite maps.

Source

pub fn rewrite(&self, comp: &mut Component)

Rewrite the component using the given maps

Trait Implementations§

Source§

impl Default for Rewriter

Source§

fn default() -> Rewriter

Returns the “default value” for a type. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.