pub struct IRStmt<T>(/* private fields */);Expand description
IR for operations that occur in the main circuit.
Implementations§
Source§impl<T> IRStmt<T>
impl<T> IRStmt<T>
Sourcepub fn call(
callee: impl AsRef<str>,
inputs: impl IntoIterator<Item = T>,
outputs: impl IntoIterator<Item = Slot>,
) -> Self
pub fn call( callee: impl AsRef<str>, inputs: impl IntoIterator<Item = T>, outputs: impl IntoIterator<Item = Slot>, ) -> Self
Creates a call to another module.
Sourcepub fn constraint(op: CmpOp, lhs: T, rhs: T) -> Self
pub fn constraint(op: CmpOp, lhs: T, rhs: T) -> Self
Creates a constraint between two expressions.
Sourcepub fn assume_deterministic(f: impl Into<Slot>) -> Self
pub fn assume_deterministic(f: impl Into<Slot>) -> Self
Indicates that the Slot must be assumed deterministic by the backend.
Sourcepub fn seq<I>(stmts: impl IntoIterator<Item = IRStmt<I>>) -> Selfwhere
I: Into<T>,
pub fn seq<I>(stmts: impl IntoIterator<Item = IRStmt<I>>) -> Selfwhere
I: Into<T>,
Creates a statement that is a sequence of other statements.
Sourcepub fn with_comment(self, comment: String) -> Self
pub fn with_comment(self, comment: String) -> Self
Prepends a comment to the statement.
Sourcepub fn map<O>(self, f: &mut impl FnMut(T) -> O) -> IRStmt<O>
pub fn map<O>(self, f: &mut impl FnMut(T) -> O) -> IRStmt<O>
Transforms the inner expression type into another.
Sourcepub fn with<O>(self, other: O) -> IRStmt<(O, T)>where
O: Clone,
pub fn with<O>(self, other: O) -> IRStmt<(O, T)>where
O: Clone,
Maps the statement’s inner type to a tuple with the passed value.
Sourcepub fn with_fn<O>(self, other: impl Fn() -> O) -> IRStmt<(O, T)>
pub fn with_fn<O>(self, other: impl Fn() -> O) -> IRStmt<(O, T)>
Maps the statement’s inner type to a tuple with the result of the closure.
Sourcepub fn into<O>(self) -> IRStmt<O>
pub fn into<O>(self) -> IRStmt<O>
Transforms the inner expression type using Into::into.
Sourcepub fn from<O>(value: IRStmt<O>) -> Selfwhere
O: Into<T>,
pub fn from<O>(value: IRStmt<O>) -> Selfwhere
O: Into<T>,
Transforms the inner expression type using From::from.
Sourcepub fn then(self, other: impl Into<Self>) -> Self
pub fn then(self, other: impl Into<Self>) -> Self
Appends the given statement to the current one.
Sourcepub fn map_into<O>(&self, f: &mut impl FnMut(&T) -> O) -> IRStmt<O>
pub fn map_into<O>(&self, f: &mut impl FnMut(&T) -> O) -> IRStmt<O>
Transforms the inner expression type into another, without moving.
Sourcepub fn try_map<O, E>(
self,
f: &mut impl FnMut(T) -> Result<O, E>,
) -> Result<IRStmt<O>, E>
pub fn try_map<O, E>( self, f: &mut impl FnMut(T) -> Result<O, E>, ) -> Result<IRStmt<O>, E>
Tries to transform the inner expression type into another.
Sourcepub fn map_inplace(&mut self, f: &mut impl FnMut(&mut T))
pub fn map_inplace(&mut self, f: &mut impl FnMut(&mut T))
Modifies the inner expression type in place.
Sourcepub fn try_map_inplace<E>(
&mut self,
f: &mut impl FnMut(&mut T) -> Result<(), E>,
) -> Result<(), E>
pub fn try_map_inplace<E>( &mut self, f: &mut impl FnMut(&mut T) -> Result<(), E>, ) -> Result<(), E>
Tries to modify the inner expression type in place.
Sourcepub fn map_slot_inplace(&mut self, f: &mut impl FnMut(&mut Slot))
pub fn map_slot_inplace(&mut self, f: &mut impl FnMut(&mut Slot))
Modifies the inner slots in place.
Sourcepub fn try_map_slot_inplace<E>(
&mut self,
f: &mut impl FnMut(&mut Slot) -> Result<(), E>,
) -> Result<(), E>
pub fn try_map_slot_inplace<E>( &mut self, f: &mut impl FnMut(&mut Slot) -> Result<(), E>, ) -> Result<(), E>
Tries to modify the inner slots n place.
Sourcepub fn iter(&self) -> IRStmtRefIter<'_, T> ⓘ
pub fn iter(&self) -> IRStmtRefIter<'_, T> ⓘ
Returns an iterator of references to the statements.
Sourcepub fn iter_mut(&mut self) -> IRStmtRefMutIter<'_, T> ⓘ
pub fn iter_mut(&mut self) -> IRStmtRefMutIter<'_, T> ⓘ
Returns an iterator of mutable references to the statements.
Sourcepub fn propagate_meta(&mut self)
pub fn propagate_meta(&mut self)
Propagates the metadata of this statement to the inner statements.
Trait Implementations§
Source§impl Canonicalize for IRStmt<IRAexpr>
impl Canonicalize for IRStmt<IRAexpr>
Source§fn canonicalize(&mut self)
fn canonicalize(&mut self)
Matches the statements against a series of known patterns and applies rewrites if able to.
Source§fn canonicalized(self) -> Selfwhere
Self: Sized,
fn canonicalized(self) -> Selfwhere
Self: Sized,
Source§impl<T> ConstantFolding for IRStmt<T>
impl<T> ConstantFolding for IRStmt<T>
Source§fn constant_fold(&mut self) -> Result<(), Error>
fn constant_fold(&mut self) -> Result<(), Error>
Folds the statements if the expressions are constant.
If a assert-like statement folds into a tautology (i.e. (= 0 0 )) gets removed. If it
folds into a unsatisfiable proposition the method returns an error.
Source§fn constant_folded(self) -> Result<Self, Self::Error>where
Self: Sized,
fn constant_folded(self) -> Result<Self, Self::Error>where
Self: Sized,
Source§fn const_value(&self) -> Option<Self::T>
fn const_value(&self) -> Option<Self::T>
Source§impl<L, R> EqvRelation<IRStmt<L>, IRStmt<R>> for SymbolicEqv
IRStmt transilitively inherits the SymbolicEqv equivalence relation.
impl<L, R> EqvRelation<IRStmt<L>, IRStmt<R>> for SymbolicEqv
IRStmt transilitively inherits the SymbolicEqv equivalence relation.
Source§impl<I> FromIterator<IRStmt<I>> for IRStmt<I>
impl<I> FromIterator<IRStmt<I>> for IRStmt<I>
Source§impl<T: IRPrintable> IRPrintable for IRStmt<T>
impl<T: IRPrintable> IRPrintable for IRStmt<T>
Source§impl<'a, T> IntoIterator for &'a IRStmt<T>
impl<'a, T> IntoIterator for &'a IRStmt<T>
Source§impl<'a, T> IntoIterator for &'a mut IRStmt<T>
impl<'a, T> IntoIterator for &'a mut IRStmt<T>
Source§impl<T> IntoIterator for IRStmt<T>
impl<T> IntoIterator for IRStmt<T>
Source§impl<T: LowerableExpr> LowerableStmt for IRStmt<T>where
CondBlock<T>: LowerableStmt,
impl<T: LowerableExpr> LowerableStmt for IRStmt<T>where
CondBlock<T>: LowerableStmt,
Source§impl<T: PartialEq> PartialEq for IRStmt<T>
impl<T: PartialEq> PartialEq for IRStmt<T>
Source§impl<T, D> Validatable for IRStmt<T>
impl<T, D> Validatable for IRStmt<T>
Source§type Diagnostic = D
type Diagnostic = D
Source§fn validate_with_context(
&self,
_: &Self::Context,
) -> Result<Vec<Self::Diagnostic>, Vec<Self::Diagnostic>>
fn validate_with_context( &self, _: &Self::Context, ) -> Result<Vec<Self::Diagnostic>, Vec<Self::Diagnostic>>
Ok with a list of non-error diagnostics or Err with a list of all the diagnostics.Source§fn validate(&self) -> Result<Vec<Self::Diagnostic>, Vec<Self::Diagnostic>>
fn validate(&self) -> Result<Vec<Self::Diagnostic>, Vec<Self::Diagnostic>>
Ok with a list of non-error diagnostics or Err with a list of all the diagnostics.Auto Trait Implementations§
impl<T> Freeze for IRStmt<T>where
T: Freeze,
impl<T> RefUnwindSafe for IRStmt<T>where
T: RefUnwindSafe,
impl<T> Send for IRStmt<T>where
T: Send,
impl<T> Sync for IRStmt<T>where
T: Sync,
impl<T> Unpin for IRStmt<T>where
T: Unpin,
impl<T> UnwindSafe for IRStmt<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, I> EmitIf<T> for Iwhere
I: IntoIterator<Item = IRStmt<T>>,
impl<T, I> EmitIf<T> for Iwhere
I: IntoIterator<Item = IRStmt<T>>,
Source§fn emit_if(self, cond: IRConstBexpr<T>) -> IRStmt<T>
fn emit_if(self, cond: IRConstBexpr<T>) -> IRStmt<T>
Source§fn emit_unless_false(self, cond: IRBexpr<T>) -> IRStmt<T>
fn emit_unless_false(self, cond: IRBexpr<T>) -> IRStmt<T>
Source§impl<T, O> EquivalentTo<O> for T
impl<T, O> EquivalentTo<O> for T
Source§impl<L, R, E> EqvRelation<&[L], &[R]> for Ewhere
E: EqvRelation<L, R>,
impl<L, R, E> EqvRelation<&[L], &[R]> for Ewhere
E: EqvRelation<L, R>,
Source§impl<L, R, E> EqvRelation<&L, &R> for Ewhere
E: EqvRelation<L, R>,
impl<L, R, E> EqvRelation<&L, &R> for Ewhere
E: EqvRelation<L, R>,
Source§impl<L, R, E> EqvRelation<&mut L, &mut R> for Ewhere
E: EqvRelation<L, R>,
impl<L, R, E> EqvRelation<&mut L, &mut R> for Ewhere
E: EqvRelation<L, R>,
Source§impl<L, R, E, const N: usize> EqvRelation<[L; N], [R; N]> for Ewhere
E: EqvRelation<L, R>,
impl<L, R, E, const N: usize> EqvRelation<[L; N], [R; N]> for Ewhere
E: EqvRelation<L, R>,
Source§impl<L, R, E> EqvRelation<Box<L>, Box<R>> for Ewhere
E: EqvRelation<L, R>,
impl<L, R, E> EqvRelation<Box<L>, Box<R>> for Ewhere
E: EqvRelation<L, R>,
Source§impl<'l, 'r, L, R, E> EqvRelation<Cow<'l, L>, Cow<'r, R>> for E
impl<'l, 'r, L, R, E> EqvRelation<Cow<'l, L>, Cow<'r, R>> for E
Source§impl<L, R, E> EqvRelation<Option<L>, Option<R>> for Ewhere
E: EqvRelation<L, R>,
impl<L, R, E> EqvRelation<Option<L>, Option<R>> for Ewhere
E: EqvRelation<L, R>,
Source§impl<L, R, E> EqvRelation<Rc<L>, Rc<R>> for Ewhere
E: EqvRelation<L, R>,
impl<L, R, E> EqvRelation<Rc<L>, Rc<R>> for Ewhere
E: EqvRelation<L, R>,
Source§impl<L, LErr, R, RErr, E> EqvRelation<Result<L, LErr>, Result<R, RErr>> for Ewhere
E: EqvRelation<L, R>,
impl<L, LErr, R, RErr, E> EqvRelation<Result<L, LErr>, Result<R, RErr>> for Ewhere
E: EqvRelation<L, R>,
Source§impl<L, R, E> EqvRelation<Vec<L>, Vec<R>> for Ewhere
E: EqvRelation<L, R>,
impl<L, R, E> EqvRelation<Vec<L>, Vec<R>> for Ewhere
E: EqvRelation<L, R>,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.