quil_rs::program::analysis

Struct BasicBlock

Source
pub struct BasicBlock<'p> { /* private fields */ }

Implementations§

Source§

impl<'p> BasicBlock<'p>

Source

pub fn label(&self) -> Option<&'p Target>

Source

pub fn instruction_index_offset(&self) -> usize

Source

pub fn instructions(&self) -> &[&'p Instruction]

Source

pub fn terminator(&self) -> &BasicBlockTerminator<'p>

Source

pub fn as_schedule_seconds( &self, program: &Program, ) -> Result<Schedule<Seconds>, BasicBlockScheduleError>

Compute the flattened schedule for this BasicBlock in terms of seconds, using a default built-in calculation for the duration of scheduled instructions.

§Arguments
  • program - The program containing this basic block. This is used to retrieve frame and calibration information.
Source

pub fn as_schedule<F, Time>( &self, program: &'p Program, get_duration: F, ) -> Result<Schedule<Time>, BasicBlockScheduleError>
where F: Fn(&Program, &Instruction) -> Option<Time>, Time: Clone + Debug + PartialOrd + Add<Time, Output = Time> + Sub<Time, Output = Time> + Zero,

Compute the schedule for this BasicBlock in terms of a generic unit of time, using a provided function to calculate the duration of scheduled instructions in that unit.

§Arguments
  • program - The program containing this basic block. This is used to retrieve frame and calibration information.
  • get_duration - A function that takes a program and an instruction and returns the duration of the instruction in the desired time unit, or None if the instruction’s duration is not known.

Note: when an instruction is expanded, the “time” of that original instruction includes the times of all of the resulting instructions. This may cause gate times to be longer than a user might expect.

To understand why, consider a program like this:

# One-qubit frame
DEFFRAME 0 "a":
    ATTRIBUTE: 1

# Two-qubit frame
DEFFRAME 0 1 "b":
    ATTRIBUTE: 1

DEFCAL A 0:
    PULSE 0 "a" flat(duration: 1.0)

DEFCAL B 0 1:
    FENCE 1
    PULSE 0 1 "b" flat(duration: 1.0)

A 0
B 0 1

B 0 will be scheduled from time 0 to time 2, because its inner FENCE is scheduled for time 0. This may be unexpected if the user expects to see only the timing of the inner PULSE.

Trait Implementations§

Source§

impl<'p> Clone for BasicBlock<'p>

Source§

fn clone(&self) -> BasicBlock<'p>

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<'p> Debug for BasicBlock<'p>

Source§

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

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

impl<'p> Default for BasicBlock<'p>

Source§

fn default() -> BasicBlock<'p>

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

impl<'b> From<&'b BasicBlockOwned> for BasicBlock<'b>

Source§

fn from(value: &'b BasicBlockOwned) -> Self

Converts to this type from the input type.
Source§

impl From<BasicBlock<'_>> for BasicBlockOwned

Source§

fn from(value: BasicBlock<'_>) -> Self

Converts to this type from the input type.
Source§

impl<'a> TryFrom<&BasicBlock<'a>> for QubitGraph<'a>

Source§

type Error = QubitGraphError

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

fn try_from(block: &BasicBlock<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Program> for BasicBlock<'a>

Source§

type Error = ProgramEmptyOrContainsMultipleBasicBlocks

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

fn try_from(value: &'a Program) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'p> Freeze for BasicBlock<'p>

§

impl<'p> RefUnwindSafe for BasicBlock<'p>

§

impl<'p> Send for BasicBlock<'p>

§

impl<'p> Sync for BasicBlock<'p>

§

impl<'p> Unpin for BasicBlock<'p>

§

impl<'p> UnwindSafe for BasicBlock<'p>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V