Enum calyx_ir::Guard

source ·
pub enum Guard<T> {
    Or(Box<Guard<T>>, Box<Guard<T>>),
    And(Box<Guard<T>>, Box<Guard<T>>),
    Not(Box<Guard<T>>),
    True,
    CompOp(PortComp, RRC<Port>, RRC<Port>),
    Port(RRC<Port>),
    Info(T),
}
Expand description

An assignment guard which has pointers to the various ports from which it reads.

Variants§

§

Or(Box<Guard<T>>, Box<Guard<T>>)

Represents c1 || c2.

§

And(Box<Guard<T>>, Box<Guard<T>>)

Represents c1 && c2.

§

Not(Box<Guard<T>>)

Represents !c1

§

True

The constant true

§

CompOp(PortComp, RRC<Port>, RRC<Port>)

Comparison operator.

§

Port(RRC<Port>)

Uses the value on a port as the condition. Same as p1 == true

§

Info(T)

Other types of information.

Implementations§

source§

impl<T> Guard<T>

source

pub fn is_true(&self) -> bool

Returns true definitely Guard::True. Returning false does not mean that the guard is not true.

source

pub fn is_false(&self) -> bool

Checks if the guard is always false. Returning false does not mean that the guard is not false.

source

pub fn is_not_done(&self, cell_name: &Id) -> bool

returns true if the self is !cell_name, false otherwise.

source

pub fn update<F>(&mut self, upd: F)where F: FnOnce(Guard<T>) -> Guard<T>,

Update the guard in place. Replaces this guard with upd(self). Uses std::mem::take for the in-place update.

source

pub fn op_str(&self) -> String

Return the string corresponding to the guard operation.

source

pub fn port(p: RRC<Port>) -> Self

source

pub fn and(self, rhs: Guard<T>) -> Selfwhere T: Eq,

source

pub fn or(self, rhs: Guard<T>) -> Selfwhere T: Eq,

source

pub fn eq(self, other: Guard<T>) -> Selfwhere T: Debug,

source

pub fn neq(self, other: Guard<T>) -> Selfwhere T: Debug,

source

pub fn le(self, other: Guard<T>) -> Selfwhere T: Debug,

source

pub fn lt(self, other: Guard<T>) -> Selfwhere T: Debug,

source

pub fn ge(self, other: Guard<T>) -> Selfwhere T: Debug,

source

pub fn gt(self, other: Guard<T>) -> Selfwhere T: Debug,

source

pub fn all_ports(&self) -> Vec<RRC<Port>>

Returns all the ports used by this guard.

source§

impl<T> Guard<T>

Helper functions for the guard.

source

pub fn for_each<F>(&mut self, f: &mut F)where F: FnMut(RRC<Port>) -> Option<Guard<T>>,

Mutates a guard by calling f on every leaf in the guard tree and replacing the leaf with the guard that f returns.

source

pub fn for_each_info<F>(&mut self, f: &mut F)where F: FnMut(&mut T) -> Option<Guard<T>>,

runs f(info) on each Guard::Info in guard. if f(info) = Some(result)replaces interval with result. iff(info) = None does nothing.

source

pub fn check_for_each_info<F>(&self, f: &mut F) -> Result<(), Error>where F: Fn(&T) -> Result<(), Error>,

runs f(info) on each info in guard. f should return Result<(), Error>, meaning that it essentially does nothing if the f returns OK(()), but returns an appropraite error otherwise

source§

impl Guard<StaticTiming>

source

pub fn add_interval(&mut self, timing_interval: StaticTiming)

updates self -> self & interval

Trait Implementations§

source§

impl<T> BitAnd<Guard<T>> for Guard<T>where T: Eq,

Construct a Guard::And:

let and_guard = g1 & g2;
§

type Output = Guard<T>

The resulting type after applying the & operator.
source§

fn bitand(self, other: Self) -> Self::Output

Performs the & operation. Read more
source§

impl<T> BitAndAssign<Guard<T>> for Guard<T>where T: Eq,

Update a Guard with Or.

g1 &= g2;
source§

fn bitand_assign(&mut self, other: Self)

Performs the &= operation. Read more
source§

impl<T> BitOr<Guard<T>> for Guard<T>where T: Eq,

Construct a Guard::Or:

let or_guard = g1 | g2;
§

type Output = Guard<T>

The resulting type after applying the | operator.
source§

fn bitor(self, other: Self) -> Self::Output

Performs the | operation. Read more
source§

impl<T> BitOrAssign<Guard<T>> for Guard<T>where T: Eq,

Update a Guard with Or.

g1 |= g2;
source§

fn bitor_assign(&mut self, other: Self)

Performs the |= operation. Read more
source§

impl<T: Clone> Clone for Guard<T>

source§

fn clone(&self) -> Guard<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for Guard<T>

source§

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

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

impl<T> Default for Guard<T>

source§

fn default() -> Guard<T>

Returns the “default value” for a type. Read more
source§

impl From<Guard<Nothing>> for Guard<StaticTiming>

source§

fn from(g: Guard<Nothing>) -> Self

Turns a normal guard into a static guard

source§

impl<T> From<Rc<RefCell<Port>>> for Guard<T>

Construct guards from ports

source§

fn from(port: RRC<Port>) -> Self

Converts to this type from the input type.
source§

impl<T> Hash for Guard<T>where T: ToString,

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T> Not for Guard<T>

Construct a Guard::Or:

let not_guard = !g1;
§

type Output = Guard<T>

The resulting type after applying the ! operator.
source§

fn not(self) -> Self

Performs the unary ! operation. Read more
source§

impl<T> Ord for Guard<T>where T: Eq,

Define an ordering on the precedence of guards. Guards are considered equal when they have the same precedence.

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<T> PartialEq<Guard<T>> for Guard<T>where T: Eq,

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> PartialOrd<Guard<T>> for Guard<T>where T: Eq,

Define order on guards

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T> Eq for Guard<T>where T: Eq,

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Guard<T>

§

impl<T> !Send for Guard<T>

§

impl<T> !Sync for Guard<T>

§

impl<T> Unpin for Guard<T>where T: Unpin,

§

impl<T> !UnwindSafe for Guard<T>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CallHasher for Twhere T: Hash + ?Sized,

§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64where H: Hash + ?Sized, B: BuildHasher,

source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.