Struct quil_rs::program::analysis::BasicBlock
source · pub struct BasicBlock<'p> { /* private fields */ }Implementations§
source§impl<'p> BasicBlock<'p>
impl<'p> BasicBlock<'p>
pub fn label(&self) -> Option<&'p Target>
pub fn instruction_index_offset(&self) -> usize
pub fn instructions(&self) -> &[&'p Instruction]
pub fn terminator(&self) -> &BasicBlockTerminator<'p>
sourcepub fn as_schedule_seconds(
&self,
program: &Program
) -> Result<Schedule<Seconds>, BasicBlockScheduleError>
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.
sourcepub 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,
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, orNoneif 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>
impl<'p> Clone for BasicBlock<'p>
source§fn clone(&self) -> BasicBlock<'p>
fn clone(&self) -> BasicBlock<'p>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl<'p> Debug for BasicBlock<'p>
impl<'p> Debug for BasicBlock<'p>
source§impl<'p> Default for BasicBlock<'p>
impl<'p> Default for BasicBlock<'p>
source§fn default() -> BasicBlock<'p>
fn default() -> BasicBlock<'p>
Returns the “default value” for a type. Read more
source§impl<'b> From<&'b BasicBlockOwned> for BasicBlock<'b>
impl<'b> From<&'b BasicBlockOwned> for BasicBlock<'b>
source§fn from(value: &'b BasicBlockOwned) -> Self
fn from(value: &'b BasicBlockOwned) -> Self
Converts to this type from the input type.
source§impl From<BasicBlock<'_>> for BasicBlockOwned
impl From<BasicBlock<'_>> for BasicBlockOwned
source§fn from(value: BasicBlock<'_>) -> Self
fn from(value: BasicBlock<'_>) -> Self
Converts to this type from the input type.
source§impl<'a> TryFrom<&BasicBlock<'a>> for QubitGraph<'a>
impl<'a> TryFrom<&BasicBlock<'a>> for QubitGraph<'a>
§type Error = QubitGraphError
type Error = QubitGraphError
The type returned in the event of a conversion error.
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> 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
Mutably borrows from an owned value. Read more
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.