Struct CalyxBuilder

Source
pub struct CalyxBuilder { /* private fields */ }
Expand description

A builder for calyx IR optimized for generation from a higher-level AST or IR.

Implementations§

Source§

impl CalyxBuilder

Source

pub fn new( prelude: Option<PathBuf>, lib_path: PathBuf, entrypoint: Option<String>, cell_name_prefix: String, ) -> Self

Constructs a new calyx builder. See the documentation at CalyxBuilder for general usage information.

  • prelude is an optional calyx file that will be parsed and inlined in additional to the standard library, which is useful for additional component definitions or imports.

  • lib_path should be the root of the calyx installation location, e.g., the folder generated from cloning the repository from GitHub.

  • entrypoint is the name of the entry component in the program. If None is passed, it will default to "main". You can use CalyxBuilder::set_entrypoint to update it.

  • cell_name_prefix is the non-empty prefix applied to all named cells (e.g., those requested via [CalyxComponent::named_reg]) to guarantee no collisions with unnamed cells (e.g., those requested via [CalyxComponent::unnamed_cell]). It must be non-empty.

Source

pub fn dummy() -> Self

This builder cannot be used.
Source

pub fn register_component(&mut self, name: String, ports: Vec<PortDef<u64>>)

Binds a component (named name)’s signature to a list of ports so it can be constructed or instantiated by another component.

Source

pub fn start_component<ComponentData: Default>( &self, name: String, ) -> CalyxComponent<'_, ComponentData>

Returns a component wrapper for a registered component. Once you are finished with the component builder, call [finish_component!].

Requires: CalyxBuilder::register_component has been issued for name.

Source

pub fn _finish_component(&mut self, component: Component)

Please use [finish_component!] instead.

Source

pub fn set_entrypoint(&mut self, entrypoint: String)

Updates the name of the program entrypoint.

Requires: CalyxBuilder::register_component has been issued for entrypoint.

Source

pub fn finalize(self) -> Context

Yields a calyx_ir::Context.

Requires: the entrypoint provided at CalyxBuilder::new is the name of a component added.

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.