pub enum ValueInstruction {
Instruction(Instruction),
ClassicalControl(ValueClassicalControlOp),
}Expand description
A value-level instruction for circuit construction.
ValueInstruction is the construction-IR counterpart of Instruction. It has two
families of variants:
Instruction(Instruction)— all non-control-flow operations (gates, directives, classical data). The wrappedInstructionmust not beInstruction::ClassicalControl; useValueInstruction::ClassicalControlfor control flow.ClassicalControl(ValueClassicalControlOp)— value-level classical control flow whose bodies recursively containValueOperationentries withParameterValueparameters.
§Conversion to Storage IR
Circuit::from_operations recursively
converts every ValueInstruction into an Instruction:
ValueInstruction::Instruction(inst)→inst(pass-through, validated to not beClassicalControl).ValueInstruction::ClassicalControl(vcc)→Instruction::ClassicalControl(cc), where every nestedValueControlBodyis recursively converted to aControlBodywith interned parameters.
Variants§
Instruction(Instruction)
A non-control-flow instruction. The wrapped Instruction must not be
Instruction::ClassicalControl.
ClassicalControl(ValueClassicalControlOp)
A value-level classical control-flow operation.
Implementations§
Source§impl ValueInstruction
impl ValueInstruction
Sourcepub fn from_instruction(inst: Instruction) -> Self
pub fn from_instruction(inst: Instruction) -> Self
Creates a ValueInstruction from a non-control-flow Instruction.
§Panics
Panics in debug builds if inst is Instruction::ClassicalControl. Use
ValueInstruction::ClassicalControl for control flow.
Sourcepub fn is_classical_control(&self) -> bool
pub fn is_classical_control(&self) -> bool
Returns true if this is a classical control-flow instruction.
Sourcepub fn is_instruction(&self) -> bool
pub fn is_instruction(&self) -> bool
Returns true if this is a non-control-flow instruction.
Sourcepub fn instruction_type(&self) -> &'static str
pub fn instruction_type(&self) -> &'static str
Returns a stable category name for this instruction.
Sourcepub fn is_standard(&self) -> bool
pub fn is_standard(&self) -> bool
Returns true if this is a standard-gate instruction.
Sourcepub fn is_unitary(&self) -> bool
pub fn is_unitary(&self) -> bool
Returns true if this is a user-defined unitary instruction.
Sourcepub fn is_circuit_gate(&self) -> bool
pub fn is_circuit_gate(&self) -> bool
Returns true if this is a circuit-backed gate instruction.
Sourcepub fn is_directive(&self) -> bool
pub fn is_directive(&self) -> bool
Returns true if this is a non-unitary directive.
Sourcepub fn is_classical_data(&self) -> bool
pub fn is_classical_data(&self) -> bool
Returns true if this is a classical-data instruction.
Sourcepub fn standard_gate(&self) -> Option<StandardGate>
pub fn standard_gate(&self) -> Option<StandardGate>
Returns the standard gate when this is a standard-gate instruction.
Sourcepub fn directive(&self) -> Option<Directive>
pub fn directive(&self) -> Option<Directive>
Returns the directive when this is a directive instruction.
Sourcepub fn mc_gate(&self) -> Option<&MCGate>
pub fn mc_gate(&self) -> Option<&MCGate>
Returns the multi-controlled gate when this is an mc-gate instruction.
Sourcepub fn unitary_gate(&self) -> Option<&UnitaryGate>
pub fn unitary_gate(&self) -> Option<&UnitaryGate>
Returns the user-defined unitary gate when this is a unitary instruction.
Sourcepub fn circuit_gate(&self) -> Option<&CircuitGate>
pub fn circuit_gate(&self) -> Option<&CircuitGate>
Returns the circuit-backed gate when this is a circuit-gate instruction.
Sourcepub fn classical_data(&self) -> Option<&ClassicalDataOp>
pub fn classical_data(&self) -> Option<&ClassicalDataOp>
Returns the classical data operation when this is a classical-data instruction.
Sourcepub fn classical_control(&self) -> Option<&ValueClassicalControlOp>
pub fn classical_control(&self) -> Option<&ValueClassicalControlOp>
Returns the value-level control-flow operation when this is a classical control-flow instruction.
Sourcepub fn as_instruction(&self) -> Option<&Instruction>
pub fn as_instruction(&self) -> Option<&Instruction>
Returns the wrapped storage instruction when this is a non-control-flow value instruction.
Sourcepub fn into_instruction(self) -> Option<Instruction>
pub fn into_instruction(self) -> Option<Instruction>
Consumes this value instruction and returns the wrapped storage instruction when it is non-control-flow.
Trait Implementations§
Source§impl Clone for ValueInstruction
impl Clone for ValueInstruction
Source§impl Debug for ValueInstruction
impl Debug for ValueInstruction
Source§impl Display for ValueInstruction
impl Display for ValueInstruction
Source§impl From<Instruction> for ValueInstruction
impl From<Instruction> for ValueInstruction
Source§fn from(inst: Instruction) -> Self
fn from(inst: Instruction) -> Self
Converts a non-control-flow Instruction into a ValueInstruction.
§Panics
Panics in debug builds if the instruction is Instruction::ClassicalControl.
Source§impl From<ValueClassicalControlOp> for ValueInstruction
impl From<ValueClassicalControlOp> for ValueInstruction
Source§fn from(op: ValueClassicalControlOp) -> Self
fn from(op: ValueClassicalControlOp) -> Self
Source§impl PartialEq for ValueInstruction
impl PartialEq for ValueInstruction
impl StructuralPartialEq for ValueInstruction
Auto Trait Implementations§
impl Freeze for ValueInstruction
impl RefUnwindSafe for ValueInstruction
impl Send for ValueInstruction
impl Sync for ValueInstruction
impl Unpin for ValueInstruction
impl UnsafeUnpin for ValueInstruction
impl UnwindSafe for ValueInstruction
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
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.impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§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> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> StdoutFmt for Twhere
T: Display,
impl<T> StdoutFmt for Twhere
T: Display,
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.